# -*- coding: utf-8 -*- import re from PyQt4 import QtCore, QtGui try: fromUtf8 = QtCore.QString.fromUtf8 except AttributeError: fromUtf8 = lambda s: s class SComboBox(QtGui.QComboBox): """ Special combobox derivative that emits a signal when a key is pressed. """ keyPressed = QtCore.pyqtSignal(int) def keyPressEvent(self, event): """ Override the inherited keyPressEvent to emit a signal. """ self.keyPressed.emit(event.key()) return QtGui.QComboBox.keyPressEvent(self, event) class Highlight(object): def __init__(self, pattern, foreground, background=None): self.pattern = pattern self.regex = re.compile(pattern) self.foreground = foreground self.background = background def setPattern(self, pattern): self.pattern = pattern try: self.regex = re.compile(pattern) except re.error: self.regex = None def translate(context, string, description=None): return QtGui.QApplication.translate(context, string, description, QtGui.QApplication.UnicodeUTF8) def create_default_highlights(): return [ Highlight(r'PASSED', u'#ffffff', '#009900'), Highlight(r'FAILED', u'#ffffff', '#990000'), Highlight(r'^\\|/', u'#666666') ] from settingsdialog import SettingsDialog from connectdialog import ConnectDialog __all__ = ['SettingsDialog', 'ConnectDialog', 'SComboBox', 'Highlight', 'translate', 'fromUtf8']