Add actions from popup
[kdepim.git] / akregator / src / articleviewer-ng / webengine / articleviewerwebengine.h
blob9772404503b5d5a5de166b3cd45d824d9986c475
1 /*
2 Copyright (c) 2015-2016 Montel Laurent <montel@kde.org>
4 This program is free software; you can redistribute it and/or modify it
5 under the terms of the GNU General Public License, version 2, as
6 published by the Free Software Foundation.
8 This program is distributed in the hope that it will be useful, but
9 WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 General Public License for more details.
13 You should have received a copy of the GNU General Public License along
14 with this program; if not, write to the Free Software Foundation, Inc.,
15 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 #ifndef ARTICLEVIEWERWEBENGINE_H
19 #define ARTICLEVIEWERWEBENGINE_H
21 #include <MessageViewer/WebEngineView>
22 #include <openurlrequest.h>
23 #include <shareserviceurlmanager.h>
24 #include <MessageViewer/ViewerPluginInterface>
26 class KActionCollection;
27 namespace MessageViewer
29 class WebHitTestResult;
30 class ViewerPluginToolManager;
31 class ViewerPluginInterface;
32 class MailWebEngineAccessKey;
33 class NetworkAccessManagerWebEngine;
35 namespace PimCommon
37 class ShareServiceUrlManager;
39 namespace KIO
41 class KUriFilterSearchProviderActions;
43 namespace Akregator
45 class ArticleViewerWebEnginePage;
46 class AKREGATOR_EXPORT ArticleViewerWebEngine : public MessageViewer::WebEngineView
48 Q_OBJECT
49 public:
50 enum ArticleAction {
51 DeleteAction = 0,
52 MarkAsRead,
53 MarkAsUnRead,
54 MarkAsImportant,
55 SendUrlArticle,
56 SendFileArticle,
57 OpenInExternalBrowser,
58 Share,
59 OpenInBackgroundTab
61 explicit ArticleViewerWebEngine(KActionCollection *ac, QWidget *parent);
62 ~ArticleViewerWebEngine();
64 void showAboutPage();
66 void disableIntroduction();
67 void setArticleAction(ArticleViewerWebEngine::ArticleAction type, const QString &articleId, const QString &feed);
69 void createViewerPluginToolManager(KActionCollection *ac, QWidget *parent);
71 protected:
72 QUrl mCurrentUrl;
73 KActionCollection *mActionCollection;
74 PimCommon::ShareServiceUrlManager *mShareServiceManager;
75 KIO::KUriFilterSearchProviderActions *mWebShortcutMenuManager;
77 private:
78 enum MousePressedButtonType {
79 RightButton = 0,
80 LeftButton,
81 MiddleButton,
84 void paintAboutScreen(const QString &templateName, const QVariantHash &data);
85 QVariantHash introductionData() const;
87 public Q_SLOTS:
88 void slotPrintPreview();
89 void slotPrint();
90 void slotCopy();
91 void slotSaveLinkAs();
92 void slotCopyLinkAddress();
93 void slotSaveImageOnDiskInFrame();
94 void slotCopyImageLocationInFrame();
95 void slotBlockImage();
96 void slotExpandUrl();
97 Q_SIGNALS:
98 void signalOpenUrlRequest(Akregator::OpenUrlRequest &);
99 void showStatusBarMessage(const QString &link);
100 void showContextMenu(const QPoint &pos);
101 void articleAction(Akregator::ArticleViewerWebEngine::ArticleAction type, const QString &articleId, const QString &feed);
102 void findTextInHtml();
103 void textToSpeech();
105 protected:
106 void resizeEvent(QResizeEvent *e) Q_DECL_OVERRIDE;
108 virtual void displayContextMenu(const QPoint &pos);
109 void forwardKeyReleaseEvent(QKeyEvent *e) Q_DECL_OVERRIDE;
110 void forwardKeyPressEvent(QKeyEvent *e) Q_DECL_OVERRIDE;
111 void forwardWheelEvent(QWheelEvent *e) Q_DECL_OVERRIDE;
112 void forwardMouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
114 private Q_SLOTS:
115 void slotServiceUrlSelected(PimCommon::ShareServiceUrlManager::ServiceType type);
116 void slotLinkHovered(const QString &link);
117 void slotLoadStarted();
118 void slotLoadFinished();
119 void slotLinkClicked(const QUrl &url);
120 void slotOpenLinkInForegroundTab();
121 void slotOpenLinkInBackgroundTab();
122 void slotOpenLinkInBrowser();
123 void slotShowContextMenu(const QPoint &pos);
124 void slotWebHitFinished(const MessageViewer::WebHitTestResult &result);
125 void slotActivatePlugin(MessageViewer::ViewerPluginInterface *interface);
126 protected:
127 ArticleViewerWebEnginePage *mPageEngine;
129 bool adblockEnabled() const;
131 void contextMenuEvent(QContextMenuEvent *e) Q_DECL_OVERRIDE;
132 QList<QAction *> viewerPluginActionList(MessageViewer::ViewerPluginInterface::SpecificFeatureTypes features);
133 private:
134 MousePressedButtonType mLastButtonClicked;
135 MessageViewer::ViewerPluginToolManager *mViewerPluginToolManager;
136 MessageViewer::MailWebEngineAccessKey *mWebEngineViewAccessKey;
137 MessageViewer::NetworkAccessManagerWebEngine *mNetworkAccessManager;
141 #endif // ARTICLEVIEWERWEBENGINE_H