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
w->update(MimeTreeParser::Force);
return true;
} else if (urlPath == QLatin1String("showAttachmentQuicklist")) {
w->setShowAttachmentQuicklist(false);
return true;
} else if (urlPath == QLatin1String("hideAttachmentQuicklist")) {
w->setShowAttachmentQuicklist(true);
return true;
} else if (urlPath == QLatin1String("showFullToAddressList")) {
w->setShowFullToAddressList(true);
......
......@@ -195,6 +195,7 @@ ViewerPrivate::ViewerPrivate(Viewer *aParent, QWidget *mainWindow,
mHtmlWriter(0),
mDecrytMessageOverwrite(false),
mShowSignatureDetails(false),
mShowAttachmentQuicklist(true),
mRecursionCountForDisplayMessage(0),
mCurrentContent(0),
mMessagePartNode(0),
......@@ -1825,6 +1826,11 @@ QString ViewerPrivate::renderAttachments(KMime::Content *node, const QColor &bgC
if (child) {
QString subHtml = renderAttachments(child, nextColor(bgColor));
if (!subHtml.isEmpty()) {
QString visibility;
if (!mShowAttachmentQuicklist) {
visibility = QStringLiteral("display:none;");
}
QString margin;
if (node != mMessage.data() || headerStylePlugin()->hasMargin()) {
......@@ -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());
if (result)
html += QStringLiteral("<div id=\"attachmentid\" style=\"background:%1; %2"
"vertical-align:middle; float:%3;\">").arg(bgColor.name()).arg(margin)
.arg(align);
"vertical-align:middle; float:%3; %4\">").arg(bgColor.name()).arg(margin).arg(align).arg(visibility);
html += subHtml;
if (result) {
html += QLatin1String("</div>");
......@@ -2305,11 +2310,12 @@ QString ViewerPrivate::attachmentInjectionHtml()
textAlign = QStringLiteral("left");
}
const QString visibility = QStringLiteral("style=\"display:none;\"");
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("</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("</a>") +
QStringLiteral("</div>");
......@@ -2713,6 +2719,16 @@ void ViewerPrivate::setExternalWindow(bool b)
mExternalWindow = b;
}
bool ViewerPrivate::showAttachmentQuicklist() const
{
return mShowAttachmentQuicklist;
}
void ViewerPrivate::setShowAttachmentQuicklist(bool showAttachmentQuicklist)
{
mShowAttachmentQuicklist = showAttachmentQuicklist;
}
void ViewerPrivate::scrollToAttachment(KMime::Content *node)
{
const QString indexStr = node->index().toString();
......
......@@ -395,6 +395,13 @@ public:
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 setUseFixedFont(bool useFixedFont);
......@@ -654,6 +661,7 @@ public:
int mLevelQuote;
bool mDecrytMessageOverwrite;
bool mShowSignatureDetails;
bool mShowAttachmentQuicklist;
bool mExternalWindow;
int mRecursionCountForDisplayMessage;
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