From fa62b299a06d4281c68012185076bd9b8114ed08 Mon Sep 17 00:00:00 2001 From: nowrep Date: Sat, 19 Jan 2013 01:05:17 +0100 Subject: [PATCH] Fixed opening popup windows with QtWebKit 2.3 It now correctly opens new tab / popup window according to arguments in window.open call. --- src/lib/popupwindow/popupwebpage.cpp | 16 +++++---------- src/lib/popupwindow/popupwindow.cpp | 27 +++++++++++++++++++++----- src/lib/preferences/acceptlanguage.cpp | 1 + 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/src/lib/popupwindow/popupwebpage.cpp b/src/lib/popupwindow/popupwebpage.cpp index 3800da670..fdc49c623 100644 --- a/src/lib/popupwindow/popupwebpage.cpp +++ b/src/lib/popupwindow/popupwebpage.cpp @@ -21,7 +21,6 @@ #include "qupzilla.h" #include "tabwidget.h" #include "tabbedwebview.h" -#include "qzsettings.h" #include #include @@ -57,7 +56,11 @@ PopupWebPage::PopupWebPage(QWebPage::WebWindowType type, QupZilla* mainClass) void PopupWebPage::slotGeometryChangeRequested(const QRect &rect) { - if (rect.isValid() && qzSettings->allowJsGeometryChange) { + /* Very ugly hack for QtWebKit 2.3 + * It now sends QRect(0, 25, 100x100) if the popup window + * geometry was not set in window.open call. + */ + if (rect.isValid() && rect != QRect(0, 25, 100, 100)) { m_geometry = rect; m_createNewWindow = true; } @@ -65,25 +68,16 @@ void PopupWebPage::slotGeometryChangeRequested(const QRect &rect) void PopupWebPage::slotMenuBarVisibilityChangeRequested(bool visible) { - if (!qzSettings->allowJsHideMenuBar) { - return; - } m_menuBarVisible = visible; } void PopupWebPage::slotStatusBarVisibilityChangeRequested(bool visible) { - if (!qzSettings->allowJsHideStatusBar) { - return; - } m_statusBarVisible = visible; } void PopupWebPage::slotToolBarVisibilityChangeRequested(bool visible) { - if (!qzSettings->allowJsHideToolBar) { - return; - } m_toolBarVisible = visible; } diff --git a/src/lib/popupwindow/popupwindow.cpp b/src/lib/popupwindow/popupwindow.cpp index aa008b2aa..d488477cf 100644 --- a/src/lib/popupwindow/popupwindow.cpp +++ b/src/lib/popupwindow/popupwindow.cpp @@ -21,6 +21,7 @@ #include "popupstatusbarmessage.h" #include "progressbar.h" #include "qupzilla.h" +#include "qzsettings.h" #include "popuplocationbar.h" #include "globalfunctions.h" @@ -152,8 +153,17 @@ void PopupWindow::closeEvent(QCloseEvent* event) event->accept(); } +void PopupWindow::titleChanged() +{ + setWindowTitle(tr("%1 - QupZilla").arg(m_view->title())); +} + void PopupWindow::setWindowGeometry(const QRect &newRect) { + if (!qzSettings->allowJsGeometryChange) { + return; + } + if (newRect.isValid()) { QRect oldRect = rect(); move(newRect.topLeft()); @@ -175,20 +185,27 @@ void PopupWindow::setWindowGeometry(const QRect &newRect) void PopupWindow::setStatusBarVisibility(bool visible) { + if (!qzSettings->allowJsHideStatusBar) { + return; + } + Q_UNUSED(visible) } void PopupWindow::setMenuBarVisibility(bool visible) { + if (!qzSettings->allowJsHideMenuBar) { + return; + } + Q_UNUSED(visible) } void PopupWindow::setToolBarVisibility(bool visible) { + if (!qzSettings->allowJsHideToolBar) { + return; + } + Q_UNUSED(visible) } - -void PopupWindow::titleChanged() -{ - setWindowTitle(tr("%1 - QupZilla").arg(m_view->title())); -} diff --git a/src/lib/preferences/acceptlanguage.cpp b/src/lib/preferences/acceptlanguage.cpp index 971887f45..e81aefc2c 100644 --- a/src/lib/preferences/acceptlanguage.cpp +++ b/src/lib/preferences/acceptlanguage.cpp @@ -77,6 +77,7 @@ AcceptLanguage::AcceptLanguage(QWidget* parent) Settings settings; settings.beginGroup("Language"); QStringList langs = settings.value("acceptLanguage", defaultLanguage()).toStringList(); + settings.endGroup(); foreach(const QString & code, langs) { QString code_ = code;