コード例 #1
0
class Config:
    def __init__(self, config):
        self.config = KConfig(config)
        self.group = None

    def setValue(self, group, option, value):
        self.group = self.config.group(group)
        self.group.writeEntry(option, QVariant(value))
        self.config.sync()

    def getBoolValue(self, group, option):
        default = self._initValue(group, option, False)
        return self.group.readEntry(option, QVariant(default)).toBool()

    def getNumValue(self, group, option):
        default = self._initValue(group, option, 0)
        return self.group.readEntry(option, QVariant(default)).toInt()[0]

    def _initValue(self, group, option, value):
        self.group = self.config.group(group)

        if defaults.has_key(option):
            return defaults[option]
        else:
            return value
コード例 #2
0
ファイル: account.py プロジェクト: dhirajkhatiwada1/uludag
 def setKopeteAccounts(self):
     "Add imported accounts into Kopete"
     config = KConfig("kopeterc")
     for account in self.accounts:
         if account["type"] == "Jabber":
             groupname = "Account_JabberProtocol_" + account["user"]
             if not config.hasGroup(groupname):
                 pluginsGroup = config.group("Plugins")
                 pluginsGroup.writeEntry("kopete_jabberEnabled", "true")
                 accountGroup = config.group(groupname)
                 accountGroup.writeEntry("AccountId", account["user"])
                 accountGroup.writeEntry("Protocol", "JabberProtocol")
                 accountGroup.writeEntry("CustomServer", "true")
                 accountGroup.writeEntry("Server", account["host"])
                 accountGroup.writeEntry("Port", account["port"])
                 if account["SSL"]:
                     accountGroup.writeEntry("UseSSL", "true")
         elif account["type"] == "MSN":
             groupname = "Account_MSNProtocol_" + account["mail"]
             if not config.hasGroup(groupname):
                 pluginsGroup = config.group("Plugins")
                 pluginsGroup.writeEntry("kopete_msnEnabled", "true")
                 accountGroup = config.group(groupname)
                 accountGroup.writeEntry("AccountId", account["mail"])
                 accountGroup.writeEntry("Protocol", "MSNProtocol")
                 accountGroup.writeEntry("serverName", "messenger.hotmail.com")
                 accountGroup.writeEntry("serverPort", 1863)
     config.sync()
コード例 #3
0
ファイル: config.py プロジェクト: pars-linux/uludag
class Config:
    def __init__(self, config):
        self.config = KConfig(config)
        self.group = None

    def setValue(self, group, option, value):
        self.group = self.config.group(group)
        self.group.writeEntry(option, str(value))
        self.config.sync()

    def getBoolValue(self, group, option):
        default = self._initValue(group, option, False)
        return self.group.readEntry(option, str(default)) == "True"

    def getNumValue(self, group, option):
        default = self._initValue(group, option, 0)
        return int(self.group.readEntry(option, str(default)))

    def _initValue(self, group, option, value):
        self.group = self.config.group(group)

        if defaults.has_key(option):
            return defaults[option]
        else:
            return value
コード例 #4
0
ファイル: account.py プロジェクト: pars-linux/uludag
 def setKopeteAccounts(self):
     "Add imported accounts into Kopete"
     config = KConfig("kopeterc")
     for account in self.accounts:
         if account["type"] == "Jabber":
             groupname = "Account_JabberProtocol_" + account["user"]
             if not config.hasGroup(groupname):
                 pluginsGroup = config.group("Plugins")
                 pluginsGroup.writeEntry("kopete_jabberEnabled", "true")
                 accountGroup = config.group(groupname)
                 accountGroup.writeEntry("AccountId", account["user"])
                 accountGroup.writeEntry("Protocol", "JabberProtocol")
                 accountGroup.writeEntry("CustomServer", "true")
                 accountGroup.writeEntry("Server", account["host"])
                 accountGroup.writeEntry("Port", account["port"])
                 if account["SSL"]:
                     accountGroup.writeEntry("UseSSL", "true")
         elif account["type"] == "MSN":
             groupname = "Account_MSNProtocol_" + account["mail"]
             if not config.hasGroup(groupname):
                 pluginsGroup = config.group("Plugins")
                 pluginsGroup.writeEntry("kopete_msnEnabled", "true")
                 accountGroup = config.group(groupname)
                 accountGroup.writeEntry("AccountId", account["mail"])
                 accountGroup.writeEntry("Protocol", "MSNProtocol")
                 accountGroup.writeEntry("serverName",
                                         "messenger.hotmail.com")
                 accountGroup.writeEntry("serverPort", 1863)
     config.sync()
コード例 #5
0
ファイル: config.py プロジェクト: jeremie1112/pisilinux
class Config:
    def __init__(self, config):
        self.config = KConfig(config)
        self.group = None

    def setValue(self, option, value):
        self.group = self.config.group(GROUP)
        self.group.writeEntry(option, QVariant(value))
        self.config.sync()

    def getValue(self, option):
        default = self._initValue(option, "")
        return self.group.readEntry(option, QVariant(default)).toString()

    def getBoolValue(self, option):
        default = self._initValue(option, False)
        return self.group.readEntry(option, QVariant(default)).toBool()

    def getNumValue(self, option):
        default = self._initValue(option, 0)
        return self.group.readEntry(option, QVariant(default)).toInt()[0]

    def _initValue(self, option, value):
        self.group = self.config.group(GROUP)
        if defaults.has_key(option):
            return defaults[option]
        return value
コード例 #6
0
class Config:
    def __init__(self, config):
        self.config = KConfig(config)
        self.group = None

    def setValue(self, option, value):
        self.group = self.config.group("General")
        self.group.writeEntry(option, QVariant(value))
        self.config.sync()
コード例 #7
0
class Package(base.Package):
    def package_config(self, config):
        self.config = KConfig(config)
        self.group = None

    def package_setValue(self, option, value):
        self.group = self.config.group("General")
        self.group.writeEntry(option, QVariant(value))
        self.config.sync()
コード例 #8
0
ファイル: scrPackage.py プロジェクト: rshipp/kapudan
class Config:
    def __init__(self, config):
        self.config = KConfig(config)
        self.group = None

    def setValue(self, option, value):
        self.group = self.config.group("General")
        self.group.writeEntry(option, value)
        self.config.sync()
コード例 #9
0
ファイル: kde.py プロジェクト: ademirel/COMAK
class Package(base.Package):

    def package_config(self,config):
        self.config = KConfig(config)
        self.group = None

    def package_setValue(self,option,value):
        self.group = self.config.group("General")
        self.group.writeEntry(option, QVariant(value))
        self.config.sync()
コード例 #10
0
ファイル: icons.py プロジェクト: pashazz/change-theme
def applyTheme(theme):
    '''
    @summary: check if theme is valid and apply it into kdeglobals
    '''
    assert theme in KIconTheme.list()
    config = KConfig('kdeglobals')
    gr = config.group('Icons')
    gr.writeEntry('Theme', theme)
    config.sync()
    KGlobalSettings.emitChange(KGlobalSettings.IconChanged)
コード例 #11
0
ファイル: ScrMouse.py プロジェクト: pars-linux/uludag
    def setHandedness(self, item):
        mapMouse = {}

        if self.ui.radioButtonRightHand.isChecked():
            handed = RIGHT_HANDED

        else:
            handed = LEFT_HANDED

        mapMouse = display.Display().get_pointer_mapping()
        num_buttons = len(mapMouse)

        if num_buttons == 1:
            mapMouse[0] = 1
        elif num_buttons == 2:
            if handed == RIGHT_HANDED:
                mapMouse[0], mapMouse[1] = 1, 3
            else:
                mapMouse[0], mapMouse[1] = 3, 1
        else:
            if handed == RIGHT_HANDED:
                mapMouse[0], mapMouse[2] = 1, 3
            else:
                mapMouse[0], mapMouse[2] = 3, 1

            if num_buttons >= 5:
                pos = 0
                for pos in range(num_buttons):
                    if mapMouse[pos] == 4 or mapMouse[pos] == 5:
                        break

                if pos < num_buttons - 1:
                    if self.ui.checkReverse.isChecked():
                        mapMouse[pos], mapMouse[pos + 1] = 5, 4
                    else:
                        mapMouse[pos], mapMouse[pos + 1] = 4, 5

        display.Display().set_pointer_mapping(mapMouse)

        config = KConfig("kcminputrc")
        group = config.group("Mouse")

        if handed == RIGHT_HANDED:
            group.writeEntry("MouseButtonMapping", QString("RightHanded"))
            self.__class__.screenSettings["selectedMouse"] = "RightHanded"
        else:
            group.writeEntry("MouseButtonMapping", QString("LeftHanded"))
            self.__class__.screenSettings["selectedMouse"] = "LeftHanded"

        group.writeEntry("ReverseScrollPolarity",
                         QString(str(self.ui.checkReverse.isChecked())))
        config.sync()

        KGlobalSettings.self().emitChange(KGlobalSettings.SettingsChanged,
                                          KGlobalSettings.SETTINGS_MOUSE)
コード例 #12
0
ファイル: emoticons.py プロジェクト: pashazz/change-theme
def applyIconTheme(themeName):
    '''
    @summary: apply emoticon theme themeName
    @raise AssertionError: if not themeName is vaild 
    '''
    assert themeName in listIconThemes()
    config = KConfig('kdeglobals')
    gr = config.group('Emoticons')
    gr.writeEntry('emoticonsTheme', themeName)
    config.sync()
    KGlobalSettings.emitChange(KGlobalSettings.IconChanged)
コード例 #13
0
ファイル: styles.py プロジェクト: pashazz/change-theme
def applyStyle(styleName):
    '''
    Apply style to KDE globals
    @param styleName:  Qt style name
    '''
    config = KConfig('kdeglobals')
    #assert
    gr = config.group('General')
    gr.writeEntry('widgetStyle', styleName.lower())
    config.sync()
    KGlobalSettings.emitChange(KGlobalSettings.StyleChanged)
コード例 #14
0
    def applySettings(self):
        # write selected configurations to future package-managerrc
        config = KConfig("package-managerrc")
        group = config.group("General")
        group.writeEntry("SystemTray", str(self.ui.showTray.isChecked()))
        group.writeEntry("UpdateCheck", str(self.ui.checkUpdate.isChecked()))
        group.writeEntry("UpdateCheckInterval", str(self.ui.updateInterval.value() * 60))
        config.sync()

        if self.ui.showTray.isChecked():
            p = subprocess.Popen(["package-manager"], stdout=subprocess.PIPE)
コード例 #15
0
    def applySettings(self):
        # write selected configurations to future package-managerrc
        config = KConfig("package-managerrc")
        group = config.group("General")
        group.writeEntry("SystemTray", str(self.ui.showTray.isChecked()))
        group.writeEntry("UpdateCheck", str(self.ui.checkUpdate.isChecked()))
        group.writeEntry("UpdateCheckInterval",
                         str(self.ui.updateInterval.value() * 60))
        config.sync()

        if self.ui.showTray.isChecked():
            p = subprocess.Popen(["package-manager"], stdout=subprocess.PIPE)
コード例 #16
0
ファイル: ScrMouse.py プロジェクト: Tayyib/uludag
    def setHandedness(self, item):
        mapMouse = {}

        if self.ui.radioButtonRightHand.isChecked():
            handed = RIGHT_HANDED

        else:
            handed = LEFT_HANDED

        mapMouse = display.Display().get_pointer_mapping()
        num_buttons = len(mapMouse)

        if num_buttons == 1:
            mapMouse[0] = 1
        elif num_buttons == 2:
            if handed == RIGHT_HANDED:
                mapMouse[0], mapMouse[1] = 1, 3
            else:
                mapMouse[0], mapMouse[1] = 3, 1
        else:
            if handed == RIGHT_HANDED:
                mapMouse[0], mapMouse[2] = 1, 3
            else:
                mapMouse[0], mapMouse[2] = 3, 1

            if num_buttons >= 5:
                pos = 0
                for pos in range(num_buttons):
                    if mapMouse[pos] == 4 or mapMouse[pos] == 5:
                        break

                if pos < num_buttons -1:
                    if self.ui.checkReverse.isChecked():
                        mapMouse[pos], mapMouse[pos + 1] = 5, 4
                    else:
                        mapMouse[pos], mapMouse[pos + 1] = 4, 5

        display.Display().set_pointer_mapping(mapMouse)

        config = KConfig("kcminputrc")
        group = config.group("Mouse")

        if handed == RIGHT_HANDED:
            group.writeEntry("MouseButtonMapping", QString("RightHanded"))
            self.__class__.screenSettings["selectedMouse"] = "RightHanded"
        else:
            group.writeEntry("MouseButtonMapping", QString("LeftHanded"))
            self.__class__.screenSettings["selectedMouse"] = "LeftHanded"

        group.writeEntry("ReverseScrollPolarity", QString(str(self.ui.checkReverse.isChecked())))
        config.sync()

        KGlobalSettings.self().emitChange(KGlobalSettings.SettingsChanged, KGlobalSettings.SETTINGS_MOUSE)
