File indexing completed on 2024-04-28 12:31:07
0001 /* 0002 SPDX-FileCopyrightText: 2007 Trolltech ASA 0003 SPDX-FileCopyrightText: 2008 Urs Wolfer <uwolfer@kde.org> 0004 SPDX-FileCopyrightText: 2009 Dawit Alemayehu <adawit@kde.org> 0005 0006 SPDX-License-Identifier: LGPL-2.1-or-later 0007 */ 0008 0009 #ifndef KWEBKITPART_H 0010 #define KWEBKITPART_H 0011 0012 #include <QWebPage> 0013 0014 #include <KParts/ReadOnlyPart> 0015 0016 namespace KParts { 0017 class BrowserExtension; 0018 class StatusBarExtension; 0019 } 0020 0021 class QWebView; 0022 class QWebFrame; 0023 class QWebHistoryItem; 0024 class WebView; 0025 class WebPage; 0026 class SearchBar; 0027 class PasswordBar; 0028 class FeaturePermissionBar; 0029 class KUrlLabel; 0030 class WebKitBrowserExtension; 0031 0032 /** 0033 * A KPart wrapper for the QtWebKit's browser rendering engine. 0034 * 0035 * This class attempts to provide the same type of integration into KPart 0036 * plugin applications, such as Konqueror, in much the same way as KHTML. 0037 * 0038 * Unlink the KHTML part however, access into the internals of the rendering 0039 * engine are provided through existing QtWebKit class ; @see QWebView. 0040 * 0041 */ 0042 class KWebKitPart : public KParts::ReadOnlyPart 0043 { 0044 Q_OBJECT 0045 Q_PROPERTY( bool modified READ isModified ) 0046 public: 0047 explicit KWebKitPart(QWidget* parentWidget, QObject* parent, 0048 const KPluginMetaData& metaData, 0049 const QByteArray& cachedHistory = QByteArray(), 0050 const QStringList& = QStringList()); 0051 ~KWebKitPart() override; 0052 0053 /** 0054 * Re-implemented for internal reasons. API remains unaffected. 0055 * 0056 * @see KParts::ReadOnlyPart::openUrl 0057 */ 0058 bool openUrl(const QUrl &) override; 0059 0060 /** 0061 * Re-implemented for internal reasons. API remains unaffected. 0062 * 0063 * @see KParts::ReadOnlyPart::closeUrl 0064 */ 0065 bool closeUrl() override; 0066 0067 /** 0068 * Returns a pointer to the render widget used to display a web page. 0069 * 0070 * @see QWebView. 0071 */ 0072 QWebView *view() const; 0073 0074 /** 0075 * Checks whether the page contains unsubmitted form changes. 0076 * 0077 * @return @p true if form changes exist. 0078 */ 0079 bool isModified() const; 0080 0081 /** 0082 * Returns if the page is currently in caret browsing mode. 0083 */ 0084 bool isCaretMode() const; 0085 0086 /** 0087 * Connects the appropriate signals from the given page to the slots 0088 * in this class. 0089 */ 0090 void connectWebPageSignals(WebPage* page); 0091 0092 void slotShowFeaturePermissionBar(QWebPage::Feature); 0093 protected: 0094 /** 0095 * Re-implemented for internal reasons. API remains unaffected. 0096 * 0097 * @see KParts::ReadOnlyPart::guiActivateEvent 0098 */ 0099 void guiActivateEvent(KParts::GUIActivateEvent *) override; 0100 0101 /** 0102 * Re-implemented for internal reasons. API remains unaffected. 0103 * 0104 * @see KParts::ReadOnlyPart::openFile 0105 */ 0106 bool openFile() override; 0107 0108 private Q_SLOTS: 0109 void slotShowSecurity(); 0110 void slotShowSearchBar(); 0111 void slotLoadStarted(); 0112 void slotLoadAborted(const QUrl &); 0113 void slotLoadFinished(bool); 0114 void slotFrameLoadFinished(bool); 0115 void slotMainFrameLoadFinished(bool); 0116 0117 void slotSearchForText(const QString &text, bool backward); 0118 void slotLinkHovered(const QString &, const QString&, const QString &); 0119 void slotSaveFrameState(QWebFrame *frame, QWebHistoryItem *item); 0120 void slotRestoreFrameState(QWebFrame *frame); 0121 void slotLinkMiddleOrCtrlClicked(const QUrl&); 0122 void slotSelectionClipboardUrlPasted(const QUrl&, const QString&); 0123 0124 void slotUrlChanged(const QUrl &); 0125 void slotWalletClosed(); 0126 void slotShowWalletMenu(); 0127 void slotLaunchWalletManager(); 0128 void slotDeleteNonPasswordStorableSite(); 0129 void slotRemoveCachedPasswords(); 0130 void slotSetTextEncoding(QTextCodec*); 0131 void slotSetStatusBarText(const QString& text); 0132 void slotWindowCloseRequested(); 0133 void slotSaveFormDataRequested(const QString &, const QUrl &); 0134 void slotSaveFormDataDone(); 0135 void slotFillFormRequestCompleted(bool); 0136 void slotFrameCreated(QWebFrame*); 0137 void slotToggleCaretMode(); 0138 0139 void slotFeaturePermissionGranted(QWebPage::Feature); 0140 void slotFeaturePermissionDenied(QWebPage::Feature); 0141 0142 private: 0143 WebPage* page(); 0144 const WebPage* page() const; 0145 void initActions(); 0146 void updateActions(); 0147 void addWalletStatusBarIcon(); 0148 0149 bool m_emitOpenUrlNotify; 0150 bool m_hasCachedFormData; 0151 bool m_doLoadFinishedActions; 0152 KUrlLabel* m_statusBarWalletLabel; 0153 SearchBar* m_searchBar; 0154 PasswordBar* m_passwordBar; 0155 FeaturePermissionBar* m_featurePermissionBar; 0156 WebKitBrowserExtension* m_browserExtension; 0157 KParts::StatusBarExtension* m_statusBarExtension; 0158 WebView* m_webView; 0159 }; 0160 0161 #endif // WEBKITPART_H