Commit 6e967df4 authored by Laurent Montel's avatar Laurent Montel 😁

Reactivate support to hide or show attachment in all emails

parent 7d84be14
...@@ -610,8 +610,10 @@ bool KMailProtocolURLHandler::handleClick(const QUrl &url, ViewerPrivate *w) con ...@@ -610,8 +610,10 @@ bool KMailProtocolURLHandler::handleClick(const QUrl &url, ViewerPrivate *w) con
w->update(MimeTreeParser::Force); w->update(MimeTreeParser::Force);
return true; return true;
} else if (urlPath == QLatin1String("showAttachmentQuicklist")) { } else if (urlPath == QLatin1String("showAttachmentQuicklist")) {
w->setShowAttachmentQuicklist(false);
return true; return true;
} else if (urlPath == QLatin1String("hideAttachmentQuicklist")) { } else if (urlPath == QLatin1String("hideAttachmentQuicklist")) {
w->setShowAttachmentQuicklist(true);
return true; return true;
} else if (urlPath == QLatin1String("showFullToAddressList")) { } else if (urlPath == QLatin1String("showFullToAddressList")) {
w->setShowFullToAddressList(true); w->setShowFullToAddressList(true);
......
...@@ -195,6 +195,7 @@ ViewerPrivate::ViewerPrivate(Viewer *aParent, QWidget *mainWindow, ...@@ -195,6 +195,7 @@ ViewerPrivate::ViewerPrivate(Viewer *aParent, QWidget *mainWindow,
mHtmlWriter(0), mHtmlWriter(0),
mDecrytMessageOverwrite(false), mDecrytMessageOverwrite(false),
mShowSignatureDetails(false), mShowSignatureDetails(false),
mShowAttachmentQuicklist(true),
mRecursionCountForDisplayMessage(0), mRecursionCountForDisplayMessage(0),
mCurrentContent(0), mCurrentContent(0),
mMessagePartNode(0), mMessagePartNode(0),
...@@ -1825,6 +1826,11 @@ QString ViewerPrivate::renderAttachments(KMime::Content *node, const QColor &bgC ...@@ -1825,6 +1826,11 @@ QString ViewerPrivate::renderAttachments(KMime::Content *node, const QColor &bgC
if (child) { if (child) {
QString subHtml = renderAttachments(child, nextColor(bgColor)); QString subHtml = renderAttachments(child, nextColor(bgColor));
if (!subHtml.isEmpty()) { if (!subHtml.isEmpty()) {
QString visibility;
if (!mShowAttachmentQuicklist) {
visibility = QStringLiteral("display:none;");
}
QString margin; QString margin;
if (node != mMessage.data() || headerStylePlugin()->hasMargin()) { if (node != mMessage.data() || headerStylePlugin()->hasMargin()) {
...@@ -1834,8 +1840,7 @@ QString ViewerPrivate::renderAttachments(KMime::Content *node, const QColor &bgC ...@@ -1834,8 +1840,7 @@ QString ViewerPrivate::renderAttachments(KMime::Content *node, const QColor &bgC
const bool result = (node->contentType()->mediaType().toLower() == "message" || node->contentType()->mediaType().toLower() == "multipart" || node == mMessage.data()); const bool result = (node->contentType()->mediaType().toLower() == "message" || node->contentType()->mediaType().toLower() == "multipart" || node == mMessage.data());
if (result) if (result)
html += QStringLiteral("<div id=\"attachmentid\" style=\"background:%1; %2" html += QStringLiteral("<div id=\"attachmentid\" style=\"background:%1; %2"
"vertical-align:middle; float:%3;\">").arg(bgColor.name()).arg(margin) "vertical-align:middle; float:%3; %4\">").arg(bgColor.name()).arg(margin).arg(align).arg(visibility);
.arg(align);
html += subHtml; html += subHtml;
if (result) { if (result) {
html += QLatin1String("</div>"); html += QLatin1String("</div>");
...@@ -2305,11 +2310,12 @@ QString ViewerPrivate::attachmentInjectionHtml() ...@@ -2305,11 +2310,12 @@ QString ViewerPrivate::attachmentInjectionHtml()
textAlign = QStringLiteral("left"); textAlign = QStringLiteral("left");
} }
const QString visibility = QStringLiteral("style=\"display:none;\"");
link += QStringLiteral("<div style=\"text-align: %1;\">").arg(textAlign) + link += QStringLiteral("<div style=\"text-align: %1;\">").arg(textAlign) +
QStringLiteral("<a id=\"kmailshowattachment\" href=\"%1\">").arg(urlHandleShow) + QStringLiteral("<a id=\"kmailshowattachment\" href=\"%1\" %2>").arg(urlHandleShow).arg(mShowAttachmentQuicklist ? QString() : visibility) +
QStringLiteral("<img id=\"imgid\" src=\"%1\" width=\"22\" height=\"22\">").arg(QUrl::fromLocalFile(imgpath + imgSrcShow).url()) + QStringLiteral("<img id=\"imgid\" src=\"%1\" width=\"22\" height=\"22\">").arg(QUrl::fromLocalFile(imgpath + imgSrcShow).url()) +
QStringLiteral("</a>") + QStringLiteral("</a>") +
QStringLiteral("<a id=\"kmailhideattachment\" href=\"%1\" style=\"display:none;\">").arg(urlHandleHide) + QStringLiteral("<a id=\"kmailhideattachment\" href=\"%1\" %2>").arg(urlHandleHide).arg(mShowAttachmentQuicklist ? visibility : QString()) +
QStringLiteral("<img id=\"imgid\" src=\"%1\" width=\"22\" height=\"22\">").arg(QUrl::fromLocalFile(imgpath + imgSrcHide).url()) + QStringLiteral("<img id=\"imgid\" src=\"%1\" width=\"22\" height=\"22\">").arg(QUrl::fromLocalFile(imgpath + imgSrcHide).url()) +
QStringLiteral("</a>") + QStringLiteral("</a>") +
QStringLiteral("</div>"); QStringLiteral("</div>");
...@@ -2713,6 +2719,16 @@ void ViewerPrivate::setExternalWindow(bool b) ...@@ -2713,6 +2719,16 @@ void ViewerPrivate::setExternalWindow(bool b)
mExternalWindow = b; mExternalWindow = b;
} }
bool ViewerPrivate::showAttachmentQuicklist() const
{
return mShowAttachmentQuicklist;
}
void ViewerPrivate::setShowAttachmentQuicklist(bool showAttachmentQuicklist)
{
mShowAttachmentQuicklist = showAttachmentQuicklist;
}
void ViewerPrivate::scrollToAttachment(KMime::Content *node) void ViewerPrivate::scrollToAttachment(KMime::Content *node)
{ {
const QString indexStr = node->index().toString(); const QString indexStr = node->index().toString();
......
...@@ -395,6 +395,13 @@ public: ...@@ -395,6 +395,13 @@ public:
void setShowSignatureDetails(bool showDetails = true); void setShowSignatureDetails(bool showDetails = true);
/* show or hide the list that points to the attachments */
bool showAttachmentQuicklist() const;
/* show or hide the list that points to the attachments */
void setShowAttachmentQuicklist(bool showAttachmentQuicklist = true);
void scrollToAttachment(KMime::Content *node); void scrollToAttachment(KMime::Content *node);
void setUseFixedFont(bool useFixedFont); void setUseFixedFont(bool useFixedFont);
...@@ -654,6 +661,7 @@ public: ...@@ -654,6 +661,7 @@ public:
int mLevelQuote; int mLevelQuote;
bool mDecrytMessageOverwrite; bool mDecrytMessageOverwrite;
bool mShowSignatureDetails; bool mShowSignatureDetails;
bool mShowAttachmentQuicklist;
bool mExternalWindow; bool mExternalWindow;
int mRecursionCountForDisplayMessage; int mRecursionCountForDisplayMessage;
KMime::Content *mCurrentContent; KMime::Content *mCurrentContent;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment