diff --git a/src/app/mainapplication.cpp b/src/app/mainapplication.cpp index af56e1918..5ec431e30 100644 --- a/src/app/mainapplication.cpp +++ b/src/app/mainapplication.cpp @@ -44,6 +44,8 @@ #include "speeddial.h" #include "webpage.h" #include "settings.h" +#include "locationbarsettings.h" +#include "webviewsettings.h" #ifdef Q_WS_WIN #define DEFAULT_CHECK_UPDATES true @@ -316,7 +318,6 @@ void MainApplication::loadSettings() int maxCachedPages = settings.value("maximumCachedPages", 3).toInt(); int scrollingLines = settings.value("wheelScrollLines", wheelScrollLines()).toInt(); QUrl userStyleSheet = QUrl::fromLocalFile(settings.value("userStyleSheet", "").toString()); - m_defaultZoom = settings.value("DefaultZoom", 100).toInt(); WebPage::UserAgent = settings.value("UserAgent", "").toString(); settings.endGroup(); @@ -373,6 +374,9 @@ void MainApplication::loadSettings() if (m_downloadManager) { m_downloadManager->loadSettings(); } + + LocationBarSettings::loadSettings(); + WebViewSettings::loadSettings(); } void MainApplication::reloadSettings() diff --git a/src/app/mainapplication.h b/src/app/mainapplication.h index 7b51d549a..78480f417 100644 --- a/src/app/mainapplication.h +++ b/src/app/mainapplication.h @@ -82,7 +82,6 @@ public: inline int windowCount() { return m_mainWindows.count(); } bool checkSettingsDir(); - int defaultZoom() { return m_defaultZoom; } void togglePrivateBrowsingMode(bool state); @@ -155,7 +154,6 @@ private: QString m_activeProfil; QString m_activeLanguage; QString m_activeThemePath; - int m_defaultZoom; bool m_isClosing; bool m_isStateChanged; diff --git a/src/app/qupzilla.cpp b/src/app/qupzilla.cpp index d39b8662a..34a2d95df 100644 --- a/src/app/qupzilla.cpp +++ b/src/app/qupzilla.cpp @@ -52,7 +52,6 @@ #include "adblockicon.h" #include "closedtabsmanager.h" #include "statusbarmessage.h" -#include "locationbarsettings.h" #include "browsinglibrary.h" #include "navigationbar.h" #include "pagescreen.h" @@ -616,7 +615,6 @@ void QupZilla::receiveMessage(Qz::AppMessageType mes, bool state) case Qz::AM_ReloadSettings: loadSettings(); m_tabWidget->loadSettings(); - LocationBarSettings::instance()->loadSettings(); break; case Qz::AM_HistoryStateChanged: diff --git a/src/navigation/locationbar.cpp b/src/navigation/locationbar.cpp index d0f17e621..bc961a769 100644 --- a/src/navigation/locationbar.cpp +++ b/src/navigation/locationbar.cpp @@ -41,7 +41,6 @@ LocationBar::LocationBar(QupZilla* mainClass) : LineEdit() , p_QupZilla(mainClass) , m_webView(0) - , m_locationBarSettings(LocationBarSettings::instance()) , m_menu(new QMenu(this)) , m_pasteAndGoAction(0) , m_clearAction(0) @@ -355,7 +354,7 @@ void LocationBar::focusOutEvent(QFocusEvent* e) void LocationBar::mouseDoubleClickEvent(QMouseEvent* event) { - if (event->button() == Qt::LeftButton && m_locationBarSettings->selectAllOnDoubleClick) { + if (event->button() == Qt::LeftButton && LocationBarSettings::selectAllOnDoubleClick) { selectAll(); } else { @@ -365,7 +364,7 @@ void LocationBar::mouseDoubleClickEvent(QMouseEvent* event) void LocationBar::mousePressEvent(QMouseEvent* event) { - if (cursorPosition() == 0 && m_locationBarSettings->selectAllOnClick) { + if (cursorPosition() == 0 && LocationBarSettings::selectAllOnClick) { selectAll(); return; } @@ -420,7 +419,7 @@ void LocationBar::keyReleaseEvent(QKeyEvent* event) { QString localDomain = tr(".co.uk", "Append domain name on ALT + Enter = Should be different for every country"); - if (event->key() == Qt::Key_Alt && m_holdingAlt && m_locationBarSettings->addCountryWithAlt && + if (event->key() == Qt::Key_Alt && m_holdingAlt && LocationBarSettings::addCountryWithAlt && !text().endsWith(localDomain) && !text().endsWith("/")) { setText(text().append(localDomain)); } diff --git a/src/navigation/locationbar.h b/src/navigation/locationbar.h index 1c219014f..680b94181 100644 --- a/src/navigation/locationbar.h +++ b/src/navigation/locationbar.h @@ -39,7 +39,6 @@ class LocationCompleter; class ClickableLabel; class BookmarkIcon; class TabbedWebView; -class LocationBarSettings; class SiteIcon; class GoIcon; class RssIcon; @@ -100,7 +99,6 @@ private: QupZilla* p_QupZilla; TabbedWebView* m_webView; LocationCompleter* m_locationCompleter; - LocationBarSettings* m_locationBarSettings; QMenu* m_menu; QAction* m_pasteAndGoAction; diff --git a/src/navigation/locationbarsettings.cpp b/src/navigation/locationbarsettings.cpp index b7bf95f06..961283735 100644 --- a/src/navigation/locationbarsettings.cpp +++ b/src/navigation/locationbarsettings.cpp @@ -19,7 +19,6 @@ #include "mainapplication.h" #include "settings.h" -LocationBarSettings* LocationBarSettings::s_instance = 0; bool LocationBarSettings::selectAllOnDoubleClick = false; bool LocationBarSettings::selectAllOnClick = false; bool LocationBarSettings::addCountryWithAlt = false; @@ -29,14 +28,6 @@ LocationBarSettings::LocationBarSettings() loadSettings(); } -LocationBarSettings* LocationBarSettings::instance() -{ - if (!s_instance) { - s_instance = new LocationBarSettings(); - } - return s_instance; -} - void LocationBarSettings::loadSettings() { Settings settings; diff --git a/src/navigation/locationbarsettings.h b/src/navigation/locationbarsettings.h index dd8f7195a..83be224dc 100644 --- a/src/navigation/locationbarsettings.h +++ b/src/navigation/locationbarsettings.h @@ -23,15 +23,10 @@ class LocationBarSettings public: LocationBarSettings(); - static LocationBarSettings* instance(); - static void loadSettings(); static bool selectAllOnDoubleClick; static bool selectAllOnClick; static bool addCountryWithAlt; - -private: - static LocationBarSettings* s_instance; }; #endif // LOCATIONBARSETTINGS_H diff --git a/src/src.pro b/src/src.pro index 49d8ed154..223666bde 100644 --- a/src/src.pro +++ b/src/src.pro @@ -192,7 +192,8 @@ SOURCES += main.cpp\ popupwindow/popupwindow.cpp \ popupwindow/popuplocationbar.cpp \ webview/tabbedwebview.cpp \ - webview/webview.cpp + webview/webview.cpp \ + webview/webviewsettings.cpp HEADERS += \ 3rdparty/qtwin.h \ @@ -324,7 +325,8 @@ HEADERS += \ popupwindow/popuplocationbar.h \ webview/tabbedwebview.h \ webview/webview.h \ - app/qz_namespace.h + app/qz_namespace.h \ + webview/webviewsettings.h FORMS += \ preferences/autofillmanager.ui \ diff --git a/src/webview/popupwebview.cpp b/src/webview/popupwebview.cpp index 3bb090fd4..196101810 100644 --- a/src/webview/popupwebview.cpp +++ b/src/webview/popupwebview.cpp @@ -26,9 +26,6 @@ void PopupWebView::setWebPage(PopupWebPage* page) m_page = page; m_page->setParent(this); setPage(m_page); - - // Set default zoom - setZoom(mApp->defaultZoom()); } PopupWebPage* PopupWebView::webPage() diff --git a/src/webview/tabbedwebview.cpp b/src/webview/tabbedwebview.cpp index b5beea06b..8b89983d7 100644 --- a/src/webview/tabbedwebview.cpp +++ b/src/webview/tabbedwebview.cpp @@ -78,9 +78,6 @@ void TabbedWebView::setWebPage(WebPage* page) connect(m_page, SIGNAL(linkHovered(QString, QString, QString)), this, SLOT(linkHovered(QString, QString, QString))); connect(m_page, SIGNAL(windowCloseRequested()), this, SLOT(closeView())); - - // Set default zoom - setZoom(mApp->defaultZoom()); } void TabbedWebView::slotIconChanged() diff --git a/src/webview/webview.cpp b/src/webview/webview.cpp index e3ff7c018..cd1be7119 100644 --- a/src/webview/webview.cpp +++ b/src/webview/webview.cpp @@ -30,6 +30,7 @@ #include "browsinglibrary.h" #include "bookmarksmanager.h" #include "settings.h" +#include "webviewsettings.h" WebView::WebView(QWidget* parent) : QWebView(parent) @@ -39,8 +40,6 @@ WebView::WebView(QWidget* parent) , m_clickedFrame(0) , m_actionsHaveImages(false) { - loadSettings(); - connect(this, SIGNAL(loadStarted()), this, SLOT(slotLoadStarted())); connect(this, SIGNAL(loadProgress(int)), this, SLOT(slotLoadProgress(int))); connect(this, SIGNAL(loadFinished(bool)), this, SLOT(slotLoadFinished())); @@ -53,14 +52,6 @@ WebView::WebView(QWidget* parent) qApp->installEventFilter(this); } -void WebView::loadSettings() -{ - Settings settings; - settings.beginGroup("Browser-Tabs-Settings"); - m_newTabAfterActive = settings.value("newTabAfterActive", true).toBool(); - settings.endGroup(); -} - QIcon WebView::icon() const { if (url().scheme() == "qupzilla") { @@ -104,6 +95,13 @@ QUrl WebView::url() const return returnUrl; } +void WebView::setPage(QWebPage *page) +{ + QWebView::setPage(page); + + setZoom(WebViewSettings::defaultZoom); +} + void WebView::load(const QUrl &url) { if (url.scheme() == "javascript") { @@ -389,7 +387,7 @@ void WebView::openUrlInSelectedTab() void WebView::openUrlInBackgroundTab() { if (QAction* action = qobject_cast(sender())) { - openUrlInNewTab(action->data().toUrl(), m_newTabAfterActive ? Qz::NT_NotSelectedTab : Qz::NT_CleanTab); + openUrlInNewTab(action->data().toUrl(), WebViewSettings::newTabAfterActive ? Qz::NT_NotSelectedTab : Qz::NT_CleanTab); } } @@ -819,7 +817,7 @@ void WebView::mouseReleaseEvent(QMouseEvent* event) QUrl link = frame->hitTestContent(event->pos()).linkUrl(); if (m_clickedUrl == link && event->modifiers() == Qt::ControlModifier) { if (isUrlValid(link)) { - openUrlInNewTab(link, m_newTabAfterActive ? Qz::NT_NotSelectedTab : Qz::NT_CleanTab); + openUrlInNewTab(link, WebViewSettings::newTabAfterActive ? Qz::NT_NotSelectedTab : Qz::NT_CleanTab); event->accept(); return; } diff --git a/src/webview/webview.h b/src/webview/webview.h index a9941602d..aa5ccbe97 100644 --- a/src/webview/webview.h +++ b/src/webview/webview.h @@ -39,7 +39,8 @@ public: QString title() const; QUrl url() const; - void loadSettings(); + void setPage(QWebPage *page); + bool isLoading() const; int loadProgress() const; @@ -146,7 +147,6 @@ private: QWebFrame* m_clickedFrame; QUrl m_clickedUrl; bool m_actionsHaveImages; - bool m_newTabAfterActive; QList m_touchPoints; }; diff --git a/src/webview/webviewsettings.cpp b/src/webview/webviewsettings.cpp new file mode 100644 index 000000000..48d1ece97 --- /dev/null +++ b/src/webview/webviewsettings.cpp @@ -0,0 +1,23 @@ +#include "webviewsettings.h" +#include "settings.h" + +int WebViewSettings::defaultZoom = 100; +bool WebViewSettings::newTabAfterActive = true; + + +WebViewSettings::WebViewSettings() +{ +} + +void WebViewSettings::loadSettings() +{ + Settings settings; + settings.beginGroup("Browser-Tabs-Settings"); + newTabAfterActive = settings.value("newTabAfterActive", true).toBool(); + settings.endGroup(); + + settings.beginGroup("Web-Browser-Settings"); + defaultZoom = settings.value("DefaultZoom", 100).toInt(); + settings.endGroup(); +} + diff --git a/src/webview/webviewsettings.h b/src/webview/webviewsettings.h new file mode 100644 index 000000000..34f4a68a0 --- /dev/null +++ b/src/webview/webviewsettings.h @@ -0,0 +1,15 @@ +#ifndef WEBVIEWSETTINGS_H +#define WEBVIEWSETTINGS_H + +class WebViewSettings +{ +public: + WebViewSettings(); + + static void loadSettings(); + + static int defaultZoom; + static bool newTabAfterActive; +}; + +#endif // WEBVIEWSETTINGS_H