1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 09:32:12 +01:00

Add QWebPage::view() that returns WebView *

This commit is contained in:
David Rosca 2015-09-24 23:00:27 +02:00
parent 02f5e032fc
commit fc85caff57
7 changed files with 31 additions and 50 deletions

View File

@ -177,16 +177,12 @@ void AutoFill::removeAllEntries()
m_manager->removeAllEntries();
}
void AutoFill::saveForm(QWebEnginePage *page, const QUrl &frameUrl, const PageFormData &formData)
void AutoFill::saveForm(WebPage *page, const QUrl &frameUrl, const PageFormData &formData)
{
// Don't save in private browsing
if (mApp->isPrivate() || !page)
return;
WebView* webView = qobject_cast<WebView*>(page->view());
if (!webView)
return;
if (!isStoringEnabled(frameUrl))
return;
@ -214,7 +210,7 @@ void AutoFill::saveForm(QWebEnginePage *page, const QUrl &frameUrl, const PageFo
}
AutoFillNotification* aWidget = new AutoFillNotification(frameUrl, formData, updateData);
webView->addNotification(aWidget);
page->view()->addNotification(aWidget);
}
// Returns all saved passwords on this page

View File

@ -26,6 +26,7 @@ class QUrl;
class QWebEnginePage;
class QNetworkRequest;
class WebPage;
class BrowserWindow;
class PasswordManager;
struct PageFormData;
@ -69,7 +70,7 @@ public:
void removeEntry(const PasswordEntry &entry);
void removeAllEntries();
void saveForm(QWebEnginePage *page, const QUrl &frameUrl, const PageFormData &formData);
void saveForm(WebPage *page, const QUrl &frameUrl, const PageFormData &formData);
QVector<PasswordEntry> completePage(QWebEnginePage *page, const QUrl &frameUrl);
QByteArray exportPasswords();

View File

