Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

commitmsg: rename "shiftTab()" signal to "leave()" for consistency

Signed-off-by: David Aguilar <davvid@gmail.com>
  • Loading branch information...
commit 223b8d3cbf0f53083047096714813396a4baff4d 1 parent 2e2b893
@davvid davvid authored
Showing with 13 additions and 6 deletions.
  1. +13 −6 cola/widgets/commitmsg.py
View
19 cola/widgets/commitmsg.py
@@ -139,7 +139,7 @@ def __init__(self, model, parent):
self.connect(self.description, SIGNAL('textChanged()'),
self.commit_message_changed)
- self.connect(self.description, SIGNAL('shiftTab()'),
+ self.connect(self.description, SIGNAL('leave()'),
self.focus_summary)
self.setFont(diff_font())
@@ -420,8 +420,8 @@ def __init__(self, parent=None):
self.extra_actions = []
self.setMinimumSize(QtCore.QSize(1, 1))
- self.action_emit_shift_tab = add_action(self,
- 'Shift Tab', self.emit_shift_tab, 'Shift+tab')
+ self.action_emit_leave = add_action(self,
+ 'Shift Tab', self.emit_leave, 'Shift+tab')
self.installEventFilter(self)
@@ -449,16 +449,23 @@ def keyPressEvent(self, event):
cursor = self.textCursor()
position = cursor.position()
if position == 0:
+ # The cursor is at the beginning of the line.
+ # If we have selection then simply reset the cursor.
+ # Otherwise, emit a signal so that the parent can
+ # change focus.
if cursor.hasSelection():
cursor.setPosition(0)
self.setTextCursor(cursor)
else:
- self.emit_shift_tab()
+ self.emit_leave()
event.accept()
return
text_before = unicode(self.toPlainText())[:position]
lines_before = text_before.count('\n')
if lines_before == 0:
+ # If we're on the first line, but not at the
+ # beginning, then move the cursor to the beginning
+ # of the line.
if event.modifiers() & Qt.ShiftModifier:
mode = QtGui.QTextCursor.KeepAnchor
else:
@@ -484,5 +491,5 @@ def keyPressEvent(self, event):
return
HintedTextEdit.keyPressEvent(self, event)
- def emit_shift_tab(self):
- self.emit(SIGNAL('shiftTab()'))
+ def emit_leave(self):
+ self.emit(SIGNAL('leave()'))
Please sign in to comment.
Something went wrong with that request. Please try again.