From 9a20d60c13e22ad7c3be66142356ca811ce65121 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Fri, 17 Jan 2014 08:39:14 +0100 Subject: [PATCH] Add tab{prev,next} command --- qutebrowser/app.py | 2 ++ qutebrowser/browser.py | 19 +++++++++++++++++++ qutebrowser/commands.py | 12 ++++++++++++ 3 files changed, 33 insertions(+) diff --git a/qutebrowser/app.py b/qutebrowser/app.py index ba2372e28..2e8894751 100644 --- a/qutebrowser/app.py +++ b/qutebrowser/app.py @@ -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() diff --git a/qutebrowser/browser.py b/qutebrowser/browser.py index 8c982fdf9..d9f257319 100644 --- a/qutebrowser/browser.py +++ b/qutebrowser/browser.py @@ -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) diff --git a/qutebrowser/commands.py b/qutebrowser/commands.py index 1aec5cad0..63f0f4579 100644 --- a/qutebrowser/commands.py +++ b/qutebrowser/commands.py @@ -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'