mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-24 04:36:34 +01:00
WebView: Handle create WebBrowserWindow
Instead of custom handling of shift + mouse click, use QWebEngineView::createWindow. It should fix the issue with JavaScript catching the mouse click performing some action and QupZilla trying to open new window. Closes #1898
This commit is contained in:
parent
385f10e345
commit
71b6d922be
@ -93,6 +93,7 @@ BrowserWindow::BrowserWindow(Qz::BrowserWindowType type, const QUrl &startUrl)
|
||||
, m_startUrl(startUrl)
|
||||
, m_windowType(type)
|
||||
, m_startTab(0)
|
||||
, m_startPage(0)
|
||||
, m_sideBarManager(new SideBarManager(this))
|
||||
, m_statusBarMessage(new StatusBarMessage(this))
|
||||
, m_isHtmlFullScreen(false)
|
||||
@ -141,6 +142,11 @@ void BrowserWindow::setStartTab(WebTab* tab)
|
||||
m_startTab = tab;
|
||||
}
|
||||
|
||||
void BrowserWindow::setStartPage(WebPage *page)
|
||||
{
|
||||
m_startPage = page;
|
||||
}
|
||||
|
||||
void BrowserWindow::postLaunch()
|
||||
{
|
||||
loadSettings();
|
||||
@ -207,6 +213,13 @@ void BrowserWindow::postLaunch()
|
||||
m_tabWidget->addView(m_startTab);
|
||||
}
|
||||
|
||||
if (m_startPage) {
|
||||
addTab = false;
|
||||
m_tabWidget->addView(QUrl());
|
||||
weView()->page()->deleteLater();
|
||||
weView()->setPage(m_startPage);
|
||||
}
|
||||
|
||||
if (addTab) {
|
||||
m_tabWidget->addView(startUrl, Qz::NT_CleanSelectedTabAtTheEnd);
|
||||
|
||||
@ -231,7 +244,7 @@ void BrowserWindow::postLaunch()
|
||||
tabWidget()->tabBar()->ensureVisible();
|
||||
|
||||
// Update focus
|
||||
if (LocationBar::convertUrlToText(weView()->webTab()->url()).isEmpty())
|
||||
if (LocationBar::convertUrlToText(weView()->page()->requestedUrl()).isEmpty())
|
||||
locationBar()->setFocus();
|
||||
else
|
||||
weView()->setFocus();
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* ============================================================
|
||||
* QupZilla - WebKit based browser
|
||||
* Copyright (C) 2010-2014 David Rosca <nowrep@gmail.com>
|
||||
* Copyright (C) 2010-2016 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
|
||||
@ -63,6 +63,7 @@ public:
|
||||
~BrowserWindow();
|
||||
|
||||
void setStartTab(WebTab* tab);
|
||||
void setStartPage(WebPage* page);
|
||||
|
||||
void restoreWindowState(const RestoreManager::WindowData &d);
|
||||
void saveSideBarWidth();
|
||||
@ -178,6 +179,7 @@ private:
|
||||
QUrl m_homepage;
|
||||
Qz::BrowserWindowType m_windowType;
|
||||
WebTab* m_startTab;
|
||||
WebPage* m_startPage;
|
||||
|
||||
QVBoxLayout* m_mainLayout;
|
||||
QSplitter* m_mainSplitter;
|
||||
|
@ -579,13 +579,12 @@ QWebEnginePage* WebPage::createWindow(QWebEnginePage::WebWindowType type)
|
||||
BrowserWindow *window = tView ? tView->browserWindow() : mApp->getWindow();
|
||||
|
||||
switch (type) {
|
||||
case QWebEnginePage::WebBrowserWindow:
|
||||
// WebBrowserWindow is only called after Shift+LeftClick on link, but we handle
|
||||
// this case ourselves, so it should never be called.
|
||||
// There is currently one case where it will be called, and that is when Shift+LeftClick
|
||||
// on a link in a frame because WebHitTestResult doesn't work with frames yet.
|
||||
qWarning() << "Asked to created WebBrowserWindow!";
|
||||
break;
|
||||
case QWebEnginePage::WebBrowserWindow: {
|
||||
BrowserWindow *window = mApp->createWindow(Qz::BW_NewWindow);
|
||||
WebPage *page = new WebPage;
|
||||
window->setStartPage(page);
|
||||
return page;
|
||||
}
|
||||
|
||||
case QWebEnginePage::WebDialog:
|
||||
if (!qzSettings->openPopupsInTabs) {
|
||||
|
@ -1011,10 +1011,6 @@ void WebView::_mouseReleaseEvent(QMouseEvent *event)
|
||||
userDefinedOpenUrlInNewTab(link, event->modifiers() & Qt::ShiftModifier);
|
||||
event->accept();
|
||||
}
|
||||
else if (event->modifiers() & Qt::ShiftModifier) {
|
||||
mApp->createWindow(Qz::BW_NewWindow, link);
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user