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