1 //
2 
3 #pragma once
4 
5 #include "kmail_export.h"
6 
7 #include "secondarywindow.h"
8 
9 #include <KMime/Message>
10 #include <QUrl>
11 
12 #include <Akonadi/Collection>
13 #include <Akonadi/Item>
14 #include <MessageViewer/Viewer>
15 #include <QModelIndex>
16 class KMReaderWin;
17 class QAction;
18 class KJob;
19 class ZoomLabelWidget;
20 
21 namespace KMail
22 {
23 class MessageActions;
24 class TagActionManager;
25 }
26 namespace Akonadi
27 {
28 class StandardMailActionManager;
29 }
30 namespace KMime
31 {
32 class Message;
33 class Content;
34 }
Q_DECLARE_METATYPE(QModelIndex)35 Q_DECLARE_METATYPE(QModelIndex)
36 
37 class KMAIL_EXPORT KMReaderMainWin : public KMail::SecondaryWindow
38 {
39     Q_OBJECT
40 
41 public:
42     KMReaderMainWin(MessageViewer::Viewer::DisplayFormatMessage format, bool htmlLoadExtDefault, const QString &name = QString());
43     explicit KMReaderMainWin(const QString &name = QString());
44     KMReaderMainWin(KMime::Content *aMsgPart, MessageViewer::Viewer::DisplayFormatMessage format, const QString &encoding, const QString &name = QString());
45     ~KMReaderMainWin() override;
46 
47     void setUseFixedFont(bool useFixedFont);
48 
49     MessageViewer::Viewer *viewer() const;
50     /**
51      * take ownership of and show @p msg
52      *
53      * The last two parameters, serNumOfOriginalMessage and nodeIdOffset, are needed when @p msg
54      * is derived from another message, e.g. the user views an encapsulated message in this window.
55      * Then, the reader needs to know about that original message, so those to parameters are passed
56      * onto setOriginalMsg() of KMReaderWin.
57      *
58      * @param encoding The message encoding.
59      * @param msg The message.
60      * @param parentCollection An Akonadi parent collection.
61      */
62     void showMessage(const QString &encoding, const Akonadi::Item &msg, const Akonadi::Collection &parentCollection = Akonadi::Collection());
63 
64     void showMessage(const QString &encoding, const QVector<KMime::Message::Ptr> &message);
65     void showMessage(const QString &encoding, const KMime::Message::Ptr &message);
66     void showMessagePopup(const Akonadi::Item &msg,
67                           const QUrl &aUrl,
68                           const QUrl &imageUrl,
69                           const QPoint &aPoint,
70                           bool contactAlreadyExists,
71                           bool uniqueContactFound,
72                           const WebEngineViewer::WebHitTestResult &result);
73     void showAndActivateWindow();
74 public Q_SLOTS:
75     void slotForwardInlineMsg();
76     void slotForwardAttachedMessage();
77     void slotRedirectMessage();
78     void slotNewMessageToRecipients();
79     void slotCustomReplyToMsg(const QString &tmpl);
80     void slotCustomReplyAllToMsg(const QString &tmpl);
81     void slotCustomForwardMsg(const QString &tmpl);
82 
83 private:
84     void slotMessagePopup(const Akonadi::Item &aMsg, const WebEngineViewer::WebHitTestResult &result, const QPoint &aPoint);
85     void slotContactSearchJobForMessagePopupDone(KJob *);
86     void slotTrashMessage();
87 
88     void slotEditToolbars();
89     void slotConfigChanged();
90     void slotUpdateToolbars();
91 
92     /// This closes the window if the setting to close the window after replying or
93     /// forwarding is set.
94     void slotReplyOrForwardFinished();
95     void slotCopyItem(QAction *);
96     void slotCopyMoveResult(KJob *job);
97     void slotMoveItem(QAction *action);
98 
99     void slotShowMessageStatusBar(const QString &msg);
100 
101     void copyOrMoveItem(const Akonadi::Collection &collection, bool move);
102     Q_REQUIRED_RESULT Akonadi::Collection parentCollection() const;
103     void initKMReaderMainWin();
104     void setupAccel();
105     QAction *copyActionMenu(QMenu *menu);
106     QAction *moveActionMenu(QMenu *menu);
107     void setZoomChanged(qreal zoomFactor);
108     void updateActions();
109     void slotSelectMoreMessageTagList();
110     void toggleMessageSetTag(const Akonadi::Item::List &select, const Akonadi::Tag &tag);
111     void slotUpdateMessageTagList(const Akonadi::Tag &tag);
112     void initializeMessage(const KMime::Message::Ptr &message);
113     void showNextMessage();
114     void showPreviousMessage();
115     void updateButtons();
116     void slotToggleMenubar(bool dontShowWarning);
117     void initializeAkonadiStandardAction();
118     void slotMarkMailAs();
119 
120     QVector<KMime::Message::Ptr> mListMessage;
121     int mCurrentMessageIndex = 0;
122     Akonadi::Collection mParentCollection;
123     Akonadi::Item mMsg;
124     // a few actions duplicated from kmmainwidget
125     QAction *mTrashAction = nullptr;
126     QAction *mSaveAtmAction = nullptr;
127     KMail::MessageActions *mMsgActions = nullptr;
128     KMReaderWin *mReaderWin = nullptr;
129     ZoomLabelWidget *mZoomLabelIndicator = nullptr;
130     KMail::TagActionManager *mTagActionManager = nullptr;
131     KToggleAction *mHideMenuBarAction = nullptr;
132     Akonadi::StandardMailActionManager *mAkonadiStandardActionManager = nullptr;
133 };
134 
135