예제 #1
0
    def __init__(self, *args):
        QtGui.QWidget.__init__(self,None)
        self.ui = Ui_mouseWidget()
        self.ui.setupUi(self)

        # Our default click behavior is double click. So make SingleClick = false (kdeglobals)
        self.clickBehavior = False

        # read default settings
        try:
            config = KConfig("kcminputrc")
            group = config.group("Mouse")
            self.__class__.screenSettings["selectedMouse"] = group.readEntry("MouseButtonMapping")

            config = KConfig("kdeglobals")
            group = config.group("KDE")

            self.__class__.screenSettings["selectedBehavior"] = str(group.readEntry("SingleClick"))

            self.ui.singleClick.setChecked(self.str2bool(self.__class__.screenSettings["selectedBehavior"]))
            self.clickBehavior = self.str2bool(self.__class__.screenSettings["selectedBehavior"])

            if self.__class__.screenSettings["selectedMouse"] == "LeftHanded":
                self.ui.radioButtonLeftHand.setChecked(True)

        except:
            pass

        # set signals
        self.connect(self.ui.radioButtonRightHand, SIGNAL("toggled(bool)"), self.setHandedness)
        self.connect(self.ui.checkReverse, SIGNAL("toggled(bool)"), self.setHandedness)
        self.connect(self.ui.singleClick, SIGNAL("clicked()"), self.clickBehaviorToggle)
        self.connect(self.ui.DoubleClick, SIGNAL("clicked()"), self.clickBehaviorToggle)
예제 #2
0
 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
    def __init__(self, *args):
        QtGui.QWidget.__init__(self,None)
        self.ui = Ui_mouseWidget()
        self.ui.setupUi(self)

        # Our default click behaviour is double click. So make SingleClick = false (kdeglobals)
        self.clickBehaviour = "False"

        # read default settings

        try:
            config = KConfig("kcminputrc")
            group = config.group("Mouse")
            self.__class__.screenSettings["selectedMouse"] =  group.readEntry("MouseButtonMapping")

            config = KConfig("kdeglobals")
            group = config.group("KDE")
            self.__class__.screenSettings["selectedBehaviour"] = str(group.readEntry("SingleClick"))

            self.ui.singleClick.setChecked(self.str2bool(self.__class__.screenSettings["selectedBehaviour"]))
            self.clickBehaviour = self.str2bool(self.__class__.screenSettings["selectedBehaviour"])

            if self.__class__.screenSettings["selectedMouse"] == "LeftHanded":
                self.ui.radioButtonLeftHand.setChecked(True)

        except:
            pass

        # set signals
        self.connect(self.ui.radioButtonRightHand, SIGNAL("toggled(bool)"), self.setHandedness)
        self.connect(self.ui.checkReverse, SIGNAL("toggled(bool)"), self.setHandedness)
예제 #4
0
 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 프로젝트: 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
예제 #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(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
예제 #7
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
예제 #8
0
    def __init__(self, *args):
        QtGui.QWidget.__init__(self, None)
        self.ui = Ui_mouseWidget()
        self.ui.setupUi(self)

        # Our default click behavior is single click. So make SingleClick = true (kdeglobals)
        self.clickBehavior = "False"

        # read default settings
        try:
            config = KConfig("kcminputrc")
            group = config.group("Mouse")
            self.__class__.screenSettings["selectedMouse"] = group.readEntry("MouseButtonMapping")

            config = KConfig("kdeglobals")
            group = config.group("KDE")

            self.__class__.screenSettings["selectedBehavior"] = str(group.readEntry("SingleClick"))
            # TODO: change this, put single click on top in the ui
            self.ui.singleClick.setChecked(True)

            self.ui.singleClick.setChecked(self.str2bool(self.__class__.screenSettings["selectedBehavior"]))
            self.clickBehavior = self.str2bool(self.__class__.screenSettings["selectedBehavior"])

            if self.__class__.screenSettings["selectedMouse"] == "LeftHanded":
                self.ui.radioButtonLeftHand.setChecked(True)

        except:
            print "Initial mouse config file."
            pass

	# ELLENORZES HOGY EGYALTALAN MILYEN TOUCHPAD VAN A GEPBEN
	srcTouchPad = commands.getoutput("egrep -i 'synap|alps|etps' /proc/bus/input/devices 2>/dev/null")

	if srcTouchPad == "":
	    print "TouchPad not found"
	    self.ui.labelTouchPadPdesc.setText("Touchpad Not Found or not available")
	    self.ui.pushTouchPadButton.setDisabled(True)
	else:
	    print "TouchPad device found:",srcTouchPad.replace("N: Name=","")

	srcMouse = commands.getoutput("egrep 'Mouse|mouse' /proc/bus/input/devices 2>/dev/null")
	if srcMouse == "":
	    print "Mouse not found"
	    self.ui.labelTouchPadPdesc.setText("<b>Mouse Not Found or not available</b>")
	    self.ui.pushTouchPadButton.setDisabled(True)
	else:
	    print "Mouse device found"

        # set signals
        self.ui.radioButtonRightHand.toggled.connect(self.setHandedness)
        self.ui.checkReverse.toggled.connect(self.setHandedness)
        self.ui.singleClick.clicked.connect(self.clickBehaviorToggle)
        self.ui.DoubleClick.clicked.connect(self.clickBehaviorToggle)
        self.ui.pushTouchPadButton.clicked.connect( self.setTouchPad)
