webenginepart.h 4.94 KB
Newer Older
1
2
3
4
/*
 * This file is part of the KDE project.
 *
 * Copyright (C) 2007 Trolltech ASA
5
 * Copyright (C) 2008 Urs Wolfer <uwolfer @ kde.org>
6
 * Copyright (C) 2009 Dawit Alemayehu <adawit@kde.org>
7
 *
8
9
10
11
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by the
 * Free Software Foundation; either version 2.1 of the License, or (at your
 * option) any later version.
12
 *
13
14
15
16
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
 * details.
17
 *
18
19
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
20
21
 *
 */
Sune Stolborg Vuorela's avatar
Sune Stolborg Vuorela committed
22
23
#ifndef WEBENGINEPART_H
#define WEBENGINEPART_H
24

25
#include <QtWebEngineWidgets/QWebEnginePage>
26

27
#include <KParts/ReadOnlyPart>
Dániel Grósz's avatar
Dániel Grósz committed
28
#include <QUrl>
29

30
31
namespace KParts {
  class BrowserExtension;
32
33
34
  class StatusBarExtension;
}

35
36
class QWebEngineView;
class QWebEngineHistoryItem;
37
38
class WebView;
class WebPage;
39
40
class SearchBar;
class PasswordBar;
41
class FeaturePermissionBar;
42
class KUrlLabel;
Sune Stolborg Vuorela's avatar
Sune Stolborg Vuorela committed
43
class WebEngineBrowserExtension;
44

45
/**
Sune Stolborg Vuorela's avatar
Sune Stolborg Vuorela committed
46
 * A KPart wrapper for the QtWebEngine's browser rendering engine.
47
 *
48
49
 * This class attempts to provide the same type of integration into KPart
 * plugin applications, such as Konqueror, in much the same way as KHTML.
50
 *
51
 * Unlink the KHTML part however, access into the internals of the rendering
Sune Stolborg Vuorela's avatar
Sune Stolborg Vuorela committed
52
 * engine are provided through existing QtWebEngine class ; @see QWebEngineView.
53
54
 *
 */
Sune Stolborg Vuorela's avatar
Sune Stolborg Vuorela committed
55
class Q_DECL_EXPORT WebEnginePart : public KParts::ReadOnlyPart
56
57
{
    Q_OBJECT
58
    Q_PROPERTY( bool modified READ isModified )
59
public:
Sune Stolborg Vuorela's avatar
Sune Stolborg Vuorela committed
60
    explicit WebEnginePart(QWidget* parentWidget = 0, QObject* parent = 0,
61
62
                         const QByteArray& cachedHistory = QByteArray(),
                         const QStringList& = QStringList());
Sune Stolborg Vuorela's avatar
Sune Stolborg Vuorela committed
63
    ~WebEnginePart();
64

65
66
67
68
69
    /**
     * Re-implemented for internal reasons. API remains unaffected.
     *
     * @see KParts::ReadOnlyPart::openUrl
     */
Dániel Grósz's avatar
Dániel Grósz committed
70
    virtual bool openUrl(const QUrl &);
71

72
73
74
75
76
    /**
     * Re-implemented for internal reasons. API remains unaffected.
     *
     * @see KParts::ReadOnlyPart::closeUrl
     */
Simon Hausmann's avatar
Simon Hausmann committed
77
    virtual bool closeUrl();
78
79

    /**
80
81
82
     * Returns a pointer to the render widget used to display a web page.
     *
     * @see QWebView.
83
     */
84
    virtual QWebEngineView *view();
85

86
87
88
89
90
91
92
    /**
     * Checks whether the page contains unsubmitted form changes.
     *
     * @return @p true if form changes exist.
     */
    bool isModified() const;

93
94
95
96
97
98
    /**
     * Connects the appropriate signals from the given page to the slots
     * in this class.
     */
    void connectWebPageSignals(WebPage* page);

99
    void slotShowFeaturePermissionBar(QWebEnginePage::Feature);
100
protected:
101
102
103
104
105
    /**
     * Re-implemented for internal reasons. API remains unaffected.
     *
     * @see KParts::ReadOnlyPart::guiActivateEvent
     */
106
107
    virtual void guiActivateEvent(KParts::GUIActivateEvent *);

108
109
110
111
112
113
    /**
     * Re-implemented for internal reasons. API remains unaffected.
     *
     * @see KParts::ReadOnlyPart::openFile
     */
    virtual bool openFile();
114

115
116
117
118
private Q_SLOTS:
    void slotShowSecurity();
    void slotShowSearchBar();
    void slotLoadStarted();
Dániel Grósz's avatar
Dániel Grósz committed
119
    void slotLoadAborted(const QUrl &);
120
    void slotLoadFinished(bool);
121
    void slotMainFrameLoadFinished(bool);
122
123

    void slotSearchForText(const QString &text, bool backward);
Sune Stolborg Vuorela's avatar
Sune Stolborg Vuorela committed
124
    void slotLinkHovered(const QString &);
125
126
    //void slotSaveFrameState(QWebFrame *frame, QWebHistoryItem *item);
    //void slotRestoreFrameState(QWebFrame *frame);
Dániel Grósz's avatar
Dániel Grósz committed
127
128
    void slotLinkMiddleOrCtrlClicked(const QUrl&);
    void slotSelectionClipboardUrlPasted(const QUrl&, const QString&);
129
130
131
132
133
134
135
136
137
138

    void slotUrlChanged(const QUrl &);
    void slotWalletClosed();
    void slotShowWalletMenu();
    void slotLaunchWalletManager();
    void slotDeleteNonPasswordStorableSite();
    void slotRemoveCachedPasswords();
    void slotSetTextEncoding(QTextCodec*);
    void slotSetStatusBarText(const QString& text);
    void slotWindowCloseRequested();
139
140
    void slotSaveFormDataRequested(const QString &, const QUrl &);
    void slotSaveFormDataDone();
141
    void slotFillFormRequestCompleted(bool);
142

143
144
    void slotFeaturePermissionGranted(QWebEnginePage::Feature);
    void slotFeaturePermissionDenied(QWebEnginePage::Feature);
145

146
private:
147
    WebPage* page();
148
    const WebPage* page() const;
149
    void initActions();
150
    void updateActions();
151
    void addWalletStatusBarIcon();
152
153
154

    bool m_emitOpenUrlNotify;
    bool m_hasCachedFormData;
155
    bool m_doLoadFinishedActions;
156
    KUrlLabel* m_statusBarWalletLabel;
157
158
    SearchBar* m_searchBar;
    PasswordBar* m_passwordBar;
159
    FeaturePermissionBar* m_featurePermissionBar;
Sune Stolborg Vuorela's avatar
Sune Stolborg Vuorela committed
160
    WebEngineBrowserExtension* m_browserExtension;
161
    KParts::StatusBarExtension* m_statusBarExtension;
162
    WebView* m_webView;
163
164
};

Sune Stolborg Vuorela's avatar
Sune Stolborg Vuorela committed
165
#endif // WEBENGINEPART_H