17#include "dkim-verify/dkimwidgetinfo.h"
18#include "viewer/mimeparttree/mimeparttreeview.h"
19#include "viewer/mimeparttree/mimetreemodel.h"
20#include "viewer/webengine/mailwebengineview.h"
22#include "widgets/zoomactionmenu.h"
23#include <Akonadi/ItemFetchJob>
24#include <Akonadi/ItemFetchScope>
25#include <Akonadi/MessageParts>
27#include <WebEngineViewer/WebEngineManageScript>
28#include <WebEngineViewer/WebHitTestResult>
30#include <Akonadi/ErrorAttribute>
32#include <KLocalizedString>
36#include <Akonadi/MDNStateAttribute>
38namespace MessageViewer
40class AbstractMessageLoadedHandler::AbstractMessageLoadedHandlerPrivate
46AbstractMessageLoadedHandler::AbstractMessageLoadedHandler()
47 : d(new AbstractMessageLoadedHandlerPrivate)
51AbstractMessageLoadedHandler::~AbstractMessageLoadedHandler() =
default;
55 d->mSession = session;
65 , d_ptr(new ViewerPrivate(this, mainWindow, actionCollection))
71Viewer::~Viewer() =
default;
73void Viewer::initialize()
75 connect(d_ptr, &ViewerPrivate::displayPopupMenu,
this, &Viewer::displayPopupMenu);
78 connect(d_ptr, &ViewerPrivate::requestConfigSync,
this, &Viewer::requestConfigSync);
79 connect(d_ptr, &ViewerPrivate::makeResourceOnline,
this, &Viewer::makeResourceOnline);
82 connect(d_ptr, &ViewerPrivate::replyMessageTo,
this, &Viewer::replyMessageTo);
85 connect(d_ptr, &ViewerPrivate::changeDisplayMail,
this, &Viewer::slotChangeDisplayMail);
86 connect(d_ptr, &ViewerPrivate::moveMessageToTrash,
this, &Viewer::moveMessageToTrash);
87 connect(d_ptr, &ViewerPrivate::pageIsScrolledToBottom,
this, &Viewer::pageIsScrolledToBottom);
88 connect(d_ptr, &ViewerPrivate::printingFinished,
this, &Viewer::printingFinished);
89 connect(d_ptr, &ViewerPrivate::zoomChanged,
this, &Viewer::zoomChanged);
91 connect(d_ptr, &ViewerPrivate::showNextMessage,
this, &Viewer::showNextMessage);
92 connect(d_ptr, &ViewerPrivate::showPreviousMessage,
this, &Viewer::showPreviousMessage);
93 connect(d_ptr, &ViewerPrivate::sendResponse,
this, &Viewer::sendResponse);
96 qGuiApp->installEventFilter(
this);
97 slotGeneralPaletteChanged();
104 slotGeneralPaletteChanged();
109void Viewer::slotGeneralPaletteChanged()
115void Viewer::changeEvent(
QEvent *event)
119 d->slotGeneralFontChanged();
130 d->setMessage(
message, updateMode);
136 if (d->messageItem() == item) {
140 d->setMessageItem(item, updateMode);
144 d->itemFetchResult(job);
146 d->displaySplashPage(
i18n(
"Loading message..."));
153 return d->mMessagePath;
159 d->mMessagePath = path;
165 d->displaySplashPage(templateName, data, domain);
171 d->enableMessageDisplay();
177 d->printMessage(msg);
180void Viewer::printPreviewMessage(
const Akonadi::Item &message)
183 d->printPreviewMessage(
message);
186void Viewer::printPreview()
189 d->slotPrintPreview();
195 d->slotPrintMessage();
201 if (!d->mResizeTimer.isActive()) {
206 d->mResizeTimer.start(100);
217void Viewer::slotAttachmentSaveAs()
220 d->slotAttachmentSaveAs();
223void Viewer::slotAttachmentSaveAll()
226 d->slotAttachmentSaveAll();
229void Viewer::slotSaveMessage()
232 d->slotSaveMessage();
238 d->mViewer->scrollUp(10);
241void Viewer::slotScrollDown()
244 d->mViewer->scrollDown(10);
250 d->mViewer->isScrolledToBottom();
253void Viewer::slotJumpDown()
256 d->mViewer->scrollPageDown(100);
259void Viewer::slotScrollPrior()
262 d->mViewer->scrollPageUp(80);
265void Viewer::slotScrollNext()
268 d->mViewer->scrollPageDown(80);
271QString Viewer::selectedText()
const
274 return d->mViewer->selectedText();
280 return d->displayFormatMessageOverwrite();
286 d->setDisplayFormatMessageOverwrite(format);
292 d->setHtmlLoadExtDefault(loadExtDefault);
298 d->setHtmlLoadExtOverride(loadExtOverride);
304 return d->htmlLoadExtOverride();
310 return d->htmlMail();
316 return d->htmlLoadExternal();
319bool Viewer::isFixedFont()
const
322 return d->mHtmlHeadSettings.fixedFont;
325void Viewer::setUseFixedFont(
bool useFixedFont)
328 d->setUseFixedFont(useFixedFont);
334 return d->mMainWindow;
340 d->setDecryptMessageOverwrite(overwrite);
352 return d->mMessageItem;
359 d->recreateCssHelper();
360 d->update(MimeTreeParser::Force);
368void Viewer::slotFind()
374const AttachmentStrategy *Viewer::attachmentStrategy()
const
377 return d->attachmentStrategy();
380void Viewer::setAttachmentStrategy(
const AttachmentStrategy *strategy)
383 d->setAttachmentStrategy(strategy);
386QString Viewer::overrideEncoding()
const
389 return d->overrideEncoding();
392void Viewer::setOverrideEncoding(
const QString &encoding)
395 d->setOverrideEncoding(encoding);
398CSSHelper *Viewer::cssHelper()
const
401 return d->cssHelper();
407 return d->mToggleFixFontAction;
410bool Viewer::mimePartTreeIsEmpty()
const
413 return d->mimePartTreeIsEmpty();
419 return d->mToggleMimePartTreeAction;
422QAction *Viewer::selectAllAction()
const
425 return d->mSelectAllAction;
428QAction *Viewer::viewSourceAction()
const
431 return d->mViewSourceAction;
434QAction *Viewer::copyURLAction()
const
437 return d->mCopyURLAction;
440QAction *Viewer::copyAction()
const
443 return d->mCopyAction;
446QAction *Viewer::speakTextAction()
const
449 return d->mSpeakTextAction;
452QAction *Viewer::copyImageLocation()
const
455 return d->mCopyImageLocation;
458QAction *Viewer::saveAsAction()
const
461 return d->mSaveMessageAction;
464QAction *Viewer::urlOpenAction()
const
467 return d->mUrlOpenAction;
470bool Viewer::printingMode()
const
473 return d->printingMode();
476void Viewer::setPrinting(
bool enable)
479 d->setPrinting(enable);
482void Viewer::writeConfig(
bool force)
485 d->writeConfig(force);
488QUrl Viewer::urlClicked()
const
491 return d->mClickedUrl;
494QUrl Viewer::imageUrlClicked()
const
497 return d->imageUrl();
503 d->update(updateMode);
509 d->setMessagePart(aMsgPart);
517void Viewer::slotShowMessageSource()
520 d->slotShowMessageSource();
523void Viewer::readConfig()
531 return d_func()->mMimePartTree->mimePartModel();
538 job->fetchScope().fetchAllAttributes();
540 job->fetchScope().fetchFullPayload(
true);
554 handler->setSession(d->mSession);
555 d->mMessageLoadedHandlers.insert(handler);
562 d->mMessageLoadedHandlers.remove(handler);
571void Viewer::selectAll()
577void Viewer::copySelectionToClipboard()
580 d->slotCopySelectedText();
583void Viewer::setZoomFactor(qreal zoomFactor)
586 d->mZoomActionMenu->setZoomFactor(zoomFactor);
589void Viewer::slotZoomReset()
592 d->mZoomActionMenu->slotZoomReset();
595void Viewer::slotZoomIn()
598 d->mZoomActionMenu->slotZoomIn();
601void Viewer::slotZoomOut()
604 d->mZoomActionMenu->slotZoomOut();
607QAction *Viewer::findInMessageAction()
const
610 return d->mFindInMessageAction;
613QAction *Viewer::shareTextAction()
const
616 return d->mShareTextAction;
619void Viewer::slotChangeDisplayMail(Viewer::DisplayFormatMessage mode,
bool loadExternal)
624 update(MimeTreeParser::Force);
628QAction *Viewer::saveMessageDisplayFormatAction()
const
631 return d->mSaveMessageDisplayFormat;
634QAction *Viewer::resetMessageDisplayFormatAction()
const
637 return d->mResetMessageDisplayFormat;
640QAction *Viewer::developmentToolsAction()
const
643 return d->mDevelopmentToolsAction;
649 return d->mDisableEmoticonAction;
652void Viewer::saveMainFrameScreenshotInFile(
const QString &filename)
655 d->saveMainFrameScreenshotInFile(filename);
661 return d->mShareServiceUrlMenu;
664HeaderStylePlugin *Viewer::headerStylePlugin()
const
667 return d->mHeaderStylePlugin;
670DKIMViewerMenu *Viewer::dkimViewerMenu()
673 return d->dkimViewerMenu();
676RemoteContentMenu *Viewer::remoteContentMenu()
const
679 return d->remoteContentMenu();
682void Viewer::showMdnInformations(
const QPair<QString, bool> &mdnInfo)
685 d->showMdnInformations(mdnInfo);
688void Viewer::mdnWarningAnimatedHide()
691 d->mdnWarningAnimatedHide();
694void Viewer::setPluginName(
const QString &pluginName)
697 d->setPluginName(pluginName);
700void Viewer::showOpenAttachmentFolderWidget(
const QList<QUrl> &urls)
703 d->showSavedFileFolderWidget(urls, MessageViewer::OpenSavedFileFolderWidget::FileType::Attachment);
706QList<QAction *> Viewer::viewerPluginActionList(ViewerPluginInterface::SpecificFeatureTypes features)
709 return d->viewerPluginActionList(features);
715 return d->interceptorUrlActions(result);
718void Viewer::runJavaScript(
const QString &code)
721 d->mViewer->page()->runJavaScript(code, WebEngineViewer::WebEngineManageScript::scriptWordId());
724void Viewer::setPrintElementBackground(
bool printElementBackground)
727 d->mViewer->setPrintElementBackground(printElementBackground);
730bool Viewer::showSignatureDetails()
const
733 return d->showSignatureDetails();
736void Viewer::setShowSignatureDetails(
bool showDetails)
739 d->setShowSignatureDetails(showDetails);
742bool Viewer::showEncryptionDetails()
const
745 return d->showEncryptionDetails();
748void Viewer::hasMultiMessages(
bool messages)
751 d->hasMultiMessages(messages);
754void Viewer::updateShowMultiMessagesButton(
bool enablePreviousButton,
bool enableNextButton)
757 d->updateShowMultiMessagesButton(enablePreviousButton, enableNextButton);
760void Viewer::setShowEncryptionDetails(
bool showDetails)
763 d->setShowEncryptionDetails(showDetails);
766qreal Viewer::webViewZoomFactor()
const
769 return d->webViewZoomFactor();
772void Viewer::setWebViewZoomFactor(qreal factor)
775 d->setWebViewZoomFactor(factor);
781 return d->mDkimWidgetInfo;
784void Viewer::exportToPdf(
const QString &fileName)
787 d->exportToPdf(fileName);
790void Viewer::showDevelopmentTools()
793 d->slotShowDevelopmentTools();
799 d->setIdentityManager(ident);
802void Viewer::setFolderIdentity(uint folderIdentity)
805 d->setFolderIdentity(folderIdentity);
810#include "moc_viewer.cpp"
QSet< QByteArray > loadedPayloadParts() const
An interface to plug in a handler that is called when an message item has been loaded into the view.
This is the main widget for the viewer.
QAbstractItemModel * messageTreeModel() const
A QAIM tree model of the message structure.
void deleteMessage()
Initiates a delete, by sending a signal to delete the message item.
void showReader(KMime::Content *aMsgPart, bool aHTML, const QString &encoding)
Emitted when the content should be shown in a separate window.
void itemRemoved()
Emitted when the item, previously set with setMessageItem, has been removed.
void closeEvent(QCloseEvent *) override
Some necessary event handling.
QString messagePath() const
The path to the message in terms of Akonadi collection hierarchy.
void print()
Print the currently displayed message.
void showMessage(const KMime::Message::Ptr &message, const QString &encoding)
Emitted when the message should be shown in a separate window.
bool event(QEvent *e) override
Watch for palette changes.
Viewer::DisplayFormatMessage displayFormatMessageOverwrite() const
Get the html override setting.
void setHtmlLoadExtDefault(bool loadExtDefault)
Default behavior for loading external references.
void setMessageItem(const Akonadi::Item &item, MimeTreeParser::UpdateMode updateMode=MimeTreeParser::Delayed)
Set the Akonadi item that will be displayed.
bool htmlMail() const
Is html mail to be supported? Takes into account override.
void showStatusBarMessage(const QString &message)
Emitted when a status bar message is shown.
void printMessage(const Akonadi::Item &msg)
Sets a message as the current one and print it immediately.
Akonadi::ItemFetchJob * createFetchJob(const Akonadi::Item &item)
Create an item fetch job that is suitable for using to fetch the message item that will be displayed ...
void setMessagePart(KMime::Content *aMsgPart)
Instead of settings a message to be shown sets a message part to be shown.
bool htmlLoadExtOverride() const
Get the load external references override setting.
void setMessage(const KMime::Message::Ptr &message, MimeTreeParser::UpdateMode updateMode=MimeTreeParser::Delayed)
Set the message that shall be shown.
void popupMenu(const Akonadi::Item &msg, const QUrl &url, const QUrl &imageUrl, const QPoint &mousePos)
The user presses the right mouse button.
bool htmlLoadExternal() const
Is loading ext.
void displaySplashPage(const QString &templateName, const QVariantHash &data, const QByteArray &domain=QByteArray())
Display a generic HTML splash page instead of a message.
void setHtmlLoadExtOverride(bool loadExtOverride)
Override default load external references setting.
void atBottom()
Returns true if the message view is scrolled to the bottom.
void slotScrollUp()
HTML Widget scrollbar and layout handling.
void setDisplayFormatMessageOverwrite(Viewer::DisplayFormatMessage format)
Override default html mail setting.
void addMessageLoadedHandler(AbstractMessageLoadedHandler *handler)
Adds a handler for actions that will be executed when the message has been loaded into the view.
void enableMessageDisplay()
Enable the displaying of messages again after an splash (or other) page was displayed.
void removeMessageLoadedHandler(AbstractMessageLoadedHandler *handler)
Removes the handler for actions that will be executed when the message has been loaded into the view.
Viewer(QWidget *parent, QWidget *widget=nullptr, KActionCollection *actionCollection=nullptr)
Create a mail viewer widget.
void setMessagePath(const QString &path)
Set the path to the message in terms of Akonadi collection hierarchy.
void clear(MimeTreeParser::UpdateMode updateMode=MimeTreeParser::Delayed)
Convenience method to clear the reader and discard the current message.
KMime::Message::Ptr message() const
Returns the current message displayed in the viewer.
Akonadi::Item messageItem() const
Returns the current message item displayed in the viewer.
void setDecryptMessageOverwrite(bool overwrite=true)
Enforce message decryption.
The WebHitTestResult class.
QString i18n(const char *text, const TYPE &arg...)
AKONADI_MIME_EXPORT const char Body[]
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)