コード例 #17
0
    def execute(self):
        self.__class__.screenSettings["summaryMessage"] ={}

        self.__class__.screenSettings["summaryMessage"].update({"selectedMouse": ki18n("Left Handed") if self.__class__.screenSettings["selectedMouse"] == "LeftHanded" else ki18n("Right Handed")})
        self.__class__.screenSettings["summaryMessage"].update({"clickBehaviour": ki18n("Single Click ") if self.clickBehaviour == "True" else ki18n("Double Click")})

        config = KConfig("kdeglobals")
        group = config.group("KDE")
        group.writeEntry("SingleClick", QString(self.clickBehaviour))
        config.sync()
        KGlobalSettings.self().emitChange(KGlobalSettings.SettingsChanged, KGlobalSettings.SETTINGS_MOUSE)

        return True
コード例 #18
0
    def setHandedness(self, item):
        self.getMouseMap()

        # mouse has 1 button
        if self.num_buttons == 1:
            self.mapMouse[0] = 1

        # mouse has 2 buttons
        elif self.num_buttons == 2:
            if self.handed == RIGHT_HANDED:
                self.mapMouse[0], self.mapMouse[1] = 1, 3
            else:
                self.mapMouse[0], self.mapMouse[1] = 3, 1

        # mouse has 3 or more buttons
        else:
            if self.handed == RIGHT_HANDED:
                self.mapMouse[0], self.mapMouse[2] = 1, 3
            else:
                self.mapMouse[0], self.mapMouse[2] = 3, 1

            if self.num_buttons >= 5:
                # get wheel position
                for pos in range(0, self.num_buttons):
                    if self.mapMouse[pos] in (4, 5):
                        break

                if pos < self.num_buttons - 1:
                    if self.ui.checkReverse.isChecked():
                        self.mapMouse[pos], self.mapMouse[pos + 1] = 5, 4
                    else:
                        self.mapMouse[pos], self.mapMouse[pos + 1] = 4, 5

        display.Display().set_pointer_mapping(self.mapMouse)

        config = KConfig("kcminputrc")
        group = config.group("Mouse")

        if self.handed == RIGHT_HANDED:
            group.writeEntry("MouseButtonMapping", "RightHanded")
            self.__class__.screenSettings["selectedMouse"] = "RightHanded"
        else:
            group.writeEntry("MouseButtonMapping", "LeftHanded")
            self.__class__.screenSettings["selectedMouse"] = "LeftHanded"

        group.writeEntry("ReverseScrollPolarity",
                         str(self.ui.checkReverse.isChecked()))
        config.sync()

        KGlobalSettings.self().emitChange(KGlobalSettings.SettingsChanged,
                                          KGlobalSettings.SETTINGS_MOUSE)
コード例 #19
0
ファイル: app.py プロジェクト: Alwnikrotikz/lilykde
class StateManager(object):
    """Manages state and meta-info for documents.
    
    Asks Documents to save information like bookmarks and cursor position, etc.
    The information is saved in the 'metainfos' config file in the applications
    data directory.
    
    """
    def __init__(self, app):
        self.app = app
        self.metainfos = KConfig("metainfos", KConfig.NoGlobals, "appdata")
        
    def groupForUrl(self, url, create=False):
        """Returns a KConfigGroup for the given KUrl.
        
        Returns None if the group does not exist and create==False.
        
        """
        if not url.isEmpty():
            encodedurl = url.prettyUrl()
            if create or self.metainfos.hasGroup(encodedurl):
                return self.metainfos.group(encodedurl.encode('utf-8'))
            
    def loadState(self, doc):
        """Asks the Document to read its state from our config."""
        group = self.groupForUrl(doc.url())
        if group:
            last = group.readEntry("time", 0.0)
            # when it is a local file, only load the state when the
            # file was not modified later
            if not doc.localPath() or (
                    os.path.exists(doc.localPath()) and
                    os.path.getmtime(doc.localPath()) <= last):
                doc.readConfig(group)
            
    def saveState(self, doc):
        """Asks the Document to save its state to our config."""
        if doc.view and not doc.url().isEmpty():
            group = self.groupForUrl(doc.url(), True)
            group.writeEntry("time", time.time())
            doc.writeConfig(group)
            group.sync()
            
    def cleanup(self):
        """Purge entries that are not used for more than a month."""
        for g in self.metainfos.groupList():
            group = self.metainfos.group(g.encode('utf-8'))
            last = group.readEntry("time", 0.0)
            if (time.time() - last) / 86400 > 31:
                group.deleteGroup()
        self.metainfos.sync()
コード例 #20
0
ファイル: kdecolors.py プロジェクト: pashazz/change-theme
def applyColorScheme(schemeFile):
    """Applies the color scheme to KDE globals"""
    scheme = KConfig(schemeFile, KConfig.NoGlobals)
    kdeglobals = KConfig("kdeglobals")
    for groupName in scheme.groupList():
        group = scheme.group(groupName)
        global_group = kdeglobals.group(groupName)
        for (k, v) in group.entryMap().items():
            if groupName == "General" and k == "Name":
                k = "ColorScheme"
            global_group.writeEntry(k, v)

    kdeglobals.sync()
    KGlobalSettings.emitChange(KGlobalSettings.PaletteChanged)
コード例 #21
0
ファイル: scrMouse.py プロジェクト: rshipp/kapudan
    def setHandedness(self, item):
        self.getMouseMap()

        # mouse has 1 button
        if self.num_buttons == 1:
            self.mapMouse[0] = 1

        # mouse has 2 buttons
        elif self.num_buttons == 2:
            if self.handed == RIGHT_HANDED:
                self.mapMouse[0], self.mapMouse[1] = 1, 3
            else:
                self.mapMouse[0], self.mapMouse[1] = 3, 1

        # mouse has 3 or more buttons
        else:
            if self.handed == RIGHT_HANDED:
                self.mapMouse[0], self.mapMouse[2] = 1, 3
            else:
                self.mapMouse[0], self.mapMouse[2] = 3, 1

            if self.num_buttons >= 5:
                # get wheel position
                for pos in range(0, self.num_buttons):
                    if self.mapMouse[pos] in (4, 5):
                        break

                if pos < self.num_buttons - 1:
                    if self.ui.checkReverse.isChecked():
                        self.mapMouse[pos], self.mapMouse[pos + 1] = 5, 4
                    else:
                        self.mapMouse[pos], self.mapMouse[pos + 1] = 4, 5

        display.Display().set_pointer_mapping(self.mapMouse)

        config = KConfig("kcminputrc")
        group = config.group("Mouse")

        if self.handed == RIGHT_HANDED:
            group.writeEntry("MouseButtonMapping", "RightHanded")
            self.__class__.screenSettings["selectedMouse"] = "RightHanded"
        else:
            group.writeEntry("MouseButtonMapping", "LeftHanded")
            self.__class__.screenSettings["selectedMouse"] = "LeftHanded"

        group.writeEntry("ReverseScrollPolarity", str(self.ui.checkReverse.isChecked()))
        config.sync()

        KGlobalSettings.self().emitChange(KGlobalSettings.SettingsChanged, KGlobalSettings.SETTINGS_MOUSE)
コード例 #22
0
ファイル: base.py プロジェクト: warvariuc/mykde
    def update_kconfig(self, src_config_path, dst_config_path):
        """Update a configuration file which is in format of kconfig.

        Args:
            src_config_path (str): relative path to the source configuration file
            dst_config_path (str): path to the file to apply patch to
        """
        assert isinstance(src_config_path, str)
        assert isinstance(dst_config_path, str)
        assert not os.path.isabs(
            src_config_path), 'The source should be relative'
        src_config_path = self.make_abs_path(src_config_path)
        assert os.path.isfile(src_config_path)
        dst_config_path = self.make_abs_path(dst_config_path)
        self.print_html(
            'Updating configuration in <code>%s</code> from <code>%s</code>.' %
            (dst_config_path, src_config_path))

        # http://api.kde.org/4.x-api/kdelibs-apidocs/kdeui/html/classKGlobalSettings.html
        # http://api.kde.org/4.x-api/kdelibs-apidocs/kdecore/html/classKConfig.html
        # http://api.kde.org/4.x-api/kdelibs-apidocs/kdecore/html/classKConfigGroup.html
        # https://projects.kde.org/projects/kde/kdebase/kde-runtime/repository/show/kreadconfig
        def update_group(src_group, dst_group, bkp_group):
            for entry_name, new_entry_value in src_group.entryMap().items():
                if hasattr(dst_group, 'writeEntry'):
                    old_entry_value = dst_group.readEntry(entry_name)
                    dst_group.writeEntry(entry_name, new_entry_value)
                    if new_entry_value != old_entry_value and old_entry_value:
                        bkp_group.writeEntry(entry_name, old_entry_value)
            for group_name in src_group.groupList():
                update_group(src_group.group(group_name),
                             dst_group.group(group_name),
                             bkp_group.group(group_name))

        src_cfg = KConfig(src_config_path, KConfig.SimpleConfig)
        dst_cfg = KConfig(dst_config_path, KConfig.SimpleConfig)
        bkp_cfg = KConfig(
            '', KConfig.SimpleConfig)  # we keep here original settings of dest

        update_group(src_cfg, dst_cfg, bkp_cfg)
        # update top level entries
        update_group(src_cfg.group(''), dst_cfg.group(''), bkp_cfg)

        dst_cfg.sync()  # save the current state of the configuration object
コード例 #23
0
ファイル: base.py プロジェクト: warvariuc/mykde
    def update_kconfig(self, src_config_path, dst_config_path):
        """Update a configuration file which is in format of kconfig.

        Args:
            src_config_path (str): relative path to the source configuration file
            dst_config_path (str): path to the file to apply patch to
        """
        assert isinstance(src_config_path, str)
        assert isinstance(dst_config_path, str)
        assert not os.path.isabs(src_config_path), 'The source should be relative'
        src_config_path = self.make_abs_path(src_config_path)
        assert os.path.isfile(src_config_path)
        dst_config_path = self.make_abs_path(dst_config_path)
        self.print_html('Updating configuration in <code>%s</code> from <code>%s</code>.'
                        % (dst_config_path, src_config_path))

        # http://api.kde.org/4.x-api/kdelibs-apidocs/kdeui/html/classKGlobalSettings.html
        # http://api.kde.org/4.x-api/kdelibs-apidocs/kdecore/html/classKConfig.html
        # http://api.kde.org/4.x-api/kdelibs-apidocs/kdecore/html/classKConfigGroup.html
        # https://projects.kde.org/projects/kde/kdebase/kde-runtime/repository/show/kreadconfig
        def update_group(src_group, dst_group, bkp_group):
            for entry_name, new_entry_value in src_group.entryMap().items():
                if hasattr(dst_group, 'writeEntry'):
                    old_entry_value = dst_group.readEntry(entry_name)
                    dst_group.writeEntry(entry_name, new_entry_value)
                    if new_entry_value != old_entry_value and old_entry_value:
                        bkp_group.writeEntry(entry_name, old_entry_value)
            for group_name in src_group.groupList():
                update_group(src_group.group(group_name), dst_group.group(group_name),
                             bkp_group.group(group_name))

        src_cfg = KConfig(src_config_path, KConfig.SimpleConfig)
        dst_cfg = KConfig(dst_config_path, KConfig.SimpleConfig)
        bkp_cfg = KConfig('', KConfig.SimpleConfig)  # we keep here original settings of dest

        update_group(src_cfg, dst_cfg, bkp_cfg)
        # update top level entries
        update_group(src_cfg.group(''), dst_cfg.group(''), bkp_cfg)

        dst_cfg.sync()  # save the current state of the configuration object
