summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-10-12 19:35:30 (GMT)
committerMontel Laurent <montel@kde.org>2016-10-12 19:36:00 (GMT)
commit75b1bd97fd877f7f200b86bab6ce4cb36bcd3097 (patch)
tree99013363c2fa96d76c1b684010fd2e9573c3a7c2
parentcbe4a2c763928e050e17547dd6a32a3eb89502ce (diff)
Use script for show/hide attachment, same for hide/show CC/To
-rw-r--r--messageviewer/src/viewer/objecttreeviewersource.cpp4
-rw-r--r--messageviewer/src/viewer/urlhandlermanager.cpp4
-rw-r--r--messageviewer/src/viewer/viewer_p.cpp16
-rw-r--r--messageviewer/src/viewer/viewer_p.h7
-rw-r--r--messageviewer/src/viewer/webengine/mailwebenginescript.cpp42
-rw-r--r--messageviewer/src/viewer/webengine/mailwebenginescript.h4
-rw-r--r--messageviewer/src/viewer/webengine/mailwebengineview.cpp18
-rw-r--r--messageviewer/src/viewer/webengine/mailwebengineview.h3
8 files changed, 94 insertions, 4 deletions
diff --git a/messageviewer/src/viewer/objecttreeviewersource.cpp b/messageviewer/src/viewer/objecttreeviewersource.cpp
index ae60770..ee43876 100644
--- a/messageviewer/src/viewer/objecttreeviewersource.cpp
+++ b/messageviewer/src/viewer/objecttreeviewersource.cpp
@@ -114,7 +114,7 @@ bool MailViewerSource::autoImportKeys() const
bool MailViewerSource::showEmoticons() const
{
- return MessageViewer::MessageViewerSettings::self()->showEmoticons();
+ return mViewer->showEmoticons();
}
bool MailViewerSource::showExpandQuotesMark() const
@@ -130,4 +130,4 @@ const MimeTreeParser::BodyPartFormatterBaseFactory *MailViewerSource::bodyPartFo
MimeTreeParser::Interface::MessagePartRendererPtr MailViewerSource::messagePartTheme(MimeTreeParser::Interface::MessagePart::Ptr msgPart)
{
return MimeTreeParser::Interface::MessagePartRenderer::Ptr(new DefaultRenderer(msgPart, mViewer->cssHelper()));
-} \ No newline at end of file
+}
diff --git a/messageviewer/src/viewer/urlhandlermanager.cpp b/messageviewer/src/viewer/urlhandlermanager.cpp
index 14e5941..6c4ed17 100644
--- a/messageviewer/src/viewer/urlhandlermanager.cpp
+++ b/messageviewer/src/viewer/urlhandlermanager.cpp
@@ -616,12 +616,16 @@ bool KMailProtocolURLHandler::handleClick(const QUrl &url, ViewerPrivate *w) con
w->setShowAttachmentQuicklist(true);
return true;
} else if (urlPath == QLatin1String("showFullToAddressList")) {
+ w->setFullToAddressList(false);
return true;
} else if (urlPath == QLatin1String("hideFullToAddressList")) {
+ w->setFullToAddressList(true);
return true;
} else if (urlPath == QLatin1String("showFullCcAddressList")) {
+ w->setFullCcAddressList(false);
return true;
} else if (urlPath == QLatin1String("hideFullCcAddressList")) {
+ w->setFullCcAddressList(true);
return true;
}
}
diff --git a/messageviewer/src/viewer/viewer_p.cpp b/messageviewer/src/viewer/viewer_p.cpp
index c8ee44f..a2cac38 100644
--- a/messageviewer/src/viewer/viewer_p.cpp
+++ b/messageviewer/src/viewer/viewer_p.cpp
@@ -740,6 +740,11 @@ void ViewerPrivate::attachmentOpen(KMime::Content *node)
attachmentOpenWith(node, offer);
}
+bool ViewerPrivate::showEmoticons() const
+{
+ return MessageViewer::MessageViewerSettings::self()->showEmoticons();
+}
+
MimeTreeParser::HtmlWriter *ViewerPrivate::htmlWriter() const
{
return mHtmlWriter;
@@ -2765,9 +2770,20 @@ bool ViewerPrivate::showAttachmentQuicklist() const
return mShowAttachmentQuicklist;
}
+void ViewerPrivate::setFullToAddressList(bool showFullTo)
+{
+ mViewer->executeHideShowToAddressScripts(showFullTo);
+}
+
+void ViewerPrivate::setFullCcAddressList(bool showFullCc)
+{
+ mViewer->executeHideShowCcAddressScripts(showFullCc);
+}
+
void ViewerPrivate::setShowAttachmentQuicklist(bool showAttachmentQuicklist)
{
mShowAttachmentQuicklist = showAttachmentQuicklist;
+ mViewer->executeHideShowAttachmentsScripts(mShowAttachmentQuicklist);
}
void ViewerPrivate::scrollToAttachment(KMime::Content *node)
diff --git a/messageviewer/src/viewer/viewer_p.h b/messageviewer/src/viewer/viewer_p.h
index 0028421..55e0328 100644
--- a/messageviewer/src/viewer/viewer_p.h
+++ b/messageviewer/src/viewer/viewer_p.h
@@ -405,6 +405,9 @@ public:
void setUseFixedFont(bool useFixedFont);
void attachmentView(KMime::Content *atmNode);
+ void setFullToAddressList(bool showFullTo);
+ void setFullCcAddressList(bool showFullCc);
+
/** Show/Hide the field with id "field" */
void toggleFullAddressList(const QString &field);
@@ -424,6 +427,7 @@ public:
QList<QAction *> interceptorUrlActions(const WebEngineViewer::WebHitTestResult &result) const;
void setPrintElementBackground(bool printElementBackground);
+ bool showEmoticons() const;
private Q_SLOTS:
void slotActivatePlugin(MessageViewer::ViewerPluginInterface *interface);
@@ -559,6 +563,7 @@ public Q_SLOTS:
void slotGeneralFontChanged();
+
Q_SIGNALS:
void showStatusBarMessage(const QString &message);
void replaceMsgByUnencryptedVersion();
@@ -661,8 +666,6 @@ public:
QColor mBackgroundError;
Viewer *const q;
- bool mShowFullToAddressList;
- bool mShowFullCcAddressList;
Akonadi::Monitor mMonitor;
QSet<AbstractMessageLoadedHandler *> mMessageLoadedHandlers;
Akonadi::Item::Id mPreviouslyViewedItem;
diff --git a/messageviewer/src/viewer/webengine/mailwebenginescript.cpp b/messageviewer/src/viewer/webengine/mailwebenginescript.cpp
index 90745d2..86ecd4e 100644
--- a/messageviewer/src/viewer/webengine/mailwebenginescript.cpp
+++ b/messageviewer/src/viewer/webengine/mailwebenginescript.cpp
@@ -39,6 +39,48 @@ QString MailWebEngineScript::manageExpandAddresses(const QString &field)
return source;
}
+QString MailWebEngineScript::createShowHideAddressScript(const QString &field, bool hide)
+{
+ QString source;
+ if (hide) {
+ source = QString::fromLatin1("qt.jQuery('#kmail%1show').hide();"
+ "qt.jQuery(\"#kmail%1hide\").show();"
+ "qt.jQuery(\"#dotsFull%1AddressList\").hide();"
+ "qt.jQuery(\"#hiddenFull%1AddressList\").show();").arg(field);
+ } else {
+ source = QString::fromLatin1("qt.jQuery(\"#kmail%1hide\").hide();"
+ "qt.jQuery(\"#kmail%1show\").show();"
+ "qt.jQuery(\"#dotsFull%1AddressList\").show();"
+ "qt.jQuery(\"#hiddenFull%1AddressList\").hide();").arg(field);
+ }
+ return source;
+}
+
+QString MailWebEngineScript::manageShowHideToAddress(bool hide)
+{
+ return MailWebEngineScript::createShowHideAddressScript(QStringLiteral("To"), hide);
+}
+
+QString MailWebEngineScript::manageShowHideCcAddress(bool hide)
+{
+ return MailWebEngineScript::createShowHideAddressScript(QStringLiteral("Cc"), hide);
+}
+
+QString MailWebEngineScript::manageShowHideAttachments(bool hide)
+{
+ QString source;
+ if (hide) {
+ source = QString::fromLatin1("qt.jQuery(\"#kmailhideattachment\").hide();"
+ "qt.jQuery(\"#kmailshowattachment\").show();"
+ "qt.jQuery(\"#attachmentid\").show();");
+ } else {
+ source = QString::fromLatin1("qt.jQuery('#kmailshowattachment').hide();"
+ "qt.jQuery(\"#kmailhideattachment\").show();"
+ "qt.jQuery(\"#attachmentid\").hide();");
+ }
+ return source;
+}
+
QString MailWebEngineScript::manageShowHideAttachments()
{
const QString source = QString::fromLatin1("qt.jQuery('#kmailshowattachment').click(function(){"
diff --git a/messageviewer/src/viewer/webengine/mailwebenginescript.h b/messageviewer/src/viewer/webengine/mailwebenginescript.h
index f2e388a..c966b89 100644
--- a/messageviewer/src/viewer/webengine/mailwebenginescript.h
+++ b/messageviewer/src/viewer/webengine/mailwebenginescript.h
@@ -30,7 +30,11 @@ namespace MailWebEngineScript
MESSAGEVIEWER_EXPORT QString injectAttachments(const QString &delayedHtml, const QString &element);
MESSAGEVIEWER_EXPORT QString replaceInnerHtml(const QString &field, const QString &html);
MESSAGEVIEWER_EXPORT QString manageShowHideAttachments();
+MESSAGEVIEWER_EXPORT QString manageShowHideAttachments(bool hide);
MESSAGEVIEWER_EXPORT QString manageExpandAddresses(const QString &field);
+MESSAGEVIEWER_EXPORT QString manageShowHideToAddress(bool hide);
+MESSAGEVIEWER_EXPORT QString manageShowHideCcAddress(bool hide);
+MESSAGEVIEWER_EXPORT QString createShowHideAddressScript(const QString &field, bool hide);
}
}
#endif // MAILWEBENGINESCRIPT_H
diff --git a/messageviewer/src/viewer/webengine/mailwebengineview.cpp b/messageviewer/src/viewer/webengine/mailwebengineview.cpp
index 916284c..d2040c5 100644
--- a/messageviewer/src/viewer/webengine/mailwebengineview.cpp
+++ b/messageviewer/src/viewer/webengine/mailwebengineview.cpp
@@ -315,6 +315,24 @@ void MailWebEngineView::scrollPageUp(int percent)
scrollPageDown(-percent);
}
+void MailWebEngineView::executeHideShowToAddressScripts(bool hide)
+{
+ const QString source = MessageViewer::MailWebEngineScript::manageShowHideToAddress(hide);
+ runJavaScriptInWordId(source);
+}
+
+void MailWebEngineView::executeHideShowCcAddressScripts(bool hide)
+{
+ const QString source = MessageViewer::MailWebEngineScript::manageShowHideCcAddress(hide);
+ runJavaScriptInWordId(source);
+}
+
+void MailWebEngineView::executeHideShowAttachmentsScripts(bool hide)
+{
+ const QString source = MessageViewer::MailWebEngineScript::manageShowHideAttachments(hide);
+ runJavaScriptInWordId(source);
+}
+
void MailWebEngineView::executeCustomRenderingScripts()
{
const QString scripts = MessageViewer::MailWebEngineScript::manageShowHideAttachments() +
diff --git a/messageviewer/src/viewer/webengine/mailwebengineview.h b/messageviewer/src/viewer/webengine/mailwebengineview.h
index 8c8d65b..de260d2 100644
--- a/messageviewer/src/viewer/webengine/mailwebengineview.h
+++ b/messageviewer/src/viewer/webengine/mailwebengineview.h
@@ -70,6 +70,9 @@ public:
void setPrintElementBackground(bool printElementBackground);
+ void executeHideShowAttachmentsScripts(bool hide);
+ void executeHideShowToAddressScripts(bool hide);
+ void executeHideShowCcAddressScripts(bool hide);
public Q_SLOTS:
void slotZoomChanged(qreal zoom);
void slotShowDetails();