mirror of
https://invent.kde.org/network/falkon.git
synced 2024-09-21 17:52:10 +02:00
PopupWindows: Port to QtWebEngine
It now correctly detects when to open tabs and when to open popup windows. Support for opening new browser windows is not yet implemented.
This commit is contained in:
parent
e854afb5d3
commit
f90a40836c
|
@ -170,7 +170,6 @@ SOURCES += \
|
|||
plugins/speeddial.cpp \
|
||||
popupwindow/popuplocationbar.cpp \
|
||||
popupwindow/popupstatusbarmessage.cpp \
|
||||
popupwindow/popupwebpage.cpp \
|
||||
popupwindow/popupwebview.cpp \
|
||||
popupwindow/popupwindow.cpp \
|
||||
preferences/acceptlanguage.cpp \
|
||||
|
@ -373,7 +372,6 @@ HEADERS += \
|
|||
plugins/speeddial.h \
|
||||
popupwindow/popuplocationbar.h \
|
||||
popupwindow/popupstatusbarmessage.h \
|
||||
popupwindow/popupwebpage.h \
|
||||
popupwindow/popupwebview.h \
|
||||
popupwindow/popupwindow.h \
|
||||
preferences/acceptlanguage.h \
|
||||
|
|
|
@ -1,155 +0,0 @@
|
|||
/* ============================================================
|
||||
* QupZilla - WebKit based browser
|
||||
* Copyright (C) 2010-2014 David Rosca <nowrep@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* ============================================================ */
|
||||
#include "popupwebpage.h"
|
||||
#include "popupwebview.h"
|
||||
#include "popupwindow.h"
|
||||
#include "browserwindow.h"
|
||||
#include "tabwidget.h"
|
||||
#include "tabbedwebview.h"
|
||||
|
||||
#include <QTimer>
|
||||
#include <QStatusBar>
|
||||
|
||||
// Wrapper class to detect whether window is opened from JavaScript window.open method
|
||||
// It has to be done this way, because QtWebKit has really bad API when it comes to opening
|
||||
// new windows.
|
||||
//
|
||||
// Got an idea how to determine it from kWebKitPart.
|
||||
|
||||
PopupWebPage::PopupWebPage(QWebEnginePage::WebWindowType type, BrowserWindow* window)
|
||||
: WebPage()
|
||||
, m_window(window)
|
||||
, m_type(type)
|
||||
, m_createNewWindow(false)
|
||||
, m_menuBarVisible(false)
|
||||
, m_statusBarVisible(false)
|
||||
, m_toolBarVisible(false)
|
||||
, m_isLoading(false)
|
||||
, m_progress(0)
|
||||
{
|
||||
connect(this, SIGNAL(geometryChangeRequested(QRect)), this, SLOT(slotGeometryChangeRequested(QRect)));
|
||||
#if QTWEBENGINE_DISABLED
|
||||
connect(this, SIGNAL(menuBarVisibilityChangeRequested(bool)), this, SLOT(slotMenuBarVisibilityChangeRequested(bool)));
|
||||
connect(this, SIGNAL(toolBarVisibilityChangeRequested(bool)), this, SLOT(slotToolBarVisibilityChangeRequested(bool)));
|
||||
connect(this, SIGNAL(statusBarVisibilityChangeRequested(bool)), this, SLOT(slotStatusBarVisibilityChangeRequested(bool)));
|
||||
#endif
|
||||
|
||||
connect(this, SIGNAL(loadStarted()), this, SLOT(slotLoadStarted()));
|
||||
connect(this, SIGNAL(loadProgress(int)), this, SLOT(slotLoadProgress(int)));
|
||||
connect(this, SIGNAL(loadFinished(bool)), this, SLOT(slotLoadFinished(bool)));
|
||||
|
||||
QTimer::singleShot(0, this, SLOT(checkBehaviour()));
|
||||
}
|
||||
|
||||
BrowserWindow* PopupWebPage::mainWindow() const
|
||||
{
|
||||
return m_window;
|
||||
}
|
||||
|
||||
void PopupWebPage::slotGeometryChangeRequested(const QRect &rect)
|
||||
{
|
||||
if (rect.isValid()) {
|
||||
m_createNewWindow = true;
|
||||
}
|
||||
|
||||
m_geometry = rect;
|
||||
}
|
||||
|
||||
void PopupWebPage::slotMenuBarVisibilityChangeRequested(bool visible)
|
||||
{
|
||||
m_menuBarVisible = visible;
|
||||
}
|
||||
|
||||
void PopupWebPage::slotStatusBarVisibilityChangeRequested(bool visible)
|
||||
{
|
||||
m_statusBarVisible = visible;
|
||||
}
|
||||
|
||||
void PopupWebPage::slotToolBarVisibilityChangeRequested(bool visible)
|
||||
{
|
||||
m_toolBarVisible = visible;
|
||||
}
|
||||
|
||||
void PopupWebPage::slotLoadStarted()
|
||||
{
|
||||
m_isLoading = true;
|
||||
m_progress = 0;
|
||||
}
|
||||
|
||||
void PopupWebPage::slotLoadProgress(int prog)
|
||||
{
|
||||
m_progress = prog;
|
||||
}
|
||||
|
||||
void PopupWebPage::slotLoadFinished(bool state)
|
||||
{
|
||||
Q_UNUSED(state)
|
||||
|
||||
m_isLoading = false;
|
||||
m_progress = 0;
|
||||
}
|
||||
|
||||
void PopupWebPage::checkBehaviour()
|
||||
{
|
||||
// If menubar/statusbar/toolbar visibility is explicitly set in window.open call,
|
||||
// at least one of those variables will be false.
|
||||
// If so, we should open new window.
|
||||
// But not when all visibilities are false, it occurs with target=_blank links
|
||||
|
||||
if (!m_createNewWindow && (!m_menuBarVisible || !m_statusBarVisible || !m_toolBarVisible) &&
|
||||
!(!m_menuBarVisible && !m_statusBarVisible && !m_toolBarVisible)
|
||||
) {
|
||||
m_createNewWindow = true;
|
||||
}
|
||||
|
||||
if (m_createNewWindow) {
|
||||
PopupWebView* view = new PopupWebView;
|
||||
view->setWebPage(this);
|
||||
|
||||
PopupWindow* popup = new PopupWindow(view);
|
||||
popup->setWindowGeometry(m_geometry);
|
||||
popup->setMenuBarVisibility(m_menuBarVisible);
|
||||
popup->setStatusBarVisibility(m_statusBarVisible);
|
||||
popup->setToolBarVisibility(m_toolBarVisible);
|
||||
popup->show();
|
||||
|
||||
if (m_isLoading) {
|
||||
view->fakeLoadingProgress(m_progress);
|
||||
}
|
||||
|
||||
m_window->addDeleteOnCloseWidget(popup);
|
||||
|
||||
disconnect(this, SIGNAL(geometryChangeRequested(QRect)), this, SLOT(slotGeometryChangeRequested(QRect)));
|
||||
disconnect(this, SIGNAL(menuBarVisibilityChangeRequested(bool)), this, SLOT(slotMenuBarVisibilityChangeRequested(bool)));
|
||||
disconnect(this, SIGNAL(toolBarVisibilityChangeRequested(bool)), this, SLOT(slotToolBarVisibilityChangeRequested(bool)));
|
||||
disconnect(this, SIGNAL(statusBarVisibilityChangeRequested(bool)), this, SLOT(slotStatusBarVisibilityChangeRequested(bool)));
|
||||
|
||||
disconnect(this, SIGNAL(loadStarted()), this, SLOT(slotLoadStarted()));
|
||||
disconnect(this, SIGNAL(loadProgress(int)), this, SLOT(slotLoadProgress(int)));
|
||||
disconnect(this, SIGNAL(loadFinished(bool)), this, SLOT(slotLoadFinished(bool)));
|
||||
}
|
||||
else {
|
||||
int index = m_window->tabWidget()->addView(QUrl(), Qz::NT_CleanSelectedTab);
|
||||
TabbedWebView* view = m_window->weView(index);
|
||||
view->setWebPage(this);
|
||||
|
||||
if (m_isLoading) {
|
||||
view->fakeLoadingProgress(m_progress);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
/* ============================================================
|
||||
* QupZilla - WebKit based browser
|
||||
* Copyright (C) 2010-2014 David Rosca <nowrep@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* ============================================================ */
|
||||
#ifndef POPUPWEBPAGE_H
|
||||
#define POPUPWEBPAGE_H
|
||||
|
||||
#include "qzcommon.h"
|
||||
#include "webpage.h"
|
||||
|
||||
class BrowserWindow;
|
||||
|
||||
class QUPZILLA_EXPORT PopupWebPage : public WebPage
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit PopupWebPage(WebWindowType type, BrowserWindow* window);
|
||||
|
||||
BrowserWindow* mainWindow() const;
|
||||
|
||||
private slots:
|
||||
void slotGeometryChangeRequested(const QRect &rect);
|
||||
void slotMenuBarVisibilityChangeRequested(bool visible);
|
||||
void slotStatusBarVisibilityChangeRequested(bool visible);
|
||||
void slotToolBarVisibilityChangeRequested(bool visible);
|
||||
|
||||
void slotLoadStarted();
|
||||
void slotLoadProgress(int prog);
|
||||
void slotLoadFinished(bool state);
|
||||
|
||||
void checkBehaviour();
|
||||
|
||||
private:
|
||||
BrowserWindow* m_window;
|
||||
QWebEnginePage::WebWindowType m_type;
|
||||
bool m_createNewWindow;
|
||||
|
||||
bool m_menuBarVisible;
|
||||
bool m_statusBarVisible;
|
||||
bool m_toolBarVisible;
|
||||
QRect m_geometry;
|
||||
|
||||
bool m_isLoading;
|
||||
bool m_progress;
|
||||
};
|
||||
|
||||
#endif // POPUPWEBPAGE_H
|
|
@ -1,6 +1,6 @@
|
|||
/* ============================================================
|
||||
* QupZilla - WebKit based browser
|
||||
* Copyright (C) 2010-2014 David Rosca <nowrep@gmail.com>
|
||||
* Copyright (C) 2010-2015 David Rosca <nowrep@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -16,7 +16,6 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* ============================================================ */
|
||||
#include "popupwebview.h"
|
||||
#include "popupwebpage.h"
|
||||
#include "mainapplication.h"
|
||||
#include "browserwindow.h"
|
||||
#include "tabwidget.h"
|
||||
|
@ -29,33 +28,11 @@
|
|||
|
||||
PopupWebView::PopupWebView(QWidget* parent)
|
||||
: WebView(parent)
|
||||
, m_page(0)
|
||||
, m_menu(new Menu(this))
|
||||
{
|
||||
m_menu->setCloseOnMiddleClick(true);
|
||||
}
|
||||
|
||||
void PopupWebView::setWebPage(PopupWebPage* page)
|
||||
{
|
||||
if (m_page == page) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_page) {
|
||||
delete m_page;
|
||||
m_page = 0;
|
||||
}
|
||||
|
||||
m_page = page;
|
||||
m_page->setParent(this);
|
||||
setPage(m_page);
|
||||
}
|
||||
|
||||
PopupWebPage* PopupWebView::webPage()
|
||||
{
|
||||
return m_page;
|
||||
}
|
||||
|
||||
QWidget* PopupWebView::overlayWidget()
|
||||
{
|
||||
return this;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* ============================================================
|
||||
* QupZilla - WebKit based browser
|
||||
* Copyright (C) 2010-2014 David Rosca <nowrep@gmail.com>
|
||||
* Copyright (C) 2010-2015 David Rosca <nowrep@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -21,7 +21,6 @@
|
|||
#include "qzcommon.h"
|
||||
#include "webview.h"
|
||||
|
||||
class PopupWebPage;
|
||||
class LoadRequest;
|
||||
class Menu;
|
||||
|
||||
|
@ -31,9 +30,6 @@ class QUPZILLA_EXPORT PopupWebView : public WebView
|
|||
public:
|
||||
explicit PopupWebView(QWidget* parent = 0);
|
||||
|
||||
void setWebPage(PopupWebPage* page);
|
||||
PopupWebPage* webPage();
|
||||
|
||||
QWidget* overlayWidget();
|
||||
void loadInNewTab(const LoadRequest &req, Qz::NewTabPositionFlags position);
|
||||
void openNewTab(Qz::NewTabPositionFlags position);
|
||||
|
@ -47,7 +43,6 @@ public slots:
|
|||
private:
|
||||
void contextMenuEvent(QContextMenuEvent* event);
|
||||
|
||||
PopupWebPage* m_page;
|
||||
Menu* m_menu;
|
||||
};
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* ============================================================
|
||||
* QupZilla - WebKit based browser
|
||||
* Copyright (C) 2010-2014 David Rosca <nowrep@gmail.com>
|
||||
* Copyright (C) 2010-2015 David Rosca <nowrep@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -17,7 +17,7 @@
|
|||
* ============================================================ */
|
||||
#include "popupwindow.h"
|
||||
#include "popupwebview.h"
|
||||
#include "popupwebpage.h"
|
||||
#include "webpage.h"
|
||||
#include "popupstatusbarmessage.h"
|
||||
#include "progressbar.h"
|
||||
#include "pagescreen.h"
|
||||
|
@ -34,7 +34,6 @@
|
|||
PopupWindow::PopupWindow(PopupWebView* view)
|
||||
: QWidget()
|
||||
, m_view(view)
|
||||
, m_page(qobject_cast<PopupWebPage*>(view->page()))
|
||||
, m_search(0)
|
||||
{
|
||||
m_layout = new QVBoxLayout(this);
|
||||
|
@ -60,7 +59,7 @@ PopupWindow::PopupWindow(PopupWebView* view)
|
|||
menuFile->addAction(QIcon::fromTheme("document-save"), tr("&Save Page As..."), m_view, SLOT(savePageAs()))->setShortcut(QKeySequence("Ctrl+S"));
|
||||
menuFile->addAction(tr("Save Page Screen"), this, SLOT(savePageScreen()));
|
||||
menuFile->addAction(QIcon::fromTheme("mail-message-new"), tr("Send Link..."), m_view, SLOT(sendPageByMail()));
|
||||
menuFile->addAction(QIcon::fromTheme("document-print"), tr("&Print..."), m_view, SLOT(printPage()))->setShortcut(QKeySequence("Ctrl+P"));
|
||||
//menuFile->addAction(QIcon::fromTheme("document-print"), tr("&Print..."), m_view, SLOT(printPage()))->setShortcut(QKeySequence("Ctrl+P"));
|
||||
menuFile->addSeparator();
|
||||
menuFile->addAction(QIcon::fromTheme("window-close"), tr("Close"), this, SLOT(close()))->setShortcut(QKeySequence("Ctrl+W"));
|
||||
m_menuBar->addMenu(menuFile);
|
||||
|
@ -87,7 +86,7 @@ PopupWindow::PopupWindow(PopupWebView* view)
|
|||
m_menuView->addAction(QIcon::fromTheme("zoom-out"), tr("Zoom &Out"), m_view, SLOT(zoomOut()))->setShortcut(QKeySequence("Ctrl+-"));
|
||||
m_menuView->addAction(QIcon::fromTheme("zoom-original"), tr("Reset"), m_view, SLOT(zoomReset()))->setShortcut(QKeySequence("Ctrl+0"));
|
||||
m_menuView->addSeparator();
|
||||
m_menuView->addAction(QIcon::fromTheme("text-html"), tr("&Page Source"), m_view, SLOT(showSource()))->setShortcut(QKeySequence("Ctrl+U"));
|
||||
//m_menuView->addAction(QIcon::fromTheme("text-html"), tr("&Page Source"), m_view, SLOT(showSource()))->setShortcut(QKeySequence("Ctrl+U"));
|
||||
m_menuBar->addMenu(m_menuView);
|
||||
|
||||
// Make shortcuts available even with hidden menubar
|
||||
|
@ -109,16 +108,18 @@ PopupWindow::PopupWindow(PopupWebView* view)
|
|||
connect(m_view, SIGNAL(titleChanged(QString)), this, SLOT(titleChanged()));
|
||||
connect(m_view, SIGNAL(urlChanged(QUrl)), m_locationBar, SLOT(showUrl(QUrl)));
|
||||
connect(m_view, SIGNAL(iconChanged()), m_locationBar, SLOT(showSiteIcon()));
|
||||
connect(m_view, SIGNAL(statusBarMessage(QString)), this, SLOT(showStatusBarMessage(QString)));
|
||||
//connect(m_view, SIGNAL(statusBarMessage(QString)), this, SLOT(showStatusBarMessage(QString)));
|
||||
connect(m_view, SIGNAL(loadStarted()), this, SLOT(loadStarted()));
|
||||
connect(m_view, SIGNAL(loadProgress(int)), this, SLOT(loadProgress(int)));
|
||||
connect(m_view, SIGNAL(loadFinished(bool)), this, SLOT(loadFinished()));
|
||||
|
||||
connect(m_page, SIGNAL(linkHovered(QString,QString,QString)), this, SLOT(showStatusBarMessage(QString)));
|
||||
connect(m_page, SIGNAL(geometryChangeRequested(QRect)), this, SLOT(setWindowGeometry(QRect)));
|
||||
connect(m_page, SIGNAL(statusBarVisibilityChangeRequested(bool)), this, SLOT(setStatusBarVisibility(bool)));
|
||||
connect(m_page, SIGNAL(menuBarVisibilityChangeRequested(bool)), this, SLOT(setMenuBarVisibility(bool)));
|
||||
connect(m_page, SIGNAL(toolBarVisibilityChangeRequested(bool)), this, SLOT(setToolBarVisibility(bool)));
|
||||
connect(m_view->page(), &WebPage::linkHovered, this, &PopupWindow::showStatusBarMessage);
|
||||
connect(m_view->page(), &WebPage::geometryChangeRequested, this, &PopupWindow::setWindowGeometry);
|
||||
#if QTWEBENGINE_DISABLED
|
||||
connect(m_view->page(), &WebPage::statusBarVisibilityChangeRequested, this, &PopupWindow::setStatusBarVisibility);
|
||||
connect(m_view->page(), &WebPage::menuBarVisibilityChangeRequested, this, &PopupWindow::setMenuBarVisibility);
|
||||
connect(m_view->page(), &WebPage::toolBarVisibilityChangeRequested, this, &PopupWindow::setToolBarVisibility);
|
||||
#endif
|
||||
|
||||
m_view->setFocus();
|
||||
titleChanged();
|
||||
|
@ -201,7 +202,7 @@ void PopupWindow::loadFinished()
|
|||
|
||||
void PopupWindow::closeEvent(QCloseEvent* event)
|
||||
{
|
||||
if (m_page->isRunningLoop()) {
|
||||
if (m_view->page()->isRunningLoop()) {
|
||||
event->ignore();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* ============================================================
|
||||
* QupZilla - WebKit based browser
|
||||
* Copyright (C) 2010-2014 David Rosca <nowrep@gmail.com>
|
||||
* Copyright (C) 2010-2015 David Rosca <nowrep@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -28,8 +28,8 @@ class QStatusBar;
|
|||
class QMenuBar;
|
||||
class QMenu;
|
||||
|
||||
class WebPage;
|
||||
class PopupWebView;
|
||||
class PopupWebPage;
|
||||
class PopupStatusBarMessage;
|
||||
class PopupLocationBar;
|
||||
class ProgressBar;
|
||||
|
@ -66,7 +66,6 @@ private:
|
|||
void closeEvent(QCloseEvent* event);
|
||||
|
||||
PopupWebView* m_view;
|
||||
PopupWebPage* m_page;
|
||||
PopupLocationBar* m_locationBar;
|
||||
PopupStatusBarMessage* m_statusBarMessage;
|
||||
ProgressBar* m_progressBar;
|
||||
|
|
|
@ -27,8 +27,8 @@
|
|||
#include "qztools.h"
|
||||
#include "speeddial.h"
|
||||
#include "autofill.h"
|
||||
#include "popupwebpage.h"
|
||||
#include "popupwebview.h"
|
||||
#include "popupwindow.h"
|
||||
#include "networkmanagerproxy.h"
|
||||
#include "adblockicon.h"
|
||||
#include "adblockmanager.h"
|
||||
|
@ -41,6 +41,7 @@
|
|||
#include "html5permissions/html5permissionsmanager.h"
|
||||
#include "schemehandlers/fileschemehandler.h"
|
||||
#include "javascript/externaljsobject.h"
|
||||
#include "tabwidget.h"
|
||||
|
||||
#ifdef NONBLOCK_JS_DIALOGS
|
||||
#include "ui_jsconfirm.h"
|
||||
|
@ -728,31 +729,6 @@ QSslCertificate WebPage::sslCertificate()
|
|||
return QSslCertificate();
|
||||
}
|
||||
|
||||
#if QTWEBENGINE_DISABLED
|
||||
bool WebPage::acceptNavigationRequest(QWebEngineFrame* frame, const QNetworkRequest &request, NavigationType type)
|
||||
{
|
||||
m_lastRequestType = type;
|
||||
m_lastRequestUrl = request.url();
|
||||
|
||||
if (type == QWebEnginePage::NavigationTypeFormResubmitted) {
|
||||
// Don't show this dialog if app is still starting
|
||||
if (!view() || !view()->isVisible()) {
|
||||
return false;
|
||||
}
|
||||
QString message = tr("To display this page, QupZilla must resend the request \n"
|
||||
"(such as a search or order confirmation) that was performed earlier.");
|
||||
bool result = (QMessageBox::question(view(), tr("Confirm form resubmission"),
|
||||
message, QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::Yes);
|
||||
if (!result) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool accept = QWebEnginePage::acceptNavigationRequest(frame, request, type);
|
||||
return accept;
|
||||
}
|
||||
#endif
|
||||
|
||||
void WebPage::populateNetworkRequest(QNetworkRequest &request)
|
||||
{
|
||||
WebPage* pagePointer = this;
|
||||
|
@ -772,15 +748,27 @@ void WebPage::populateNetworkRequest(QNetworkRequest &request)
|
|||
|
||||
QWebEnginePage* WebPage::createWindow(QWebEnginePage::WebWindowType type)
|
||||
{
|
||||
if (m_view) {
|
||||
return new PopupWebPage(type, m_view->browserWindow());
|
||||
switch (type) {
|
||||
case QWebEnginePage::WebBrowserWindow: // TODO
|
||||
case QWebEnginePage::WebBrowserTab: {
|
||||
int index = m_view->browserWindow()->tabWidget()->addView(QUrl(), Qz::NT_CleanSelectedTab);
|
||||
TabbedWebView* view = m_view->browserWindow()->weView(index);
|
||||
view->setPage(new WebPage);
|
||||
return view->page();
|
||||
}
|
||||
|
||||
if (PopupWebPage* popupPage = qobject_cast<PopupWebPage*>(this)) {
|
||||
return new PopupWebPage(type, popupPage->mainWindow());
|
||||
case QWebEnginePage::WebDialog: {
|
||||
PopupWebView* view = new PopupWebView;
|
||||
view->setPage(new WebPage);
|
||||
PopupWindow* popup = new PopupWindow(view);
|
||||
popup->show();
|
||||
m_view->browserWindow()->addDeleteOnCloseWidget(popup);
|
||||
return view->page();
|
||||
}
|
||||
|
||||
return 0;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
QObject* WebPage::createPlugin(const QString &classid, const QUrl &url,
|
||||
|
@ -800,6 +788,30 @@ QObject* WebPage::createPlugin(const QString &classid, const QUrl &url,
|
|||
return 0;
|
||||
}
|
||||
|
||||
bool WebPage::acceptNavigationRequest(const QUrl &url, QWebEnginePage::NavigationType type, bool isMainFrame)
|
||||
{
|
||||
m_lastRequestUrl = url;
|
||||
|
||||
#if QTWEBENGINE_DISABLED
|
||||
if (type == QWebEnginePage::NavigationTypeFormResubmitted) {
|
||||
// Don't show this dialog if app is still starting
|
||||
if (!view() || !view()->isVisible()) {
|
||||
return false;
|
||||
}
|
||||
QString message = tr("To display this page, QupZilla must resend the request \n"
|
||||
"(such as a search or order confirmation) that was performed earlier.");
|
||||
bool result = (QMessageBox::question(view(), tr("Confirm form resubmission"),
|
||||
message, QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::Yes);
|
||||
if (!result) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return QWebEnginePage::acceptNavigationRequest(url, type, isMainFrame);
|
||||
|
||||
}
|
||||
|
||||
void WebPage::addAdBlockRule(const AdBlockRule* rule, const QUrl &url)
|
||||
{
|
||||
AdBlockedEntry entry;
|
||||
|
|
|
@ -128,10 +128,11 @@ private:
|
|||
#if QTWEBENGINE_DISABLED
|
||||
bool supportsExtension(Extension extension) const;
|
||||
bool extension(Extension extension, const ExtensionOption* option, ExtensionReturn* output = 0);
|
||||
bool acceptNavigationRequest(QWebFrame* frame, const QNetworkRequest &request, NavigationType type);
|
||||
QString chooseFile(QWebFrame* originatingFrame, const QString &oldFile);
|
||||
#endif
|
||||
|
||||
bool acceptNavigationRequest(const QUrl &url, NavigationType type, bool isMainFrame) Q_DECL_OVERRIDE;
|
||||
|
||||
void handleUnknownProtocol(const QUrl &url);
|
||||
void desktopServicesOpen(const QUrl &url);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user