コード例 #24
0
ファイル: kde.py プロジェクト: ademirel/COMAK
    def setStyleSettings(self):

        if scrStyleWidget.screenSettings["iconChanged"]:
            hasChanged = True
            configKdeGlobals = KConfig("kdeglobals")
            group = configKdeGlobals.group("General")

            groupIconTheme = configKdeGlobals.group("Icons")
            groupIconTheme.writeEntry("Theme", scrStyleWidget.screenSettings["iconTheme"])

            configKdeGlobals.sync()

            # Change Icon theme
            kdeui.KIconTheme.reconfigure()
            kdeui.KIconCache.deleteCache()
            deleteIconCache()

        if scrStyleWidget.screenSettings["styleChanged"]:
            hasChanged = True
            configKdeGlobals = KConfig("kdeglobals")
            group = configKdeGlobals.group("General")
            group.writeEntry("widgetStyle", scrStyleWidget.screenSettings["styleDetails"][unicode(scrStyleWidget.screenSettings["styleName"])]["widgetStyle"])
            groupIconTheme = configKdeGlobals.group("Icons")
            groupIconTheme.writeEntry("Theme", scrStyleWidget.screenSettings["iconTheme"])
            #groupIconTheme.writeEntry("Theme", scrStyleWidget.screenSettings["styleDetails"][unicode(scrStyleWidget.screenSettings["styleName"])]["iconTheme"])

            configKdeGlobals.sync()

            # Change Icon theme
            kdeui.KIconTheme.reconfigure()
            kdeui.KIconCache.deleteCache()
            deleteIconCache()

            for i in range(kdeui.KIconLoader.LastGroup):
                kdeui.KGlobalSettings.self().emitChange(kdeui.KGlobalSettings.IconChanged, i)

            # Change widget style & color
            for key, value in scrStyleWidget.screenSettings["styleDetails"][unicode(scrStyleWidget.screenSettings["styleName"])]["colorScheme"].items():
                colorGroup = configKdeGlobals.group(key)
                for key2, value2 in value.items():
                        colorGroup.writeEntry(str(key2), str(value2))

            configKdeGlobals.sync()
            kdeui.KGlobalSettings.self().emitChange(kdeui.KGlobalSettings.StyleChanged)

            configPlasmaRc = KConfig("plasmarc")
            groupDesktopTheme = configPlasmaRc.group("Theme")
            groupDesktopTheme.writeEntry("name", scrStyleWidget.screenSettings["styleDetails"][unicode(scrStyleWidget.screenSettings["styleName"])]["desktopTheme"])
            configPlasmaRc.sync()

            configPlasmaApplet = KConfig("plasma-desktop-appletsrc")
            group = configPlasmaApplet.group("Containments")
            for each in list(group.groupList()):
                subgroup = group.group(each)
                subcomponent = subgroup.readEntry('plugin')
                if subcomponent == 'panel':
                    #print subcomponent
                    subgroup.writeEntry('location', scrStyleWidget.screenSettings["styleDetails"][unicode(scrStyleWidget.screenSettings["styleName"])]["panelPosition"])

            configPlasmaApplet.sync()

            configKwinRc = KConfig("kwinrc")
            groupWindowDecoration = configKwinRc.group("Style")
            groupWindowDecoration.writeEntry("PluginLib", scrStyleWidget.screenSettings["styleDetails"][unicode(scrStyleWidget.screenSettings["styleName"])]["windowDecoration"])
            configKwinRc.sync()

        session = dbus.SessionBus()

        try:
            proxy = session.get_object('org.kde.kwin', '/KWin')
            proxy.reconfigure()
        except dbus.DBusException:
            pass
コード例 #25
0
class Widget(QtGui.QWidget, ScreenWidget):
    screenSettings = {}
    screenSettings["hasChanged"] = False

    # title and description at the top of the dialog window
    title = ki18n("Insert some catchy title about keyboards..")
    desc = ki18n("Select your keyboard layout")

    def __init__(self, *args):
        QtGui.QWidget.__init__(self,None)
        self.ui = Ui_keyboardWidget()
        self.ui.setupUi(self)
        self.ui.picKeyboard.setPixmap(QtGui.QPixmap(':/raw/pics/keyboards.png'))

        # get Layout config
        self.config = KConfig("kxkbrc")
        self.group = self.config.group("Layout")
        self.layoutList = str(self.group.readEntry("LayoutList"))
        self.lastLayout = 0

        for lang in localedata.languages:
            for each in localedata.languages[lang].keymaps:
                item = QtGui.QListWidgetItem(self.ui.listWidgetKeyboard)
                item.setText(each.name)
                item.setToolTip(each.xkb_layout)
                item.setStatusTip(each.xkb_variant)
                self.ui.listWidgetKeyboard.addItem(item)

        self.ui.listWidgetKeyboard.connect(self.ui.listWidgetKeyboard, SIGNAL("itemSelectionChanged()"), self.setKeyboard)

    def setKeyboard(self):
        layout = self.ui.listWidgetKeyboard.currentItem().toolTip()
        variant = self.ui.listWidgetKeyboard.currentItem().statusTip()

        subprocess.Popen(["setxkbmap", layout, variant])
        if variant:
            self.lastLayout = layout + "(" + variant + ")"
        else:
            self.lastLayout = layout

    def shown(self):
        pass

    def execute(self):
        if self.lastLayout:
            layoutArr = self.layoutList.split(",")

            if self.lastLayout not in layoutArr:
                layoutArr.insert(0, str(self.lastLayout))
            else:
                layoutArr.remove(self.lastLayout)
                layoutArr.insert(0, str(self.lastLayout))

            for i in layoutArr:
                if i == "":
                    layoutArr.remove(i)

            layoutList =  ",".join(layoutArr)
            self.group.writeEntry("LayoutList", layoutList)
            self.group.writeEntry("DisplayNames", layoutList)
            self.config.sync()
        return True
コード例 #26
0
class Widget(QtGui.QWidget, ScreenWidget):
    screenSettings = {}
    screenSettings["hasChanged"] = False

    # title and description at the top of the dialog window
    title = ki18n("Insert some catchy title about keyboards..")
    desc = ki18n("Select your keyboard layout")

    def __init__(self, *args):
        QtGui.QWidget.__init__(self,None)
        self.ui = Ui_keyboardWidget()
        self.ui.setupUi(self)

        # get layout config
        self.config = KConfig("kxkbrc")
        self.group = self.config.group("Layout")
        self.layoutList = str(self.group.readEntry("LayoutList"))
        self.lastLayout = 0
 
        # get language list
        self.languageList = self.getLanguageList()
        self.syslang = self.getCurrentSystemLanguage()
        print "DETECTED SYSTEM LANGUAGE:", self.syslang.strip()
        # generate language list
        for language in self.languageList:
            languageCode, languageName, languageLayout, languageVariant = language

            item = QtGui.QListWidgetItem(self.ui.listWidgetKeyboard)
            item.setText(languageName)
            item.setToolTip(languageLayout)
            item.setStatusTip(languageVariant)
            self.ui.listWidgetKeyboard.addItem(item)

            # select appropriate keymap
            if self.getCurrentSystemLanguage().strip() == languageCode.strip():
                if languageCode.strip()=="hu" and languageVariant.strip() == "f":
                    break
                else:
                    self.ui.listWidgetKeyboard.setCurrentItem(item)

        self.ui.listWidgetKeyboard.sortItems()
        self.ui.listWidgetKeyboard.connect(self.ui.listWidgetKeyboard, SIGNAL("itemSelectionChanged()"), self.setKeyboard)
        self.ui.pushKeybButton.connect(self.ui.pushKeybButton, SIGNAL("clicked()"), self.setKeyboardAdvanced)

    def getCurrentSystemLanguage(self):
        lang = "en"

        try:
            langFile = open('/etc/sysconfig/i18n', 'r')
            #lang = langFile.readline().rstrip('\n').strip()
            for line in langFile.readlines():
        	line = line.strip('\n')
        	field = line.split('=')
        	if field[0] == 'LANGUAGE':
        	    langline = field[1]
        	    langfield = langline.split('_')
        	    lang = langfield[0]
        	    if lang == '':
        		print "Lang not found in configfile"

        except IOError:
            print "Cannot read language file"

        return lang

    def getLanguageList(self):
        languageList = []

        for language in localedata.languages.items():
            lcode, lprops = language

            lkeymaps = lprops.keymaps

            for lmap in lkeymaps:
                lname = lmap.name
                llayout = lmap.xkb_layout
                lvariant = lmap.xkb_variant

                languageList.append([lcode, lname, llayout, lvariant])

        return languageList

    def setKeyboard(self):
        layout = self.ui.listWidgetKeyboard.currentItem().toolTip()
        variant = self.ui.listWidgetKeyboard.currentItem().statusTip()

        subprocess.Popen(["setxkbmap", layout, variant])
        if variant:
            self.lastLayout = layout + "(" + variant + ")"
        else:
            self.lastLayout = layout

    def shown(self):
        pass

    def execute(self):
        if self.lastLayout:
            layoutArr = self.layoutList.split(",")

            if self.lastLayout not in layoutArr:
                layoutArr.insert(0, str(self.lastLayout))
            else:
                layoutArr.remove(self.lastLayout)
                layoutArr.insert(0, str(self.lastLayout))

            for i in layoutArr:
                if i == "":
                    layoutArr.remove(i)

            layoutList =  ",".join(layoutArr)
            self.group.writeEntry("LayoutList", layoutList)
            self.group.writeEntry("DisplayNames", layoutList)
            self.config.sync()
        return True


    def setKeyboardAdvanced(self):
	print "GO ADVANCED KEYBOARD SETTINGS"
        #self.ui.listWidgetKeyboard.setDisabled(True)
        p = subprocess.Popen(["settings", "keyboard"], stdout=subprocess.PIPE)