예제 #9
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()
예제 #10
0
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)
예제 #11
0
    def __init__(self, *args):
        QtGui.QWidget.__init__(self, None)
        self.ui = Ui_menuWidget()
        self.ui.setupUi(self)

        # read default menu style first
        config = KConfig("plasma-desktop-appletsrc")
        group = config.group("Containments")

        self.menuNames = {}
        self.menuNames["launcher"] = {
            "menuIndex": 0,
            "summaryMessage": ki18n("Kick-off Menu"),
            "image": QtGui.QPixmap(":/raw/pixmap/kickoff.png"),
            "description": ki18n(
                "Kick-off menu is the default menu of Pisi Linux.<br><br>The program shortcuts are easy to access and well organized."
            ),
        }
        self.menuNames["simplelauncher"] = {
            "menuIndex": 1,
            "summaryMessage": ki18n("Simple Menu"),
            "image": QtGui.QPixmap(":/raw/pixmap/simple.png"),
            "description": ki18n(
                "Simple menu is an old style menu from KDE 3.<br><br>It is a very lightweight menu thus it is recommended for slower PC's."
            ),
        }
        self.menuNames["lancelot_launcher"] = {
            "menuIndex": 2,
            "summaryMessage": ki18n("Lancelot Menu"),
            "image": QtGui.QPixmap(":/raw/pixmap/lancelot.png"),
            "description": ki18n(
                "Lancelot is an advanced and highly customizable menu for Pisi Linux.<br><br>The program shortcuts are easy to access and well organized."
            ),
        }

        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:
                        self.__class__.screenSettings["selectedMenu"] = subg2.readEntry("plugin")

        # set menu preview to default menu
        # if default menu could not found, default to kickoff
        if not self.__class__.screenSettings.has_key("selectedMenu"):
            self.__class__.screenSettings["selectedMenu"] = "launcher"

        self.ui.pictureMenuStyles.setPixmap(self.menuNames[str(self.__class__.screenSettings["selectedMenu"])]["image"])
        self.ui.labelMenuDescription.setText(
            self.menuNames[str(self.__class__.screenSettings["selectedMenu"])]["description"].toString()
        )
        self.ui.menuStyles.setCurrentIndex(
            self.menuNames[str(self.__class__.screenSettings["selectedMenu"])]["menuIndex"]
        )

        self.ui.menuStyles.connect(self.ui.menuStyles, SIGNAL("activated(const QString &)"), self.setMenuStyle)
예제 #12
0
def installKateModeRC():
    """ Preset a few variables in the LilyPond Kate mode """
    katemoderc = KConfig("katemoderc", KConfig.NoGlobals)
    rc = katemoderc.group("LilyPond")
    rc.writeEntry("Variables", "kate: "
        "indent-mode lilypond; "
        )
    rc.sync()
예제 #13
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, value)
        self.config.sync()
예제 #14
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()
예제 #15
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()
예제 #16
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
예제 #17
0
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)
예제 #18
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()
예제 #19
0
    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)
예제 #20
0
def applyTheme(themeName):
    ''' @summary: apply themefile to plasmarc
        @param themeName: theme name - use os.path.basename of any of listThemes()
        @attention: we don't check if theme is correct
    '''
    if not isinstance(themeName, str):
        raise ValueError ('themeName must be str object')
    assert (themeName in (os.path.basename(p) for p in listThemes()))
    plasma = KConfig('plasmarc', KConfig.NoGlobals)
    themegr = plasma.group('Theme')
    themegr.writeEntry('name', themeName)
예제 #21
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)
예제 #22
0
        def getResourceConfigGroup(account):
            """Get Resource Config Groups for account type"""

            accountGroups = []
            if account["type"] =="SMTP":
                config = KConfig("mailtransports")
                generalGroup = config.group("General")
                defaultAccount = generalGroup.readEntry("default-transport")
                if defaultAccount:
                    groupname = QString("Transport ").append(defaultAccount)
                    transportGroup = config.group(groupname)
                    accountGroups.append(transportGroup)
                    return accountGroups[0]
            else:
                config = KConfig("kmailrc")
                for each in list(config.groupList()):
                    if each.contains("Account") and not each.endsWith("Wizard"):
                        account = config.group(each)
                        accountGroups.append(account)
            return accountGroups
예제 #23
0
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)
예제 #24
0
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)
예제 #25
0
        def getResourceConfigGroup(account):
            """Get Resource Config Groups for account type"""

            accountGroups = []
            if account["type"] == "SMTP":
                config = KConfig("mailtransports")
                generalGroup = config.group("General")
                defaultAccount = generalGroup.readEntry("default-transport")
                if defaultAccount:
                    groupname = QString("Transport ").append(defaultAccount)
                    transportGroup = config.group(groupname)
                    accountGroups.append(transportGroup)
                    return accountGroups[0]
            else:
                config = KConfig("kmailrc")
                for each in list(config.groupList()):
                    if each.contains(
                            "Account") and not each.endsWith("Wizard"):
                        account = config.group(each)
                        accountGroups.append(account)
            return accountGroups
예제 #26
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)
예제 #27
0
파일: app.py 프로젝트: Alwnikrotikz/lilykde
 def kateModeVariables(self):
     """Returns a dict with katemoderc variables.
     
     The current mode is used. Returns None if there is no document mode
     active and there is no application default mode.
     
     """
     mode = self.doc and self.doc.mode() or self.app.defaultMode
     if mode:
         c = KConfig("katemoderc", KConfig.NoGlobals)
         v = c.group(mode).readEntry("Variables", "")
         return dict(re.findall(r"([a-z]+(?:-[a-z]+)*)\s+([^;]*)", v))
예제 #28
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)
예제 #29
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
예제 #30
0
    def __init__(self, *args):
        QtGui.QWidget.__init__(self, None)
        self.ui = Ui_mouseWidget()
        self.ui.setupUi(self)

        # Our default click behavior is single click. So make SingleClick = true (kdeglobals)
        self.clickBehavior = True

        # read default settings
        try:
            config = KConfig("kcminputrc")
            group = config.group("Mouse")
            self.__class__.screenSettings["selectedMouse"] = group.readEntry(
                "MouseButtonMapping")

            config = KConfig("kdeglobals")
            group = config.group("KDE")

            self.__class__.screenSettings["selectedBehavior"] = str(
                group.readEntry("SingleClick"))
            # TODO: change this, put single click on top in the ui
            self.ui.singleClick.setChecked(True)

            self.ui.singleClick.setChecked(
                self.str2bool(
                    self.__class__.screenSettings["selectedBehavior"]))
            self.clickBehavior = self.str2bool(
                self.__class__.screenSettings["selectedBehavior"])

            if self.__class__.screenSettings["selectedMouse"] == "LeftHanded":
                self.ui.radioButtonLeftHand.setChecked(True)

        except:
            pass

        # set signals
        self.ui.radioButtonRightHand.toggled.connect(self.setHandedness)
        self.ui.checkReverse.toggled.connect(self.setHandedness)
        self.ui.singleClick.clicked.connect(self.clickBehaviorToggle)
        self.ui.DoubleClick.clicked.connect(self.clickBehaviorToggle)
예제 #31
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
예제 #32
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)
예제 #33
0
    def __init__(self, *args):
        QtGui.QWidget.__init__(self,None)
        self.ui = Ui_menuWidget()
        self.ui.setupUi(self)

        # read default menu style first
        config = KConfig("plasma-desktop-appletsrc")
        group = config.group("Containments")

        self.menuNames = {}
        self.menuNames["launcher"] = {
                "menuIndex": 0,
                "summaryMessage": ki18n("Kick-off Menu"),
                "image": QtGui.QPixmap(':/raw/pixmap/kickoff.png'),
                "description": ki18n("Kick-off menu is the default menu of Pisi Linux.<br><br>The program shortcuts are easy to access and well organized.")
                }
        self.menuNames["simplelauncher"] = {
                "menuIndex": 1,
                "summaryMessage": ki18n("Simple Menu"),
                "image": QtGui.QPixmap(':/raw/pixmap/simple.png'),
                "description": ki18n("Simple menu is an old style menu from KDE 3.<br><br>It is a very lightweight menu thus it is recommended for slower PC's.")
                }
        self.menuNames["lancelot_launcher"] = {
                "menuIndex": 2,
                "summaryMessage": ki18n("Lancelot Menu"),
                "image": QtGui.QPixmap(':/raw/pixmap/lancelot.png'),
                "description": ki18n("Lancelot is an advanced and highly customizable menu for Pisi Linux.<br><br>The program shortcuts are easy to access and well organized.")
                }

        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:
                        self.__class__.screenSettings["selectedMenu"] =  subg2.readEntry('plugin')

        # set menu preview to default menu
        # if default menu could not found, default to kickoff
        if not self.__class__.screenSettings.has_key("selectedMenu"):
            self.__class__.screenSettings["selectedMenu"] =  "launcher"

        self.ui.pictureMenuStyles.setPixmap(self.menuNames[str(self.__class__.screenSettings["selectedMenu"])]["image"])
        self.ui.labelMenuDescription.setText(self.menuNames[str(self.__class__.screenSettings["selectedMenu"])]["description"].toString())
        self.ui.menuStyles.setCurrentIndex(self.menuNames[str(self.__class__.screenSettings["selectedMenu"])]["menuIndex"])

        self.ui.menuStyles.connect(self.ui.menuStyles, SIGNAL("activated(const QString &)"), self.setMenuStyle)
예제 #34
0
    def __init__(self, *args):
        QtGui.QWidget.__init__(self, None)
        self.ui = Ui_menuWidget()
        self.ui.setupUi(self)

        # read default menu style first
        config = KConfig("plasma-appletsrc")
        group = config.group("Containments")

        self.menuNames = {}
        self.menuNames["launcher"] = {
            "menuIndex": 0,
            "summaryMessage": ki18n("Kick-off Menu"),
            "image": QtGui.QPixmap(":/raw/pics/kickoff.png"),
            "description": ki18n("Default menu of Pardus GNU/Linux."),
        }
        self.menuNames["simplelauncher"] = {
            "menuIndex": 1,
            "summaryMessage": ki18n("Simple Menu"),
            "image": QtGui.QPixmap(":/raw/pics/simple.png"),
            "description": ki18n("An old style menu from KDE 3."),
        }
        self.menuNames["lancelot_launcher"] = {
            "menuIndex": 2,
            "summaryMessage": ki18n("Lancelot Menu"),
            "image": QtGui.QPixmap(":/raw/pics/lancelot.png"),
            "description": ki18n("An advanced menu for KDE4."),
        }

        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:
                        self.__class__.screenSettings["selectedMenu"] = subg2.readEntry("plugin")

        # set menu preview to default menu
        self.ui.pictureMenuStyles.setPixmap(self.menuNames[str(self.__class__.screenSettings["selectedMenu"])]["image"])
        self.ui.labelMenuDescription.setText(
            self.menuNames[str(self.__class__.screenSettings["selectedMenu"])]["description"].toString()
        )
        self.ui.menuStyles.setCurrentIndex(
            self.menuNames[str(self.__class__.screenSettings["selectedMenu"])]["menuIndex"]
        )

        self.ui.menuStyles.connect(self.ui.menuStyles, SIGNAL("activated(const QString &)"), self.setMenuStyle)
