Messagelib

viewer.h
1 /*
2  This file is part of KMail, the KDE mail client.
3  SPDX-FileCopyrightText: 1997 Markus Wuebben <[email protected]>
4  SPDX-FileCopyrightText: 2009 Klarälvdalens Datakonsult AB, a KDAB Group company, [email protected]
5  SPDX-FileCopyrightText: 2009 Andras Mantia <[email protected]>
6 
7  SPDX-License-Identifier: GPL-2.0-or-later
8 */
9 
10 #ifndef MESSAGEVIEWER_H
11 #define MESSAGEVIEWER_H
12 
13 #include "messageviewer_export.h"
14 #include "config-messageviewer.h"
15 #include "messageviewer/viewerplugininterface.h"
16 #include <MimeTreeParser/Enums>
17 
18 #include <KMime/Message>
19 
20 #include <QWidget>
21 
22 namespace Akonadi {
23 class Item;
24 class ItemFetchJob;
25 }
26 
27 class KActionCollection;
28 class QAction;
29 class KToggleAction;
30 class KActionMenu;
31 
32 class QAbstractItemModel;
33 class QCloseEvent;
34 class QEvent;
35 class QResizeEvent;
36 
37 namespace WebEngineViewer {
38 class WebHitTestResult;
39 }
40 
41 namespace MessageViewer {
42 class WebHitTestResult;
43 class DKIMWidgetInfo;
44 class DKIMViewerMenu;
45 class AttachmentStrategy;
46 class HeaderStylePlugin;
47 class CSSHelper;
48 class ViewerPrivate;
49 class Viewer;
50 
55 class MESSAGEVIEWER_EXPORT AbstractMessageLoadedHandler
56 {
57 public:
60 
67  virtual void setItem(const Akonadi::Item &item) = 0;
68 
69 protected:
70  Akonadi::Session *session() const;
71 
72 private:
73  void setSession(Akonadi::Session *session);
74 
75  friend class Viewer;
76  class Private;
77  Private *const d;
78 };
79 
85 class MESSAGEVIEWER_EXPORT Viewer : public QWidget
86 {
87  Q_OBJECT
88 
89  Q_DECLARE_PRIVATE(Viewer)
90 
91 public:
98  explicit Viewer(QWidget *parent, QWidget *widget = nullptr, KActionCollection *actionCollection = nullptr);
99  ~Viewer() override;
100 
104  Q_REQUIRED_RESULT KMime::Message::Ptr message() const;
105 
109  Q_REQUIRED_RESULT Akonadi::Item messageItem() const;
110 
111  enum DisplayFormatMessage {
112  UseGlobalSetting = 0,
113  Text = 1,
114  Html = 2,
115  Unknown = 3,
116  ICal = 4
117  };
118 
119  enum AttachmentAction {
120  Open = 1,
121  OpenWith,
122  View,
123  Save,
124  Properties,
125  Delete,
126  Copy,
127  ScrollTo,
128  ReplyMessageToAuthor,
129  ReplyMessageToAll
130  };
131 
132  enum ResourceOnlineMode {
133  AllResources = 0,
134  SelectedResource = 1
135  };
136 
142  void setMessage(const KMime::Message::Ptr &message, MimeTreeParser::UpdateMode updateMode = MimeTreeParser::Delayed);
143 
150  void setMessageItem(const Akonadi::Item &item, MimeTreeParser::UpdateMode updateMode = MimeTreeParser::Delayed);
151 
155  Q_REQUIRED_RESULT QString messagePath() const;
156 
160  void setMessagePath(const QString &path);
161 
166  void setMessagePart(KMime::Content *aMsgPart);
167 
173  void clear(MimeTreeParser::UpdateMode updateMode = MimeTreeParser::Delayed);
174 
175  void update(MimeTreeParser::UpdateMode updateMode = MimeTreeParser::Delayed);
176 
181  void printMessage(const Akonadi::Item &msg);
182 
183  void printPreviewMessage(const Akonadi::Item &message);
184 
186  void print();
187  void printPreview();
188 
190  Q_REQUIRED_RESULT Viewer::DisplayFormatMessage displayFormatMessageOverwrite() const;
191 
193  void setDisplayFormatMessageOverwrite(Viewer::DisplayFormatMessage format);
194 
196  bool htmlLoadExtOverride() const;
197 
203  void setHtmlLoadExtDefault(bool loadExtDefault);
204 
210  void setHtmlLoadExtOverride(bool loadExtOverride);
211 
213  Q_REQUIRED_RESULT bool htmlMail() const;
214 
216  Q_REQUIRED_RESULT bool htmlLoadExternal() const;
217 
224  void displaySplashPage(const QString &templateName, const QVariantHash &data, const QByteArray &domain = QByteArray());
225 
227  void enableMessageDisplay();
228 
230  void atBottom();
231 
232  Q_REQUIRED_RESULT bool isFixedFont() const;
233  void setUseFixedFont(bool useFixedFont);
234 
235  Q_REQUIRED_RESULT QWidget *mainWindow();
236 
238  void setDecryptMessageOverwrite(bool overwrite = true);
239 
242  void deleteMessage();
243 
244  Q_REQUIRED_RESULT const AttachmentStrategy *attachmentStrategy() const;
245  void setAttachmentStrategy(const AttachmentStrategy *strategy);
246 
247  Q_REQUIRED_RESULT QString overrideEncoding() const;
248  void setOverrideEncoding(const QString &encoding);
249  Q_REQUIRED_RESULT CSSHelper *cssHelper() const;
250  void setPrinting(bool enable);
251 
252  void selectAll();
253  void copySelectionToClipboard();
254 
255  void setZoomFactor(qreal zoomFactor);
256 
257  Q_REQUIRED_RESULT KToggleAction *toggleFixFontAction() const;
258 
259  Q_REQUIRED_RESULT KToggleAction *toggleMimePartTreeAction() const;
260 
261  Q_REQUIRED_RESULT QAction *selectAllAction() const;
262  Q_REQUIRED_RESULT QAction *copyURLAction() const;
263  Q_REQUIRED_RESULT QAction *copyAction() const;
264  Q_REQUIRED_RESULT QAction *urlOpenAction() const;
265  Q_REQUIRED_RESULT QAction *speakTextAction() const;
266  Q_REQUIRED_RESULT QAction *copyImageLocation() const;
267  Q_REQUIRED_RESULT QAction *viewSourceAction() const;
268  Q_REQUIRED_RESULT QAction *findInMessageAction() const;
269  Q_REQUIRED_RESULT QAction *saveAsAction() const;
270  Q_REQUIRED_RESULT QAction *saveMessageDisplayFormatAction() const;
271  Q_REQUIRED_RESULT QAction *resetMessageDisplayFormatAction() const;
272  Q_REQUIRED_RESULT QAction *shareTextAction() const;
273 
274  Q_REQUIRED_RESULT QAction *developmentToolsAction() const;
275  Q_REQUIRED_RESULT KToggleAction *disableEmoticonAction() const;
276  Q_REQUIRED_RESULT KActionMenu *shareServiceUrlMenu() const;
277  Q_REQUIRED_RESULT HeaderStylePlugin *headerStylePlugin() const;
278  Q_REQUIRED_RESULT MessageViewer::DKIMViewerMenu *dkimViewerMenu();
279 
280  void setPluginName(const QString &pluginName);
281 
282  void writeConfig(bool withSync = true);
283 
284  Q_REQUIRED_RESULT QUrl urlClicked() const;
285  Q_REQUIRED_RESULT QUrl imageUrlClicked() const;
286 
287  void readConfig();
288 
290  QAbstractItemModel *messageTreeModel() const;
291 
298  Akonadi::ItemFetchJob *createFetchJob(const Akonadi::Item &item);
299 
304  void addMessageLoadedHandler(AbstractMessageLoadedHandler *handler);
305 
310  void removeMessageLoadedHandler(AbstractMessageLoadedHandler *handler);
311 
312  Q_REQUIRED_RESULT QString selectedText() const;
313 
314  void saveMainFrameScreenshotInFile(const QString &filename);
315  bool mimePartTreeIsEmpty() const;
316 
317  void showOpenAttachmentFolderWidget(const QList<QUrl> &urls);
318  Q_REQUIRED_RESULT QList<QAction *> viewerPluginActionList(
320  Q_REQUIRED_RESULT QList<QAction *> interceptorUrlActions(const WebEngineViewer::WebHitTestResult &result) const;
321 
322  void runJavaScript(const QString &code);
323  void setPrintElementBackground(bool printElementBackground);
324 
325  Q_REQUIRED_RESULT bool printingMode() const;
326 
327  Q_REQUIRED_RESULT bool showSignatureDetails() const;
328  void setShowSignatureDetails(bool showDetails);
329 
330  Q_REQUIRED_RESULT qreal webViewZoomFactor() const;
331  void setWebViewZoomFactor(qreal factor);
332 
333  Q_REQUIRED_RESULT bool showEncryptionDetails() const;
334  void setShowEncryptionDetails(bool showDetails);
335 
336  void hasMultiMessages(bool messages);
337  void updateShowMultiMessagesButton(bool enablePreviousButton, bool enableNextButton);
338  Q_REQUIRED_RESULT MessageViewer::DKIMWidgetInfo *dkimWidgetInfo();
339 
340  void exportToPdf(const QString &fileName);
341 
342  void showDevelopmentTools();
343 Q_SIGNALS:
344  void moveMessageToTrash();
345  void pageIsScrolledToBottom(bool);
346 
351  void showStatusBarMessage(const QString &message);
352 
354  void popupMenu(const Akonadi::Item &msg, const QUrl &url, const QUrl &imageUrl, const QPoint &mousePos);
355  void displayPopupMenu(const Akonadi::Item &msg, const WebEngineViewer::WebHitTestResult &result, const QPoint &mousePos);
360  void urlClicked(const Akonadi::Item &, const QUrl &);
361 
362  void requestConfigSync();
363 
365  void showReader(KMime::Content *aMsgPart, bool aHTML, const QString &encoding);
366 
368  void showMessage(const KMime::Message::Ptr &message, const QString &encoding);
369 
370  void replyMessageTo(const KMime::Message::Ptr &message, bool replyToAll);
371 
372  void deleteMessage(const Akonadi::Item &);
373 
375  void itemRemoved();
376 
377  void makeResourceOnline(MessageViewer::Viewer::ResourceOnlineMode mode);
378 
379  void printingFinished();
380  void zoomChanged(qreal zoomFactor);
381  void showNextMessage();
382  void showPreviousMessage();
383 
384 private:
385  void initialize();
386 
387 public Q_SLOTS:
388 
395  void slotScrollUp();
396  void slotScrollDown();
397  void slotScrollPrior();
398  void slotScrollNext();
399  void slotJumpDown();
400  void slotFind();
401  void slotSaveMessage();
402  void slotAttachmentSaveAs();
403  void slotAttachmentSaveAll();
404  void slotShowMessageSource();
405  void slotZoomIn();
406  void slotZoomOut();
407  void slotZoomReset();
408  void slotChangeDisplayMail(Viewer::DisplayFormatMessage, bool);
409 protected:
411  void closeEvent(QCloseEvent *) override;
412  void resizeEvent(QResizeEvent *) override;
414  Q_REQUIRED_RESULT bool event(QEvent *e) override;
415  void changeEvent(QEvent *event) override;
416 
417  ViewerPrivate *const d_ptr;
418 };
419 }
420 
421 #endif
The DKIMWidgetInfo class.
This is the main widget for the viewer.
Definition: viewer.h:85
The WebHitTestResult class.
The CSSHelper class.
Definition: csshelper.h:21
The HeaderStylePlugin class.
The AttachmentStrategy class.
An interface to plug in a handler that is called when an message item has been loaded into the view...
Definition: viewer.h:55
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Nov 30 2020 23:14:53 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.