From 3e31e889210ae50fd476a2a167aa92902e682d3c Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 7 Oct 2014 17:09:24 +0200 Subject: [PATCH] Only close window (instead of quitting) when closing last tab. This also renames the 'quit' value for tabs->last-close to 'close' to avoid confusion. Fixes #154. --- qutebrowser/browser/commands.py | 4 ---- qutebrowser/config/configtypes.py | 2 +- qutebrowser/widgets/mainwindow.py | 3 ++- qutebrowser/widgets/tabbedbrowser.py | 8 ++++---- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index 4e28c3515..63bba1d90 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -222,10 +222,6 @@ class CommandDispatcher: Args: count: The tab index to close, or None - - Emit: - quit: If last tab was closed and last-close in config is set to - quit. """ tab = self._cntwidget(count) if tab is None: diff --git a/qutebrowser/config/configtypes.py b/qutebrowser/config/configtypes.py index e833b9153..4dbcea3b4 100644 --- a/qutebrowser/config/configtypes.py +++ b/qutebrowser/config/configtypes.py @@ -1163,7 +1163,7 @@ class LastClose(BaseType): valid_values = ValidValues(('ignore', "Don't do anything."), ('blank', "Load a blank page."), - ('quit', "Quit qutebrowser.")) + ('close', "Close the window.")) class AcceptCookies(BaseType): diff --git a/qutebrowser/widgets/mainwindow.py b/qutebrowser/widgets/mainwindow.py index e1640392c..30d4fcb2b 100644 --- a/qutebrowser/widgets/mainwindow.py +++ b/qutebrowser/widgets/mainwindow.py @@ -200,7 +200,7 @@ class MainWindow(QWidget): prompter = self._get_object('prompter') # misc - self._tabbed_browser.quit.connect(app.shutdown) + self._tabbed_browser.close_window.connect(self.close) mode_manager.entered.connect(hints.on_mode_entered) # status bar @@ -294,6 +294,7 @@ class MainWindow(QWidget): self._completion.setGeometry(rect) @cmdutils.register(instance='main-window', scope='window') + @pyqtSlot() def close(self): """Close the current window. diff --git a/qutebrowser/widgets/tabbedbrowser.py b/qutebrowser/widgets/tabbedbrowser.py index a830b6449..19caad1fa 100644 --- a/qutebrowser/widgets/tabbedbrowser.py +++ b/qutebrowser/widgets/tabbedbrowser.py @@ -72,7 +72,7 @@ class TabbedBrowser(tabwidget.TabWidget): arg 1: x-position in %. arg 2: y-position in %. cur_load_status_changed: Loading status of current tab changed. - quit: The last tab was closed, quit application. + close_window: The last tab was closed, close this window. resized: Emitted when the browser window has resized, so the completion widget can adjust its size to it. arg: The new size. @@ -92,7 +92,7 @@ class TabbedBrowser(tabwidget.TabWidget): cur_scroll_perc_changed = pyqtSignal(int, int) cur_load_status_changed = pyqtSignal(str) start_download = pyqtSignal('QNetworkReply*') - quit = pyqtSignal() + close_window = pyqtSignal() resized = pyqtSignal('QRect') got_cmd = pyqtSignal(str) current_tab_changed = pyqtSignal(webview.WebView) @@ -229,9 +229,9 @@ class TabbedBrowser(tabwidget.TabWidget): last_close = config.get('tabs', 'last-close') if self.count() > 1: self._remove_tab(tab) - elif last_close == 'quit': + elif last_close == 'close': self._remove_tab(tab) - self.quit.emit() + self.close_window.emit() elif last_close == 'blank': tab.openurl('about:blank')