예제 #35
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)
예제 #36
0
 def slotFinished(self):
     if wallpaperWidget.Widget.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", wallpaperWidget.Widget.selectedWallpaper)
         self.killPlasma()
         QtGui.qApp.quit()
     else:
         QtGui.qApp.quit()
예제 #37
0
 def slotFinished(self):
     if wallpaperWidget.Widget.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",
                                   wallpaperWidget.Widget.selectedWallpaper)
         self.killPlasma()
         QtGui.qApp.quit()
     else:
         QtGui.qApp.quit()
예제 #38
0
파일: ScrSearch.py 프로젝트: Tayyib/uludag
    def __init__(self, *args):
        QtGui.QWidget.__init__(self,None)
        self.ui = Ui_searchWidget()
        self.ui.setupUi(self)

        config = KConfig("nepomukserverrc")
        group = config.group("Basic Settings")
        isNepomuk = str(group.readEntry('Start Nepomuk'))

        if isNepomuk.lower() == "true":
            self.ui.checkBoxNepomuk.setChecked(True)
            self.__class__.screenSettings["state"] = True
        else:
            self.ui.checkBoxNepomuk.setChecked(False)
            self.__class__.screenSettings["state"] = False

        self.ui.checkBoxNepomuk.connect(self.ui.checkBoxNepomuk, SIGNAL("toggled(bool)"), self.activateNepomuk)
예제 #39
0
        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()
예제 #40
0
    def __init__(self, *args):
        QtGui.QWidget.__init__(self,None)
        self.ui = Ui_menuWidget()
        self.ui.setupUi(self)

        # read default menu style first
        config = KConfig("plasma-appletsrc")
        group = config.group("Containments")

        self.menuNames = {}
        self.menuNames["launcher"] = {
                "menuIndex": 0,
                "summaryMessage": ki18n("Kick-off Menu"),
                "image": QtGui.QPixmap(':/raw/pics/kickoff.png'),
                "description": ki18n("Default menu of Pardus GNU/Linux.")
                }
        self.menuNames["simplelauncher"] = {
                "menuIndex": 1,
                "summaryMessage": ki18n("Simple Menu"),
                "image": QtGui.QPixmap(':/raw/pics/simple.png'),
                "description": ki18n("An old style menu from KDE 3.")
                }
        self.menuNames["lancelot_launcher"] = {
                "menuIndex": 2,
                "summaryMessage": ki18n("Lancelot Menu"),
                "image": QtGui.QPixmap(':/raw/pics/lancelot.png'),
                "description": ki18n("An advanced menu for KDE4.")
                }

        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:
                        self.__class__.screenSettings["selectedMenu"] =  subg2.readEntry('plugin')

        # set menu preview to default menu
        self.ui.pictureMenuStyles.setPixmap(self.menuNames[str(self.__class__.screenSettings["selectedMenu"])]["image"])
        self.ui.labelMenuDescription.setText(self.menuNames[str(self.__class__.screenSettings["selectedMenu"])]["description"].toString())
        self.ui.menuStyles.setCurrentIndex(self.menuNames[str(self.__class__.screenSettings["selectedMenu"])]["menuIndex"])

        self.ui.menuStyles.connect(self.ui.menuStyles, SIGNAL("activated(const QString &)"), self.setMenuStyle)
예제 #41
0
def installOkularPartRC():
    """ Set our custom editor command in okularpartrc """
    # determine the command needed to run us
    command = sys.argv[0]
    if os.path.sep in command: # does the command contain a directory separator?
        if not os.path.isabs(command):
            command = os.path.abspath(command)
        if command == KStandardDirs.findExe("frescobaldi"):
            command = "frescobaldi"
    command += " --smart --line %l --column %c"
    okularpartrc = KConfig("okularpartrc", KConfig.NoGlobals)
    group = okularpartrc.group("General")
    group.writeEntry("ExternalEditor", "Custom")
    group.writeEntry("ExternalEditorCommand", command)
    if not group.readEntry("WatchFile", True):
        group.writeEntry("WatchFile", True)
    group.sync()
예제 #42
0
        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()
예제 #43
0
    def __init__(self, *args):
        QtGui.QWidget.__init__(self,None)
        self.ui = Ui_searchWidget()
        self.ui.setupUi(self)

        self.ui.labelSearchImage.setPixmap(QtGui.QPixmap(':/raw/pics/nepomuk.png'))

        config = KConfig("nepomukserverrc")
        group = config.group("Basic Settings")
        isNepomuk = str(group.readEntry('Start Nepomuk'))

        if isNepomuk.lower() == "true":
            self.ui.checkBoxNepomuk.setChecked(True)
            self.__class__.screenSettings["state"] = True
        else:
            self.ui.checkBoxNepomuk.setChecked(False)
            self.__class__.screenSettings["state"] = False

        self.ui.checkBoxNepomuk.connect(self.ui.checkBoxNepomuk, SIGNAL("toggled(bool)"), self.activateNepomuk)
