Skip to content

Commit

Permalink
New option "Open new empty tabs after active tab".
Browse files Browse the repository at this point in the history
  • Loading branch information
nowrep committed Jan 25, 2013
1 parent 3cdb4c2 commit c1c1b41
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 11 deletions.
5 changes: 3 additions & 2 deletions src/lib/app/mainapplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ void MainApplication::postLaunch()
}

if (m_postLaunchActions.contains(OpenNewTab)) {
getWindow()->tabWidget()->addView(QUrl(), Qz::NT_SelectedTabAtTheEnd);
getWindow()->tabWidget()->addView(QUrl(), Qz::NT_SelectedNewEmptyTab);
}

AutoSaver* saver = new AutoSaver();
Expand Down Expand Up @@ -550,7 +550,8 @@ void MainApplication::addNewTab(const QUrl &url)
if (!getWindow()) {
return;
}
getWindow()->tabWidget()->addView(url, Qz::NT_SelectedTabAtTheEnd);

getWindow()->tabWidget()->addView(url, url.isEmpty() ? Qz::NT_SelectedNewEmptyTab : Qz::NT_SelectedTabAtTheEnd);
}

QupZilla* MainApplication::makeNewWindow(Qz::BrowserWindow type, const QUrl &startUrl)
Expand Down
2 changes: 1 addition & 1 deletion src/lib/app/qupzilla.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1477,7 +1477,7 @@ void QupZilla::aboutQupZilla()

void QupZilla::addTab()
{
m_tabWidget->addView(QUrl(), Qz::NT_SelectedTabAtTheEnd, true);
m_tabWidget->addView(QUrl(), Qz::NT_SelectedNewEmptyTab, true);
}

void QupZilla::webSearch()
Expand Down
4 changes: 3 additions & 1 deletion src/lib/app/qz_namespace.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* ============================================================
* QupZilla - WebKit based browser
* Copyright (C) 2010-2012 David Rosca <[email protected]>
* Copyright (C) 2010-2013 David Rosca <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -75,7 +75,9 @@ enum NewTabPositionFlag {
NT_NotSelectedTab = 2,
NT_CleanTab = 4,
NT_TabAtTheEnd = 8,
NT_NewEmptyTab = 16,

NT_SelectedNewEmptyTab = NT_SelectedTab | NT_TabAtTheEnd | NT_NewEmptyTab,
NT_SelectedTabAtTheEnd = NT_SelectedTab | NT_TabAtTheEnd,
NT_NotSelectedTabAtTheEnd = NT_NotSelectedTab | NT_TabAtTheEnd,
NT_CleanSelectedTabAtTheEnd = NT_SelectedTab | NT_TabAtTheEnd | NT_CleanTab,
Expand Down
2 changes: 2 additions & 0 deletions src/lib/preferences/preferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ Preferences::Preferences(QupZilla* mainClass, QWidget* parent)
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->openNewEmptyTabAfterActive->setChecked(settings.value("newEmptyTabAfterActive", false).toBool());
ui->switchToNewTabs->setChecked(settings.value("OpenNewTabsSelected", false).toBool());
ui->dontQuitOnTab->setChecked(settings.value("dontQuitWithOneTab", false).toBool());
ui->askWhenClosingMultipleTabs->setChecked(settings.value("AskOnClosing", false).toBool());
Expand Down Expand Up @@ -824,6 +825,7 @@ void Preferences::saveSettings()
settings.setValue("hideTabsWithOneTab", ui->hideTabsOnTab->isChecked());
settings.setValue("ActivateLastTabWhenClosingActual", ui->activateLastTab->isChecked());
settings.setValue("newTabAfterActive", ui->openNewTabAfterActive->isChecked());
settings.setValue("newEmptyTabAfterActive", ui->openNewEmptyTabAfterActive->isChecked());
settings.setValue("OpenNewTabsSelected", ui->switchToNewTabs->isChecked());
settings.setValue("dontQuitWithOneTab", ui->dontQuitOnTab->isChecked());
settings.setValue("AskOnClosing", ui->askWhenClosingMultipleTabs->isChecked());
Expand Down
7 changes: 7 additions & 0 deletions src/lib/preferences/preferences.ui
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,13 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="openNewEmptyTabAfterActive">
<property name="text">
<string>Open new empty tabs after active tab</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="switchToNewTabs">
<property name="text">
Expand Down
15 changes: 11 additions & 4 deletions src/lib/webview/tabwidget.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* ============================================================
* QupZilla - WebKit based browser
* Copyright (C) 2010-2012 David Rosca <[email protected]>
* Copyright (C) 2010-2013 David Rosca <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -64,7 +64,7 @@ void AddTabButton::mouseReleaseEvent(QMouseEvent* event)
QUrl guessedUrl = WebView::guessUrlFromString(selectionClipboard);

if (!guessedUrl.isEmpty()) {
m_tabWidget->addView(guessedUrl, Qz::NT_SelectedTabAtTheEnd);
m_tabWidget->addView(guessedUrl, Qz::NT_SelectedNewEmptyTab);
}
}

