Display keystring in statusbar
This commit is contained in:
parent
289f08f7a7
commit
6acac5cb71
@ -21,6 +21,8 @@ class QuteBrowser(QApplication):
|
||||
self.mainwindow.status.cmd.got_cmd.connect(self.commandparser.parse)
|
||||
self.mainwindow.status.cmd.got_cmd.connect(self.mainwindow.tabs.setFocus)
|
||||
self.commandparser.error.connect(self.mainwindow.status.disp_error)
|
||||
self.keyparser.keystring_updated.connect(
|
||||
self.mainwindow.status.txt.set_keystring)
|
||||
|
||||
self.init_cmds()
|
||||
self.mainwindow.show()
|
||||
|
@ -7,6 +7,7 @@ import re
|
||||
class KeyParser(QObject):
|
||||
keystring = ''
|
||||
set_cmd_text = pyqtSignal(str)
|
||||
keystring_updated = pyqtSignal(str)
|
||||
key_to_cmd = {}
|
||||
|
||||
def from_cmd_dict(self, d):
|
||||
@ -16,6 +17,10 @@ class KeyParser(QObject):
|
||||
self.key_to_cmd[cmd.key] = cmd
|
||||
|
||||
def handle(self, e):
|
||||
self._handle(e)
|
||||
self.keystring_updated.emit(self.keystring)
|
||||
|
||||
def _handle(self, e):
|
||||
logging.debug('Got key: {} / text: "{}"'.format(e.key(), e.text()))
|
||||
txt = e.text().strip()
|
||||
if not txt:
|
||||
|
@ -1,6 +1,7 @@
|
||||
from PyQt5.QtWidgets import QLineEdit, QHBoxLayout, QLabel, QWidget, QShortcut, QProgressBar, QSizePolicy
|
||||
from PyQt5.QtCore import pyqtSignal, Qt, QSize
|
||||
from PyQt5.QtGui import QValidator, QKeySequence
|
||||
import logging
|
||||
|
||||
class StatusBar(QWidget):
|
||||
has_error = False
|
||||
@ -101,9 +102,12 @@ class StatusText(QLabel):
|
||||
super().__setattr__(name, value)
|
||||
self.update()
|
||||
|
||||
def set_keystring(self, s):
|
||||
self.keystring = s
|
||||
|
||||
def update(self):
|
||||
self.setText(''.join([self.keystring, self.error, self.text,
|
||||
self.scrollperc]))
|
||||
super().setText(' '.join([self.keystring, self.error, self.text,
|
||||
self.scrollperc]))
|
||||
|
||||
class StatusCommand(QLineEdit):
|
||||
got_cmd = pyqtSignal(str)
|
||||
|
Loading…
Reference in New Issue
Block a user