1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 02:36:34 +01:00

Option to open new tabs after active tab (enabled by default)

This commit is contained in:
Mladen Pejaković 2012-01-24 15:16:33 +01:00
parent 361cc6a184
commit beca87fe19
4 changed files with 50 additions and 28 deletions

View File

@ -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());

View File

@ -642,14 +642,14 @@
</property>
</widget>
</item>
<item row="9" column="0" colspan="4">
<item row="10" column="0" colspan="4">
<widget class="QLabel" name="label_25">
<property name="text">
<string>&lt;b&gt;Address Bar behaviour&lt;/b&gt;</string>
</property>
</widget>
</item>
<item row="13" column="1">
<item row="14" column="1">
<spacer name="verticalSpacer_8">
<property name="orientation">
<enum>Qt::Vertical</enum>
@ -662,21 +662,7 @@
</property>
</spacer>
</item>
<item row="10" column="1" colspan="3">
<widget class="QCheckBox" name="selectAllOnFocus">
<property name="text">
<string>Select all text by double clicking in address bar</string>
</property>
</widget>
</item>
<item row="12" column="1" colspan="3">
<widget class="QCheckBox" name="addCountryWithAlt">
<property name="text">
<string>Add .co.uk domain by pressing ALT key</string>
</property>
</widget>
</item>
<item row="8" column="1">
<item row="9" column="1">
<spacer name="verticalSpacer_7">
<property name="orientation">
<enum>Qt::Vertical</enum>
@ -689,14 +675,28 @@
</property>
</spacer>
</item>
<item row="6" column="1">
<item row="11" column="1" colspan="3">
<widget class="QCheckBox" name="selectAllOnFocus">
<property name="text">
<string>Select all text by double clicking in address bar</string>
</property>
</widget>
</item>
<item row="13" column="1" colspan="3">
<widget class="QCheckBox" name="addCountryWithAlt">
<property name="text">
<string>Add .co.uk domain by pressing ALT key</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QCheckBox" name="askWhenClosingMultipleTabs">
<property name="text">
<string>Ask when closing multiple tabs</string>
</property>
</widget>
</item>
<item row="11" column="1" colspan="3">
<item row="12" column="1" colspan="3">
<widget class="QCheckBox" name="selectAllOnClick">
<property name="text">
<string>Select all text by clicking in address bar</string>
@ -723,20 +723,27 @@
</property>
</widget>
</item>
<item row="5" column="1">
<item row="6" column="1">
<widget class="QCheckBox" name="dontQuitOnTab">
<property name="text">
<string>Don't quit upon closing last tab</string>
</property>
</widget>
</item>
<item row="7" column="1">
<item row="8" column="1">
<widget class="QCheckBox" name="closedInsteadOpened">
<property name="text">
<string>Closed tabs list instead of opened in tab bar</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QCheckBox" name="openNewTabAfterActive">
<property name="text">
<string>Open new tabs after active tab</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="stackedWidgetPage4">

View File

@ -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<QAction*>(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;
}

View File

@ -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<QTouchEvent::TouchPoint> m_touchPoints;
};