File indexing completed on 2024-05-12 05:20:44

0001 //
0002 
0003 #pragma once
0004 
0005 #include "kmail_export.h"
0006 
0007 #include "secondarywindow.h"
0008 
0009 #include <KMime/Message>
0010 #include <QUrl>
0011 
0012 #include <Akonadi/Collection>
0013 #include <Akonadi/Item>
0014 #include <MessageViewer/Viewer>
0015 #include <QModelIndex>
0016 class KMReaderWin;
0017 class QAction;
0018 class KJob;
0019 class ZoomLabelWidget;
0020 
0021 namespace KMail
0022 {
0023 class MessageActions;
0024 class TagActionManager;
0025 }
0026 namespace Akonadi
0027 {
0028 class StandardMailActionManager;
0029 }
0030 namespace KMime
0031 {
0032 class Message;
0033 class Content;
0034 }
0035 Q_DECLARE_METATYPE(QModelIndex)
0036 
0037 class KMAIL_EXPORT KMReaderMainWin : public KMail::SecondaryWindow
0038 {
0039     Q_OBJECT
0040 
0041 public:
0042     KMReaderMainWin(MessageViewer::Viewer::DisplayFormatMessage format, bool htmlLoadExtDefault, const QString &name = QString());
0043     explicit KMReaderMainWin(const QString &name = QString());
0044     KMReaderMainWin(KMime::Content *aMsgPart, MessageViewer::Viewer::DisplayFormatMessage format, const QString &encoding, const QString &name = QString());
0045     ~KMReaderMainWin() override;
0046 
0047     void setUseFixedFont(bool useFixedFont);
0048 
0049     [[nodiscard]] MessageViewer::Viewer *viewer() const;
0050     /**
0051      * take ownership of and show @p msg
0052      *
0053      * The last two parameters, serNumOfOriginalMessage and nodeIdOffset, are needed when @p msg
0054      * is derived from another message, e.g. the user views an encapsulated message in this window.
0055      * Then, the reader needs to know about that original message, so those to parameters are passed
0056      * onto setOriginalMsg() of KMReaderWin.
0057      *
0058      * @param encoding The message encoding.
0059      * @param msg The message.
0060      * @param parentCollection An Akonadi parent collection.
0061      */
0062     void showMessage(const QString &encoding, const Akonadi::Item &msg, const Akonadi::Collection &parentCollection = Akonadi::Collection());
0063 
0064     void showMessage(const QString &encoding, const QList<KMime::Message::Ptr> &message);
0065     void showMessage(const QString &encoding, const KMime::Message::Ptr &message);
0066     void showMessagePopup(const Akonadi::Item &msg,
0067                           const QUrl &aUrl,
0068                           const QUrl &imageUrl,
0069                           const QPoint &aPoint,
0070                           bool contactAlreadyExists,
0071                           bool uniqueContactFound,
0072                           const WebEngineViewer::WebHitTestResult &result);
0073     void showAndActivateWindow();
0074 public Q_SLOTS:
0075     void slotForwardInlineMsg();
0076     void slotForwardAttachedMessage();
0077     void slotRedirectMessage();
0078     void slotNewMessageToRecipients();
0079     void slotCustomReplyToMsg(const QString &tmpl);
0080     void slotCustomReplyAllToMsg(const QString &tmpl);
0081     void slotCustomForwardMsg(const QString &tmpl);
0082 
0083 private:
0084     void slotMessagePopup(const Akonadi::Item &aMsg, const WebEngineViewer::WebHitTestResult &result, const QPoint &aPoint);
0085     void slotContactSearchJobForMessagePopupDone(KJob *);
0086     void slotTrashMessage();
0087 
0088     void slotEditToolbars();
0089     void slotConfigChanged();
0090     void slotUpdateToolbars();
0091 
0092     /// This closes the window if the setting to close the window after replying or
0093     /// forwarding is set.
0094     void slotReplyOrForwardFinished();
0095     void slotCopyItem(QAction *);
0096     void slotCopyMoveResult(KJob *job);
0097     void slotMoveItem(QAction *action);
0098 
0099     void slotShowMessageStatusBar(const QString &msg);
0100 
0101     void copyOrMoveItem(const Akonadi::Collection &collection, bool move);
0102     [[nodiscard]] Akonadi::Collection parentCollection() const;
0103     void initKMReaderMainWin();
0104     void setupAccel();
0105     QAction *copyActionMenu(QMenu *menu);
0106     QAction *moveActionMenu(QMenu *menu);
0107     void setZoomChanged(qreal zoomFactor);
0108     void updateActions();
0109     void slotSelectMoreMessageTagList();
0110     void toggleMessageSetTag(const Akonadi::Item::List &select, const Akonadi::Tag &tag);
0111     void slotUpdateMessageTagList(const Akonadi::Tag &tag);
0112     void initializeMessage(const KMime::Message::Ptr &message);
0113     void showNextMessage();
0114     void showPreviousMessage();
0115     void updateButtons();
0116     void slotToggleMenubar(bool dontShowWarning);
0117     void initializeAkonadiStandardAction();
0118     void slotMarkMailAs();
0119 
0120     QList<KMime::Message::Ptr> mListMessage;
0121     int mCurrentMessageIndex = 0;
0122     Akonadi::Collection mParentCollection;
0123     Akonadi::Item mMsg;
0124     // a few actions duplicated from kmmainwidget
0125     QAction *mTrashAction = nullptr;
0126     QAction *mSaveAtmAction = nullptr;
0127     KMail::MessageActions *mMsgActions = nullptr;
0128     KMReaderWin *mReaderWin = nullptr;
0129     ZoomLabelWidget *mZoomLabelIndicator = nullptr;
0130     KMail::TagActionManager *mTagActionManager = nullptr;
0131     KToggleAction *mHideMenuBarAction = nullptr;
0132     Akonadi::StandardMailActionManager *mAkonadiStandardActionManager = nullptr;
0133 };