New command: tab_focus_last / Ctrl-Tab
This commit is contained in:
parent
4e7eb41cb9
commit
96d456fdee
3
TODO
3
TODO
@ -284,9 +284,6 @@ Open quickmark in a new tab (command tab_quickmark, aliases: tabqmarks).
|
||||
tab-handling
|
||||
------------
|
||||
|
||||
C-Tab
|
||||
Toggle between current and last focused tab (command toggle_tab, aliases: ttab)
|
||||
|
||||
gt
|
||||
Show all open tabs. (command buffers, aliases: bu).
|
||||
|
||||
|
@ -593,6 +593,7 @@ DATA = OrderedDict([
|
||||
(']]', 'nextpage'),
|
||||
('{{', 'tabprevpage'),
|
||||
('}}', 'tabnextpage'),
|
||||
('<Ctrl-Tab>', 'tab_focus_last'),
|
||||
('<Ctrl-V>', 'enter_mode passthrough'),
|
||||
('<Ctrl-Q>', 'quit'),
|
||||
('<Ctrl-Shift-T>', 'undo'),
|
||||
|
@ -54,6 +54,8 @@ class TabbedBrowser(TabWidget):
|
||||
_filter: A SignalFilter instance.
|
||||
cur: A CurCommandDispatcher instance to dispatch commands to the
|
||||
current tab.
|
||||
last_focused: The tab which was focused last.
|
||||
now_focused: The tab which is focused now.
|
||||
|
||||
Signals:
|
||||
cur_progress: Progress of the current tab changed (loadProgress).
|
||||
@ -89,13 +91,14 @@ class TabbedBrowser(TabWidget):
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
self.currentChanged.connect(lambda idx:
|
||||
self.widget(idx).signal_cache.replay())
|
||||
self.currentChanged.connect(self.on_current_changed)
|
||||
self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
|
||||
self._tabs = []
|
||||
self._url_stack = []
|
||||
self._filter = SignalFilter(self)
|
||||
self.cur = CurCommandDispatcher(self)
|
||||
self.last_focused = None
|
||||
self.now_focused = None
|
||||
# FIXME adjust this to font size
|
||||
self.setIconSize(QSize(12, 12))
|
||||
|
||||
@ -427,6 +430,14 @@ class TabbedBrowser(TabWidget):
|
||||
self.insertTab(new_idx, tab, icon, label)
|
||||
self.setCurrentIndex(new_idx)
|
||||
|
||||
@cmdutils.register(instance='mainwindow.tabs')
|
||||
def tab_focus_last(self):
|
||||
"""Focus the tab which was last focused."""
|
||||
idx = self.indexOf(self.last_focused)
|
||||
if idx == -1:
|
||||
message.error("Last focused tab vanished!")
|
||||
return
|
||||
self.setCurrentIndex(idx)
|
||||
|
||||
@pyqtSlot(str, str)
|
||||
def on_config_changed(self, section, option):
|
||||
@ -482,6 +493,14 @@ class TabbedBrowser(TabWidget):
|
||||
if mode == "command":
|
||||
self.setFocus()
|
||||
|
||||
@pyqtSlot(int)
|
||||
def on_current_changed(self, idx):
|
||||
"""Set last_focused and replay signal cache if focus changed."""
|
||||
tab = self.widget(idx)
|
||||
tab.signal_cache.replay()
|
||||
self.last_focused = self.now_focused
|
||||
self.now_focused = tab
|
||||
|
||||
def resizeEvent(self, e):
|
||||
"""Extend resizeEvent of QWidget to emit a resized signal afterwards.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user