Add tabclose command

This commit is contained in:
Florian Bruhin 2014-01-17 08:03:42 +01:00
parent ad52436875
commit 928bdbe160
3 changed files with 13 additions and 0 deletions

View File

@ -17,6 +17,7 @@ def main():
cmds.cmd_dict['open'].signal.connect(mw.tabs.openurl)
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)
kp.from_cmd_dict(cmds.cmd_dict, mw)
mw.show()

View File

@ -22,6 +22,12 @@ class TabbedBrowser(TabWidget):
tab = self.tabs[self.currentIndex()]
tab.openurl(url)
@pyqtSlot()
def close_act(self):
idx = self.currentIndex()
self.tabs.pop(idx)
self.removeTab(idx)
class BrowserTab(QWebView):
def __init__(self, parent):
super().__init__(parent)

View File

@ -75,6 +75,12 @@ class TabOpenCmd(Command):
def run(self, argv):
self.signal.emit(argv[0])
class TabCloseCmd(Command):
nargs = 0
name = 'tabclose'
key = 'd'
signal = pyqtSignal()
class QuitCmd(Command):
nargs = 0
name = 'quit'