Exemple #1
0
 def __init__(self, section, section_name):
     QtGui.QWidget.__init__(self)
     self.grid = QtGui.QGridLayout()
     self.grid.setAlignment(QtCore.Qt.AlignTop)
     self.section = section
     self.section_name = section_name
     self.fields = {}
     self.setLayout(self.grid)
     self.grid.setColumnStretch(2, 1)
     self.grid.setSpacing(10)
     self.int_validator = QtGui.QIntValidator(0, 2147483647, self)
     toolbar_icons = [
          ('ToolButtonFollowStyle', 'Default'),
          ('ToolButtonIconOnly', 'Icon Only'),
          ('ToolButtonTextOnly', 'Text Only'),
          ('ToolButtonTextBesideIcon', 'Text Alongside Icons'),
          ('ToolButtonTextUnderIcon', 'Text Under Icons')]
     tray_options = [
         ('always', 'Always'),
         ('unread', 'On Unread Messages'),
         ('never', 'Never'),
     ]
     list_positions = [
         ('left', 'Left'),
         ('right', 'Right'),
     ]
     sort_options = ['A-Z Ranked', 'A-Z', 'Z-A Ranked', 'Z-A']
     spellcheck_langs = [(x, x) for x in
                         InputLineSpell.list_languages()]
     spellcheck_langs.insert(0, ('', ''))
     focus_opts = ["requested", "always", "never"]
     self.comboboxes = {"style": QtGui.QStyleFactory.keys(),
                        "position": list_positions,
                        "toolbar_icons": toolbar_icons,
                        "focus_new_tabs": focus_opts,
                        "tray_icon": tray_options,
                        "sort": sort_options,
                        "spellcheck_dictionary": spellcheck_langs}
Exemple #2
0
 def keyPressEvent(self, event):
     key = event.key()
     modifiers = event.modifiers()
     scroll = self.scroll_widget.verticalScrollBar()
     text_cursor = self.textCursor()
     newline = (key == QtCore.Qt.Key_Enter or key == QtCore.Qt.Key_Return)
     if modifiers == (QtCore.Qt.ControlModifier | QtCore.Qt.ShiftModifier):
         if key == QtCore.Qt.Key_Tab or key == QtCore.Qt.Key_Backtab:
             self.bufferSwitchPrev.emit()
         elif key == QtCore.Qt.Key_X and not text_cursor.hasSelection():
             self.bufferSwitchActivePrevious.emit()
         else:
             InputLineSpell.keyPressEvent(self, event)
     elif modifiers == QtCore.Qt.ControlModifier:
         if key == QtCore.Qt.Key_PageUp or key == QtCore.Qt.Key_Backtab:
             self.bufferSwitchPrev.emit()
         elif key == QtCore.Qt.Key_PageDown or key == QtCore.Qt.Key_Tab:
             self.bufferSwitchNext.emit()
         elif key == QtCore.Qt.Key_X and not text_cursor.hasSelection():
             self.bufferSwitchActive.emit()
         elif key == QtCore.Qt.Key_C and not text_cursor.hasSelection():
             # We might wish to copy text from the buffer above us:
             self.specialKey.emit("copy")
         elif key == QtCore.Qt.Key_K:
             pass  # TODO: Color
         elif key == QtCore.Qt.Key_Underscore:
             pass  # TODO: Underline
         elif key == QtCore.Qt.Key_B:
             pass  # TODO: Bold
         elif key == QtCore.Qt.Key_I:
             pass  # TODO: Italics
         elif key == QtCore.Qt.Key_V or key == QtCore.Qt.Key_R:
             pass  # TODO: Reverse
         else:
             InputLineSpell.keyPressEvent(self, event)
     elif modifiers == QtCore.Qt.AltModifier:
         if key in (QtCore.Qt.Key_Left, QtCore.Qt.Key_Up):
             self.bufferSwitchPrev.emit()
         elif key in (QtCore.Qt.Key_Right, QtCore.Qt.Key_Down):
             self.bufferSwitchNext.emit()
         elif key == QtCore.Qt.Key_PageUp:
             scroll.setValue(scroll.value() - (scroll.pageStep() / 10))
         elif key == QtCore.Qt.Key_PageDown:
             scroll.setValue(scroll.value() + (scroll.pageStep() / 10))
         elif key == QtCore.Qt.Key_Home:
             scroll.setValue(scroll.minimum())
         elif key == QtCore.Qt.Key_End:
             scroll.setValue(scroll.maximum())
         else:
             InputLineSpell.keyPressEvent(self, event)
     elif key == QtCore.Qt.Key_PageUp:
         scroll.setValue(scroll.value() - scroll.pageStep())
     elif key == QtCore.Qt.Key_PageDown:
         scroll.setValue(scroll.value() + scroll.pageStep())
     elif key == QtCore.Qt.Key_Up or key == QtCore.Qt.Key_Down:
         # Compare position, optionally only nativate history if no change:
         pos1 = self.textCursor().position()
         InputLineSpell.keyPressEvent(self, event)
         pos2 = self.textCursor().position()
         if pos1 == pos2:
             if key == QtCore.Qt.Key_Up:
                 # Add to history if there is text like curses weechat:
                 txt = self.toPlainText().encode('utf-8')
                 if txt != "" and len(self._history) == self._history_index:
                     self._history.append(txt)
                 self._history_navigate(-1)
             elif key == QtCore.Qt.Key_Down:
                 self._history_navigate(1)
     elif newline and modifiers != QtCore.Qt.ShiftModifier:
         self._input_return_pressed()
     else:
         InputLineSpell.keyPressEvent(self, event)
Exemple #3
0
 def __init__(self, scroll_widget):
     InputLineSpell.__init__(self, False)
     self.scroll_widget = scroll_widget
     self._history = []
     self._history_index = -1