[CloseOnLastTab] Changed behavior of "Don't quit upon closing last tab" option

It is now "Don't close window upon closing last tab", as it is more
reasonable to bind it to window, not the whole app.

Instead of loading the url-on-new-tab, it now simply blocks closing last
tab
remotes/origin/falkon
nowrep 12 years ago
parent 853e3905ee
commit 22452aa825
  1. 4
      src/lib/preferences/preferences.cpp
  2. 4
      src/lib/preferences/preferences.ui
  3. 32
      src/lib/webview/tabwidget.cpp
  4. 2
      src/lib/webview/tabwidget.h

@ -239,7 +239,7 @@ Preferences::Preferences(BrowserWindow* window, QWidget* parent)
ui->openNewEmptyTabAfterActive->setChecked(settings.value("newEmptyTabAfterActive", false).toBool());
ui->alwaysSwitchTabsWithWheel->setChecked(settings.value("AlwaysSwitchTabsWithWheel", false).toBool());
ui->switchToNewTabs->setChecked(settings.value("OpenNewTabsSelected", false).toBool());
ui->dontQuitOnTab->setChecked(settings.value("dontQuitWithOneTab", false).toBool());
ui->dontCloseOnLastTab->setChecked(settings.value("dontCloseWithOneTab", false).toBool());
ui->askWhenClosingMultipleTabs->setChecked(settings.value("AskOnClosing", false).toBool());
ui->closedInsteadOpened->setChecked(settings.value("closedInsteadOpenedTabs", false).toBool());
ui->showTabPreviews->setChecked(settings.value("showTabPreviews", false).toBool());
@ -921,7 +921,7 @@ void Preferences::saveSettings()
settings.setValue("newEmptyTabAfterActive", ui->openNewEmptyTabAfterActive->isChecked());
settings.setValue("AlwaysSwitchTabsWithWheel", ui->alwaysSwitchTabsWithWheel->isChecked());
settings.setValue("OpenNewTabsSelected", ui->switchToNewTabs->isChecked());
settings.setValue("dontQuitWithOneTab", ui->dontQuitOnTab->isChecked());
settings.setValue("dontCloseWithOneTab", ui->dontCloseOnLastTab->isChecked());
settings.setValue("AskOnClosing", ui->askWhenClosingMultipleTabs->isChecked());
settings.setValue("closedInsteadOpenedTabs", ui->closedInsteadOpened->isChecked());
settings.setValue("showTabPreviews", ui->showTabPreviews->isChecked());

@ -743,9 +743,9 @@
</widget>
</item>
<item>
<widget class="QCheckBox" name="dontQuitOnTab">
<widget class="QCheckBox" name="dontCloseOnLastTab">
<property name="text">
<string>Don't quit upon closing last tab</string>
<string>Don't close window upon closing last tab</string>
</property>
</widget>
</item>

@ -189,7 +189,7 @@ void TabWidget::loadSettings()
{
Settings settings;
settings.beginGroup("Browser-Tabs-Settings");
m_dontQuitWithOneTab = settings.value("dontQuitWithOneTab", false).toBool();
m_dontCloseWithOneTab = settings.value("dontCloseWithOneTab", false).toBool();
m_closedInsteadOpened = settings.value("closedInsteadOpenedTabs", false).toBool();
m_newTabAfterActive = settings.value("newTabAfterActive", true).toBool();
m_newEmptyTabAfterActive = settings.value("newEmptyTabAfterActive", false).toBool();
@ -466,28 +466,28 @@ void TabWidget::closeTab(int index, bool force)
TabbedWebView* webView = webTab->view();
WebPage* webPage = webView->page();
if (!force && webView->url().toString() == QLatin1String("qupzilla:restore") && mApp->restoreManager()) {
// Don't close restore page!
// Don't close restore page!
if (!force && webView->url().toString() == QL1S("qupzilla:restore") && mApp->restoreManager()) {
return;
}
if (!force && count() == 1) {
if (m_dontQuitWithOneTab && mApp->windowCount() == 1) {
webView->load(m_urlOnNewTab);
return;
}
else {
m_window->close();
return;
}
// window.onbeforeunload handling
if (!webView->onBeforeUnload()) {
return;
}
// Save last tab url and history
// Save tab url and history
m_closedTabsManager->saveView(webTab, index);
// window.onbeforeunload handling
if (!webView->onBeforeUnload()) {
m_closedTabsManager->takeLastClosedTab();
// This would close last tab, so we close the window instead
if (!force && count() == 1) {
// But only if we can
if (m_dontCloseWithOneTab) {
// We won't actually close the tab
m_closedTabsManager->takeLastClosedTab();
return;
}
m_window->close();
return;
}

@ -149,7 +149,7 @@ private:
inline bool validIndex(int index) const { return index >= 0 && index < count(); }
bool m_dontQuitWithOneTab;
bool m_dontCloseWithOneTab;
bool m_closedInsteadOpened;
bool m_newTabAfterActive;
bool m_newEmptyTabAfterActive;

Loading…
Cancel
Save