Ejemplo n.º 1
0
    def __init__(self, parent=None):
        hint = N_('Extended description...')
        SpellCheckTextEdit.__init__(self, hint, parent)
        self.extra_actions = []

        self.action_emit_leave = qtutils.add_action(self,
                'Shift Tab', self.emit_leave, 'Shift+tab')
Ejemplo n.º 2
0
    def __init__(self, parent=None):
        hint = N_('Extended description...')
        SpellCheckTextEdit.__init__(self, hint, parent)
        self.extra_actions = []

        self.action_emit_leave = qtutils.add_action(self,
                'Shift Tab', self.emit_leave, 'Shift+tab')
Ejemplo n.º 3
0
    def __init__(self, parent=None):
        hint = N_('Extended description...')
        SpellCheckTextEdit.__init__(self, hint, parent)
        self.extra_actions = []
        self.setMinimumSize(QtCore.QSize(1, 1))

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

        self.installEventFilter(self)
Ejemplo n.º 4
0
    def __init__(self, parent=None):
        hint = N_('Extended description...')
        SpellCheckTextEdit.__init__(self, hint, parent)
        self.extra_actions = []
        self.setMinimumSize(QtCore.QSize(1, 1))

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

        self.installEventFilter(self)
Ejemplo n.º 5
0
 def keyPressEvent(self, event):
     if event.key() == Qt.Key_Up:
         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_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:
                 mode = QtGui.QTextCursor.MoveAnchor
             cursor.setPosition(0, mode)
             self.setTextCursor(cursor)
             event.accept()
             return
     elif event.key() == Qt.Key_Down:
         cursor = self.textCursor()
         position = cursor.position()
         all_text = unicode(self.toPlainText())
         text_after = all_text[position:]
         lines_after = text_after.count('\n')
         if lines_after == 0:
             if event.modifiers() & Qt.ShiftModifier:
                 mode = QtGui.QTextCursor.KeepAnchor
             else:
                 mode = QtGui.QTextCursor.MoveAnchor
             cursor.setPosition(len(all_text), mode)
             self.setTextCursor(cursor)
             event.accept()
             return
     SpellCheckTextEdit.keyPressEvent(self, event)
Ejemplo n.º 6
0
 def keyPressEvent(self, event):
     if event.key() == Qt.Key_Up:
         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_leave()
             event.accept()
             return
         text_before = ustr(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:
                 mode = QtGui.QTextCursor.MoveAnchor
             cursor.setPosition(0, mode)
             self.setTextCursor(cursor)
             event.accept()
             return
     elif event.key() == Qt.Key_Down:
         cursor = self.textCursor()
         position = cursor.position()
         all_text = ustr(self.toPlainText())
         text_after = all_text[position:]
         lines_after = text_after.count('\n')
         if lines_after == 0:
             if event.modifiers() & Qt.ShiftModifier:
                 mode = QtGui.QTextCursor.KeepAnchor
             else:
                 mode = QtGui.QTextCursor.MoveAnchor
             cursor.setPosition(len(all_text), mode)
             self.setTextCursor(cursor)
             event.accept()
             return
     SpellCheckTextEdit.keyPressEvent(self, event)
Ejemplo n.º 7
0
 def setFont(self, font):
     SpellCheckTextEdit.setFont(self, font)
     fm = self.fontMetrics()
     self.setMinimumSize(QtCore.QSize(1, fm.height() * 2))
Ejemplo n.º 8
0
 def setFont(self, font):
     SpellCheckTextEdit.setFont(self, font)
     fm = self.fontMetrics()
     self.setMinimumSize(QtCore.QSize(1, fm.height() * 2))