From 7c7c1787bcaa0fe089a37c48fe1c654f0b836e70 Mon Sep 17 00:00:00 2001 From: nowrep Date: Tue, 3 Apr 2012 20:23:15 +0200 Subject: [PATCH] Fixed saving settings in plugins. --- src/lib/adblock/adblockicon.cpp | 2 +- src/lib/app/qupzilla.cpp | 4 +-- src/lib/network/qupzillaschemehandler.cpp | 2 +- src/lib/other/aboutdialog.cpp | 2 +- src/lib/popupwindow/popupwindow.cpp | 2 +- src/lib/webview/tabbedwebview.cpp | 25 +++---------------- src/lib/webview/tabbedwebview.h | 5 +--- src/lib/webview/tabwidget.cpp | 6 ++--- src/lib/webview/webtab.cpp | 2 +- src/lib/webview/webview.cpp | 3 ++- src/lib/webview/webview.h | 1 + .../AccessKeysNavigation/akn_handler.cpp | 8 +++--- .../AccessKeysNavigation/akn_handler.h | 4 +-- .../AccessKeysNavigation/akn_settings.cpp | 2 +- 14 files changed, 25 insertions(+), 43 deletions(-) diff --git a/src/lib/adblock/adblockicon.cpp b/src/lib/adblock/adblockicon.cpp index 7d4da2cbe..cab060d9b 100644 --- a/src/lib/adblock/adblockicon.cpp +++ b/src/lib/adblock/adblockicon.cpp @@ -104,7 +104,7 @@ void AdBlockIcon::createMenu(QMenu* menu) } menu->addSeparator(); - QList entries = p_QupZilla->weView()->webPage()->adBlockedEntries(); + QList entries = p_QupZilla->weView()->page()->adBlockedEntries(); if (entries.isEmpty()) { menu->addAction(tr("No content blocked"))->setEnabled(false); } diff --git a/src/lib/app/qupzilla.cpp b/src/lib/app/qupzilla.cpp index 8954edc99..2592929b8 100644 --- a/src/lib/app/qupzilla.cpp +++ b/src/lib/app/qupzilla.cpp @@ -1467,7 +1467,7 @@ void QupZilla::savePage() } DownloadManager* dManager = mApp->downManager(); - dManager->download(request, weView()->webPage(), false, suggestedFileName); + dManager->download(request, weView()->page(), false, suggestedFileName); } void QupZilla::sendLink() @@ -1746,7 +1746,7 @@ void QupZilla::disconnectObjects() foreach(WebTab * tab, m_tabWidget->allTabs()) { tab->disconnectObjects(); tab->view()->disconnectObjects(); - tab->view()->webPage()->disconnectObjects(); + tab->view()->page()->disconnectObjects(); } foreach(const QWeakPointer &pointer, m_deleteOnCloseWidgets) { diff --git a/src/lib/network/qupzillaschemehandler.cpp b/src/lib/network/qupzillaschemehandler.cpp index 3bb2d7218..6a2e5361a 100644 --- a/src/lib/network/qupzillaschemehandler.cpp +++ b/src/lib/network/qupzillaschemehandler.cpp @@ -372,7 +372,7 @@ QString QupZillaSchemeReply::configPage() } QString page = cPage; - page.replace("%USER-AGENT%", mApp->getWindow()->weView()->webPage()->userAgentForUrl(QUrl())); + page.replace("%USER-AGENT%", mApp->getWindow()->weView()->page()->userAgentForUrl(QUrl())); QString pluginsString; const QList &availablePlugins = mApp->plugins()->getAvailablePlugins(); diff --git a/src/lib/other/aboutdialog.cpp b/src/lib/other/aboutdialog.cpp index 3d9219c0d..47b9864ec 100644 --- a/src/lib/other/aboutdialog.cpp +++ b/src/lib/other/aboutdialog.cpp @@ -65,7 +65,7 @@ void AboutDialog::showAbout() m_aboutHtml += QString("

© %1 %2
").arg(QupZilla::COPYRIGHT, QupZilla::AUTHOR); m_aboutHtml += tr("Build time: %1

").arg(QupZilla::BUILDTIME); m_aboutHtml += QString("

%1

").arg(QupZilla::WWWADDRESS); - m_aboutHtml += "

" + mApp->getWindow()->weView()->webPage()->userAgentForUrl(QUrl()) + "

"; + m_aboutHtml += "

" + mApp->getWindow()->weView()->page()->userAgentForUrl(QUrl()) + "

"; m_aboutHtml += ""; } ui->textBrowser->setHtml(m_aboutHtml); diff --git a/src/lib/popupwindow/popupwindow.cpp b/src/lib/popupwindow/popupwindow.cpp index f6dbe9db1..0aae20f9d 100644 --- a/src/lib/popupwindow/popupwindow.cpp +++ b/src/lib/popupwindow/popupwindow.cpp @@ -30,7 +30,7 @@ PopupWindow::PopupWindow(PopupWebView* view, bool showStatusBar) : QWidget() , m_view(view) - , m_page(view->webPage()) + , m_page(qobject_cast(view->page())) { m_layout = new QVBoxLayout(this); m_layout->setContentsMargins(0, 0, 0, 0); diff --git a/src/lib/webview/tabbedwebview.cpp b/src/lib/webview/tabbedwebview.cpp index f80114442..e932cdf02 100644 --- a/src/lib/webview/tabbedwebview.cpp +++ b/src/lib/webview/tabbedwebview.cpp @@ -40,7 +40,6 @@ TabbedWebView::TabbedWebView(QupZilla* mainClass, WebTab* webTab) : WebView(webTab) , p_QupZilla(mainClass) , m_tabWidget(p_QupZilla->tabWidget()) - , m_page(0) , m_webTab(webTab) , m_menu(new Menu(this)) , m_mouseTrack(false) @@ -68,21 +67,11 @@ TabbedWebView::TabbedWebView(QupZilla* mainClass, WebTab* webTab) void TabbedWebView::setWebPage(WebPage* page) { - if (m_page == page) { - return; - } + page->setWebView(this); + page->setParent(this); + setPage(page); - if (m_page) { - delete m_page; - m_page = 0; - } - - m_page = page; - m_page->setWebView(this); - m_page->setParent(this); - setPage(m_page); - - connect(m_page, SIGNAL(linkHovered(QString, QString, QString)), this, SLOT(linkHovered(QString, QString, QString))); + connect(page, SIGNAL(linkHovered(QString, QString, QString)), this, SLOT(linkHovered(QString, QString, QString))); } void TabbedWebView::slotIconChanged() @@ -104,11 +93,6 @@ void TabbedWebView::inspectElement() triggerPageAction(QWebPage::InspectElement); } -WebPage* TabbedWebView::webPage() const -{ - return m_page; -} - WebTab* TabbedWebView::webTab() const { return m_webTab; @@ -234,7 +218,6 @@ void TabbedWebView::linkHovered(const QString &link, const QString &title, const p_QupZilla->statusBarMessage()->clearMessage(); } } - m_hoveredLink = link; } int TabbedWebView::tabIndex() const diff --git a/src/lib/webview/tabbedwebview.h b/src/lib/webview/tabbedwebview.h index a5cc2483c..4e06b0010 100644 --- a/src/lib/webview/tabbedwebview.h +++ b/src/lib/webview/tabbedwebview.h @@ -37,9 +37,8 @@ public: explicit TabbedWebView(QupZilla* mainClass, WebTab* webTab); ~TabbedWebView(); - void setWebPage(WebPage* page); + void setWebPage(WebPage* pag); - WebPage* webPage() const; WebTab* webTab() const; TabWidget* tabWidget() const; @@ -93,10 +92,8 @@ private: QupZilla* p_QupZilla; TabWidget* m_tabWidget; - QString m_hoveredLink; QString m_currentIp; - WebPage* m_page; WebTab* m_webTab; Menu* m_menu; diff --git a/src/lib/webview/tabwidget.cpp b/src/lib/webview/tabwidget.cpp index b74473a66..4132ceee8 100644 --- a/src/lib/webview/tabwidget.cpp +++ b/src/lib/webview/tabwidget.cpp @@ -309,7 +309,7 @@ int TabWidget::addView(QNetworkRequest req, const QString &title, const Qz::NewT p_QupZilla->locationBar()->setFocus(); } - if (openFlags & Qz::NT_SelectedTab) { + if (openFlags & Qz::NT_SelectedTab || openFlags & Qz::NT_NotSelectedTab) { m_isClosingToLastTabIndex = true; } @@ -329,7 +329,7 @@ void TabWidget::closeTab(int index) } TabbedWebView* webView = webTab->view(); - WebPage* webPage = webView->webPage(); + WebPage* webPage = webView->page(); if (count() == 1) { if (m_dontQuitWithOneTab) { @@ -376,7 +376,7 @@ void TabWidget::currentTabChanged(int index) return; } - m_isClosingToLastTabIndex = false; + m_isClosingToLastTabIndex = m_lastBackgroundTabIndex == index; m_lastBackgroundTabIndex = -1; WebTab* webTab = weTab(index); diff --git a/src/lib/webview/webtab.cpp b/src/lib/webview/webtab.cpp index cd2cff0c5..419bd3623 100644 --- a/src/lib/webview/webtab.cpp +++ b/src/lib/webview/webtab.cpp @@ -90,7 +90,7 @@ WebTab::WebTab(QupZilla* mainClass, LocationBar* locationBar) connect(m_view, SIGNAL(loadFinished(bool)), m_locationBar.data(), SLOT(siteIconChanged())); connect(m_view, SIGNAL(urlChanged(QUrl)), m_locationBar.data(), SLOT(showUrl(QUrl))); connect(m_view, SIGNAL(rssChanged(bool)), m_locationBar.data(), SLOT(showRSSIcon(bool))); - connect(m_view->webPage(), SIGNAL(privacyChanged(bool)), m_locationBar.data(), SLOT(setPrivacy(bool))); + connect(m_view, SIGNAL(privacyChanged(bool)), m_locationBar.data(), SLOT(setPrivacy(bool))); connect(m_locationBar.data(), SIGNAL(loadUrl(QUrl)), m_view, SLOT(load(QUrl))); } diff --git a/src/lib/webview/webview.cpp b/src/lib/webview/webview.cpp index 301503785..d9e2b93a8 100644 --- a/src/lib/webview/webview.cpp +++ b/src/lib/webview/webview.cpp @@ -119,7 +119,8 @@ void WebView::setPage(QWebPage* page) m_page = qobject_cast(page); setZoom(WebViewSettings::defaultZoom); - connect(page, SIGNAL(saveFrameStateRequested(QWebFrame*, QWebHistoryItem*)), this, SLOT(frameStateChanged())); + connect(m_page, SIGNAL(saveFrameStateRequested(QWebFrame*, QWebHistoryItem*)), this, SLOT(frameStateChanged())); + connect(m_page, SIGNAL(privacyChanged(bool)), this, SIGNAL(privacyChanged(bool))); mApp->plugins()->emitWebPageCreated(m_page); } diff --git a/src/lib/webview/webview.h b/src/lib/webview/webview.h index 7326331e1..3904a90a9 100644 --- a/src/lib/webview/webview.h +++ b/src/lib/webview/webview.h @@ -56,6 +56,7 @@ public: signals: void viewportResized(QSize); void showNotification(QWidget*); + void privacyChanged(bool); public slots: void zoomIn(); diff --git a/src/plugins/AccessKeysNavigation/akn_handler.cpp b/src/plugins/AccessKeysNavigation/akn_handler.cpp index b54ec1d23..605cdc826 100644 --- a/src/plugins/AccessKeysNavigation/akn_handler.cpp +++ b/src/plugins/AccessKeysNavigation/akn_handler.cpp @@ -66,19 +66,19 @@ Qt::Key keyFromCode(int code) AKN_Handler::AKN_Handler(const QString &sPath, QObject* parent) : QObject(parent) , m_accessKeysVisible(false) - , m_settingsPath(sPath) + , m_settingsFile(sPath + "extensions.ini") { loadSettings(); } -QString AKN_Handler::settingsPath() +QString AKN_Handler::settingsFile() { - return m_settingsPath; + return m_settingsFile; } void AKN_Handler::loadSettings() { - QSettings settings(m_settingsPath, QSettings::IniFormat); + QSettings settings(m_settingsFile, QSettings::IniFormat); settings.beginGroup("AccessKeysNavigation"); m_key = keyFromCode(settings.value("Key", 0).toInt()); diff --git a/src/plugins/AccessKeysNavigation/akn_handler.h b/src/plugins/AccessKeysNavigation/akn_handler.h index 1871f2414..c7a86fbc8 100644 --- a/src/plugins/AccessKeysNavigation/akn_handler.h +++ b/src/plugins/AccessKeysNavigation/akn_handler.h @@ -37,7 +37,7 @@ class AKN_Handler : public QObject public: explicit AKN_Handler(const QString &sPath, QObject* parent = 0); - QString settingsPath(); + QString settingsFile(); void loadSettings(); bool handleKeyPress(QObject* obj, QKeyEvent* event); @@ -66,7 +66,7 @@ private: Qt::Key m_key; bool m_isDoublePress; QTime m_lastKeyPressTime; - QString m_settingsPath; + QString m_settingsFile; }; #endif // AKN_HANDLER_H diff --git a/src/plugins/AccessKeysNavigation/akn_settings.cpp b/src/plugins/AccessKeysNavigation/akn_settings.cpp index ee01b4fff..4c9321a52 100644 --- a/src/plugins/AccessKeysNavigation/akn_settings.cpp +++ b/src/plugins/AccessKeysNavigation/akn_settings.cpp @@ -28,7 +28,7 @@ AKN_Settings::AKN_Settings(AKN_Handler* handler, QWidget* parent) : QDialog(parent) , ui(new Ui::AKN_Settings) , m_handler(handler) - , m_settingsFile(handler->settingsPath() + "extensions.ini") + , m_settingsFile(handler->settingsFile()) { ui->setupUi(this);