Use new api
[kdepim.git] / akregator / src / articleviewer-ng / webengine / articleviewerwebengine.h
blob47dfa21993de3f2a193e23209b67f9ab90f7cc33
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 <QWebEngineView>
22 #include <openurlrequest.h>
23 #include <shareserviceurlmanager.h>
25 class KActionCollection;
26 namespace MessageViewer
28 class WebHitTestResult;
30 namespace PimCommon
32 class ShareServiceUrlManager;
34 namespace KIO
36 class KUriFilterSearchProviderActions;
38 namespace Akregator
40 class AKREGATOR_EXPORT ArticleViewerWebEngine : public QWebEngineView
42 Q_OBJECT
43 public:
44 enum ArticleAction {
45 DeleteAction = 0,
46 MarkAsRead,
47 MarkAsUnRead,
48 MarkAsImportant,
49 SendUrlArticle,
50 SendFileArticle,
51 OpenInExternalBrowser,
52 Share,
53 OpenInBackgroundTab
55 explicit ArticleViewerWebEngine(KActionCollection *ac, QWidget *parent);
56 ~ArticleViewerWebEngine();
58 void showAboutPage();
60 void disableIntroduction();
61 void setArticleAction(ArticleViewerWebEngine::ArticleAction type, const QString &articleId, const QString &feed);
63 bool zoomTextOnlyInFrame() const;
65 protected:
66 QUrl mCurrentUrl;
67 KActionCollection *mActionCollection;
68 PimCommon::ShareServiceUrlManager *mShareServiceManager;
69 KIO::KUriFilterSearchProviderActions *mWebShortcutMenuManager;
71 private:
72 enum MousePressedButtonType {
73 RightButton = 0,
74 LeftButton,
75 MiddleButton,
78 void paintAboutScreen(const QString &templateName, const QVariantHash &data);
79 QVariantHash introductionData() const;
81 public Q_SLOTS:
82 void slotPrintPreview();
83 void slotPrint();
84 void slotCopy();
85 void slotZoomTextOnlyInFrame(bool textOnlyInFrame);
86 void slotSaveLinkAs();
87 void slotCopyLinkAddress();
88 void slotSaveImageOnDiskInFrame();
89 void slotCopyImageLocationInFrame();
90 void slotBlockImage();
91 Q_SIGNALS:
92 void signalOpenUrlRequest(Akregator::OpenUrlRequest &);
93 void showStatusBarMessage(const QString &link);
94 void showContextMenu(const QPoint &pos);
95 void articleAction(Akregator::ArticleViewerWebEngine::ArticleAction type, const QString &articleId, const QString &feed);
96 void findTextInHtml();
97 void textToSpeech();
99 protected:
100 void keyReleaseEvent(QKeyEvent *e) Q_DECL_OVERRIDE;
101 void keyPressEvent(QKeyEvent *e) Q_DECL_OVERRIDE;
102 void wheelEvent(QWheelEvent *e) Q_DECL_OVERRIDE;
103 void resizeEvent(QResizeEvent *e) Q_DECL_OVERRIDE;
104 void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
106 virtual void displayContextMenu(const QPoint &pos);
108 private Q_SLOTS:
109 void slotServiceUrlSelected(PimCommon::ShareServiceUrlManager::ServiceType type);
110 void slotLinkHovered(const QString &link);
111 void slotLoadStarted();
112 void slotLoadFinished();
113 void slotLinkClicked(const QUrl &url);
114 void slotOpenLinkInForegroundTab();
115 void slotOpenLinkInBackgroundTab();
116 void slotOpenLinkInBrowser();
117 void slotShowContextMenu(const QPoint &pos);
118 protected:
119 MessageViewer::WebHitTestResult *mContextMenuHitResult;
121 bool adblockEnabled() const;
123 void contextMenuEvent(QContextMenuEvent *e) Q_DECL_OVERRIDE;
124 private:
125 QUrl linkOrImageUrlAt(const QPoint &global) const;
126 MousePressedButtonType mLastButtonClicked;
127 //MessageViewer::WebViewAccessKey *mWebViewAccessKey;
131 #endif // ARTICLEVIEWERWEBENGINE_H