Exemplo n.º 1
0
    def __init__(self, parent=None):
        KStatusNotifierItem.__init__(self, parent)
        self.setTitle('synaptiks')
        self.setIconByName('synaptiks')
        self.setCategory(KStatusNotifierItem.Hardware)
        self.setStatus(KStatusNotifierItem.Passive)
        self.setup_actions()

        self._config = SynaptiksTrayConfiguration(self)

        try:
            self.touchpad = Touchpad.find_first(Display.from_qt())
        except Exception as error:
            # show an error message
            from synaptiks.kde.error import get_localized_error_message
            error_message = get_localized_error_message(error)
            options = KMessageBox.Options(KMessageBox.Notify |
                                          KMessageBox.AllowLink)
            KMessageBox.error(None, error_message, '', options)
            # disable all touchpad related actions
            for act in (self.touchpad_on_action, self.preferences_action):
                act.setEnabled(False)
            # disable synaptiks autostart, the user can still start synaptiks
            # manually again, if the reason of the error is fixed
            self._config.findItem('Autostart').setProperty(False)
            self._config.writeConfig()
        else:
            self.activateRequested.connect(self.show_configuration_dialog)
            # setup the touchpad manager
            self.setup_manager(self.touchpad)
Exemplo n.º 2
0
 def __init__(self, error, component_data, parent=None):
     SynaptiksKCMBase.__init__(self, component_data, parent)
     if isinstance(error, basestring):
         error_message = error
     else:
         from synaptiks.kde.error import get_localized_error_message
         error_message = get_localized_error_message(error)
     self.setLayout(QHBoxLayout(self))
     icon = QLabel('foobar', self)
     icon.setPixmap(KIconLoader.global_().loadIcon(
         'dialog-warning', KIconLoader.Desktop, KIconLoader.SizeLarge))
     icon.setAlignment(Qt.AlignTop | Qt.AlignLeft)
     # do not expand the icon horizontally, to avoid a wide empty space
     # between icon and text, and to given as much space as possible to the
     # text contents
     icon.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Expanding)
     self.layout().addWidget(icon)
     message = QLabel(error_message, self)
     message.setAlignment(Qt.AlignTop | Qt.AlignLeft)
     message.setWordWrap(True)
     message.setOpenExternalLinks(True)
     self.layout().addWidget(message)
     self.setButtons(self.Help)