Browse files

commitmsg: simplify the way we handle up/down arrow keys

Add QActions so that we can do without needing to trap the arrow keys in
a keyPressEvent().  This is much simpler.

Signed-off-by: David Aguilar <davvid@gmail.com>
  • Loading branch information...
1 parent 0957585 commit 2e2b8937e7a47bf36d186f80f9ffa3c9068bd71d @davvid davvid committed Mar 29, 2013
Showing with 3 additions and 20 deletions.
  1. +3 −20 cola/widgets/commitmsg.py
View
23 cola/widgets/commitmsg.py
@@ -119,15 +119,12 @@ def __init__(self, model, parent):
# Handle the one-off autowrapping
connect_action_bool(self.autowrap_action, self.set_linebreak)
+ add_action(self.summary, N_('Move Down'), self.focus_description,
+ Qt.Key_Down, Qt.Key_Return, Qt.Key_Enter)
+
self.model.add_observer(self.model.message_commit_message_changed,
self.set_commit_message)
- self.connect(self.summary, SIGNAL('returnPressed()'),
- self.focus_description)
-
- self.connect(self.summary, SIGNAL('downPressed()'),
- self.focus_description)
-
self.connect(self.summary, SIGNAL('cursorPosition(int,int)'),
self.emit_position)
@@ -407,20 +404,6 @@ def __init__(self, parent=None):
HintedLineEdit.__init__(self, hint, parent)
self.extra_actions = []
- def keyPressEvent(self, event):
- if event.key() == Qt.Key_Down:
- position = self.cursorPosition()
- curtext = unicode(self.text())
- if position == len(curtext):
- self.emit(SIGNAL('downPressed()'))
- event.accept()
- return
- if event.key() in (Qt.Key_Return, Qt.Key_Enter):
- self.emit(SIGNAL('returnPressed()'))
- event.accept()
- return
- HintedLineEdit.keyPressEvent(self, event)
-
def contextMenuEvent(self, event):
menu = self.createStandardContextMenu()
if self.extra_actions:

0 comments on commit 2e2b893

Please sign in to comment.