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