Expand Down Expand Up @@ -93,7 +93,7 @@ void AddTabButton::dropEvent(QDropEvent* event)
}

foreach(const QUrl & url, mime->urls()) {
m_tabWidget->addView(url, Qz::NT_SelectedTabAtTheEnd);
m_tabWidget->addView(url, Qz::NT_SelectedNewEmptyTab);
}
}

Expand Down Expand Up @@ -151,6 +151,7 @@ void TabWidget::loadSettings()
m_dontQuitWithOneTab = settings.value("dontQuitWithOneTab", false).toBool();
m_closedInsteadOpened = settings.value("closedInsteadOpenedTabs", false).toBool();
m_newTabAfterActive = settings.value("newTabAfterActive", true).toBool();
m_newEmptyTabAfterActive = settings.value("newEmptyTabAfterActive", false).toBool();
settings.endGroup();

settings.beginGroup("Web-URL-Settings");
Expand Down Expand Up @@ -288,7 +289,13 @@ int TabWidget::addView(QNetworkRequest req, const QString &title, const Qz::NewT
url = m_urlOnNewTab;
}

if (position == -1 && m_newTabAfterActive && !(openFlags & Qz::NT_TabAtTheEnd)) {
bool openAfterActive = m_newTabAfterActive && !(openFlags & Qz::NT_TabAtTheEnd);

if (openFlags == Qz::NT_SelectedNewEmptyTab && m_newEmptyTabAfterActive) {
openAfterActive = true;
}

if (openAfterActive && position == -1) {
// If we are opening newBgTab from pinned tab, make sure it won't be
// opened between other pinned tabs
if (openFlags & Qz::NT_NotSelectedTab && m_lastBackgroundTabIndex != -1) {
Expand Down
3 changes: 2 additions & 1 deletion src/lib/webview/tabwidget.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* ============================================================
* QupZilla - WebKit based browser
* Copyright (C) 2010-2012 David Rosca <[email protected]>
* Copyright (C) 2010-2013 David Rosca <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -140,6 +140,7 @@ private slots:
bool m_dontQuitWithOneTab;
bool m_closedInsteadOpened;
bool m_newTabAfterActive;
bool m_newEmptyTabAfterActive;
QUrl m_urlOnNewTab;
QupZilla* p_QupZilla;

Expand Down
4 changes: 2 additions & 2 deletions src/plugins/MouseGestures/mousegestures.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* ============================================================
* Mouse Gestures plugin for QupZilla
* Copyright (C) 2012 David Rosca <[email protected]>
* Copyright (C) 2013 David Rosca <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -135,7 +135,7 @@ void MouseGestures::downGestured()
return;
}

m_view.data()->openUrlInNewTab(QUrl(), Qz::NT_SelectedTabAtTheEnd);
m_view.data()->openUrlInNewTab(QUrl(), Qz::NT_SelectedNewEmptyTab);
}

void MouseGestures::leftGestured()
Expand Down

0 comments on commit c1c1b41

Please sign in to comment.