Add tab{prev,next} command

This commit is contained in:
Florian Bruhin 2014-01-17 08:39:14 +01:00
parent c392993c79
commit 9a20d60c13
3 changed files with 33 additions and 0 deletions

View File

@ -18,6 +18,8 @@ def main():
cmds.cmd_dict['tabopen'].signal.connect(mw.tabs.tabopen)
cmds.cmd_dict['quit'].signal.connect(QApplication.closeAllWindows) # FIXME
cmds.cmd_dict['tabclose'].signal.connect(mw.tabs.close_act)
cmds.cmd_dict['tabprev'].signal.connect(mw.tabs.switch_prev)
cmds.cmd_dict['tabnext'].signal.connect(mw.tabs.switch_next)
kp.from_cmd_dict(cmds.cmd_dict, mw)
mw.show()

View File

@ -32,6 +32,25 @@ class TabbedBrowser(TabWidget):
# FIXME
pass
@pyqtSlot()
def switch_prev(self):
idx = self.currentIndex()
if idx > 0:
self.setCurrentIndex(idx - 1)
else:
# FIXME
pass
@pyqtSlot()
def switch_next(self):
idx = self.currentIndex()
if idx < self.count() - 1:
self.setCurrentIndex(idx + 1)
else:
# FIXME
pass
class BrowserTab(QWebView):
def __init__(self, parent):
super().__init__(parent)

View File

@ -81,6 +81,18 @@ class TabCloseCmd(Command):
key = 'd'
signal = pyqtSignal()
class TabNextCmd(Command):
nargs = 0
name = 'tabnext'
key = 'Shift+j'
signal = pyqtSignal()
class TabPrevCmd(Command):
nargs = 0
name = 'tabprev'
key = 'Shift+k'
signal = pyqtSignal()
class QuitCmd(Command):
nargs = 0
name = 'quit'