Use object registry for status-cmd.

This commit is contained in:
Florian Bruhin 2014-09-23 21:46:38 +02:00
parent 9a3ceebf2e
commit 40812f81b6
3 changed files with 15 additions and 14 deletions

View File

@ -374,7 +374,7 @@ class Application(QApplication):
status = self.mainwindow.status
completion = self.mainwindow.completion
tabs = self.mainwindow.tabs
cmd = self.mainwindow.status.cmd
cmd = self.registry['status-cmd']
completer = self.registry['completer']
searchrunner = self.registry['searchrunner']
messagebridge = self.registry['messagebridge']
@ -387,7 +387,7 @@ class Application(QApplication):
# status bar
modeman.entered.connect(status.on_mode_entered)
modeman.left.connect(status.on_mode_left)
modeman.left.connect(status.cmd.on_mode_left)
modeman.left.connect(cmd.on_mode_left)
modeman.left.connect(status.prompt.prompter.on_mode_left)
# commands
@ -581,7 +581,7 @@ class Application(QApplication):
pages = []
try:
history = self.mainwindow.status.cmd.history[-5:]
history = self.registry['status-cmd'].history[-5:]
except Exception:
log.destroy.exception("Error while getting history: {}")
history = []
@ -669,7 +669,7 @@ class Application(QApplication):
def report(self):
"""Report a bug in qutebrowser."""
pages = self._recover_pages()
history = self.mainwindow.status.cmd.history[-5:]
history = self.registry['status-cmd'].history[-5:]
objects = self.get_all_objects()
self._crashdlg = crash.ReportDialog(pages, history, objects)
self._crashdlg.show()

View File

@ -41,12 +41,12 @@ class StatusBar(QWidget):
"""The statusbar at the bottom of the mainwindow.
Attributes:
cmd: The Command widget in the statusbar.
txt: The Text widget in the statusbar.
keystring: The KeyString widget in the statusbar.
percentage: The Percentage widget in the statusbar.
url: The UrlText widget in the statusbar.
prog: The Progress widget in the statusbar.
_cmd: The Command widget in the statusbar.
_hbox: The main QHBoxLayout.
_stack: The QStackedLayout with cmd/txt widgets.
_text_queue: A deque of (error, text) tuples to be displayed.
@ -132,8 +132,9 @@ class StatusBar(QWidget):
self._hbox.addLayout(self._stack)
self._stack.setContentsMargins(0, 0, 0, 0)
self.cmd = command.Command()
self._stack.addWidget(self.cmd)
self._cmd = command.Command()
utils.register_object('status-cmd', self._cmd)
self._stack.addWidget(self._cmd)
self.txt = textwidget.Text()
self._stack.addWidget(self.txt)
@ -147,8 +148,8 @@ class StatusBar(QWidget):
self._stack.addWidget(self.prompt)
self._previous_widget = PreviousWidget.none
self.cmd.show_cmd.connect(self._show_cmd_widget)
self.cmd.hide_cmd.connect(self._hide_cmd_widget)
self._cmd.show_cmd.connect(self._show_cmd_widget)
self._cmd.hide_cmd.connect(self._hide_cmd_widget)
self._hide_cmd_widget()
self.prompt.show_prompt.connect(self._show_prompt_widget)
self.prompt.hide_prompt.connect(self._hide_prompt_widget)
@ -260,7 +261,7 @@ class StatusBar(QWidget):
if self._text_pop_timer.isActive():
self._timer_was_active = True
self._text_pop_timer.stop()
self._stack.setCurrentWidget(self.cmd)
self._stack.setCurrentWidget(self._cmd)
def _hide_cmd_widget(self):
"""Show temporary text instead of command widget."""

View File

@ -160,7 +160,7 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit):
self.setFocus()
self.show_cmd.emit()
@cmdutils.register(instance='mainwindow.status.cmd', name='set-cmd-text')
@cmdutils.register(instance='status-cmd', name='set-cmd-text')
def set_cmd_text_command(self, text):
"""Preset the statusbar to some text.
@ -216,7 +216,7 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit):
self.setFocus()
self.show_cmd.emit()
@cmdutils.register(instance='mainwindow.status.cmd', hide=True,
@cmdutils.register(instance='status-cmd', hide=True,
modes=[usertypes.KeyMode.command])
def command_history_prev(self):
"""Go back in the commandline history."""
@ -231,7 +231,7 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit):
if item:
self.set_cmd_text(item)
@cmdutils.register(instance='mainwindow.status.cmd', hide=True,
@cmdutils.register(instance='status-cmd', hide=True,
modes=[usertypes.KeyMode.command])
def command_history_next(self):
"""Go forward in the commandline history."""
@ -244,7 +244,7 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit):
if item:
self.set_cmd_text(item)
@cmdutils.register(instance='mainwindow.status.cmd', hide=True,
@cmdutils.register(instance='status-cmd', hide=True,
modes=[usertypes.KeyMode.command])
def command_accept(self):
"""Execute the command currently in the commandline.