예제 #44
0
파일: expand.py 프로젝트: mkhoeini/kate
def indentationCharacters(document):
    ''' The characters used to indent in a document as set by variables in the
    document or in the configuration. Will be something like '\t' or '    '
    '''
    v = document.variableInterface()
    # cache
    if not hasattr(indentationCharacters, 'configurationUseTabs'):
        config = KConfig('katerc')
        group = config.group('Kate Document Defaults')
        flags = str(group.readEntry('Basic Config Flags'))
        # gross, but there's no public API for this. Growl.
        indentationCharacters.configurationUseTabs = True
        if flags and int(flags) & 0x2000000:
            print 'insert spaces instead of tabulators'
            indentationCharacters.configurationUseTabs = False

        indentWidth = str(group.readEntry('Indentation Width'))
        indentationCharacters.configurationIndentWidth = int(
            indentWidth) if indentWidth else 4
    # indent with tabs or spaces
    useTabs = True
    spaceIndent = v.variable('space-indent')
    if spaceIndent == 'on':
        useTabs = False
    elif spaceIndent == 'off':
        useTabs = True
    else:
        useTabs = indentationCharacters.configurationUseTabs

    if useTabs:
        return '\t'
    else:
        indentWidth = v.variable('indent-width')
        if indentWidth and indentWidth.isdigit():
            return ' ' * int(indentWidth)
        else:
            # default
            return ' ' * indentationCharacters.configurationIndentWidth
예제 #45
0
def indentationCharacters(document):
    ''' The characters used to indent in a document as set by variables in the
    document or in the configuration. Will be something like '\t' or '    '
    '''
    v = document.variableInterface()
    # cache
    if not hasattr(indentationCharacters, 'configurationUseTabs'):
        config = KConfig('katerc')
        group = config.group('Kate Document Defaults')
        flags = str(group.readEntry('Basic Config Flags'))
        # gross, but there's no public API for this. Growl.
        indentationCharacters.configurationUseTabs = True
        if flags and int(flags) & 0x2000000:
            print 'insert spaces instead of tabulators'
            indentationCharacters.configurationUseTabs = False

        indentWidth = str(group.readEntry('Indentation Width'))
        indentationCharacters.configurationIndentWidth = int(indentWidth) if indentWidth else 4
    # indent with tabs or spaces
    useTabs = True
    spaceIndent = v.variable('space-indent')
    if spaceIndent == 'on':
        useTabs = False
    elif spaceIndent == 'off':
        useTabs = True
    else:
        useTabs = indentationCharacters.configurationUseTabs

    if useTabs:
        return '\t'
    else:
        indentWidth = v.variable('indent-width')
        if indentWidth and indentWidth.isdigit():
            return ' ' * int(indentWidth)
        else:
            # default
            return ' ' * indentationCharacters.configurationIndentWidth
예제 #46
0
    def prepareConfigDialog(self):
        """Prepare the Configuration Dialog."""
        self.bcolor, self.dialog = QColor(), KDialog()
        self.dialog.setWindowTitle(__package__ + "Settings")
        self.layBox = QGridLayout(self.dialog.mainWidget())
        self.title = KTitleWidget(self.dialog)
        self.title.setText(__doc__ + " !")
        self.title.setAutoHideTimeout(3000)
        self.FontButton = KFontRequester(self.dialog)
        self.tfont = QFont(QVariant(self.configurations.readEntry("TextFont",
                           QVariant(QFont()))))
        self.FontButton.setFont(self.tfont)
        self.ColorButton = KColorButton(self.dialog)
        self.tcolor = QColor(self.configurations.readEntry("TextColor",
                             QColor("#000").name()))
        self.ColorButton.setColor(self.tcolor)
        self.BColorButton = KColorButton(self.dialog)
        # button to update the DB via sudo updatedb

        self.UpdateDB = KPushButton("Update Database", self.dialog,
                                    clicked=lambda: self.update_db())
        self.UpdateDB.setToolTip("Database is Updated every Reboot and Daily!")
        self.Histor = KPushButton("Delete my History", self.dialog,
                                  clicked=delete_my_history)
        self.Histor.setToolTip("History is Deleted every Reboot !")
        # list of banned words separated by spaces
        self.banned = KTextEdit(self.dialog)
        self.banned.setPlainText(self.configurations.readEntry(
            "Banned", "sex p**n drugs suicide decapitate religion").toString())
        # set the colors
        cg = KConfig("kdeglobals")
        color = cg.group("Colors:View").readEntry(
            "BackgroundAlternate").split(",")
        self.bcolor = QColor(int(color[0]), int(color[1]), int(color[2]))
        self.BColorButton.setColor(self.bcolor)
        self.history_file_path_field = KLineEdit(HISTORY_FILE_PATH)
        self.history_file_path_field.setDisabled(True)
        self.python_file_path_field = KLineEdit(__file__)
        self.python_file_path_field.setDisabled(True)
        self.kill_baloo = QCheckBox("Disable Baloo")
        self.kill_baloo.setToolTip("Enable/Disable Desktop Search Indexing")
        self.kill_baloo.stateChanged.connect(lambda: call(
            DISABLE_BALOO_CMD.format(str(
                not self.kill_baloo.isChecked()).lower()), shell=True))
        self.kill_baloo.stateChanged.connect(lambda: QMessageBox.information(
            self.dialog, __doc__, """
            <b>Indexing Disabled, Baloo is Dead !
            """ if self.kill_baloo.isChecked() else """
            <b>Indexing Enabled, Baloo is Running !"""))
        self.updatez = KPushButton("Check for Updates", self.dialog,
                                   clicked=lambda: self.check_for_updates())
        self.updatez.setToolTip("Check for Pylou updates from the internet")
        self.home_sweet_home = QCheckBox("Only Search Home")
        self.home_sweet_home.setToolTip("Only Search on my Home folders")
        self.home_sweet_home.setChecked(
            bool(self.configurations.readEntry("Home", True)))
        # pack all widgets
        self.layBox.addWidget(self.title, 0, 1)
        self.layBox.addWidget(QLabel("Font"), 1, 0)
        self.layBox.addWidget(self.FontButton, 1, 1)
        self.layBox.addWidget(QLabel("Text Color"), 2, 0)
        self.layBox.addWidget(self.ColorButton, 2, 1)
        self.layBox.addWidget(QLabel("Alternate Color"), 3, 0)
        self.layBox.addWidget(self.BColorButton, 3, 1)
        self.layBox.addWidget(QLabel(), 4, 0)
        self.layBox.addWidget(QLabel("Mainteniance"), 5, 0)
        self.layBox.addWidget(self.UpdateDB, 5, 1)
        self.layBox.addWidget(QLabel("Privacy"), 6, 0)
        self.layBox.addWidget(self.Histor, 6, 1)
        self.layBox.addWidget(QLabel("History file"), 7, 0)
        self.layBox.addWidget(self.history_file_path_field, 7, 1)
        self.layBox.addWidget(QLabel(__package__ + "file"), 8, 0)
        self.layBox.addWidget(self.python_file_path_field, 8, 1)
        self.layBox.addWidget(QLabel("Banned Words"), 9, 0)
        self.layBox.addWidget(self.banned, 9, 1)
        self.layBox.addWidget(QLabel("SelfUpdating"), 10, 0)
        self.layBox.addWidget(self.updatez, 10, 1)
        self.layBox.addWidget(QLabel("<b>Disable Indexing"), 12, 0)
        self.layBox.addWidget(self.kill_baloo, 12, 1)
        self.layBox.addWidget(QLabel("Search Paths"), 13, 0)
        self.layBox.addWidget(self.home_sweet_home, 13, 1)
        # button box on the bottom
        self.dialog.setButtons(KDialog.ButtonCodes(
            KDialog.ButtonCode(KDialog.Ok | KDialog.Cancel | KDialog.Apply)))
        # connect
        self.dialog.applyClicked.connect(self.configAccepted)
        self.dialog.okClicked.connect(self.configAccepted)
