Add opencur and tabopencur

This commit is contained in:
Florian Bruhin 2014-02-06 13:34:49 +01:00
parent bb7df14c08
commit e2589a35b3
4 changed files with 29 additions and 0 deletions

View File

@ -71,6 +71,8 @@ class QuteBrowser(QApplication):
self.aboutToQuit.connect(config.config.save)
self.mainwindow.tabs.keypress.connect(self.keyparser.handle)
self.keyparser.set_cmd_text.connect(self.mainwindow.status.cmd.set_cmd)
self.mainwindow.tabs.set_cmd_text.connect(
self.mainwindow.status.cmd.set_cmd)
self.mainwindow.status.cmd.got_cmd.connect(self.commandparser.run)
self.mainwindow.status.cmd.got_search.connect(self.searchparser.search)
self.mainwindow.status.cmd.got_search_rev.connect(
@ -226,7 +228,9 @@ class QuteBrowser(QApplication):
handlers = {
'open': self.mainwindow.tabs.openurl,
'opencur': self.mainwindow.tabs.opencur,
'tabopen': self.mainwindow.tabs.tabopen,
'tabopencur': self.mainwindow.tabs.tabopencur,
'quit': self.quit,
'tabclose': self.mainwindow.tabs.cur_close,
'tabprev': self.mainwindow.tabs.switch_prev,

View File

@ -31,6 +31,12 @@ class Open(Command):
count = True
class OpenCur(Command):
"""Fill the statusbar with :open and the current url."""
nargs = 0
hide = True
class TabOpen(Command):
"""Open a page in a new tab.
@ -41,6 +47,12 @@ class TabOpen(Command):
split_args = False
class TabOpenCur(Command):
"""Fill the statusbar with :tabopen and the current url."""
nargs = 0
hide = True
class TabClose(Command):
"""Close the current tab, or tab [count]."""
nargs = 0

View File

@ -25,7 +25,9 @@ default_config = """
[keybind]
o = open
go = opencur
O = tabopen
gO = tabopencur
d = tabclose
J = tabnext
K = tabprev

View File

@ -40,6 +40,7 @@ class TabbedBrowser(TabWidget):
cur_statusbar_message = pyqtSignal(str) # Status bar message
# Current tab changed scroll position
cur_scroll_perc_changed = pyqtSignal(int, int)
set_cmd_text = pyqtSignal(str) # Set commandline to a given text
keypress = pyqtSignal('QKeyEvent')
_url_stack = [] # Stack of URLs of closed tabs
@ -76,6 +77,11 @@ class TabbedBrowser(TabWidget):
# FIXME sometimes this doesn't load
tab.open_tab.connect(self.tabopen)
def tabopencur(self):
"""Set the statusbar to :tabopen and the current URL."""
url = self.currentWidget().url().toString()
self.set_cmd_text.emit(':tabopen ' + url)
def openurl(self, url, count=None):
"""Open an url in the current/[count]th tab.
@ -86,6 +92,11 @@ class TabbedBrowser(TabWidget):
if tab is not None:
tab.openurl(url)
def opencur(self):
"""Set the statusbar to :open and the current URL."""
url = self.currentWidget().url().toString()
self.set_cmd_text.emit(':open ' + url)
def undo_close(self):
"""Undo closing a tab.