diff --git a/src/preferences/preferences.cpp b/src/preferences/preferences.cpp index 3c9a6627d..19e5f2c51 100644 --- a/src/preferences/preferences.cpp +++ b/src/preferences/preferences.cpp @@ -160,7 +160,7 @@ Preferences::Preferences(QupZilla* mainClass, QWidget* parent) ui->startProfile->addItem(actProfileName); QDir profilesDir(mApp->PROFILEDIR + "profiles/"); QStringList list_ = profilesDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot); - foreach(const QString &name, list_) { + foreach(const QString & name, list_) { if (actProfileName == name) { continue; } @@ -192,6 +192,7 @@ Preferences::Preferences(QupZilla* mainClass, QWidget* parent) ui->makeMovable->setChecked(settings.value("makeTabsMovable", true).toBool()); ui->hideTabsOnTab->setChecked(settings.value("hideTabsWithOneTab", false).toBool()); ui->activateLastTab->setChecked(settings.value("ActivateLastTabWhenClosingActual", false).toBool()); + ui->openNewTabAfterActive->setChecked(settings.value("newTabAfterActive", true).toBool()); ui->dontQuitOnTab->setChecked(settings.value("dontQuitWithOneTab", false).toBool()); ui->askWhenClosingMultipleTabs->setChecked(settings.value("AskOnClosing", false).toBool()); ui->closedInsteadOpened->setChecked(settings.value("closedInsteadOpenedTabs", false).toBool()); @@ -345,7 +346,7 @@ Preferences::Preferences(QupZilla* mainClass, QWidget* parent) QDir lanDir(mApp->TRANSLATIONSDIR); QStringList list = lanDir.entryList(QStringList("*.qm")); - foreach(const QString &name, list) { + foreach(const QString & name, list) { if (name.startsWith("qt_") || name == activeLanguage) { continue; } @@ -685,6 +686,7 @@ void Preferences::saveSettings() settings.setValue("makeTabsMovable", ui->makeMovable->isChecked()); settings.setValue("hideTabsWithOneTab", ui->hideTabsOnTab->isChecked()); settings.setValue("ActivateLastTabWhenClosingActual", ui->activateLastTab->isChecked()); + settings.setValue("newTabAfterActive", ui->openNewTabAfterActive->isChecked()); settings.setValue("dontQuitWithOneTab", ui->dontQuitOnTab->isChecked()); settings.setValue("AskOnClosing", ui->askWhenClosingMultipleTabs->isChecked()); settings.setValue("closedInsteadOpenedTabs", ui->closedInsteadOpened->isChecked()); diff --git a/src/preferences/preferences.ui b/src/preferences/preferences.ui index d8fc1b3d1..6674767af 100644 --- a/src/preferences/preferences.ui +++ b/src/preferences/preferences.ui @@ -642,14 +642,14 @@ - + <b>Address Bar behaviour</b> - + Qt::Vertical @@ -662,21 +662,7 @@ - - - - Select all text by double clicking in address bar - - - - - - - Add .co.uk domain by pressing ALT key - - - - + Qt::Vertical @@ -689,14 +675,28 @@ - + + + + Select all text by double clicking in address bar + + + + + + + Add .co.uk domain by pressing ALT key + + + + Ask when closing multiple tabs - + Select all text by clicking in address bar @@ -723,20 +723,27 @@ - + Don't quit upon closing last tab - + Closed tabs list instead of opened in tab bar + + + + Open new tabs after active tab + + + diff --git a/src/webview/webview.cpp b/src/webview/webview.cpp index f3e1d5395..530d403b7 100644 --- a/src/webview/webview.cpp +++ b/src/webview/webview.cpp @@ -29,6 +29,7 @@ #include "searchenginesmanager.h" #include "browsinglibrary.h" #include "bookmarksmanager.h" +#include "settings.h" WebView::WebView(QWidget* parent) : QWebView(parent) @@ -38,6 +39,8 @@ 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())); @@ -50,6 +53,14 @@ 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") { @@ -378,9 +389,9 @@ void WebView::openUrlInSelectedTab() void WebView::openUrlInBackgroundTab() { if (QAction* action = qobject_cast(sender())) { - openUrlInNewTab(action->data().toUrl(), Qz::NT_NotSelectedTab); + openUrlInNewTab(action->data().toUrl(), m_newTabAfterActive ? Qz::NT_NotSelectedTab : Qz::NT_CleanTab); } -}\ +} void WebView::loadClickedFrame() { @@ -509,7 +520,7 @@ void WebView::createContextMenu(QMenu* menu, const QWebHitTestResult &hitTest, c QMenu* pageMenu = page()->createStandardContextMenu(); int i = 0; - foreach(QAction* act, pageMenu->actions()) { + foreach(QAction * act, pageMenu->actions()) { if (act->isSeparator()) { menu->addSeparator(); continue; @@ -765,7 +776,7 @@ void WebView::mousePressEvent(QMouseEvent* event) if (frame) { QUrl link = frame->hitTestContent(event->pos()).linkUrl(); if (isUrlValid(link)) { - openUrlInNewTab(link, Qz::NT_NotSelectedTab); + openUrlInNewTab(link, m_newTabAfterActive ? Qz::NT_NotSelectedTab : Qz::NT_CleanTab); event->accept(); return; } @@ -786,7 +797,7 @@ void WebView::mousePressEvent(QMouseEvent* event) if (frame && event->modifiers() == Qt::ControlModifier) { QUrl link = frame->hitTestContent(event->pos()).linkUrl(); if (isUrlValid(link)) { - openUrlInNewTab(link, Qz::NT_NotSelectedTab); + openUrlInNewTab(link, m_newTabAfterActive ? Qz::NT_NotSelectedTab : Qz::NT_CleanTab); event->accept(); return; } diff --git a/src/webview/webview.h b/src/webview/webview.h index 83f07680e..5c7f8937a 100644 --- a/src/webview/webview.h +++ b/src/webview/webview.h @@ -39,6 +39,7 @@ public: QString title() const; QUrl url() const; + void loadSettings(); bool isLoading() const; int loadProgress() const; @@ -143,6 +144,7 @@ private: QWebElement m_mediaElement; QWebFrame* m_clickedFrame; bool m_actionsHaveImages; + bool m_newTabAfterActive; QList m_touchPoints; };