예제 #47
0
    def __init__(self, *args):
        QtGui.QWidget.__init__(self, None)
        self.ui = Ui_styleWidget()
        self.ui.setupUi(self)

        self.styleDetails = {}
        self.catLang = KGlobal.locale().language()

        config = KConfig("kwinrc")
        group = config.group("Desktops")
        defaultDesktopNumber = int(group.readEntry('Number'))

        self.ui.spinBoxDesktopNumbers.setValue(defaultDesktopNumber)
        lst2 = glob.glob1("/usr/kde/4/share/apps/kaptan/gui/styles", "*.style")

        for desktopFiles in lst2:
            parser = DesktopParser()
            parser.read("/usr/kde/4/share/apps/kaptan/gui/styles/" +
                        str(desktopFiles))
            try:
                styleName = unicode(
                    parser.get_locale('Style', 'name[%s]' % self.catLang, ''))
            except:
                styleName = unicode(parser.get_locale('Style', 'name', ''))
            try:
                styleDesc = unicode(
                    parser.get_locale('Style',
                                      'description[%s]' % self.catLang, ''))
            except:
                styleDesc = unicode(
                    parser.get_locale('Style', 'description', ''))
            try:
                # TODO find a fallback values for these & handle exceptions seperately.
                #styleApplet = parser.get_locale('Style', 'applets', '')
                panelPosition = parser.get_locale('Style', 'panelPosition', '')
                #styleColorScheme = parser.get_locale('Style', 'colorScheme', '')
                widgetStyle = unicode(
                    parser.get_locale('Style', 'widgetStyle', ''))
                desktopTheme = unicode(
                    parser.get_locale('Style', 'desktopTheme', ''))
                colorScheme = unicode(
                    parser.get_locale('Style', 'colorScheme', ''))
                iconTheme = unicode(parser.get_locale('Style', 'iconTheme',
                                                      ''))
                windowDecoration = unicode(
                    parser.get_locale('Style', 'windowDecoration', ''))
                styleThumb = unicode(
                    os.path.join("/usr/kde/4/share/apps/kaptan/gui/styles/",
                                 parser.get_locale('Style', 'thumbnail', '')))

                colorDict = {}
                colorDir = "/usr/kde/4/share/apps/color-schemes/"
                self.Config = ConfigParser()
                self.Config.optionxform = str
                color = colorDir + colorScheme + ".colors"
                if not os.path.exists(color):
                    color = colorDir + "Oxygen.colors"

                self.Config.read(color)
                #colorConfig= KConfig("kdeglobals")
                for i in self.Config.sections():
                    #colorGroup = colorConfig.group(str(i))
                    colorDict[i] = {}
                    for key, value in self.ConfigSectionMap(i).items():
                        colorDict[i][key] = value
                        #colorGroup.writeEntry(str(key), str(value))

                self.styleDetails[styleName] = {
                    "description": styleDesc,
                    "widgetStyle": widgetStyle,
                    "colorScheme": colorDict,
                    "desktopTheme": desktopTheme,
                    "iconTheme": iconTheme,
                    "windowDecoration": windowDecoration,
                    "panelPosition": panelPosition
                }

                item = QtGui.QListWidgetItem(self.ui.listStyles)
                widget = StyleItemWidget(unicode(styleName),
                                         unicode(styleDesc), styleThumb,
                                         self.ui.listStyles)
                self.ui.listStyles.setItemWidget(item, widget)
                item.setSizeHint(QSize(120, 170))
                item.setStatusTip(styleName)
            except:
                print "Warning! Invalid syntax in ", desktopFiles

        self.ui.listStyles.connect(self.ui.listStyles,
                                   SIGNAL("itemSelectionChanged()"),
                                   self.setStyle)
        self.ui.comboBoxDesktopType.connect(
            self.ui.comboBoxDesktopType, SIGNAL("activated(const QString &)"),
            self.setDesktopType)
        self.ui.spinBoxDesktopNumbers.connect(
            self.ui.spinBoxDesktopNumbers,
            SIGNAL("valueChanged(const QString &)"), self.addDesktop)
