Example #1
0
    def _loadState(self):
        """
        Loads window's settings from configuration.
        """
        log.debug("Loading main window's settings")
        if self._views:
            index = config.getInt(self._NAME, "views", "last", 0)
            view = self._views[0]
            try:
                view = self._views[index]
            except IndexError:
                log.error("Failed to load view #%d" % index)
            view.activate()

        section = "geometry"
        self.window.setGeometry(
            config.getInt(self._NAME, section, "window_x", 50),
            config.getInt(self._NAME, section, "window_y", 50),
            config.getInt(self._NAME, section, "window_w", 800),
            config.getInt(self._NAME, section, "window_h", 600),
        )
        state = config.get(self._NAME, section, "window_state")
        if state:
            byteData = QtCore.QByteArray.fromBase64(state)
            self.window.restoreState(byteData)
Example #2
0
    def _loadState(self):
        '''
        Loads the dialog state from configuration.
        '''
        self._matchType = config.getInt(self._CONFIG_NAME,
                                        self._CONFIG_SECTION_OPTIONS,
                                        "match_type", self._PARTIAL_MATCH)
        self._caseSensitiveMatch = config.getBool(self._CONFIG_NAME,
                                                  self._CONFIG_SECTION_OPTIONS,
                                                  "case_sensitive", False)
        self._method = config.getInt(self._CONFIG_NAME,
                                     self._CONFIG_SECTION_OPTIONS,
                                     "method", self._DEEP_METHOD)

        if self._matchType == self._EXACT_MATCH:
            self.checkBoxExactMatch.setChecked(True)
        elif self._matchType == self._PARTIAL_MATCH:
            self.checkBoxExactMatch.setChecked(False)

        self.checkBoxCaseSensitive.setChecked(self._caseSensitiveMatch)
        
        if self._method == self._DEEP_METHOD:
            self.radioButtonDeep.setChecked(True)
        elif self._method == self._SIMPLE_METHOD:
            self.radioButtonSimple.setChecked(True)

        self._refreshCompleters()
        log.info("Search dialog state was loaded from configuration")
Example #3
0
    def _loadState(self):
        '''
        Loads the dialog state from configuration.
        '''
        self._matchType = config.getInt(self._CONFIG_NAME,
                                        self._CONFIG_SECTION_OPTIONS,
                                        "match_type", self._PARTIAL_MATCH)
        self._caseSensitiveMatch = config.getBool(self._CONFIG_NAME,
                                                  self._CONFIG_SECTION_OPTIONS,
                                                  "case_sensitive", False)
        self._method = config.getInt(self._CONFIG_NAME,
                                     self._CONFIG_SECTION_OPTIONS, "method",
                                     self._DEEP_METHOD)

        if self._matchType == self._EXACT_MATCH:
            self.checkBoxExactMatch.setChecked(True)
        elif self._matchType == self._PARTIAL_MATCH:
            self.checkBoxExactMatch.setChecked(False)

        self.checkBoxCaseSensitive.setChecked(self._caseSensitiveMatch)

        if self._method == self._DEEP_METHOD:
            self.radioButtonDeep.setChecked(True)
        elif self._method == self._SIMPLE_METHOD:
            self.radioButtonSimple.setChecked(True)

        self._refreshCompleters()
        log.info("Search dialog state was loaded from configuration")
Example #4
0
    def __init__(self, conf=None):
        '''
        Initializes daemon by starting and configuring a server.

        :param conf: A path to a daemon configuration file
        :type conf: string
        '''
        if conf is not None:
            if os.path.isfile(conf):
                config.update('daemon', conf)
            else:
                log.warning("Configuration file %s does not exist."
                            " Skipped" % conf)
        port = config.getInt('daemon', 'connection', 'port')
        ip = config.get('daemon', 'connection', 'address')
        if ip is None:
            log.warning("No attribute IP in daemon configuration file. "
                        "Using default value %s" % DEFAULT_IP)
            config.set('daemon', 'connection', 'address', DEFAULT_IP)
            ip = DEFAULT_IP
        if port is None:
            log.warning("No attribute port in daemon configuration file. "
                        "Using default value %d" % DEFAULT_PORT)
            config.set('daemon', 'connection', 'port', DEFAULT_PORT)
            port = DEFAULT_PORT
        server.Server.__init__(self, (ip, port))
        info = protocol.create(protocol.MSG_TYPE_RESPONSE,
                               protocol.MSG_TARGET_SYSTEM,
                               protocol.MSG_NAME_INFO,
                               version=config.VERSION,
                               locale=(locale.getdefaultlocale()[0] or ''),
                               extensions=protocol.getExtensions(),
                               status=True)
        self._infoData = info.marshal()
Example #5
0
    def getInt(self):
        '''
        Gets a value of the settings option converted to integer. If the option
        does not exist the 'None' is returned.

        :return: A value of the option
        :rtype: integer
        '''
        return config.getInt(self._name, self._section,
                             self._option, self._default)