コード例 #27
0
    def execute(self):
        hasChanged = False

        # Wallpaper Settings
        if self.wallpaperSettings["hasChanged"] == True:
            hasChanged = True
            if self.wallpaperSettings["selectedWallpaper"]:
                config = KConfig("plasma-desktop-appletsrc")
                group = config.group("Containments")
                for each in list(group.groupList()):
                    subgroup = group.group(each)
                    subcomponent = subgroup.readEntry("plugin")
                    if subcomponent == "desktop" or subcomponent == "folderview":
                        subg = subgroup.group("Wallpaper")
                        subg_2 = subg.group("image")
                        subg_2.writeEntry("wallpaper", self.wallpaperSettings["selectedWallpaper"])

        # Search Settings
        if self.searchSettings["hasChanged"] == True:
            config = KConfig("nepomukserverrc")
            group = config.group("Service-nepomukstrigiservice")
            # group = config.group("Basic Settings")
            group.writeEntry("autostart", str(self.searchSettings["state"]).lower())
            # group.writeEntry('Start Nepomuk', str(self.searchSettings["state"]).lower())

            session = dbus.SessionBus()

            try:
                proxy = session.get_object("org.kde.NepomukServer", "/nepomukserver")
                proxy.reconfigure()
                proxy.enableNepomuk(self.searchSettings["state"])
            except dbus.DBusException:
                pass

        # Menu Settings
        if self.menuSettings["hasChanged"] == True:
            hasChanged = True
            config = KConfig("plasma-desktop-appletsrc")
            group = config.group("Containments")

            for each in list(group.groupList()):
                subgroup = group.group(each)
                subcomponent = subgroup.readEntry("plugin")
                if subcomponent == "panel":
                    subg = subgroup.group("Applets")
                    for i in list(subg.groupList()):
                        subg2 = subg.group(i)
                        launcher = subg2.readEntry("plugin")
                        if str(launcher).find("launcher") >= 0:
                            subg2.writeEntry("plugin", self.menuSettings["selectedMenu"])
        # Desktop Type
        if self.styleSettings["hasChangedDesktopType"] == True:
            hasChanged = True
            config = KConfig("plasma-desktop-appletsrc")
            group = config.group("Containments")

            for each in list(group.groupList()):
                subgroup = group.group(each)
                subcomponent = subgroup.readEntry("plugin")
                subcomponent2 = subgroup.readEntry("screen")
                if subcomponent == "desktop" or subcomponent == "folderview":
                    if int(subcomponent2) == 0:
                        subgroup.writeEntry("plugin", self.styleSettings["desktopType"])

            config.sync()

        # Number of Desktops
        if self.styleSettings["hasChangedDesktopNumber"] == True:
            hasChanged = True
            config = KConfig("kwinrc")
            group = config.group("Desktops")
            group.writeEntry("Number", self.styleSettings["desktopNumber"])
            group.sync()

            info = kdeui.NETRootInfo(QtGui.QX11Info.display(), kdeui.NET.NumberOfDesktops | kdeui.NET.DesktopNames)
            info.setNumberOfDesktops(int(self.styleSettings["desktopNumber"]))
            info.activate()

            session = dbus.SessionBus()

            try:
                proxy = session.get_object("org.kde.kwin", "/KWin")
                proxy.reconfigure()
            except dbus.DBusException:
                pass

            config.sync()

        # Theme Settings
        if self.styleSettings["hasChanged"] == True:
            hasChanged = True
            configKdeGlobals = KConfig("kdeglobals")
            group = configKdeGlobals.group("General")
            group.writeEntry(
                "widgetStyle",
                self.styleSettings["styleDetails"][unicode(self.styleSettings["styleName"])]["widgetStyle"],
            )

            groupIconTheme = configKdeGlobals.group("Icons")
            groupIconTheme.writeEntry(
                "Theme", self.styleSettings["styleDetails"][unicode(self.styleSettings["styleName"])]["iconTheme"]
            )

            configKdeGlobals.sync()

            # Change Icon theme
            kdeui.KIconTheme.reconfigure()
            kdeui.KIconCache.deleteCache()

            for i in range(kdeui.KIconLoader.LastGroup):
                kdeui.KGlobalSettings.self().emitChange(kdeui.KGlobalSettings.IconChanged, i)

            # Change widget style & color
            for key, value in self.styleSettings["styleDetails"][unicode(self.styleSettings["styleName"])][
                "colorScheme"
            ].items():
                colorGroup = configKdeGlobals.group(key)
                for key2, value2 in value.items():
                    colorGroup.writeEntry(str(key2), str(value2))

            configKdeGlobals.sync()
            kdeui.KGlobalSettings.self().emitChange(kdeui.KGlobalSettings.StyleChanged)

            configPlasmaRc = KConfig("plasmarc")
            groupDesktopTheme = configPlasmaRc.group("Theme")
            groupDesktopTheme.writeEntry(
                "name", self.styleSettings["styleDetails"][unicode(self.styleSettings["styleName"])]["desktopTheme"]
            )
            configPlasmaRc.sync()

            configPlasmaApplet = KConfig("plasma-desktop-appletsrc")
            group = configPlasmaApplet.group("Containments")
            for each in list(group.groupList()):
                subgroup = group.group(each)
                subcomponent = subgroup.readEntry("plugin")
                if subcomponent == "panel":
                    print subcomponent
                    subgroup.writeEntry(
                        "location",
                        self.styleSettings["styleDetails"][unicode(self.styleSettings["styleName"])]["panelPosition"],
                    )

            configPlasmaApplet.sync()

            configKwinRc = KConfig("kwinrc")
            groupWindowDecoration = configKwinRc.group("Style")
            groupWindowDecoration.writeEntry(
                "PluginLib",
                self.styleSettings["styleDetails"][unicode(self.styleSettings["styleName"])]["windowDecoration"],
            )
            configKwinRc.sync()

            session = dbus.SessionBus()

            try:
                proxy = session.get_object("org.kde.kwin", "/KWin")
                proxy.reconfigure()
            except dbus.DBusException:
                pass

        # Smolt Settings
        # if self.smoltSettings["profileSend"] == True:
        ##    self.procSettings = QProcess()
        ##    command = "smoltSendProfile"
        #    arguments = ["-a", "--submitOnly"]
        #    self.procSettings.startDetached(command, arguments)

        if hasChanged == True:
            self.killPlasma()

        return True
コード例 #28
0
ファイル: scrKeyboard.py プロジェクト: harunpehlivan/project
class Widget(QtGui.QWidget, Screen):
    screenSettings = {}
    screenSettings["hasChanged"] = False

    # title and description at the top of the dialog window
    title = ki18n("Keyboard")
    desc = ki18n("Keyboard Layout Language")

    def __init__(self, *args):
        QtGui.QWidget.__init__(self, None)
        self.ui = Ui_keyboardWidget()
        self.ui.setupUi(self)

        # get layout config
        self.config = KConfig("kxkbrc")
        self.group = self.config.group("Layout")
        self.layoutList = str(self.group.readEntry("LayoutList"))
        self.lastLayout = 0

        # get language list
        self.languageList = self.getLanguageList()

        # generate language list
        for language in self.languageList:
            languageCode, languageName, languageLayout, languageVariant = language

            item = QtGui.QListWidgetItem(self.ui.listWidgetKeyboard)
            item.setText(languageName)
            item.setToolTip(languageLayout)
            item.setStatusTip(languageVariant)
            self.ui.listWidgetKeyboard.addItem(item)

            # select appropriate keymap
            if self.getCurrentSystemLanguage().strip() == languageCode.strip():
                if languageCode.strip() == "tr" and languageVariant.strip() == "f":
                    break
                else:
                    self.ui.listWidgetKeyboard.setCurrentItem(item)

        self.ui.listWidgetKeyboard.sortItems()
        self.ui.listWidgetKeyboard.connect(
            self.ui.listWidgetKeyboard, SIGNAL("itemSelectionChanged()"), self.setKeyboard
        )

    def getCurrentSystemLanguage(self):
        lang = "en"

        try:
            langFile = open("/etc/mudur/language", "r")
            lang = langFile.readline().rstrip("\n").strip()
        except IOError:
            print "Cannot read /etc/mudur/language file"

        return lang

    def getLanguageList(self):
        languageList = []

        for language in localedata.languages.items():
            lcode, lprops = language

            lkeymaps = lprops.keymaps

            for lmap in lkeymaps:
                lname = lmap.name
                llayout = lmap.xkb_layout
                lvariant = lmap.xkb_variant

                languageList.append([lcode, lname, llayout, lvariant])

        return languageList

    def setKeyboard(self):
        layout = self.ui.listWidgetKeyboard.currentItem().toolTip()
        variant = self.ui.listWidgetKeyboard.currentItem().statusTip()

        subprocess.Popen(["setxkbmap", layout, variant])
        if variant:
            self.lastLayout = layout + "(" + variant + ")"
        else:
            self.lastLayout = layout

    def shown(self):
        pass

    def execute(self):
        if self.lastLayout:
            layoutArr = self.layoutList.split(",")

            if self.lastLayout not in layoutArr:
                layoutArr.insert(0, str(self.lastLayout))
            else:
                layoutArr.remove(self.lastLayout)
                layoutArr.insert(0, str(self.lastLayout))

            for i in layoutArr:
                if i == "":
                    layoutArr.remove(i)

            layoutList = ",".join(layoutArr)
            self.group.writeEntry("LayoutList", layoutList)
            self.group.writeEntry("DisplayNames", layoutList)
            self.config.sync()
        return True
コード例 #29
0
ファイル: scrKeyboard.py プロジェクト: gultekin-e/pisi-work
class Widget(QtGui.QWidget, Screen):
    screenSettings = {}
    screenSettings["hasChanged"] = False

    # title and description at the top of the dialog window
    title = ki18n("Keyboard")
    desc = ki18n("Keyboard Layout Language")

    def __init__(self, *args):
        QtGui.QWidget.__init__(self, None)
        self.ui = Ui_keyboardWidget()
        self.ui.setupUi(self)

        # get layout config
        self.config = KConfig("kxkbrc")
        self.group = self.config.group("Layout")
        self.layoutList = str(self.group.readEntry("LayoutList"))
        self.lastLayout = 0

        # get language list
        self.languageList = self.getLanguageList()

        # generate language list
        for language in self.languageList:
            languageCode, languageName, languageLayout, languageVariant = language

            item = QtGui.QListWidgetItem(self.ui.listWidgetKeyboard)
            item.setText(languageName)
            item.setToolTip(languageLayout)
            item.setStatusTip(languageVariant)
            self.ui.listWidgetKeyboard.addItem(item)

            # select appropriate keymap
            if self.getCurrentSystemLanguage().strip() == languageCode.strip():
                if languageCode.strip() == "tr" and languageVariant.strip(
                ) == "f":
                    break
                else:
                    self.ui.listWidgetKeyboard.setCurrentItem(item)

        self.ui.listWidgetKeyboard.sortItems()
        self.ui.listWidgetKeyboard.connect(self.ui.listWidgetKeyboard,
                                           SIGNAL("itemSelectionChanged()"),
                                           self.setKeyboard)

    def getCurrentSystemLanguage(self):
        lang = "en"

        try:
            langFile = open('/etc/mudur/language', 'r')
            lang = langFile.readline().rstrip('\n').strip()
        except IOError:
            print "Cannot read /etc/mudur/language file"

        return lang

    def getLanguageList(self):
        languageList = []

        for language in localedata.languages.items():
            lcode, lprops = language

            lkeymaps = lprops.keymaps

            for lmap in lkeymaps:
                lname = lmap.name
                llayout = lmap.xkb_layout
                lvariant = lmap.xkb_variant

                languageList.append([lcode, lname, llayout, lvariant])

        return languageList

    def setKeyboard(self):
        layout = self.ui.listWidgetKeyboard.currentItem().toolTip()
        variant = self.ui.listWidgetKeyboard.currentItem().statusTip()

        subprocess.Popen(["setxkbmap", layout, variant])
        if variant:
            self.lastLayout = layout + "(" + variant + ")"
        else:
            self.lastLayout = layout

    def shown(self):
        pass

    def execute(self):
        if self.lastLayout:
            layoutArr = self.layoutList.split(",")

            if self.lastLayout not in layoutArr:
                layoutArr.insert(0, str(self.lastLayout))
            else:
                layoutArr.remove(self.lastLayout)
                layoutArr.insert(0, str(self.lastLayout))

            for i in layoutArr:
                if i == "":
                    layoutArr.remove(i)

            layoutList = ",".join(layoutArr)
            self.group.writeEntry("LayoutList", layoutList)
            self.group.writeEntry("DisplayNames", layoutList)
            self.config.sync()
        return True
