Handle up/down/tab keypresses in StatusCommand
This commit is contained in:
parent
7e3144964e
commit
ca86eea4ae
@ -146,7 +146,6 @@ class StatusCommand(QLineEdit):
|
|||||||
got_cmd = pyqtSignal(str) # Emitted when a command is triggered by the user
|
got_cmd = pyqtSignal(str) # Emitted when a command is triggered by the user
|
||||||
bar = None # The status bar object
|
bar = None # The status bar object
|
||||||
esc_pressed = pyqtSignal() # Emitted when escape is pressed
|
esc_pressed = pyqtSignal() # Emitted when escape is pressed
|
||||||
esc = None # The esc QShortcut object
|
|
||||||
|
|
||||||
def __init__(self, bar):
|
def __init__(self, bar):
|
||||||
super().__init__(bar)
|
super().__init__(bar)
|
||||||
@ -155,10 +154,14 @@ class StatusCommand(QLineEdit):
|
|||||||
self.setValidator(self.CmdValidator())
|
self.setValidator(self.CmdValidator())
|
||||||
self.returnPressed.connect(self.process_cmd)
|
self.returnPressed.connect(self.process_cmd)
|
||||||
|
|
||||||
self.esc = QShortcut(self)
|
for (key, handler) in [(Qt.Key_Escape, self.esc_pressed),
|
||||||
self.esc.setKey(QKeySequence(Qt.Key_Escape))
|
(Qt.Key_Up, self.key_up_handler),
|
||||||
self.esc.setContext(Qt.WidgetWithChildrenShortcut)
|
(Qt.Key_Down, self.key_down_handler),
|
||||||
self.esc.activated.connect(self.esc_pressed)
|
(Qt.Key_Tab, self.key_tab_handler)]:
|
||||||
|
sc = QShortcut(self)
|
||||||
|
sc.setKey(QKeySequence(key))
|
||||||
|
sc.setContext(Qt.WidgetWithChildrenShortcut)
|
||||||
|
sc.activated.connect(handler)
|
||||||
|
|
||||||
def process_cmd(self):
|
def process_cmd(self):
|
||||||
"""Handle the command in the status bar"""
|
"""Handle the command in the status bar"""
|
||||||
@ -183,3 +186,11 @@ class StatusCommand(QLineEdit):
|
|||||||
self.bar.clear_error()
|
self.bar.clear_error()
|
||||||
super().focusInEvent(e)
|
super().focusInEvent(e)
|
||||||
|
|
||||||
|
def key_up_handler(self):
|
||||||
|
logging.debug('up pressed')
|
||||||
|
|
||||||
|
def key_down_handler(self):
|
||||||
|
logging.debug('down pressed')
|
||||||
|
|
||||||
|
def key_tab_handler(self):
|
||||||
|
logging.debug('tab pressed')
|
||||||
|
Loading…
Reference in New Issue
Block a user