Example #6
0
    def getInt(self):
        '''
        Gets a value of the settings option converted to integer. If the option
        does not exist the 'None' is returned.

        :return: A value of the option
        :rtype: integer
        '''
        return config.getInt(self._name, self._section, self._option,
                             self._default)
Example #7
0
    def _loadState(self):
        '''
        Loads window's settings from configuration.
        '''
        log.debug("Loading main window's settings")
        if self._views:
            index = config.getInt(self._NAME, "views", "last", 0)
            view = self._views[0]
            try:
                view = self._views[index]
            except IndexError:
                log.error("Failed to load view #%d" % index)
            view.activate()

        section = "geometry"
        self.window.setGeometry(
            config.getInt(self._NAME, section, "window_x", 50),
            config.getInt(self._NAME, section, "window_y", 50),
            config.getInt(self._NAME, section, "window_w", 800),
            config.getInt(self._NAME, section, "window_h", 600))
        state = config.get(self._NAME, section, "window_state")
        if state:
            byteData = QtCore.QByteArray.fromBase64(state)
            self.window.restoreState(byteData)
Example #8
0
    def __init__(self, view):
        QtCore.QObject.__init__(self, view)
        self._elements = view.loadUi(self._DIALOG_UI)
        self.dialog = self._elements['dialog']
        self._character = self._elements['comboBoxChar']
        self._keycode = self._elements['lineEditKeycode']
        self._addMod = self._elements['buttonAdd']
        self._removeMod = self._elements['buttonRemove']
        self._ok = self._elements['buttonBox'].button(
            QtGui.QDialogButtonBox.Ok)
        self._modifiers = self._elements['listWidget']
        self._addEditDialog = AddEditDialog(view)

        self._character.editTextChanged.connect(self._update)
        self._keycode.textEdited.connect(self._clearAndDisable)
        self._ok.clicked.connect(self._execute)
        self._addEditDialog.modifierAccepted.connect(self._addModifier)
        self._modifiers.setSortingEnabled(True)
        self._modifiers.itemActivated.connect(self._deselectItem)
        self._modifiers.itemSelectionChanged.connect(self._switchButtons)
        self._addMod.clicked.connect(self._showAddEditDialog)
        self._removeMod.clicked.connect(self._removeModifier)

        for name, code in constants.KEY_SYMS.iteritems():
            prettyName = ' '.join([s.capitalize() for s in name.split('_')])
            self._character.addItem(prettyName, userData=str(code))
        self._character.setCompleter(None)
        self._keycode.setValidator(QtGui.QIntValidator(self.dialog))
        for name in sorted(self._MODIFIERS):
            self._createItem(name, self._MODIFIERS[name])
        self._userModifiers = []
        for name in config.get(self._CONFIG_NAME, self._CONFIG_SECTION):
            code = config.getInt(self._CONFIG_NAME, self._CONFIG_SECTION, name)
            if code is not None and code not in self._userModifiers:
                self._createItem(name, code)
                self._userModifiers.append(name)
        self._deviceTab = None
Example #9
0
    def __init__(self, view):
        QtCore.QObject.__init__(self, view)
        self._elements = view.loadUi(self._DIALOG_UI)
        self.dialog = self._elements['dialog']
        self._character = self._elements['comboBoxChar']
        self._keycode = self._elements['lineEditKeycode']
        self._addMod = self._elements['buttonAdd']
        self._removeMod = self._elements['buttonRemove']
        self._ok = self._elements['buttonBox'].button(QtGui.QDialogButtonBox.Ok)
        self._modifiers = self._elements['listWidget']
        self._addEditDialog = AddEditDialog(view)

        self._character.editTextChanged.connect(self._update)
        self._keycode.textEdited.connect(self._clearAndDisable)
        self._ok.clicked.connect(self._execute)
        self._addEditDialog.modifierAccepted.connect(self._addModifier)
        self._modifiers.setSortingEnabled(True)
        self._modifiers.itemActivated.connect(self._deselectItem)
        self._modifiers.itemSelectionChanged.connect(self._switchButtons)
        self._addMod.clicked.connect(self._showAddEditDialog)
        self._removeMod.clicked.connect(self._removeModifier)

        for name, code in constants.KEY_SYMS.iteritems():
            prettyName = ' '.join([s.capitalize() for s in name.split('_')])
            self._character.addItem(prettyName, userData=str(code))
        self._character.setCompleter(None)
        self._keycode.setValidator(QtGui.QIntValidator(self.dialog))
        for name in sorted(self._MODIFIERS):
            self._createItem(name, self._MODIFIERS[name])
        self._userModifiers = []
        for name in config.get(self._CONFIG_NAME, self._CONFIG_SECTION):
            code = config.getInt(self._CONFIG_NAME, self._CONFIG_SECTION, name)
            if code is not None and code not in self._userModifiers:
                self._createItem(name, code)
                self._userModifiers.append(name)
        self._deviceTab = None