コード例 #30
0
    def shown(self):
        self.wallpaperSettings = wallpaperWidget.Widget.screenSettings
        self.mouseSettings = mouseWidget.Widget.screenSettings
        self.menuSettings = menuWidget.Widget.screenSettings
        self.styleSettings = styleWidget.Widget.screenSettings
        self.avatarSettings = avatarWidget.Widget.screenSettings

        subject = "<p><li><b>%s</b></li><ul>"
        item = "<li>%s</li>"
        end = "</ul></p>"
        content = QString("")

        content.append("""<html><body><ul>""")

        # Mouse Settings
        content.append(subject % ki18n("Mouse Settings").toString())

        content.append(
            item %
            ki18n("Selected Mouse configuration: <b>%s</b>").toString() %
            self.mouseSettings["summaryMessage"]["selectedMouse"].toString())
        content.append(
            item % ki18n("Selected clicking behaviour: <b>%s</b>").toString() %
            self.mouseSettings["summaryMessage"]["clickBehaviour"].toString())
        content.append(end)

        # Menu Settings
        content.append(subject % ki18n("Menu Settings").toString())
        content.append(item % ki18n("Selected Menu: <b>%s</b>").toString() %
                       self.menuSettings["summaryMessage"].toString())
        content.append(end)

        # Wallpaper Settings
        content.append(subject % ki18n("Wallpaper Settings").toString())
        if not self.wallpaperSettings["hasChanged"]:
            content.append(
                item % ki18n("You haven't selected any wallpaper.").toString())
        else:
            content.append(
                item % ki18n("Selected Wallpaper: <b>%s</b>").toString() %
                os.path.basename(
                    str(self.wallpaperSettings["selectedWallpaper"])))
        content.append(end)

        # Style Settings
        content.append(subject % ki18n("Style Settings").toString())

        if not self.styleSettings["hasChanged"]:
            content.append(item %
                           ki18n("You haven't selected any style.").toString())
        else:
            content.append(item %
                           ki18n("Selected Style: <b>%s</b>").toString() %
                           unicode(self.styleSettings["summaryMessage"]))

        content.append(end)

        # Wallpaper Settings
        if self.wallpaperSettings["hasChanged"]:
            hasChanged = True
            if self.wallpaperSettings["selectedWallpaper"]:
                config = KConfig("plasma-desktop-appletsrc")
                group = config.group("Containments")
                for each in list(group.groupList()):
                    subgroup = group.group(each)
                    subcomponent = subgroup.readEntry('plugin')
                    if subcomponent == 'desktop' or subcomponent == 'folderview':
                        subg = subgroup.group('Wallpaper')
                        subg_2 = subg.group('image')
                        subg_2.writeEntry(
                            "wallpaper",
                            self.wallpaperSettings["selectedWallpaper"])

        # Menu Settings
        if self.menuSettings["hasChanged"]:
            hasChanged = True
            config = KConfig("plasma-desktop-appletsrc")
            group = config.group("Containments")

            for each in list(group.groupList()):
                subgroup = group.group(each)
                subcomponent = subgroup.readEntry('plugin')
                if subcomponent == 'panel':
                    subg = subgroup.group('Applets')
                    for i in list(subg.groupList()):
                        subg2 = subg.group(i)
                        launcher = subg2.readEntry('plugin')
                        if str(launcher).find('launcher') >= 0:
                            subg2.writeEntry('plugin',
                                             self.menuSettings["selectedMenu"])

        def removeFolderViewWidget():
            config = KConfig("plasma-desktop-appletsrc")

            sub_lvl_0 = config.group("Containments")

            for sub in list(sub_lvl_0.groupList()):
                sub_lvl_1 = sub_lvl_0.group(sub)

                if sub_lvl_1.hasGroup("Applets"):
                    sub_lvl_2 = sub_lvl_1.group("Applets")

                    for sub2 in list(sub_lvl_2.groupList()):
                        sub_lvl_3 = sub_lvl_2.group(sub2)
                        plugin = sub_lvl_3.readEntry('plugin')

                        if plugin == 'folderview':
                            sub_lvl_3.deleteGroup()

        # Desktop Type
        if self.styleSettings["hasChangedDesktopType"]:
            hasChanged = True
            config = KConfig("plasma-desktop-appletsrc")
            group = config.group("Containments")

            for each in list(group.groupList()):
                subgroup = group.group(each)
                subcomponent = subgroup.readEntry('plugin')
                subcomponent2 = subgroup.readEntry('screen')
                if subcomponent == 'desktop' or subcomponent == 'folderview':
                    if int(subcomponent2) == 0:
                        subgroup.writeEntry('plugin',
                                            self.styleSettings["desktopType"])

            # Remove folder widget - normally this would be done over dbus but thanks to improper naming of the plasma interface
            # this is not possible
            # ValueError: Invalid interface or error name 'org.kde.plasma-desktop': contains invalid character '-'
            #
            # Related Bug:
            # Bug 240358 - Invalid D-BUS interface name 'org.kde.plasma-desktop.PlasmaApp' found while parsing introspection
            # https://bugs.kde.org/show_bug.cgi?id=240358

            if self.styleSettings["desktopType"] == "folderview":
                removeFolderViewWidget()

            config.sync()

        # Number of Desktops
        if self.styleSettings["hasChangedDesktopNumber"]:
            hasChanged = True
            config = KConfig("kwinrc")
            group = config.group("Desktops")
            group.writeEntry('Number', self.styleSettings["desktopNumber"])
            group.sync()

            info = kdeui.NETRootInfo(
                QtGui.QX11Info.display(),
                kdeui.NET.NumberOfDesktops | kdeui.NET.DesktopNames)
            info.setNumberOfDesktops(int(self.styleSettings["desktopNumber"]))
            info.activate()

            session = dbus.SessionBus()

            try:
                proxy = session.get_object('org.kde.kwin', '/KWin')
                proxy.reconfigure()
            except dbus.DBusException:
                pass

            config.sync()

        def deleteIconCache():
            try:
                os.remove("/var/tmp/kdecache-%s/icon-cache.kcache" %
                          os.environ.get("USER"))
            except:
                pass

            for i in range(kdeui.KIconLoader.LastGroup):
                kdeui.KGlobalSettings.self().emitChange(
                    kdeui.KGlobalSettings.IconChanged, i)

        # Theme Settings
        if self.styleSettings["hasChanged"]:
            if self.styleSettings["iconChanged"]:
                hasChanged = True
                configKdeGlobals = KConfig("kdeglobals")
                group = configKdeGlobals.group("General")

                groupIconTheme = configKdeGlobals.group("Icons")
                groupIconTheme.writeEntry("Theme",
                                          self.styleSettings["iconTheme"])

                configKdeGlobals.sync()

                # Change Icon theme
                kdeui.KIconTheme.reconfigure()
                kdeui.KIconCache.deleteCache()
                deleteIconCache()

            if self.styleSettings["styleChanged"]:
                hasChanged = True
                configKdeGlobals = KConfig("kdeglobals")
                group = configKdeGlobals.group("General")
                group.writeEntry(
                    "widgetStyle", self.styleSettings["styleDetails"][unicode(
                        self.styleSettings["styleName"])]["widgetStyle"])

                groupIconTheme = configKdeGlobals.group("Icons")
                groupIconTheme.writeEntry("Theme",
                                          self.styleSettings["iconTheme"])
                #groupIconTheme.writeEntry("Theme", self.styleSettings["styleDetails"][unicode(self.styleSettings["styleName"])]["iconTheme"])

                configKdeGlobals.sync()

                # Change Icon theme
                kdeui.KIconTheme.reconfigure()
                kdeui.KIconCache.deleteCache()
                deleteIconCache()

                for i in range(kdeui.KIconLoader.LastGroup):
                    kdeui.KGlobalSettings.self().emitChange(
                        kdeui.KGlobalSettings.IconChanged, i)

                # Change widget style & color
                for key, value in self.styleSettings["styleDetails"][unicode(
                        self.styleSettings["styleName"])]["colorScheme"].items(
                        ):
                    colorGroup = configKdeGlobals.group(key)
                    for key2, value2 in value.items():
                        colorGroup.writeEntry(str(key2), str(value2))

                configKdeGlobals.sync()
                kdeui.KGlobalSettings.self().emitChange(
                    kdeui.KGlobalSettings.StyleChanged)

                configPlasmaRc = KConfig("plasmarc")
                groupDesktopTheme = configPlasmaRc.group("Theme")
                groupDesktopTheme.writeEntry(
                    "name", self.styleSettings["styleDetails"][unicode(
                        self.styleSettings["styleName"])]["desktopTheme"])
                configPlasmaRc.sync()

                configPlasmaApplet = KConfig("plasma-desktop-appletsrc")
                group = configPlasmaApplet.group("Containments")
                for each in list(group.groupList()):
                    subgroup = group.group(each)
                    subcomponent = subgroup.readEntry('plugin')
                    if subcomponent == 'panel':
                        #print subcomponent
                        subgroup.writeEntry(
                            'location',
                            self.styleSettings["styleDetails"][unicode(
                                self.styleSettings["styleName"])]
                            ["panelPosition"])

                configPlasmaApplet.sync()

                configKwinRc = KConfig("kwinrc")
                groupWindowDecoration = configKwinRc.group("Style")
                groupWindowDecoration.writeEntry(
                    "PluginLib", self.styleSettings["styleDetails"][unicode(
                        self.styleSettings["styleName"])]["windowDecoration"])
                configKwinRc.sync()

            session = dbus.SessionBus()

            try:
                proxy = session.get_object('org.kde.kwin', '/KWin')
                proxy.reconfigure()
            except dbus.DBusException:
                pass

        # Avatar Settings
        if self.avatarSettings["hasChanged"]:
            hasChanged = True

        if hasChanged:
            self.killPlasma()

        return True
コード例 #31
0
ファイル: scrSummary.py プロジェクト: rshipp/kapudan
    def execute(self):
        hasChanged = False
        rootActions = ""

        # Wallpaper Settings
        if self.wallpaperSettings["hasChanged"]:
            hasChanged = True
            if self.wallpaperSettings["selectedWallpaper"]:
                config = KConfig("plasma-desktop-appletsrc")
                group = config.group("Containments")
                for each in list(group.groupList()):
                    subgroup = group.group(each)
                    subcomponent = subgroup.readEntry('plugin')
                    if subcomponent == 'desktop' or subcomponent == 'folderview':
                        subg = subgroup.group('Wallpaper')
                        subg_2 = subg.group('image')
                        subg_2.writeEntry("wallpaper", self.wallpaperSettings["selectedWallpaper"])

        # Menu Settings
        if self.menuSettings["hasChanged"]:
            hasChanged = True
            config = KConfig("plasma-desktop-appletsrc")
            group = config.group("Containments")

            for each in list(group.groupList()):
                subgroup = group.group(each)
                subcomponent = subgroup.readEntry('plugin')
                if subcomponent == 'panel':
                    subg = subgroup.group('Applets')
                    for i in list(subg.groupList()):
                        subg2 = subg.group(i)
                        launcher = subg2.readEntry('plugin')
                        if str(launcher).find('launcher') >= 0:
                            subg2.writeEntry('plugin', self.menuSettings["selectedMenu"])

        def removeFolderViewWidget():
            config = KConfig("plasma-desktop-appletsrc")

            sub_lvl_0 = config.group("Containments")

            for sub in list(sub_lvl_0.groupList()):
                sub_lvl_1 = sub_lvl_0.group(sub)

                if sub_lvl_1.hasGroup("Applets"):
                    sub_lvl_2 = sub_lvl_1.group("Applets")

                    for sub2 in list(sub_lvl_2.groupList()):
                        sub_lvl_3 = sub_lvl_2.group(sub2)
                        plugin = sub_lvl_3.readEntry('plugin')

                        if plugin == 'folderview':
                            sub_lvl_3.deleteGroup()

        # Desktop Type
        if self.styleSettings["hasChangedDesktopType"]:
            hasChanged = True
            config = KConfig("plasma-desktop-appletsrc")
            group = config.group("Containments")

            for each in list(group.groupList()):
                subgroup = group.group(each)
                subcomponent = subgroup.readEntry('plugin')
                subcomponent2 = subgroup.readEntry('screen')
                if subcomponent == 'desktop' or subcomponent == 'folderview':
                    if int(subcomponent2) == 0:
                        subgroup.writeEntry('plugin', self.styleSettings["desktopType"])

            # Remove folder widget - normally this would be done over dbus but thanks to improper naming of the plasma interface
            # this is not possible
            # ValueError: Invalid interface or error name 'org.kde.plasma-desktop': contains invalid character '-'
            #
            # Related Bug:
            # Bug 240358 - Invalid D-BUS interface name 'org.kde.plasma-desktop.PlasmaApp' found while parsing introspection
            # https://bugs.kde.org/show_bug.cgi?id=240358

            if self.styleSettings["desktopType"] == "folderview":
                removeFolderViewWidget()

            config.sync()

        # Number of Desktops
        if self.styleSettings["hasChangedDesktopNumber"]:
            hasChanged = True
            config = KConfig("kwinrc")
            group = config.group("Desktops")
            group.writeEntry('Number', self.styleSettings["desktopNumber"])
            group.sync()

            info = kdeui.NETRootInfo(QtGui.QX11Info.display(), kdeui.NET.NumberOfDesktops | kdeui.NET.DesktopNames)
            info.setNumberOfDesktops(int(self.styleSettings["desktopNumber"]))
            info.activate()

            session = dbus.SessionBus()

            try:
                proxy = session.get_object('org.kde.kwin', '/KWin')
                proxy.reconfigure()
            except dbus.DBusException:
                pass

            config.sync()

        def deleteIconCache():
            try:
                os.remove("/var/tmp/kdecache-%s/icon-cache.kcache" % os.environ.get("USER"))
            except:
                pass

            for i in range(kdeui.KIconLoader.LastGroup):
                kdeui.KGlobalSettings.self().emitChange(kdeui.KGlobalSettings.IconChanged, i)

        # Theme Settings
        if self.styleSettings["hasChanged"]:
#            if self.styleSettings["iconChanged"]:
#                hasChanged = True
#                configKdeGlobals = KConfig("kdeglobals")
#                group = configKdeGlobals.group("General")
#
#                groupIconTheme = configKdeGlobals.group("Icons")
#                groupIconTheme.writeEntry("Theme", self.styleSettings["iconTheme"])
#
#                configKdeGlobals.sync()
#
#                # Change Icon theme
#                kdeui.KIconTheme.reconfigure()
#                kdeui.KIconCache.deleteCache()
#                deleteIconCache()

            if self.styleSettings["styleChanged"]:
                hasChanged = True
                configKdeGlobals = KConfig("kdeglobals")
                group = configKdeGlobals.group("General")
                group.writeEntry("widgetStyle", self.styleSettings["styleDetails"][unicode(self.styleSettings["styleName"])]["widgetStyle"])

                #groupIconTheme = configKdeGlobals.group("Icons")
                #groupIconTheme.writeEntry("Theme", self.styleSettings["iconTheme"])
                #groupIconTheme.writeEntry("Theme", self.styleSettings["styleDetails"][unicode(self.styleSettings["styleName"])]["iconTheme"])

                configKdeGlobals.sync()

                # Change Icon theme
                kdeui.KIconTheme.reconfigure()
                kdeui.KIconCache.deleteCache()
                deleteIconCache()

                for i in range(kdeui.KIconLoader.LastGroup):
                    kdeui.KGlobalSettings.self().emitChange(kdeui.KGlobalSettings.IconChanged, i)

                # Change widget style & color
                for key, value in self.styleSettings["styleDetails"][unicode(self.styleSettings["styleName"])]["colorScheme"].items():
                    colorGroup = configKdeGlobals.group(key)
                    for key2, value2 in value.items():
                            colorGroup.writeEntry(str(key2), str(value2))

                configKdeGlobals.sync()
                kdeui.KGlobalSettings.self().emitChange(kdeui.KGlobalSettings.StyleChanged)

                configPlasmaRc = KConfig("plasmarc")
                groupDesktopTheme = configPlasmaRc.group("Theme")
                groupDesktopTheme.writeEntry("name", self.styleSettings["styleDetails"][unicode(self.styleSettings["styleName"])]["desktopTheme"])
                configPlasmaRc.sync()

                configPlasmaApplet = KConfig("plasma-desktop-appletsrc")
                group = configPlasmaApplet.group("Containments")
                for each in list(group.groupList()):
                    subgroup = group.group(each)
                    subcomponent = subgroup.readEntry('plugin')
                    if subcomponent == 'panel':
                        #print subcomponent
                        subgroup.writeEntry('location', self.styleSettings["styleDetails"][unicode(self.styleSettings["styleName"])]["panelPosition"])

                configPlasmaApplet.sync()

                configKwinRc = KConfig("kwinrc")
                groupWindowDecoration = configKwinRc.group("Style")
                groupWindowDecoration.writeEntry("PluginLib", self.styleSettings["styleDetails"][unicode(self.styleSettings["styleName"])]["windowDecoration"])
                configKwinRc.sync()

            session = dbus.SessionBus()

            try:
                proxy = session.get_object('org.kde.kwin', '/KWin')
                proxy.reconfigure()
            except dbus.DBusException:
                pass

        # Notifier Settings
        if self.packageSettings["hasChanged"]:
            if self.packageSettings["enabled"]:
                rootActions += "disable_notifier "
            else:
                rootActions += "enable_notifier "

        # Services Settings
        if self.servicesSettings["hasChanged"]:
            if self.servicesSettings["enableCups"] and not self.daemon.isEnabled("org.cups.cupsd"):
                rootActions += "enable_cups "
            elif not self.servicesSettings["enableCups"] and self.daemon.isEnabled("org.cups.cupsd"):
                rootActions += "disable_cups "
            if self.servicesSettings["enableBluetooth"] and not self.daemon.isEnabled("bluetooth"):
                rootActions += "enable_blue "
            elif not self.servicesSettings["enableBluetooth"] and self.daemon.isEnabled("bluetooth"):
                rootActions += "disable_blue "

        # Security Settings
        if self.securitySettings["hasChanged"]:
            if self.securitySettings["enableClam"] and not self.daemon.isEnabled("clamd"):
                rootActions += "enable_clam "
            elif not self.securitySettings["enableClam"] and self.daemon.isEnabled("clamd"):
                rootActions += "disable_clam "
            if self.securitySettings["enableFire"] and not self.daemon.isEnabled("ufw"):
                rootActions += "enable_fire "
            elif not self.securitySettings["enableFire"] and self.daemon.isEnabled("ufw"):
                rootActions += "disable_fire "

        # Extra Settings
        if self.extraSettings["hasChanged"]:
            if self.extraSettings["enableExtra"]:
                rootActions += "enable_extra "
            else:
                rootActions += "disable_extra "

        if hasChanged:
            self.killPlasma()

        if not rootActions == "":
            os.system("kdesu konsole -e kapudan-rootactions " + rootActions)

        return True
コード例 #32
0
ファイル: ScrKeyboard.py プロジェクト: pars-linux/uludag
class Widget(QtGui.QWidget, ScreenWidget):
    screenSettings = {}
    screenSettings["hasChanged"] = False

    # title and description at the top of the dialog window
    title = ki18n("Insert some catchy title about keyboards..")
    desc = ki18n("Select your keyboard layout")

    def __init__(self, *args):
        QtGui.QWidget.__init__(self, None)
        self.ui = Ui_keyboardWidget()
        self.ui.setupUi(self)
        self.ui.picKeyboard.setPixmap(
            QtGui.QPixmap(':/raw/pics/keyboards.png'))

        # get Layout config
        self.config = KConfig("kxkbrc")
        self.group = self.config.group("Layout")
        self.layoutList = str(self.group.readEntry("LayoutList"))
        self.lastLayout = 0

        for lang in localedata.languages:
            for each in localedata.languages[lang].keymaps:
                item = QtGui.QListWidgetItem(self.ui.listWidgetKeyboard)
                item.setText(each.name)
                item.setToolTip(each.xkb_layout)
                item.setStatusTip(each.xkb_variant)
                self.ui.listWidgetKeyboard.addItem(item)

        self.ui.listWidgetKeyboard.connect(self.ui.listWidgetKeyboard,
                                           SIGNAL("itemSelectionChanged()"),
                                           self.setKeyboard)

    def setKeyboard(self):
        layout = self.ui.listWidgetKeyboard.currentItem().toolTip()
        variant = self.ui.listWidgetKeyboard.currentItem().statusTip()

        subprocess.Popen(["setxkbmap", layout, variant])
        if variant:
            self.lastLayout = layout + "(" + variant + ")"
        else:
            self.lastLayout = layout

    def shown(self):
        pass

    def execute(self):
        if self.lastLayout:
            layoutArr = self.layoutList.split(",")

            if self.lastLayout not in layoutArr:
                layoutArr.insert(0, str(self.lastLayout))
            else:
                layoutArr.remove(self.lastLayout)
                layoutArr.insert(0, str(self.lastLayout))

            for i in layoutArr:
                if i == "":
                    layoutArr.remove(i)

            layoutList = ",".join(layoutArr)
            self.group.writeEntry("LayoutList", layoutList)
            self.group.writeEntry("DisplayNames", layoutList)
            self.config.sync()
        return True
コード例 #33
0
ファイル: scrSummary.py プロジェクト: rshipp/kapudan
    def execute(self):
        hasChanged = False
        rootActions = ""

        # Wallpaper Settings
        if self.wallpaperSettings["hasChanged"]:
            hasChanged = True
            if self.wallpaperSettings["selectedWallpaper"]:
                config = KConfig("plasma-desktop-appletsrc")
                group = config.group("Containments")
                for each in list(group.groupList()):
                    subgroup = group.group(each)
                    subcomponent = subgroup.readEntry('plugin')
                    if subcomponent == 'desktop' or subcomponent == 'folderview':
                        subg = subgroup.group('Wallpaper')
                        subg_2 = subg.group('image')
                        subg_2.writeEntry(
                            "wallpaper",
                            self.wallpaperSettings["selectedWallpaper"])

        # Menu Settings
        if self.menuSettings["hasChanged"]:
            hasChanged = True
            config = KConfig("plasma-desktop-appletsrc")
            group = config.group("Containments")

            for each in list(group.groupList()):
                subgroup = group.group(each)
                subcomponent = subgroup.readEntry('plugin')
                if subcomponent == 'panel':
                    subg = subgroup.group('Applets')
                    for i in list(subg.groupList()):
                        subg2 = subg.group(i)
                        launcher = subg2.readEntry('plugin')
                        if str(launcher).find('launcher') >= 0:
                            subg2.writeEntry('plugin',
                                             self.menuSettings["selectedMenu"])

        def removeFolderViewWidget():
            config = KConfig("plasma-desktop-appletsrc")

            sub_lvl_0 = config.group("Containments")

            for sub in list(sub_lvl_0.groupList()):
                sub_lvl_1 = sub_lvl_0.group(sub)

                if sub_lvl_1.hasGroup("Applets"):
                    sub_lvl_2 = sub_lvl_1.group("Applets")

                    for sub2 in list(sub_lvl_2.groupList()):
                        sub_lvl_3 = sub_lvl_2.group(sub2)
                        plugin = sub_lvl_3.readEntry('plugin')

                        if plugin == 'folderview':
                            sub_lvl_3.deleteGroup()

        # Desktop Type
        if self.styleSettings["hasChangedDesktopType"]:
            hasChanged = True
            config = KConfig("plasma-desktop-appletsrc")
            group = config.group("Containments")

            for each in list(group.groupList()):
                subgroup = group.group(each)
                subcomponent = subgroup.readEntry('plugin')
                subcomponent2 = subgroup.readEntry('screen')
                if subcomponent == 'desktop' or subcomponent == 'folderview':
                    if int(subcomponent2) == 0:
                        subgroup.writeEntry('plugin',
                                            self.styleSettings["desktopType"])

            # Remove folder widget - normally this would be done over dbus but thanks to improper naming of the plasma interface
            # this is not possible
            # ValueError: Invalid interface or error name 'org.kde.plasma-desktop': contains invalid character '-'
            #
            # Related Bug:
            # Bug 240358 - Invalid D-BUS interface name 'org.kde.plasma-desktop.PlasmaApp' found while parsing introspection
            # https://bugs.kde.org/show_bug.cgi?id=240358

            if self.styleSettings["desktopType"] == "folderview":
                removeFolderViewWidget()

            config.sync()

        # Number of Desktops
        if self.styleSettings["hasChangedDesktopNumber"]:
            hasChanged = True
            config = KConfig("kwinrc")
            group = config.group("Desktops")
            group.writeEntry('Number', self.styleSettings["desktopNumber"])
            group.sync()

            info = kdeui.NETRootInfo(
                QtGui.QX11Info.display(),
                kdeui.NET.NumberOfDesktops | kdeui.NET.DesktopNames)
            info.setNumberOfDesktops(int(self.styleSettings["desktopNumber"]))
            info.activate()

            session = dbus.SessionBus()

            try:
                proxy = session.get_object('org.kde.kwin', '/KWin')
                proxy.reconfigure()
            except dbus.DBusException:
                pass

            config.sync()

        def deleteIconCache():
            try:
                os.remove("/var/tmp/kdecache-%s/icon-cache.kcache" %
                          os.environ.get("USER"))
            except:
                pass

            for i in range(kdeui.KIconLoader.LastGroup):
                kdeui.KGlobalSettings.self().emitChange(
                    kdeui.KGlobalSettings.IconChanged, i)

        # Theme Settings
        if self.styleSettings["hasChanged"]:
            #            if self.styleSettings["iconChanged"]:
            #                hasChanged = True
            #                configKdeGlobals = KConfig("kdeglobals")
            #                group = configKdeGlobals.group("General")
            #
            #                groupIconTheme = configKdeGlobals.group("Icons")
            #                groupIconTheme.writeEntry("Theme", self.styleSettings["iconTheme"])
            #
            #                configKdeGlobals.sync()
            #
            #                # Change Icon theme
            #                kdeui.KIconTheme.reconfigure()
            #                kdeui.KIconCache.deleteCache()
            #                deleteIconCache()

            if self.styleSettings["styleChanged"]:
                hasChanged = True
                configKdeGlobals = KConfig("kdeglobals")
                group = configKdeGlobals.group("General")
                group.writeEntry(
                    "widgetStyle", self.styleSettings["styleDetails"][unicode(
                        self.styleSettings["styleName"])]["widgetStyle"])

                #groupIconTheme = configKdeGlobals.group("Icons")
                #groupIconTheme.writeEntry("Theme", self.styleSettings["iconTheme"])
                #groupIconTheme.writeEntry("Theme", self.styleSettings["styleDetails"][unicode(self.styleSettings["styleName"])]["iconTheme"])

                configKdeGlobals.sync()

                # Change Icon theme
                kdeui.KIconTheme.reconfigure()
                kdeui.KIconCache.deleteCache()
                deleteIconCache()

                for i in range(kdeui.KIconLoader.LastGroup):
                    kdeui.KGlobalSettings.self().emitChange(
                        kdeui.KGlobalSettings.IconChanged, i)

                # Change widget style & color
                for key, value in self.styleSettings["styleDetails"][unicode(
                        self.styleSettings["styleName"])]["colorScheme"].items(
                        ):
                    colorGroup = configKdeGlobals.group(key)
                    for key2, value2 in value.items():
                        colorGroup.writeEntry(str(key2), str(value2))

                configKdeGlobals.sync()
                kdeui.KGlobalSettings.self().emitChange(
                    kdeui.KGlobalSettings.StyleChanged)

                configPlasmaRc = KConfig("plasmarc")
                groupDesktopTheme = configPlasmaRc.group("Theme")
                groupDesktopTheme.writeEntry(
                    "name", self.styleSettings["styleDetails"][unicode(
                        self.styleSettings["styleName"])]["desktopTheme"])
                configPlasmaRc.sync()

                configPlasmaApplet = KConfig("plasma-desktop-appletsrc")
                group = configPlasmaApplet.group("Containments")
                for each in list(group.groupList()):
                    subgroup = group.group(each)
                    subcomponent = subgroup.readEntry('plugin')
                    if subcomponent == 'panel':
                        #print subcomponent
                        subgroup.writeEntry(
                            'location',
                            self.styleSettings["styleDetails"][unicode(
                                self.styleSettings["styleName"])]
                            ["panelPosition"])

                configPlasmaApplet.sync()

                configKwinRc = KConfig("kwinrc")
                groupWindowDecoration = configKwinRc.group("Style")
                groupWindowDecoration.writeEntry(
                    "PluginLib", self.styleSettings["styleDetails"][unicode(
                        self.styleSettings["styleName"])]["windowDecoration"])
                configKwinRc.sync()

            session = dbus.SessionBus()

            try:
                proxy = session.get_object('org.kde.kwin', '/KWin')
                proxy.reconfigure()
            except dbus.DBusException:
                pass

        # Notifier Settings
        if self.packageSettings["hasChanged"]:
            if self.packageSettings["enabled"]:
                rootActions += "disable_notifier "
            else:
                rootActions += "enable_notifier "

        # Services Settings
        if self.servicesSettings["hasChanged"]:
            if self.servicesSettings[
                    "enableCups"] and not self.daemon.isEnabled(
                        "org.cups.cupsd"):
                rootActions += "enable_cups "
            elif not self.servicesSettings[
                    "enableCups"] and self.daemon.isEnabled("org.cups.cupsd"):
                rootActions += "disable_cups "
            if self.servicesSettings[
                    "enableBluetooth"] and not self.daemon.isEnabled(
                        "bluetooth"):
                rootActions += "enable_blue "
            elif not self.servicesSettings[
                    "enableBluetooth"] and self.daemon.isEnabled("bluetooth"):
                rootActions += "disable_blue "

        # Security Settings
        if self.securitySettings["hasChanged"]:
            if self.securitySettings[
                    "enableClam"] and not self.daemon.isEnabled("clamd"):
                rootActions += "enable_clam "
            elif not self.securitySettings[
                    "enableClam"] and self.daemon.isEnabled("clamd"):
                rootActions += "disable_clam "
            if self.securitySettings[
                    "enableFire"] and not self.daemon.isEnabled("ufw"):
                rootActions += "enable_fire "
            elif not self.securitySettings[
                    "enableFire"] and self.daemon.isEnabled("ufw"):
                rootActions += "disable_fire "

        # Extra Settings
        if self.extraSettings["hasChanged"]:
            if self.extraSettings["enableExtra"]:
                rootActions += "enable_extra "
            else:
                rootActions += "disable_extra "

        if hasChanged:
            self.killPlasma()

        if not rootActions == "":
            os.system("kdesu konsole -e kapudan-rootactions " + rootActions)

        return True