예제 #48
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
예제 #49
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)
예제 #50
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
예제 #51
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
예제 #52
0
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
예제 #53
0
class Kaptan(QtGui.QWidget):
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        self.initializeGlobals()
        self.initializeUI()
        self.signalHandler()

    def initializeGlobals(self):
        ''' initializes global variables '''
        self.screenData = None
        self.moveInc = 1
        self.menuText = ""
        self.titles = []
        self.descriptions = []
        self.currentDir = os.path.dirname(os.path.realpath(__file__))
        self.screensPath = self.currentDir + "/kaptan/screens/scr*py"
        self.kaptanConfig = KConfig("kaptanrc")
        self.plasmaConfig = KConfig("plasma-desktop-appletsrc")

    def signalHandler(self):
        ''' connects signals to slots '''
        self.connect(self.ui.buttonNext, QtCore.SIGNAL("clicked()"),
                     self.slotNext)
        self.connect(self.ui.buttonApply, QtCore.SIGNAL("clicked()"),
                     self.slotNext)
        self.connect(self.ui.buttonBack, QtCore.SIGNAL("clicked()"),
                     self.slotBack)
        self.connect(self.ui.buttonFinish, QtCore.SIGNAL("clicked()"),
                     QtGui.qApp, QtCore.SLOT("quit()"))
        self.connect(self.ui.buttonCancel, QtCore.SIGNAL("clicked()"),
                     QtGui.qApp, QtCore.SLOT("quit()"))

    def initializeUI(self):
        ''' initializes the human interface '''
        self.ui = Ui_kaptan()
        self.ui.setupUi(self)

        # load screens
        tools.loadScreens(self.screensPath, globals())

        # kaptan screen settings
        self.headScreens = [
            scrWelcome, scrMouse, scrStyle, scrMenu, scrWallpaper
        ]
        self.tailScreens = [scrSummary, scrGoodbye]
        self.screens = self.screenOrganizer(self.headScreens, self.tailScreens)

        # Add screens to StackWidget
        self.createWidgets(self.screens)

        # Get Screen Titles
        for screen in self.screens:
            title = screen.Widget.title.toString()
            self.titles.append(title)

        # draw progress pie
        self.countScreens = len(self.screens)
        self.pie = DrawPie(self.countScreens, self.ui.labelProgress)

        # Initialize Menu
        self.menu = Menu(self.titles, self.ui.labelMenu)
        self.menu.start()

    def screenOrganizer(self, headScreens, tailScreens):
        ''' appends unsorted screens to the list '''
        screens = []

        allScreens = [
            value for key, value in globals().iteritems()
            if key.startswith("scr")
        ]

        otherScreens = list((set(allScreens) - set(headScreens)) -
                            set(tailScreens))
        otherScreens.remove(scrKeyboard)
        otherScreens.remove(scrPackage)

        screens.extend(headScreens)
        screens.extend(otherScreens)

        # Append other screens depending on the following cases
        if tools.isLiveCD():
            screens.append(scrKeyboard)

        else:
            screens.append(scrPackage)

        screens.extend(tailScreens)

        return screens

    def getCur(self, d):
        ''' returns the id of current stack '''
        new = self.ui.mainStack.currentIndex() + d
        total = self.ui.mainStack.count()
        if new < 0: new = 0
        if new > total: new = total
        return new

    def setCurrent(self, id=None):
        ''' move to id numbered step '''
        if id: self.stackMove(id)

    def slotNext(self, dryRun=False):
        ''' execute next step '''
        self.menuText = ""
        curIndex = self.ui.mainStack.currentIndex() + 1

        # update pie progress
        self.pie.updatePie(curIndex)

        # animate menu
        self.menu.next()

        _w = self.ui.mainStack.currentWidget()

        ret = _w.execute()
        if ret:
            self.stackMove(self.getCur(self.moveInc))
            self.moveInc = 1

    def slotBack(self):
        ''' execute previous step '''
        self.menuText = ""
        curIndex = self.ui.mainStack.currentIndex()

        # update pie progress
        self.pie.updatePie(curIndex - 1)

        # animate menu
        self.menu.prev()

        _w = self.ui.mainStack.currentWidget()

        _w.backCheck()
        self.stackMove(self.getCur(self.moveInc * -1))
        self.moveInc = 1

    def stackMove(self, id):
        ''' move to id numbered stack '''
        if not id == self.ui.mainStack.currentIndex() or id == 0:
            self.ui.mainStack.setCurrentIndex(id)

            # Set screen title
            self.ui.screenTitle.setText(self.descriptions[id])

            _w = self.ui.mainStack.currentWidget()
            _w.update()
            _w.shown()

        if self.ui.mainStack.currentIndex() == len(self.screens) - 3:
            self.ui.buttonNext.show()
            self.ui.buttonApply.hide()
            self.ui.buttonFinish.hide()

        if self.ui.mainStack.currentIndex() == len(self.screens) - 2:
            self.ui.buttonNext.hide()
            self.ui.buttonApply.show()
            self.ui.buttonFinish.hide()

        if self.ui.mainStack.currentIndex() == len(self.screens) - 1:
            self.ui.buttonApply.hide()
            self.ui.buttonFinish.show()

        if self.ui.mainStack.currentIndex() == 0:
            self.ui.buttonBack.hide()
            self.ui.buttonFinish.hide()
            self.ui.buttonApply.hide()
        else:
            self.ui.buttonBack.show()

    def createWidgets(self, screens=[]):
        ''' create all widgets and add inside stack '''
        self.ui.mainStack.removeWidget(self.ui.page)
        for screen in screens:
            _scr = screen.Widget()

            # Append screen descriptions to list
            self.descriptions.append(_scr.desc.toString())

            # Append screens to stack widget
            self.ui.mainStack.addWidget(_scr)

        self.stackMove(0)

    def disableNext(self):
        self.buttonNext.setEnabled(False)

    def disableBack(self):
        self.buttonBack.setEnabled(False)

    def enableNext(self):
        self.buttonNext.setEnabled(True)

    def enableBack(self):
        self.buttonBack.setEnabled(True)

    def isNextEnabled(self):
        return self.buttonNext.isEnabled()

    def isBackEnabled(self):
        return self.buttonBack.isEnabled()

    def __del__(self):
        group = self.kaptanConfig.group("General")
        group.writeEntry("RunOnStart", "False")
