Add last_close setting.

This commit is contained in:
Florian Bruhin 2014-02-17 16:50:41 +01:00
parent 01096b995c
commit 9c0f0e8ac5
3 changed files with 19 additions and 11 deletions

View File

@ -102,6 +102,7 @@ class QuteBrowser(QApplication):
self.mainwindow.status.cmd.on_set_cmd_text)
self.mainwindow.tabs.set_cmd_text.connect(
self.mainwindow.status.cmd.on_set_cmd_text)
self.mainwindow.tabs.quit.connect(self.shutdown)
self.mainwindow.status.cmd.got_cmd.connect(self.commandparser.run)
self.mainwindow.status.cmd.got_search.connect(self.searchparser.search)
self.mainwindow.status.cmd.got_search_rev.connect(

View File

@ -51,6 +51,8 @@ scrollbuttons = false
position = north
# previous, left, right
select_on_remove = previous
# ignore, blank, quit
last_close = quit
[searchengines]
DEFAULT = ${duckduckgo}

View File

@ -36,6 +36,7 @@ from PyQt5.QtWebKitWidgets import QWebView, QWebPage
import qutebrowser.utils.about as about
import qutebrowser.utils.url as urlutils
import qutebrowser.utils.config as config
from qutebrowser.widgets.tabbar import TabWidget
from qutebrowser.utils.signals import SignalCache, dbg_signal
from qutebrowser.utils.misc import read_file
@ -68,6 +69,7 @@ class TabbedBrowser(TabWidget):
set_cmd_text = pyqtSignal(str) # Set commandline to a given text
keypress = pyqtSignal('QKeyEvent')
shutdown_complete = pyqtSignal() # All tabs have been shut down.
quit = pyqtSignal() # Last tab closed, quit application.
_url_stack = [] # Stack of URLs of closed tabs
_space = None # Space QShortcut
_tabs = None
@ -148,18 +150,21 @@ class TabbedBrowser(TabWidget):
Command handler for :close.
"""
idx = self.currentIndex() if count is None else count - 1
tab = self._widget(count)
if tab is None:
return
last_close = config.config.get('tabbar', 'last_close')
if self.count() > 1:
idx = self.currentIndex() if count is None else count - 1
tab = self._widget(count)
if tab is not None:
# FIXME maybe we actually should store the webview objects here
self._url_stack.append(tab.url())
self.removeTab(idx)
tab.shutdown(callback=functools.partial(self._cb_tab_shutdown,
tab))
else:
# FIXME
pass
# FIXME maybe we actually should store the webview objects here
self._url_stack.append(tab.url())
self.removeTab(idx)
tab.shutdown(callback=functools.partial(self._cb_tab_shutdown,
tab))
elif last_close == 'quit':
self.quit.emit()
elif last_close == 'blank':
tab.openurl('about:blank')
def _cb_tab_shutdown(self, tab):
"""Called after a tab has been shut down completely."""