コード例 #34
0
class FuzzyOpen(QDialog):
    reason = ""

    def __init__(self, parent=None, connections={}):
        self.urls = []
        self.projectPaths = []

        QDialog.__init__(self, parent)
        uic.loadUi(os.path.join(os.path.dirname(__file__), "fuzzyopen.ui"), self)
        self.setModal(True)
        self.listUrl.setItemDelegate(HtmlItemDelegate(self.listUrl))
        self.hideProgress()

        self.iconLoader = KIconLoader()
        self.btnSettings.setIcon(QIcon(self.iconLoader.loadIcon("configure", KIconLoader.Small)))
        self.btnRefresh.setIcon(QIcon(self.iconLoader.loadIcon("view-refresh", KIconLoader.Small)))

        self.config = KConfig("katefuzzyopenrc")
        configPaths = self.config.group("ProjectPaths")
        for key in configPaths.keyList():
            path = configPaths.readPathEntry(key, "")
            if not path.endswith("/"):
                path += "/"
            self.projectPaths.append(path)

        configFilters = self.config.group("Filters")
        self.lister = DirLister()
        self.lister.fileFound.connect(self.listerFileFound)
        self.lister.directoryChanged.connect(self.listerDirChanged)
        self.lister.completed.connect(self.listerCompleted)
        self.lister.setIncludeFilters(configFilters.readEntry("include", ""))
        self.lister.setExcludeFilters(configFilters.readEntry("exclude", "~$\n\.bak$\n/\."))

    def showEvent(self, event):
        katerect = kate.mainInterfaceWindow().window().rect()
        diarect = self.rect()
        diarect.moveCenter(katerect.center())
        self.move(diarect.topLeft())

        self.reset()
        self.list()

    def getProjectUrl(self, url):
        for path in self.projectPaths:
            if url.url().startswith(path):
                return path
        return False

    def showProgress(self, text):
        self.lblProgress.setText(text)
        self.lblProgress.show()

    def hideProgress(self):
        self.lblProgress.hide()

    def reset(self):
        self.urls = []
        self.txtFilter.setText("")
        self.txtFilter.setFocus()
        self.listUrl.clear()
        self.lister.stop()

    def list(self):
        url = kate.activeDocument().url()
        self.project = self.getProjectUrl(url)

        for doc in kate.documentManager.documents():
            self.addFileUrl(doc.url(), "Open document")

        if self.project:
            self.reason = "In project %s" % self.project
            self.rootPath = KUrl(self.project)
        else:
            self.reason = "Same path of %s" % url.fileName()
            self.rootPath = url.upUrl()

        self.lister.list(self.rootPath, recurse=self.project != False)

    def addFileUrl(self, url, reason=None):
        if url not in self.urls:
            mime = KMimeType.findByUrl(url)[0]
            path = url.url()
            filename = url.fileName()

            item = QListWidgetItem()
            if self.project and path.startswith(self.project):
                path = path[len(self.project):]
                item.setWhatsThis(path)
                item.setText("<b>%s</b>: <i>%s</i>" % (filename, path))
            else:
                item.setWhatsThis(filename)
                item.setText("<b>%s</b>" % filename)
            if reason:
                item.setToolTip(reason)
            item.setIcon(QIcon(self.iconLoader.loadMimeTypeIcon(mime.iconName(), KIconLoader.Small)))
            self.listUrl.addItem(item)

            if url.fileName().find(self.txtFilter.text()) < 0:
                self.listUrl.setItemHidden(item, True)
            self.urls.append(url)

            self.refreshFilter()

    def refreshFilter(self):
        self.on_txtFilter_textEdited(self.txtFilter.text())

    def on_txtFilter_textEdited(self, s):
        firstMatch = -1
        pattern = re.compile(".*".join([re.escape(c) for c in s]), re.I)
        for i in range(self.listUrl.count()):
            matched = pattern.search(self.listUrl.item(i).whatsThis())
            if matched and firstMatch < 0:
                firstMatch = i
            self.listUrl.setItemHidden(self.listUrl.item(i), matched is None)
        self.listUrl.setItemSelected(self.listUrl.item(firstMatch), True)

    def on_txtFilter_keyPressed(self, event):
        selected = self.listUrl.selectedItems()
        if selected:
            current_index = self.listUrl.row(selected[0])
        else:
            current_index = -1

        increment = 0
        if event.key() == Qt.Key_Up:
            increment = -1
        elif event.key() == Qt.Key_Down:
            increment = 1

        if increment != 0:
            current_index += increment
            while 0 <= current_index < self.listUrl.count():
                if self.listUrl.isRowHidden(current_index):
                    current_index += increment
                else:
                    self.listUrl.setItemSelected(self.listUrl.item(current_index), True)
                    current_index = -1

    def on_txtFilter_returnPressed(self):
        if len(self.listUrl.selectedItems()) > 0:
            self.on_listUrl_itemActivated(self.listUrl.selectedItems()[0])

    def on_listUrl_itemActivated(self, item):
        self.lister.stop()
        self.close()
        i = self.listUrl.row(item)
        if 0 <= i < len(self.urls):
            url = self.urls[i]
            kate.mainInterfaceWindow().activateView(kate.documentManager.openUrl(url))

    @pyqtSignature("")
    def on_btnSettings_clicked(self):
        settingsDialog = SettingsDialog(kate.activeDocument().url(), self)
        settingsDialog.txtIncludePatterns.setPlainText("\n".join([r.pattern for r in self.lister.includeFilters]))
        settingsDialog.txtExcludePatterns.setPlainText("\n".join([r.pattern for r in self.lister.excludeFilters]))
        for path in self.projectPaths:
            settingsDialog.listProjectPaths.addItem(path)

        if settingsDialog.exec_():
            configPaths = self.config.group("ProjectPaths")
            for key in configPaths.keyList():
                configPaths.deleteEntry(key)
            self.projectPaths = []
            i = 0
            while i < settingsDialog.listProjectPaths.count():
                item = settingsDialog.listProjectPaths.item(i)
                configPaths.writePathEntry("path%s" % i, item.text())
                self.projectPaths.append(item.text())
                i += 1

            configFilters = self.config.group("Filters")
            includeFilters = settingsDialog.txtIncludePatterns.toPlainText()
            self.lister.setIncludeFilters(includeFilters)
            configFilters.writeEntry("include", includeFilters)

            excludeFilters = settingsDialog.txtExcludePatterns.toPlainText()
            self.lister.setExcludeFilters(excludeFilters)
            configFilters.writeEntry("exclude", excludeFilters)

            self.config.sync()

    @pyqtSignature("")
    def on_btnRefresh_clicked(self):
        url = self.rootPath.url()
        for k in self.lister.cache.keys():
            if k.startswith(url):
                del self.lister.cache[k]
        self.reset()
        self.list()

    def listerFileFound(self, url):
        QApplication.processEvents()
        self.addFileUrl(url, self.reason)

    def listerDirChanged(self, url):
        self.showProgress(url.url())

    def listerCompleted(self):
        self.hideProgress()
