Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: git-cola/git-cola
base: 2e2b8937e7
...
head fork: git-cola/git-cola
compare: 00364657d9
Checking mergeability… Don't worry, you can still create the pull request.
  • 3 commits
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Commits on Mar 30, 2013
@davvid davvid commitmsg: rename "shiftTab()" signal to "leave()" for consistency
Signed-off-by: David Aguilar <davvid@gmail.com>
223b8d3
@davvid davvid grep: replace the GrepLineEdit class with a QAction
Simpler, again ;-)

Signed-off-by: David Aguilar <davvid@gmail.com>
1e52aa0
@davvid davvid grep: allow moving between query and result using the arrow keys
The query input field already knew to focus the results when pressing
either enter, return, or the down-arrow key.  Teach the results field to
focus the input field when the up-arrow is pressed.

This makes the behavior consistent with the commit message editor.

Signed-off-by: David Aguilar <davvid@gmail.com>
0036465
Showing with 31 additions and 20 deletions.
  1. +13 −6 cola/widgets/commitmsg.py
  2. +18 −14 cola/widgets/grep.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()'))
View
32 cola/widgets/grep.py
@@ -49,7 +49,7 @@ def __init__(self, parent):
self.input_label.setFont(diff_font())
hint = N_('command-line arguments')
- self.input_txt = GrepLineEdit(hint, self)
+ self.input_txt = HintedLineEdit(hint, self)
self.input_txt.enable_hint(True)
hint = N_('grep result...')
@@ -107,9 +107,12 @@ def __init__(self, parent):
self.connect(self.input_txt, SIGNAL('textChanged(QString)'),
self.input_txt_changed)
- self.connect(self.input_txt, SIGNAL('returnPressed()'),
- lambda: self.result_txt.setFocus())
+ self.connect(self.result_txt, SIGNAL('leave()'),
+ lambda: self.input_txt.setFocus())
+ qtutils.add_action(self.input_txt, 'FocusResults',
+ lambda: self.result_txt.setFocus(),
+ Qt.Key_Down, Qt.Key_Enter, Qt.Key_Return)
qtutils.connect_button(self.edit_button, self.edit)
qtutils.connect_button(self.refresh_button, self.search)
qtutils.connect_button(self.close_button, self.close)
@@ -148,17 +151,6 @@ def edit(self):
goto_grep(self.result_txt.selected_line()),
-class GrepLineEdit(HintedLineEdit):
- def __init__(self, hint, parent):
- HintedLineEdit.__init__(self, hint, parent)
-
- def keyPressEvent(self, event):
- if event.key() in (Qt.Key_Return, Qt.Key_Enter):
- self.emit(SIGNAL('returnPressed()'))
- else:
- HintedLineEdit.keyPressEvent(self, event)
-
-
class GrepTextView(HintedTextView):
def __init__(self, hint, parent):
HintedTextView.__init__(self, hint, parent)
@@ -241,6 +233,18 @@ def paintEvent(self, event):
painter = QtGui.QPainter(self.viewport())
painter.fillRect(rect, Qt.SolidPattern)
+ def keyPressEvent(self, event):
+ if event.key() == Qt.Key_Up:
+ cursor = self.textCursor()
+ position = cursor.position()
+ if position == 0 and not cursor.hasSelection():
+ # 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.
+ self.emit(SIGNAL('leave()'))
+ return HintedTextView.keyPressEvent(self, event)
+
def goto_grep(line):
"""Called when Search -> Grep's right-click 'goto' action."""

No commit comments for this range

Something went wrong with that request. Please try again.