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)
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)
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
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
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
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()
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()
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()
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()
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()
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()
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)
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)
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)
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 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)
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)
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)
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)
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)
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))
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
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)
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)
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)
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()
def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent) self.ui = Ui_kaptanUI() self.ui.setupUi(self) self.screens = availableScreens self.screenData = None self.moveInc = 1 self.menuText = "" self.config = KConfig("kaptanrc") self.createWidgets(self.screens) self.screenId = [] for each in self.screens: #title = each.Widget().windowTitle() title = "camera" self.screenId.append(title) if self.screens.index(each) == 0: self.menuText += self.putBold(title) else: self.menuText += self.putBr(title) self.ui.labelMenu.setText(self.menuText) QtCore.QObject.connect(self.ui.buttonNext, QtCore.SIGNAL("clicked()"), self.slotNext) QtCore.QObject.connect(self.ui.buttonBack, QtCore.SIGNAL("clicked()"), self.slotBack) QtCore.QObject.connect(self.ui.buttonFinish, QtCore.SIGNAL("clicked()"), QtGui.qApp, QtCore.SLOT("quit()")) QtCore.QObject.connect(self.ui.buttonCancel, QtCore.SIGNAL("clicked()"), QtGui.qApp, QtCore.SLOT("quit()"))
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 __init__(self, parent=None): QtGui.QWidget.__init__(self, parent) self.ui = Ui_MigrationUI() self.ui.setupUi(self) self.screens = availableScreens self.moveInc = 1 self.menuText = "" self.config = KConfig("migrationrc") self.createWidget(self.screens) self.screenId = [] for each in self.screens: title = each.Widget().title title = i18n(title) self.screenId.append(title) if self.screens.index(each) == 0: self.menuText += self.putBold(title) else: self.menuText += self.putBr(title) self.ui.labelMenu.setText(self.menuText) QtCore.QObject.connect(self.ui.buttonNext, QtCore.SIGNAL("clicked()"), self.slotNext) QtCore.QObject.connect(self.ui.buttonBack, QtCore.SIGNAL("clicked()"), self.slotBack) QtCore.QObject.connect(self.ui.buttonFinish, QtCore.SIGNAL("clicked()"), QtGui.qApp, QtCore.SLOT("quit()")) QtCore.QObject.connect(self.ui.buttonCancel, QtCore.SIGNAL("clicked()"), QtGui.qApp, QtCore.SLOT("quit()"))
def __init__(self, parent=None, connections={}): self.urls = [] self.projectPaths = [] QDialog.__init__(self, parent) uic.loadUi(os.path.join(os.path.dirname(__file__), "fuzzyopen.ui"), self) self.setModal(True) self.listUrl.setItemDelegate(HtmlItemDelegate(self.listUrl)) self.hideProgress() self.iconLoader = KIconLoader() self.btnSettings.setIcon(QIcon(self.iconLoader.loadIcon("configure", KIconLoader.Small))) self.btnRefresh.setIcon(QIcon(self.iconLoader.loadIcon("view-refresh", KIconLoader.Small))) self.config = KConfig("katefuzzyopenrc") configPaths = self.config.group("ProjectPaths") for key in configPaths.keyList(): path = configPaths.readPathEntry(key, "") if not path.endswith("/"): path += "/" self.projectPaths.append(path) configFilters = self.config.group("Filters") self.lister = DirLister() self.lister.fileFound.connect(self.listerFileFound) self.lister.directoryChanged.connect(self.listerDirChanged) self.lister.completed.connect(self.listerCompleted) self.lister.setIncludeFilters(configFilters.readEntry("include", "")) self.lister.setExcludeFilters(configFilters.readEntry("exclude", "~$\n\.bak$\n/\."))
def __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)
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()
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()
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)
def get_last_session(): config = KConfig('katerc') kgroup = KConfigGroup(config, "General") session = kgroup.readEntry("Last Session") if session: session = unicode(session) session = session.replace('.katesession', '') return session return None
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)
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 + "/migration/gui/Scr*py" self.migrationConfig = KConfig("migrationrc")
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)
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
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
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
def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent) self.ui = Ui_kaptanUI() self.ui.setupUi(self) # Kaptan screen settings self.commonScreens = [ welcomeWidget, avatarWidget, mouseWidget, styleWidget, menuWidget, wallpaperWidget, networkWidget ] self.endScreens = [summaryWidget, goodbyeWidget] self.screens = self.appendOtherScreens( self.commonScreens) + self.endScreens self.screenData = None self.moveInc = 1 self.menuText = "" self.config = KConfig("kaptanrc") self.titles = [] self.descriptions = [] # Draw progress pie self.countScreens = len(self.screens) self.pie = DrawPie(self.countScreens, self.ui.labelProgress) # 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) # Initialize Menu self.menu = Menu(self.titles, self.ui.labelMenu) self.menu.start() QtCore.QObject.connect(self.ui.buttonNext, QtCore.SIGNAL("clicked()"), self.slotNext) QtCore.QObject.connect(self.ui.buttonBack, QtCore.SIGNAL("clicked()"), self.slotBack) QtCore.QObject.connect(self.ui.buttonFinish, QtCore.SIGNAL("clicked()"), QtGui.qApp, QtCore.SLOT("quit()")) QtCore.QObject.connect(self.ui.buttonCancel, QtCore.SIGNAL("clicked()"), QtGui.qApp, QtCore.SLOT("quit()"))
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 __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 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)
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()
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
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 __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)
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)
def __init__(self, config): self.config = KConfig(config) self.group = None
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)
def setKMailAccounts(self): """Add imported accounts into Kmail""" #Set default config and configGroup #config = KConfig("kmailrc") #configGroup = KConfigGroup(config, "Account") 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: print "defaultSMTPAccount:%s" % 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) print "accountGroups:%s" % accountGroups return accountGroups for account in self.accounts: print "account type:%s ve host:%s" % (account["type"], account["host"]) print "account keys%s" % account.keys() # Add POP3 Account: if account["type"] == "POP3": validAccount = None if getResourceConfigGroup(account): for accountGroup in getResourceConfigGroup(account): if not isKMailAccountValid(accountGroup, account): continue print "Popa girdir...." config = KConfig("kmailrc") configGroup = KConfigGroup(config, "Account") configGroup.writeEntry("trash", "trash") configGroup.writeEntry("Type", "Pop") configGroup.writeEntry("Name", account["name"]) configGroup.writeEntry("auth", "USER") configGroup.writeEntry("host", account["host"]) configGroup.writeEntry("login", account["user"]) # Set Inbox Folder: inbox = account.get("inbox", "inbox") folder = kMailFolderName(inbox) configGroup.writeEntry("Folder", folder) # Create inbox if not exists: folders = inbox.split("/") for i in xrange(len(folders)): foldername = "/".join(folders[:(i + 1)]) foldername = kMailFolderName(foldername) folderpath = os.path.expanduser( "~/.kde4/share/apps/kmail/mail/" + foldername) if not os.path.exists(folderpath): os.makedirs(folderpath) os.makedirs(os.path.join(folderpath, "cur")) os.makedirs(os.path.join(folderpath, "new")) os.makedirs(os.path.join(folderpath, "tmp")) if account.has_key("SSL") and account["SSL"]: configGroup.writeEntry("use-ssl", "true") configGroup.writeEntry("port", "995") else: configGroup.writeEntry("use-ssl", "false") configGroup.writeEntry("port", "110") if account.has_key("port") and account["port"]: configGroup.writeEntry("port", account["port"]) configGroup.writeEntry("use-tls", "false") configGroup.sync() # Add IMAP Account: elif account["type"] == "IMAP": print "imap de.." if getResourceConfigGroup(account): for accountGroup in getResourceConfigGroup(account): print "iskmailAccount girilecek" if not isKMailAccountValid(accountGroup, account): continue print "IMAP girddiii" config = KConfig("kmailrc") configGroup = KConfigGroup(config, "Account") configGroup.writeEntry("Folder", "") configGroup.writeEntry("trash", "trash") configGroup.writeEntry("Type", "Pop") configGroup.writeEntry("Name", account["name"]) configGroup.writeEntry("auth", "USER") configGroup.writeEntry("host", account["host"]) configGroup.writeEntry("login", account["user"]) if account.has_key("SSL") and account["SSL"]: configGroup.writeEntry("use-ssl", "true") configGroup.writeEntry("port", 993) else: configGroup.writeEntry("use-ssl", "false") configGroup.writeEntry("port", "143") if account.has_key("port") and account["port"]: configGroup.writeEntry("port", account["port"]) configGroup.writeEntry("use-tls", "false") configGroup.sync() # Add SMTP Account: elif account["type"] == "SMTP": accountGroup = getResourceConfigGroup(account) if not isKMailAccountValid(accountGroup, account): return print "SMTP girdi...." config = KConfig("mailtransports") configGroup = KConfigGroup(config, "Transport") if account.get("auth", False) and account.has_key("user"): configGroup.writeEntry("auth", "true") configGroup.writeEntry("authtype", "PLAIN") configGroup.writeEntry("user", account["user"]) configGroup.writeEntry("name", account["host"]) configGroup.writeEntry("host", account["host"]) if account.has_key("SSL") and account["SSL"]: configGroup.writeEntry("encryption", "SSL") configGroup.writeEntry("port", "465") else: configGroup.writeEntry("port", "25") if account.has_key("TLS") and account["TLS"]: configGroup.writeEntry("encryption", "TLS") if account.has_key("port") and account["port"]: configGroup.writeEntry("port", account["port"]) configGroup.sync()