Example #1
0
 def paintEvent(self, event):
     HintedTextView.paintEvent(self, event)
     if self.hasFocus():
         # Qt doesn't redraw the cursor when using movePosition().
         # So.. draw our own cursor.
         rect = self.cursorRect()
         painter = QtGui.QPainter(self.viewport())
         painter.fillRect(rect, Qt.SolidPattern)
Example #2
0
 def paintEvent(self, event):
     HintedTextView.paintEvent(self, event)
     if self.hasFocus():
         # Qt doesn't redraw the cursor when using movePosition().
         # So.. draw our own cursor.
         rect = self.cursorRect()
         painter = QtGui.QPainter(self.viewport())
         painter.fillRect(rect, Qt.SolidPattern)
Example #3
0
    def __init__(self, hint, parent):
        HintedTextView.__init__(self, hint, parent)
        self.goto_action = qtutils.add_action(
                self, 'Launch Editor',
                lambda: guicmds.goto_grep(self.selected_line()))
        self.goto_action.setShortcut(defs.editor_shortcut)

        qtutils.add_action(self, 'Up',
                lambda: self.move(QtGui.QTextCursor.Up),
                Qt.Key_K)

        qtutils.add_action(self, 'Down',
                lambda: self.move(QtGui.QTextCursor.Down),
                Qt.Key_J)

        qtutils.add_action(self, 'Left',
                lambda: self.move(QtGui.QTextCursor.Left),
                Qt.Key_H)

        qtutils.add_action(self, 'Right',
                lambda: self.move(QtGui.QTextCursor.Right),
                Qt.Key_L)

        qtutils.add_action(self, 'StartOfLine',
                lambda: self.move(QtGui.QTextCursor.StartOfLine),
                Qt.Key_0)

        qtutils.add_action(self, 'EndOfLine',
                lambda: self.move(QtGui.QTextCursor.EndOfLine),
                Qt.Key_Dollar)

        qtutils.add_action(self, 'WordLeft',
                lambda: self.move(QtGui.QTextCursor.WordLeft),
                Qt.Key_B)

        qtutils.add_action(self, 'WordRight',
                lambda: self.move(QtGui.QTextCursor.WordRight),
                Qt.Key_W)

        qtutils.add_action(self, 'PageUp',
                lambda: self.page(-self.height()/2),
                'Shift+Space')

        qtutils.add_action(self, 'PageDown',
                lambda: self.page(self.height()/2),
                Qt.Key_Space)
Example #4
0
    def __init__(self, hint, parent):
        HintedTextView.__init__(self, hint, parent)
        self.goto_action = qtutils.add_action(self, 'Launch Editor', self.edit)
        self.goto_action.setShortcut(cmds.Edit.SHORTCUT)

        qtutils.add_action(self, 'Up',
                lambda: self.move(QtGui.QTextCursor.Up),
                Qt.Key_K)

        qtutils.add_action(self, 'Down',
                lambda: self.move(QtGui.QTextCursor.Down),
                Qt.Key_J)

        qtutils.add_action(self, 'Left',
                lambda: self.move(QtGui.QTextCursor.Left),
                Qt.Key_H)

        qtutils.add_action(self, 'Right',
                lambda: self.move(QtGui.QTextCursor.Right),
                Qt.Key_L)

        qtutils.add_action(self, 'StartOfLine',
                lambda: self.move(QtGui.QTextCursor.StartOfLine),
                Qt.Key_0)

        qtutils.add_action(self, 'EndOfLine',
                lambda: self.move(QtGui.QTextCursor.EndOfLine),
                Qt.Key_Dollar)

        qtutils.add_action(self, 'WordLeft',
                lambda: self.move(QtGui.QTextCursor.WordLeft),
                Qt.Key_B)

        qtutils.add_action(self, 'WordRight',
                lambda: self.move(QtGui.QTextCursor.WordRight),
                Qt.Key_W)

        qtutils.add_action(self, 'PageUp',
                lambda: self.page(-self.height()//2),
                'Shift+Space')

        qtutils.add_action(self, 'PageDown',
                lambda: self.page(self.height()//2),
                Qt.Key_Space)
Example #5
0
 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)
Example #6
0
 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)
Example #7
0
 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()'))
         elif self.value()[:position].count('\n') == 0:
             cursor.movePosition(QtGui.QTextCursor.StartOfLine)
             self.setTextCursor(cursor)
     return HintedTextView.keyPressEvent(self, event)
Example #8
0
 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()'))
         elif self.value()[:position].count('\n') == 0:
             cursor.movePosition(QtGui.QTextCursor.StartOfLine)
             self.setTextCursor(cursor)
     return HintedTextView.keyPressEvent(self, event)
Example #9
0
    def __init__(self, hint, parent):
        HintedTextView.__init__(self, hint, parent)
        self.goto_action = qtutils.add_action(self, "Launch Editor", self.edit)
        self.goto_action.setShortcut(cmds.Edit.SHORTCUT)

        qtutils.add_action(self, "Up", lambda: self.move(QtGui.QTextCursor.Up), Qt.Key_K)

        qtutils.add_action(self, "Down", lambda: self.move(QtGui.QTextCursor.Down), Qt.Key_J)

        qtutils.add_action(self, "Left", lambda: self.move(QtGui.QTextCursor.Left), Qt.Key_H)

        qtutils.add_action(self, "Right", lambda: self.move(QtGui.QTextCursor.Right), Qt.Key_L)

        qtutils.add_action(self, "StartOfLine", lambda: self.move(QtGui.QTextCursor.StartOfLine), Qt.Key_0)

        qtutils.add_action(self, "EndOfLine", lambda: self.move(QtGui.QTextCursor.EndOfLine), Qt.Key_Dollar)

        qtutils.add_action(self, "WordLeft", lambda: self.move(QtGui.QTextCursor.WordLeft), Qt.Key_B)

        qtutils.add_action(self, "WordRight", lambda: self.move(QtGui.QTextCursor.WordRight), Qt.Key_W)

        qtutils.add_action(self, "PageUp", lambda: self.page(-self.height() / 2), "Shift+Space")

        qtutils.add_action(self, "PageDown", lambda: self.page(self.height() / 2), Qt.Key_Space)