@ -51,11 +51,8 @@ void HTML5PermissionsManager::requestPermissions(WebPage* page, const QUrl &orig
}
// Ask user for permission
WebView* view = qobject_cast<WebView*>(page->view());
if (view) {
HTML5PermissionsNotification* notif = new HTML5PermissionsNotification(origin, page, feature);
view->addNotification(notif);
}
page->view()->addNotification(notif);
}
void HTML5PermissionsManager::rememberPermissions(const QUrl &origin, const QWebEnginePage::Feature &feature,

View File

@ -102,22 +102,22 @@ WebPage::~WebPage()
}
}
WebView *WebPage::view() const
{
return static_cast<WebView*>(QWebEnginePage::view());
}
void WebPage::scheduleAdjustPage()
{
WebView* webView = qobject_cast<WebView*>(view());
if (!webView) {
return;
}
if (webView->isLoading()) {
if (view()->isLoading()) {
m_adjustingScheduled = true;
}
else {
const QSize originalSize = webView->size();
const QSize originalSize = view()->size();
QSize newSize(originalSize.width() - 1, originalSize.height() - 1);
webView->resize(newSize);
webView->resize(originalSize);
view()->resize(newSize);
view()->resize(originalSize);
}
}
@ -311,12 +311,7 @@ void WebPage::setupWebChannel()
void WebPage::windowCloseRequested()
{
WebView* webView = qobject_cast<WebView*>(view());
if (!webView) {
return;
}
webView->closeView();
view()->closeView();
}
void WebPage::authentication(const QUrl &requestUrl, QAuthenticator* auth)
@ -455,12 +450,8 @@ void WebPage::proxyAuthentication(const QUrl &requestUrl, QAuthenticator* auth,
void WebPage::doWebSearch(const QString &text)
{
WebView* webView = qobject_cast<WebView*>(view());
if (webView) {
const LoadRequest searchRequest = mApp->searchEnginesManager()->searchResult(text);
webView->load(searchRequest);
}
view()->load(searchRequest);
}
void WebPage::featurePermissionRequested(const QUrl &origin, const QWebEnginePage::Feature &feature)
@ -839,8 +830,7 @@ bool WebPage::javaScriptPrompt(const QUrl &securityOrigin, const QString &msg, c
return false;
}
WebView* webView = qobject_cast<WebView*>(view());
ResizableFrame* widget = new ResizableFrame(webView->overlayWidget());
ResizableFrame* widget = new ResizableFrame(view()->overlayWidget());
widget->setObjectName("jsFrame");
Ui_jsPrompt* ui = new Ui_jsPrompt();
@ -868,7 +858,7 @@ bool WebPage::javaScriptPrompt(const QUrl &securityOrigin, const QString &msg, c
*result = x;
delete widget;
webView->setFocus();
view()->setFocus();
return _result;
#endif
@ -883,8 +873,7 @@ bool WebPage::javaScriptConfirm(const QUrl &securityOrigin, const QString &msg)
return false;
}
WebView* webView = qobject_cast<WebView*>(view());
ResizableFrame* widget = new ResizableFrame(webView->overlayWidget());
ResizableFrame* widget = new ResizableFrame(view()->overlayWidget());
widget->setObjectName("jsFrame");
Ui_jsConfirm* ui = new Ui_jsConfirm();
@ -908,7 +897,7 @@ bool WebPage::javaScriptConfirm(const QUrl &securityOrigin, const QString &msg)
bool result = ui->buttonBox->clickedButtonRole() == QDialogButtonBox::AcceptRole;
delete widget;
webView->setFocus();
view()->setFocus();
return result;
#endif
@ -937,18 +926,17 @@ void WebPage::javaScriptAlert(const QUrl &securityOrigin, const QString &msg)
m_blockAlerts = dialog.isChecked();
#else
WebView* webView = qobject_cast<WebView*>(view());
ResizableFrame* widget = new ResizableFrame(webView->overlayWidget());
ResizableFrame* widget = new ResizableFrame(view()->overlayWidget());
widget->setObjectName("jsFrame");
Ui_jsAlert* ui = new Ui_jsAlert();
ui->setupUi(widget);
ui->message->setText(msg);
ui->buttonBox->button(QDialogButtonBox::Ok)->setFocus();
widget->resize(webView->size());
widget->resize(view()->size());
widget->show();
connect(webView, SIGNAL(viewportResized(QSize)), widget, SLOT(slotResize(QSize)));
connect(view(), SIGNAL(viewportResized(QSize)), widget, SLOT(slotResize(QSize)));
QEventLoop eLoop;
m_runningLoop = &eLoop;
@ -963,7 +951,7 @@ void WebPage::javaScriptAlert(const QUrl &securityOrigin, const QString &msg)
delete widget;
webView->setFocus();
view()->setFocus();
#endif
}

View File

@ -28,10 +28,8 @@
class QEventLoop;
class QWebEngineDownloadItem;
class BrowserWindow;
class WebView;
class AdBlockRule;
class SpeedDial;
class NetworkManagerProxy;
class DelayedFileWatcher;
class QUPZILLA_EXPORT WebPage : public QWebEnginePage
@ -50,6 +48,8 @@ public:
WebPage(QObject* parent = 0);
~WebPage();
WebView *view() const;
void setSSLCertificate(const QSslCertificate &cert);
QSslCertificate sslCertificate();
@ -113,7 +113,6 @@ private:
static QTime s_lastUnsupportedUrlTime;
static QStringList s_ignoredSslErrors;
NetworkManagerProxy* m_networkProxy;
DelayedFileWatcher* m_fileWatcher;
QEventLoop* m_runningLoop;

View File

@ -123,7 +123,7 @@ WebPage* WebView::page() const
return m_page;
}
void WebView::setPage(QWebEnginePage* page)
void WebView::setPage(WebPage *page)
{
if (m_page == page) {
return;

View File

@ -41,7 +41,7 @@ public:
bool isTitleEmpty() const;
WebPage* page() const;
void setPage(QWebEnginePage* page);
void setPage(WebPage* page);
void load(const QUrl &url);
void load(const LoadRequest &request);