Add empty command

This commit is contained in:
Florian Bruhin 2014-01-17 06:56:18 +01:00
parent 5eab225fa1
commit 837f53edea
2 changed files with 8 additions and 2 deletions

View File

@ -26,13 +26,13 @@ class CommandParser(QObject):
class Command(QObject):
nargs = 0
name = ''
name = None
key = None
signal = None
@classmethod
def bind(cls):
if cls.name:
if cls.name is not None:
cmd_dict[cls.name] = cls()
def check(self, argv):
@ -46,6 +46,11 @@ class Command(QObject):
raise NotImplementedError
self.signal.emit()
class EmptyCmd(Command):
nargs = 0
name = ''
key = ':'
class OpenCmd(Command):
nargs = 1
name = 'open'

View File

@ -9,6 +9,7 @@ class KeyParser(QObject):
def from_cmd_dict(self, d, parent):
for cmd in d.values():
if cmd.key is not None:
print('reg: {} -> {}'.format(cmd.name, cmd.key))
sc = QShortcut(parent)
sc.setKey(QKeySequence(cmd.key))
sc.setContext(Qt.WidgetWithChildrenShortcut)