예제 #54
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
예제 #55
0
    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
예제 #56
0
파일: scrMenu.py 프로젝트: rshipp/kapudan
    def __init__(self, *args):
        QtGui.QWidget.__init__(self, None)
        self.ui = Ui_menuWidget()
        self.ui.setupUi(self)

        # read default menu style first
        config = KConfig("plasma-desktop-appletsrc")
        group = config.group("Containments")

        self.menuNames = {}
        self.menuNames["launcher"] = {
            "menuIndex":
            0,
            "summaryMessage":
            i18n("Kick-off Menu"),
            "image":
            QtGui.QPixmap(':/raw/pixmap/kickoff.png'),
            "description":
            i18n(
                "Kick-off menu is the default menu of Chakra.<br><br>The program shortcuts are easy to access and well organized."
            )
        }
        self.menuNames["simplelauncher"] = {
            "menuIndex":
            1,
            "summaryMessage":
            i18n("Simple Menu"),
            "image":
            QtGui.QPixmap(':/raw/pixmap/simple.png'),
            "description":
            i18n(
                "Simple menu is an old style menu from KDE 3.<br><br>It is a very lightweight menu thus it is recommended for slower PC's."
            )
        }
        self.menuNames["lancelot_launcher"] = {
            "menuIndex":
            2,
            "summaryMessage":
            i18n("Lancelot Menu"),
            "image":
            QtGui.QPixmap(':/raw/pixmap/lancelot.png'),
            "description":
            i18n(
                "Lancelot is an advanced and highly customizable menu for Chakra.<br><br>The program shortcuts are easy to access and well organized."
            )
        }
        self.menuNames["homerunlauncher"] = {
            "menuIndex":
            3,
            "summaryMessage":
            i18n("Homerun Menu"),
            "image":
            QtGui.QPixmap(':/raw/pixmap/homerun.png'),
            "description":
            i18n(
                "Homerun is a full screen launcher with content organized in tabs."
            )
        }
        self.menuNames["appmenu-qml"] = {
            "menuIndex":
            4,
            "summaryMessage":
            i18n("AppMenu QML"),
            "image":
            QtGui.QPixmap(':/raw/pixmap/appmenu-qml.png'),
            "description":
            i18n(
                "This plasmoid shows a menu of the installed applications, similar to Lancelot but much simpler"
            )
        }
        self.menuNames["org.kde.homerun-kicker"] = {
            "menuIndex": 5,
            "summaryMessage": i18n("Homerun Kicker"),
            "image": QtGui.QPixmap(':/raw/pixmap/homerun-kicker.png'),
            "description": i18n("A non-fullscreen version of Homerun.")
        }

        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:
                        self.__class__.screenSettings[
                            "selectedMenu"] = subg2.readEntry('plugin')

        # set menu preview to default menu
        # if default menu could not found, default to kickoff
        if "selectedMenu" not in self.__class__.screenSettings:
            self.__class__.screenSettings["selectedMenu"] = "launcher"

        self.ui.pictureMenuStyles.setPixmap(self.menuNames[str(
            self.__class__.screenSettings["selectedMenu"])]["image"])
        self.ui.labelMenuDescription.setText(self.menuNames[str(
            self.__class__.screenSettings["selectedMenu"])]["description"])
        self.ui.menuStyles.setCurrentIndex(self.menuNames[str(
            self.__class__.screenSettings["selectedMenu"])]["menuIndex"])

        self.ui.menuStyles.activated.connect(self.setMenuStyle)