コード例 #35
0
ファイル: scrSummary.py プロジェクト: circass/pisi-work
    def shown(self):
        self.wallpaperSettings = wallpaperWidget.Widget.screenSettings
        self.mouseSettings = mouseWidget.Widget.screenSettings
        self.menuSettings = menuWidget.Widget.screenSettings
        self.styleSettings = styleWidget.Widget.screenSettings
        self.avatarSettings = avatarWidget.Widget.screenSettings

        subject = "<p><li><b>%s</b></li><ul>"
        item    = "<li>%s</li>"
        end     = "</ul></p>"
        content = QString("")

        content.append("""<html><body><ul>""")

        # Mouse Settings
        content.append(subject % ki18n("Mouse Settings").toString())

        content.append(item % ki18n("Selected Mouse configuration: <b>%s</b>").toString() % self.mouseSettings["summaryMessage"]["selectedMouse"].toString())
        content.append(item % ki18n("Selected clicking behaviour: <b>%s</b>").toString() % self.mouseSettings["summaryMessage"]["clickBehaviour"].toString())
        content.append(end)

        # Menu Settings
        content.append(subject % ki18n("Menu Settings").toString())
        content.append(item % ki18n("Selected Menu: <b>%s</b>").toString() % self.menuSettings["summaryMessage"].toString())
        content.append(end)

        # Wallpaper Settings
        content.append(subject % ki18n("Wallpaper Settings").toString())
        if not self.wallpaperSettings["hasChanged"]:
            content.append(item % ki18n("You haven't selected any wallpaper.").toString())
        else:
            content.append(item % ki18n("Selected Wallpaper: <b>%s</b>").toString() % os.path.basename(str(self.wallpaperSettings["selectedWallpaper"])))
        content.append(end)

        # Style Settings
        content.append(subject % ki18n("Style Settings").toString())

        if not self.styleSettings["hasChanged"]:
            content.append(item % ki18n("You haven't selected any style.").toString())
        else:
            content.append(item % ki18n("Selected Style: <b>%s</b>").toString() % unicode(self.styleSettings["summaryMessage"]))

        content.append(end)

        # Wallpaper Settings
        if self.wallpaperSettings["hasChanged"]:
            hasChanged = True
            if self.wallpaperSettings["selectedWallpaper"]:
                config =  KConfig("plasma-desktop-appletsrc")
                group = config.group("Containments")
                for each in list(group.groupList()):
                    subgroup = group.group(each)
                    subcomponent = subgroup.readEntry('plugin')
                    if subcomponent == 'desktop' or subcomponent == 'folderview':
                        subg = subgroup.group('Wallpaper')
                        subg_2 = subg.group('image')
                        subg_2.writeEntry("wallpaper", self.wallpaperSettings["selectedWallpaper"])

        # Menu Settings
        if self.menuSettings["hasChanged"]:
            hasChanged = True
            config = KConfig("plasma-desktop-appletsrc")
            group = config.group("Containments")

            for each in list(group.groupList()):
                subgroup = group.group(each)
                subcomponent = subgroup.readEntry('plugin')
                if subcomponent == 'panel':
                    subg = subgroup.group('Applets')
                    for i in list(subg.groupList()):
                        subg2 = subg.group(i)
                        launcher = subg2.readEntry('plugin')
                        if str(launcher).find('launcher') >= 0:
                            subg2.writeEntry('plugin', self.menuSettings["selectedMenu"] )


        def removeFolderViewWidget():
            config = KConfig("plasma-desktop-appletsrc")

            sub_lvl_0 = config.group("Containments")

            for sub in list(sub_lvl_0.groupList()):
                sub_lvl_1 = sub_lvl_0.group(sub)

                if sub_lvl_1.hasGroup("Applets"):
                    sub_lvl_2 = sub_lvl_1.group("Applets")

                    for sub2 in list(sub_lvl_2.groupList()):
                        sub_lvl_3 = sub_lvl_2.group(sub2)
                        plugin = sub_lvl_3.readEntry('plugin')

                        if plugin == 'folderview':
                            sub_lvl_3.deleteGroup()


        # Desktop Type
        if self.styleSettings["hasChangedDesktopType"]:
            hasChanged = True
            config =  KConfig("plasma-desktop-appletsrc")
            group = config.group("Containments")

            for each in list(group.groupList()):
                subgroup = group.group(each)
                subcomponent = subgroup.readEntry('plugin')
                subcomponent2 = subgroup.readEntry('screen')
                if subcomponent == 'desktop' or subcomponent == 'folderview':
                    if int(subcomponent2) == 0:
                        subgroup.writeEntry('plugin', self.styleSettings["desktopType"])

            # Remove folder widget - normally this would be done over dbus but thanks to improper naming of the plasma interface
            # this is not possible
            # ValueError: Invalid interface or error name 'org.kde.plasma-desktop': contains invalid character '-'
            #
            # Related Bug:
            # Bug 240358 - Invalid D-BUS interface name 'org.kde.plasma-desktop.PlasmaApp' found while parsing introspection
            # https://bugs.kde.org/show_bug.cgi?id=240358

            if self.styleSettings["desktopType"] == "folderview":
                removeFolderViewWidget()

            config.sync()

        # Number of Desktops
        if self.styleSettings["hasChangedDesktopNumber"]:
            hasChanged = True
            config = KConfig("kwinrc")
            group = config.group("Desktops")
            group.writeEntry('Number', self.styleSettings["desktopNumber"])
            group.sync()

            info =  kdeui.NETRootInfo(QtGui.QX11Info.display(), kdeui.NET.NumberOfDesktops | kdeui.NET.DesktopNames)
            info.setNumberOfDesktops(int(self.styleSettings["desktopNumber"]))
            info.activate()

            session = dbus.SessionBus()

            try:
                proxy = session.get_object('org.kde.kwin', '/KWin')
                proxy.reconfigure()
            except dbus.DBusException:
                pass

            config.sync()


        def deleteIconCache():
            try:
                os.remove("/var/tmp/kdecache-%s/icon-cache.kcache" % os.environ.get("USER"))
            except:
                pass

            for i in range(kdeui.KIconLoader.LastGroup):
                kdeui.KGlobalSettings.self().emitChange(kdeui.KGlobalSettings.IconChanged, i)


        # Theme Settings
        if self.styleSettings["hasChanged"]:
            if self.styleSettings["iconChanged"]:
                hasChanged = True
                configKdeGlobals = KConfig("kdeglobals")
                group = configKdeGlobals.group("General")

                groupIconTheme = configKdeGlobals.group("Icons")
                groupIconTheme.writeEntry("Theme", self.styleSettings["iconTheme"])

                configKdeGlobals.sync()

                # Change Icon theme
                kdeui.KIconTheme.reconfigure()
                kdeui.KIconCache.deleteCache()
                deleteIconCache()

            if self.styleSettings["styleChanged"]:
                hasChanged = True
                configKdeGlobals = KConfig("kdeglobals")
                group = configKdeGlobals.group("General")
                group.writeEntry("widgetStyle", self.styleSettings["styleDetails"][unicode(self.styleSettings["styleName"])]["widgetStyle"])

                groupIconTheme = configKdeGlobals.group("Icons")
                groupIconTheme.writeEntry("Theme", self.styleSettings["iconTheme"])
                #groupIconTheme.writeEntry("Theme", self.styleSettings["styleDetails"][unicode(self.styleSettings["styleName"])]["iconTheme"])

                configKdeGlobals.sync()

                # Change Icon theme
                kdeui.KIconTheme.reconfigure()
                kdeui.KIconCache.deleteCache()
                deleteIconCache()

                for i in range(kdeui.KIconLoader.LastGroup):
                    kdeui.KGlobalSettings.self().emitChange(kdeui.KGlobalSettings.IconChanged, i)

                # Change widget style & color
                for key, value in self.styleSettings["styleDetails"][unicode(self.styleSettings["styleName"])]["colorScheme"].items():
                    colorGroup = configKdeGlobals.group(key)
                    for key2, value2 in value.items():
                            colorGroup.writeEntry(str(key2), str(value2))

                configKdeGlobals.sync()
                kdeui.KGlobalSettings.self().emitChange(kdeui.KGlobalSettings.StyleChanged)

                configPlasmaRc = KConfig("plasmarc")
                groupDesktopTheme = configPlasmaRc.group("Theme")
                groupDesktopTheme.writeEntry("name", self.styleSettings["styleDetails"][unicode(self.styleSettings["styleName"])]["desktopTheme"])
                configPlasmaRc.sync()

                configPlasmaApplet = KConfig("plasma-desktop-appletsrc")
                group = configPlasmaApplet.group("Containments")
                for each in list(group.groupList()):
                    subgroup = group.group(each)
                    subcomponent = subgroup.readEntry('plugin')
                    if subcomponent == 'panel':
                        #print subcomponent
                        subgroup.writeEntry('location', self.styleSettings["styleDetails"][unicode(self.styleSettings["styleName"])]["panelPosition"])

                configPlasmaApplet.sync()

                configKwinRc = KConfig("kwinrc")
                groupWindowDecoration = configKwinRc.group("Style")
                groupWindowDecoration.writeEntry("PluginLib", self.styleSettings["styleDetails"][unicode(self.styleSettings["styleName"])]["windowDecoration"])
                configKwinRc.sync()

            session = dbus.SessionBus()

            try:
                proxy = session.get_object('org.kde.kwin', '/KWin')
                proxy.reconfigure()
            except dbus.DBusException:
                pass


        # Avatar Settings
        if self.avatarSettings["hasChanged"]:
            hasChanged = True

        if hasChanged:
            self.killPlasma()

        return True
コード例 #36
0
    def setStyleSettings(self):

        if scrStyleWidget.screenSettings["iconChanged"]:
            hasChanged = True
            configKdeGlobals = KConfig("kdeglobals")
            group = configKdeGlobals.group("General")

            groupIconTheme = configKdeGlobals.group("Icons")
            groupIconTheme.writeEntry(
                "Theme", scrStyleWidget.screenSettings["iconTheme"])

            configKdeGlobals.sync()

            # Change Icon theme
            kdeui.KIconTheme.reconfigure()
            kdeui.KIconCache.deleteCache()
            deleteIconCache()

        if scrStyleWidget.screenSettings["styleChanged"]:
            hasChanged = True
            configKdeGlobals = KConfig("kdeglobals")
            group = configKdeGlobals.group("General")
            group.writeEntry(
                "widgetStyle",
                scrStyleWidget.screenSettings["styleDetails"][unicode(
                    scrStyleWidget.screenSettings["styleName"])]
                ["widgetStyle"])
            groupIconTheme = configKdeGlobals.group("Icons")
            groupIconTheme.writeEntry(
                "Theme", scrStyleWidget.screenSettings["iconTheme"])
            #groupIconTheme.writeEntry("Theme", scrStyleWidget.screenSettings["styleDetails"][unicode(scrStyleWidget.screenSettings["styleName"])]["iconTheme"])

            configKdeGlobals.sync()

            # Change Icon theme
            kdeui.KIconTheme.reconfigure()
            kdeui.KIconCache.deleteCache()
            deleteIconCache()

            for i in range(kdeui.KIconLoader.LastGroup):
                kdeui.KGlobalSettings.self().emitChange(
                    kdeui.KGlobalSettings.IconChanged, i)

            # Change widget style & color
            for key, value in scrStyleWidget.screenSettings["styleDetails"][
                    unicode(scrStyleWidget.screenSettings["styleName"]
                            )]["colorScheme"].items():
                colorGroup = configKdeGlobals.group(key)
                for key2, value2 in value.items():
                    colorGroup.writeEntry(str(key2), str(value2))

            configKdeGlobals.sync()
            kdeui.KGlobalSettings.self().emitChange(
                kdeui.KGlobalSettings.StyleChanged)

            configPlasmaRc = KConfig("plasmarc")
            groupDesktopTheme = configPlasmaRc.group("Theme")
            groupDesktopTheme.writeEntry(
                "name", scrStyleWidget.screenSettings["styleDetails"][unicode(
                    scrStyleWidget.screenSettings["styleName"])]
                ["desktopTheme"])
            configPlasmaRc.sync()

            configPlasmaApplet = KConfig("plasma-desktop-appletsrc")
            group = configPlasmaApplet.group("Containments")
            for each in list(group.groupList()):
                subgroup = group.group(each)
                subcomponent = subgroup.readEntry('plugin')
                if subcomponent == 'panel':
                    #print subcomponent
                    subgroup.writeEntry(
                        'location',
                        scrStyleWidget.screenSettings["styleDetails"][unicode(
                            scrStyleWidget.screenSettings["styleName"])]
                        ["panelPosition"])

            configPlasmaApplet.sync()

            configKwinRc = KConfig("kwinrc")
            groupWindowDecoration = configKwinRc.group("Style")
            groupWindowDecoration.writeEntry(
                "PluginLib",
                scrStyleWidget.screenSettings["styleDetails"][unicode(
                    scrStyleWidget.screenSettings["styleName"])]
                ["windowDecoration"])
            configKwinRc.sync()

        session = dbus.SessionBus()

        try:
            proxy = session.get_object('org.kde.kwin', '/KWin')
            proxy.reconfigure()
        except dbus.DBusException:
            pass