Skip to content

Commit

Permalink
commitmsg: rename "shiftTab()" signal to "leave()" for consistency
Browse files Browse the repository at this point in the history
Signed-off-by: David Aguilar <davvid@gmail.com>
  • Loading branch information
davvid committed Mar 30, 2013
1 parent 2e2b893 commit 223b8d3
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions cola/widgets/commitmsg.py
Expand Up @@ -139,7 +139,7 @@ def __init__(self, model, parent):
self.connect(self.description, SIGNAL('textChanged()'), self.connect(self.description, SIGNAL('textChanged()'),
self.commit_message_changed) self.commit_message_changed)


self.connect(self.description, SIGNAL('shiftTab()'), self.connect(self.description, SIGNAL('leave()'),
self.focus_summary) self.focus_summary)


self.setFont(diff_font()) self.setFont(diff_font())
Expand Down Expand Up @@ -420,8 +420,8 @@ def __init__(self, parent=None):
self.extra_actions = [] self.extra_actions = []
self.setMinimumSize(QtCore.QSize(1, 1)) self.setMinimumSize(QtCore.QSize(1, 1))


self.action_emit_shift_tab = add_action(self, self.action_emit_leave = add_action(self,
'Shift Tab', self.emit_shift_tab, 'Shift+tab') 'Shift Tab', self.emit_leave, 'Shift+tab')


self.installEventFilter(self) self.installEventFilter(self)


Expand Down Expand Up @@ -449,16 +449,23 @@ def keyPressEvent(self, event):
cursor = self.textCursor() cursor = self.textCursor()
position = cursor.position() position = cursor.position()
if position == 0: 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(): if cursor.hasSelection():
cursor.setPosition(0) cursor.setPosition(0)
self.setTextCursor(cursor) self.setTextCursor(cursor)
else: else:
self.emit_shift_tab() self.emit_leave()
event.accept() event.accept()
return return
text_before = unicode(self.toPlainText())[:position] text_before = unicode(self.toPlainText())[:position]
lines_before = text_before.count('\n') lines_before = text_before.count('\n')
if lines_before == 0: 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: if event.modifiers() & Qt.ShiftModifier:
mode = QtGui.QTextCursor.KeepAnchor mode = QtGui.QTextCursor.KeepAnchor
else: else:
Expand All @@ -484,5 +491,5 @@ def keyPressEvent(self, event):
return return
HintedTextEdit.keyPressEvent(self, event) HintedTextEdit.keyPressEvent(self, event)


def emit_shift_tab(self): def emit_leave(self):
self.emit(SIGNAL('shiftTab()')) self.emit(SIGNAL('leave()'))

0 comments on commit 223b8d3

Please sign in to comment.