Rename variable
[kdepim.git] / kmail / kmreadermainwin.cpp
blobcbbf8e4d42edd2f4e57c2a7fd5f537588027cedb
1 /*
2 This file is part of KMail, the KDE mail client.
3 Copyright (c) 2002 Don Sanders <sanders@kde.org>
4 Copyright (c) 2011-2016 Montel Laurent <montel@kde.org>
6 KMail is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License, version 2, as
8 published by the Free Software Foundation.
10 KMail is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 // A toplevel KMainWindow derived class for displaying
21 // single messages or single message parts.
23 // Could be extended to include support for normal main window
24 // widgets like a toolbar.
26 #include "kmreadermainwin.h"
27 #include "kmreaderwin.h"
29 #include <kactionmenu.h>
30 #include <kedittoolbar.h>
31 #include <KLocalizedString>
32 #include <kstandardshortcut.h>
33 #include <kwindowsystem.h>
34 #include <QAction>
35 #include <kfontaction.h>
36 #include <kstandardaction.h>
37 #include <ktoggleaction.h>
38 #include <ktoolbar.h>
39 #include "kmail_debug.h"
40 #include <KFontAction>
41 #include <KFontSizeAction>
42 #include <QStatusBar>
43 #include <KMessageBox>
44 #include <KAcceleratorManager>
45 #include "kmcommands.h"
46 #include <QMenuBar>
47 #include <qmenu.h>
48 #include "kmmainwidget.h"
49 #include "MessageViewer/CSSHelper"
50 #include <TemplateParser/CustomTemplatesMenu>
51 #include "messageactions.h"
52 #include "util.h"
53 #include "mailcommon/mailkernel.h"
54 #include "MailCommon/FolderCollection"
55 #include "messageviewer/headerstyleplugin.h"
56 #include "messageviewer/headerstyle.h"
58 #include <KActionCollection>
59 #include <Akonadi/Contact/ContactSearchJob>
60 #include <KEmailAddress>
61 #include <kmime/kmime_message.h>
63 #include <messageviewer/viewer.h>
64 #include <AkonadiCore/item.h>
65 #include <AkonadiCore/itemcopyjob.h>
66 #include <AkonadiCore/itemcreatejob.h>
67 #include <AkonadiCore/itemmovejob.h>
68 #include <Akonadi/KMime/MessageFlags>
69 #include "kpimtextedit/texttospeech.h"
70 #include "messagecore/messagehelpers.h"
71 #include <mailcommon/mailutil.h>
73 using namespace MailCommon;
75 KMReaderMainWin::KMReaderMainWin(MessageViewer::Viewer::DisplayFormatMessage format, bool htmlLoadExtOverride,
76 char *name)
77 : KMail::SecondaryWindow(name ? name : "readerwindow#")
79 mReaderWin = new KMReaderWin(this, this, actionCollection());
80 //mReaderWin->setShowCompleteMessage( true );
81 mReaderWin->setDisplayFormatMessageOverwrite(format);
82 mReaderWin->setHtmlLoadExtOverride(htmlLoadExtOverride);
83 mReaderWin->setDecryptMessageOverwrite(true);
84 initKMReaderMainWin();
87 KMReaderMainWin::KMReaderMainWin(char *name)
88 : KMail::SecondaryWindow(name ? name : "readerwindow#")
90 mReaderWin = new KMReaderWin(this, this, actionCollection());
91 initKMReaderMainWin();
94 KMReaderMainWin::KMReaderMainWin(KMime::Content *aMsgPart, MessageViewer::Viewer::DisplayFormatMessage format, const QString &encoding, char *name)
95 : KMail::SecondaryWindow(name ? name : "readerwindow#")
97 mReaderWin = new KMReaderWin(this, this, actionCollection());
98 mReaderWin->setOverrideEncoding(encoding);
99 mReaderWin->setDisplayFormatMessageOverwrite(format);
100 mReaderWin->setMsgPart(aMsgPart);
101 initKMReaderMainWin();
104 void KMReaderMainWin::initKMReaderMainWin()
106 setCentralWidget(mReaderWin);
107 setupAccel();
108 setupGUI(Keys | StatusBar | Create, QStringLiteral("kmreadermainwin.rc"));
109 mMsgActions->setupForwardingActionsList(this);
110 applyMainWindowSettings(KMKernel::self()->config()->group("Separate Reader Window"));
111 if (! mReaderWin->message().isValid()) {
112 menuBar()->hide();
113 toolBar(QStringLiteral("mainToolBar"))->hide();
115 connect(kmkernel, &KMKernel::configChanged, this, &KMReaderMainWin::slotConfigChanged);
116 connect(mReaderWin, SIGNAL(showStatusBarMessage(QString)), statusBar(), SLOT(showMessage(QString)));
119 KMReaderMainWin::~KMReaderMainWin()
121 KConfigGroup grp(KMKernel::self()->config()->group("Separate Reader Window"));
122 saveMainWindowSettings(grp);
125 void KMReaderMainWin::setUseFixedFont(bool useFixedFont)
127 mReaderWin->setUseFixedFont(useFixedFont);
130 void KMReaderMainWin::showMessage(const QString &encoding, const Akonadi::Item &msg, const Akonadi::Collection &parentCollection)
133 mParentCollection = parentCollection;
134 mReaderWin->setOverrideEncoding(encoding);
135 mReaderWin->setMessage(msg, MessageViewer::Force);
136 KMime::Message::Ptr message = MessageCore::Util::message(msg);
137 QString caption;
138 if (message) {
139 caption = message->subject()->asUnicodeString();
141 if (mParentCollection.isValid()) {
142 caption += QLatin1String(" - ");
143 caption += MailCommon::Util::fullCollectionPath(mParentCollection);
145 if (!caption.isEmpty()) {
146 setCaption(caption);
148 mMsg = msg;
149 mMsgActions->setCurrentMessage(msg);
151 const bool canChange = mParentCollection.isValid() ? (bool)(mParentCollection.rights() & Akonadi::Collection::CanDeleteItem) : false;
152 mTrashAction->setEnabled(canChange);
154 mReaderWin->viewer()->headerStylePlugin()->headerStyle()->setReadOnlyMessage(!canChange);
156 menuBar()->show();
157 toolBar(QStringLiteral("mainToolBar"))->show();
160 void KMReaderMainWin::showMessage(const QString &encoding, const KMime::Message::Ptr &message)
162 if (!message) {
163 return;
166 Akonadi::Item item;
168 item.setPayload<KMime::Message::Ptr>(message);
169 Akonadi::MessageFlags::copyMessageFlags(*message, item);
170 item.setMimeType(KMime::Message::mimeType());
172 mMsg = item;
173 mMsgActions->setCurrentMessage(item);
175 mReaderWin->setOverrideEncoding(encoding);
176 mReaderWin->setMessage(message);
177 setCaption(message->subject()->asUnicodeString());
179 mTrashAction->setEnabled(false);
181 menuBar()->show();
182 toolBar(QStringLiteral("mainToolBar"))->show();
185 void KMReaderMainWin::slotReplyOrForwardFinished()
187 if (KMailSettings::self()->closeAfterReplyOrForward()) {
188 close();
192 Akonadi::Collection KMReaderMainWin::parentCollection() const
194 if (mParentCollection.isValid()) {
195 return mParentCollection;
196 } else {
197 return mMsg.parentCollection();
201 void KMReaderMainWin::slotExecuteMailAction(MessageViewer::Viewer::MailAction action)
203 switch (action) {
204 case MessageViewer::Viewer::Trash:
205 slotTrashMessage();
206 break;
207 case MessageViewer::Viewer::Reply:
208 slotCustomReplyToMsg(QString());
209 break;
210 case MessageViewer::Viewer::ReplyToAll:
211 break;
212 case MessageViewer::Viewer::Forward:
213 slotRedirectMessage();
214 break;
215 case MessageViewer::Viewer::NewMessage:
216 break;
217 case MessageViewer::Viewer::Print:
218 break;
219 case MessageViewer::Viewer::PrintPreview:
220 break;
224 void KMReaderMainWin::slotTrashMessage()
226 if (!mMsg.isValid()) {
227 return;
229 KMTrashMsgCommand *command = new KMTrashMsgCommand(parentCollection(), mMsg, -1);
230 command->start();
231 close();
234 void KMReaderMainWin::slotForwardInlineMsg()
236 if (!mReaderWin->message().hasPayload<KMime::Message::Ptr>()) {
237 return;
239 KMCommand *command = Q_NULLPTR;
240 const Akonadi::Collection parentCol = mReaderWin->message().parentCollection();
241 if (parentCol.isValid()) {
242 QSharedPointer<FolderCollection> fd = FolderCollection::forCollection(parentCol, false);
243 if (fd)
244 command = new KMForwardCommand(this, mReaderWin->message(),
245 fd->identity());
246 else {
247 command = new KMForwardCommand(this, mReaderWin->message());
249 } else {
250 command = new KMForwardCommand(this, mReaderWin->message());
252 connect(command, &KMTrashMsgCommand::completed, this, &KMReaderMainWin::slotReplyOrForwardFinished);
253 command->start();
256 void KMReaderMainWin::slotForwardAttachedMessage()
258 if (!mReaderWin->message().hasPayload<KMime::Message::Ptr>()) {
259 return;
261 KMCommand *command = Q_NULLPTR;
262 const Akonadi::Collection parentCol = mReaderWin->message().parentCollection();
263 if (parentCol.isValid()) {
264 QSharedPointer<FolderCollection> fd = FolderCollection::forCollection(parentCol, false);
265 if (fd)
266 command = new KMForwardAttachedCommand(this, mReaderWin->message(),
267 fd->identity());
268 else {
269 command = new KMForwardAttachedCommand(this, mReaderWin->message());
271 } else {
272 command = new KMForwardAttachedCommand(this, mReaderWin->message());
275 connect(command, &KMTrashMsgCommand::completed, this, &KMReaderMainWin::slotReplyOrForwardFinished);
276 command->start();
279 void KMReaderMainWin::slotRedirectMessage()
281 const Akonadi::Item currentItem = mReaderWin->message();
282 if (!currentItem.hasPayload<KMime::Message::Ptr>()) {
283 return;
285 KMCommand *command = new KMRedirectCommand(this, currentItem);
286 connect(command, &KMTrashMsgCommand::completed, this, &KMReaderMainWin::slotReplyOrForwardFinished);
287 command->start();
290 void KMReaderMainWin::slotCustomReplyToMsg(const QString &tmpl)
292 const Akonadi::Item currentItem = mReaderWin->message();
293 if (!currentItem.hasPayload<KMime::Message::Ptr>()) {
294 return;
296 KMCommand *command = new KMReplyCommand(this,
297 currentItem,
298 MessageComposer::ReplySmart,
299 mReaderWin->copyText(),
300 false, tmpl);
301 connect(command, &KMTrashMsgCommand::completed, this, &KMReaderMainWin::slotReplyOrForwardFinished);
302 command->start();
305 void KMReaderMainWin::slotCustomReplyAllToMsg(const QString &tmpl)
307 const Akonadi::Item currentItem = mReaderWin->message();
308 if (!currentItem.hasPayload<KMime::Message::Ptr>()) {
309 return;
311 KMCommand *command = new KMReplyCommand(this,
312 currentItem,
313 MessageComposer::ReplyAll,
314 mReaderWin->copyText(),
315 false, tmpl);
316 connect(command, &KMTrashMsgCommand::completed, this, &KMReaderMainWin::slotReplyOrForwardFinished);
318 command->start();
321 void KMReaderMainWin::slotCustomForwardMsg(const QString &tmpl)
323 const Akonadi::Item currentItem = mReaderWin->message();
324 if (!currentItem.hasPayload<KMime::Message::Ptr>()) {
325 return;
327 KMCommand *command = new KMForwardCommand(this,
328 currentItem,
329 0, tmpl);
330 connect(command, &KMTrashMsgCommand::completed, this, &KMReaderMainWin::slotReplyOrForwardFinished);
332 command->start();
335 void KMReaderMainWin::slotConfigChanged()
337 //readConfig();
338 mMsgActions->setupForwardActions(actionCollection());
339 mMsgActions->setupForwardingActionsList(this);
342 void KMReaderMainWin::setupAccel()
344 if (!kmkernel->xmlGuiInstanceName().isEmpty()) {
345 setComponentName(kmkernel->xmlGuiInstanceName(), i18n("kmail2"));
347 mMsgActions = new KMail::MessageActions(actionCollection(), this);
348 mMsgActions->setMessageView(mReaderWin);
349 connect(mMsgActions, &KMail::MessageActions::replyActionFinished, this, &KMReaderMainWin::slotReplyOrForwardFinished);
351 //----- File Menu
353 mSaveAtmAction = new QAction(QIcon::fromTheme(QStringLiteral("mail-attachment")), i18n("Save A&ttachments..."), actionCollection());
354 connect(mSaveAtmAction, &QAction::triggered, mReaderWin->viewer(), &MessageViewer::Viewer::slotAttachmentSaveAll);
356 mTrashAction = new QAction(QIcon::fromTheme(QStringLiteral("user-trash")), i18n("&Move to Trash"), this);
357 mTrashAction->setIconText(i18nc("@action:intoolbar Move to Trash", "Trash"));
358 KMail::Util::addQActionHelpText(mTrashAction, i18n("Move message to trashcan"));
359 actionCollection()->addAction(QStringLiteral("move_to_trash"), mTrashAction);
360 actionCollection()->setDefaultShortcut(mTrashAction, QKeySequence(Qt::Key_Delete));
361 connect(mTrashAction, &QAction::triggered, this, &KMReaderMainWin::slotTrashMessage);
363 QAction *closeAction = KStandardAction::close(this, SLOT(close()), actionCollection());
364 QList<QKeySequence> closeShortcut = closeAction->shortcuts();
365 closeAction->setShortcuts(closeShortcut << QKeySequence(Qt::Key_Escape));
367 //----- Message Menu
368 connect(mReaderWin->viewer(), &MessageViewer::Viewer::popupMenu, this, &KMReaderMainWin::slotMessagePopup);
370 connect(mReaderWin->viewer(), &MessageViewer::Viewer::itemRemoved, this, &QWidget::close);
372 setStandardToolBarMenuEnabled(true);
373 KStandardAction::configureToolbars(this, SLOT(slotEditToolbars()), actionCollection());
374 connect(mReaderWin->viewer(), &MessageViewer::Viewer::moveMessageToTrash, this, &KMReaderMainWin::slotTrashMessage);
375 connect(mReaderWin->viewer(), &MessageViewer::Viewer::executeMailAction, this, &KMReaderMainWin::slotExecuteMailAction);
378 QAction *KMReaderMainWin::copyActionMenu(QMenu *menu)
380 KMMainWidget *mainwin = kmkernel->getKMMainWidget();
381 if (mainwin) {
382 KActionMenu *action = new KActionMenu(menu);
383 action->setIcon(QIcon::fromTheme(QStringLiteral("edit-copy")));
384 action->setText(i18n("Copy Message To..."));
385 mainwin->standardMailActionManager()->standardActionManager()->createActionFolderMenu(action->menu(), Akonadi::StandardActionManager::CopyItemToMenu);
386 connect(action->menu(), &QMenu::triggered, this, &KMReaderMainWin::slotCopyItem);
387 return action;
389 return Q_NULLPTR;
392 QAction *KMReaderMainWin::moveActionMenu(QMenu *menu)
394 KMMainWidget *mainwin = kmkernel->getKMMainWidget();
395 if (mainwin) {
396 KActionMenu *action = new KActionMenu(menu);
397 action->setText(i18n("Move Message To..."));
398 mainwin->standardMailActionManager()->standardActionManager()->createActionFolderMenu(action->menu(), Akonadi::StandardActionManager::MoveItemToMenu);
399 connect(action->menu(), &QMenu::triggered, this, &KMReaderMainWin::slotMoveItem);
401 return action;
403 return Q_NULLPTR;
407 void KMReaderMainWin::slotMoveItem(QAction *action)
409 if (action) {
410 const QModelIndex index = action->data().value<QModelIndex>();
411 const Akonadi::Collection collection = index.data(Akonadi::EntityTreeModel::CollectionRole).value<Akonadi::Collection>();
412 copyOrMoveItem(collection, true);
416 void KMReaderMainWin::copyOrMoveItem(const Akonadi::Collection &collection, bool move)
418 if (mMsg.isValid()) {
419 if (move) {
420 Akonadi::ItemMoveJob *job = new Akonadi::ItemMoveJob(mMsg, collection, this);
421 connect(job, &KJob::result, this, &KMReaderMainWin::slotCopyMoveResult);
422 } else {
423 Akonadi::ItemCopyJob *job = new Akonadi::ItemCopyJob(mMsg, collection, this);
424 connect(job, &KJob::result, this, &KMReaderMainWin::slotCopyMoveResult);
426 } else {
427 Akonadi::ItemCreateJob *job = new Akonadi::ItemCreateJob(mMsg, collection, this);
428 connect(job, &KJob::result, this, &KMReaderMainWin::slotCopyMoveResult);
432 void KMReaderMainWin::slotCopyItem(QAction *action)
434 if (action) {
435 const QModelIndex index = action->data().value<QModelIndex>();
436 const Akonadi::Collection collection = index.data(Akonadi::EntityTreeModel::CollectionRole).value<Akonadi::Collection>();
437 copyOrMoveItem(collection, false);
441 void KMReaderMainWin::slotCopyMoveResult(KJob *job)
443 if (job->error()) {
444 KMessageBox::sorry(this, i18n("Cannot copy item. %1", job->errorString()));
448 void KMReaderMainWin::slotMessagePopup(const Akonadi::Item &aMsg, const QUrl &aUrl, const QUrl &imageUrl, const QPoint &aPoint)
450 mMsg = aMsg;
452 const QString email = KEmailAddress::firstEmailAddress(aUrl.path()).toLower();
453 if (aUrl.scheme() == QLatin1String("mailto") && !email.isEmpty()) {
454 Akonadi::ContactSearchJob *job = new Akonadi::ContactSearchJob(this);
455 job->setLimit(1);
456 job->setQuery(Akonadi::ContactSearchJob::Email, email, Akonadi::ContactSearchJob::ExactMatch);
457 job->setProperty("msg", QVariant::fromValue(mMsg));
458 job->setProperty("point", aPoint);
459 job->setProperty("imageUrl", imageUrl);
460 job->setProperty("url", aUrl);
461 connect(job, &Akonadi::ItemCopyJob::result, this, &KMReaderMainWin::slotContactSearchJobForMessagePopupDone);
462 } else {
463 showMessagePopup(mMsg, aUrl, imageUrl, aPoint, false, false);
467 void KMReaderMainWin::slotContactSearchJobForMessagePopupDone(KJob *job)
469 const Akonadi::ContactSearchJob *searchJob = qobject_cast<Akonadi::ContactSearchJob *>(job);
470 const bool contactAlreadyExists = !searchJob->contacts().isEmpty();
472 const Akonadi::Item::List listContact = searchJob->items();
473 const bool uniqueContactFound = (listContact.count() == 1);
474 if (uniqueContactFound) {
475 mReaderWin->setContactItem(listContact.first(), searchJob->contacts().at(0));
476 } else {
477 mReaderWin->clearContactItem();
480 const Akonadi::Item msg = job->property("msg").value<Akonadi::Item>();
481 const QPoint aPoint = job->property("point").toPoint();
482 const QUrl imageUrl = job->property("imageUrl").toUrl();
483 const QUrl url = job->property("url").toUrl();
485 showMessagePopup(msg, url, imageUrl, aPoint, contactAlreadyExists, uniqueContactFound);
488 void KMReaderMainWin::showMessagePopup(const Akonadi::Item &msg, const QUrl &url, const QUrl &imageUrl, const QPoint &aPoint, bool contactAlreadyExists, bool uniqueContactFound)
490 QMenu *menu = Q_NULLPTR;
492 bool urlMenuAdded = false;
493 bool copyAdded = false;
494 const bool messageHasPayload = msg.hasPayload<KMime::Message::Ptr>();
495 if (!url.isEmpty()) {
496 if (url.scheme() == QLatin1String("mailto")) {
497 // popup on a mailto URL
498 menu = new QMenu;
499 menu->addAction(mReaderWin->mailToComposeAction());
500 if (messageHasPayload) {
501 menu->addAction(mReaderWin->mailToReplyAction());
502 menu->addAction(mReaderWin->mailToForwardAction());
503 menu->addSeparator();
506 if (contactAlreadyExists) {
507 if (uniqueContactFound) {
508 menu->addAction(mReaderWin->editContactAction());
509 } else {
510 menu->addAction(mReaderWin->openAddrBookAction());
512 } else {
513 menu->addAction(mReaderWin->addAddrBookAction());
514 menu->addAction(mReaderWin->addToExistingContactAction());
516 menu->addSeparator();
517 menu->addMenu(mReaderWin->viewHtmlOption());
518 menu->addSeparator();
519 menu->addAction(mReaderWin->copyURLAction());
520 copyAdded = true;
521 urlMenuAdded = true;
522 } else if (url.scheme() != QLatin1String("attachment")) {
523 // popup on a not-mailto URL
524 menu = new QMenu;
525 menu->addAction(mReaderWin->urlOpenAction());
526 menu->addAction(mReaderWin->addBookmarksAction());
527 menu->addAction(mReaderWin->urlSaveAsAction());
528 menu->addAction(mReaderWin->copyURLAction());
529 menu->addSeparator();
530 menu->addAction(mReaderWin->shareServiceUrlMenu());
531 menu->addSeparator();
532 menu->addActions(mReaderWin->viewerPluginActionList(MessageViewer::ViewerPluginInterface::NeedUrl));
533 if (!imageUrl.isEmpty()) {
534 menu->addSeparator();
535 menu->addAction(mReaderWin->copyImageLocation());
536 menu->addAction(mReaderWin->downloadImageToDiskAction());
537 menu->addAction(mReaderWin->shareImage());
538 if (mReaderWin->adblockEnabled()) {
539 menu->addSeparator();
540 menu->addAction(mReaderWin->blockImage());
543 urlMenuAdded = true;
546 const QString selectedText(mReaderWin->copyText());
547 if (!selectedText.isEmpty()) {
548 if (!menu) {
549 menu = new QMenu;
551 if (urlMenuAdded) {
552 menu->addSeparator();
554 if (messageHasPayload) {
555 menu->addAction(mMsgActions->replyMenu());
556 menu->addSeparator();
557 menu->addAction(mMsgActions->mailingListActionMenu());
558 menu->addSeparator();
560 if (!copyAdded) {
561 menu->addAction(mReaderWin->copyAction());
563 menu->addAction(mReaderWin->selectAllAction());
564 menu->addSeparator();
565 mMsgActions->addWebShortcutsMenu(menu, selectedText);
566 menu->addSeparator();
567 menu->addActions(mReaderWin->viewerPluginActionList(MessageViewer::ViewerPluginInterface::NeedSelection));
568 if (KPIMTextEdit::TextToSpeech::self()->isReady()) {
569 menu->addSeparator();
570 menu->addAction(mReaderWin->speakTextAction());
572 } else if (!urlMenuAdded) {
573 if (!menu) {
574 menu = new QMenu;
577 // popup somewhere else (i.e., not a URL) on the message
578 if (messageHasPayload) {
579 bool replyForwardMenu = false;
580 Akonadi::Collection col = parentCollection();
581 if (col.isValid()) {
582 if (!(CommonKernel->folderIsSentMailFolder(col) ||
583 CommonKernel->folderIsDrafts(col) ||
584 CommonKernel->folderIsTemplates(col))) {
585 replyForwardMenu = true;
587 } else if (messageHasPayload) {
588 replyForwardMenu = true;
590 if (replyForwardMenu) {
591 // add the reply and forward actions only if we are not in a sent-mail,
592 // templates or drafts folder
593 menu->addAction(mMsgActions->replyMenu());
594 menu->addAction(mMsgActions->forwardMenu());
595 menu->addSeparator();
597 menu->addAction(copyActionMenu(menu));
598 menu->addAction(moveActionMenu(menu));
599 menu->addSeparator();
600 menu->addAction(mMsgActions->mailingListActionMenu());
602 menu->addSeparator();
603 if (!imageUrl.isEmpty()) {
604 menu->addSeparator();
605 menu->addAction(mReaderWin->copyImageLocation());
606 menu->addAction(mReaderWin->downloadImageToDiskAction());
607 menu->addAction(mReaderWin->shareImage());
608 menu->addSeparator();
609 if (mReaderWin->adblockEnabled()) {
610 menu->addAction(mReaderWin->blockImage());
611 menu->addSeparator();
615 menu->addAction(mReaderWin->viewSourceAction());
616 menu->addAction(mReaderWin->toggleFixFontAction());
617 if (!mReaderWin->mimePartTreeIsEmpty()) {
618 menu->addAction(mReaderWin->toggleMimePartTreeAction());
620 menu->addSeparator();
621 if (mMsgActions->printPreviewAction()) {
622 menu->addAction(mMsgActions->printPreviewAction());
624 menu->addAction(mMsgActions->printAction());
625 menu->addAction(mReaderWin->saveAsAction());
626 menu->addAction(mSaveAtmAction);
627 if (msg.isValid()) {
628 menu->addSeparator();
629 menu->addActions(mReaderWin->viewerPluginActionList(MessageViewer::ViewerPluginInterface::NeedMessage));
630 menu->addSeparator();
631 menu->addAction(mReaderWin->saveMessageDisplayFormatAction());
632 menu->addAction(mReaderWin->resetMessageDisplayFormatAction());
634 } else {
635 menu->addAction(mReaderWin->toggleFixFontAction());
636 if (!mReaderWin->mimePartTreeIsEmpty()) {
637 menu->addAction(mReaderWin->toggleMimePartTreeAction());
640 if (mReaderWin->adblockEnabled()) {
641 menu->addSeparator();
642 menu->addAction(mReaderWin->openBlockableItems());
644 if (msg.isValid()) {
645 menu->addAction(mMsgActions->addFollowupReminderAction());
647 if (msg.isValid()) {
648 menu->addSeparator();
649 menu->addAction(mMsgActions->addFollowupReminderAction());
651 if (kmkernel->allowToDebugBalooSupport()) {
652 menu->addSeparator();
653 menu->addAction(mMsgActions->debugBalooAction());
656 if (menu) {
657 KAcceleratorManager::manage(menu);
658 menu->exec(aPoint, Q_NULLPTR);
659 delete menu;
663 void KMReaderMainWin::slotEditToolbars()
665 KConfigGroup grp(KMKernel::self()->config(), "ReaderWindow");
666 saveMainWindowSettings(grp);
667 KEditToolBar dlg(guiFactory(), this);
668 connect(&dlg, &KEditToolBar::newToolBarConfig, this, &KMReaderMainWin::slotUpdateToolbars);
669 dlg.exec();
672 void KMReaderMainWin::slotUpdateToolbars()
674 createGUI(QStringLiteral("kmreadermainwin.rc"));
675 applyMainWindowSettings(KConfigGroup(KMKernel::self()->config(), "ReaderWindow"));