def __init__(self, *args): QtGui.QWidget.__init__(self, None) self.ui = Ui_wallpaperWidget() self.ui.setupUi(self) # Get system locale self.catLang = KGlobal.locale().language() # Get screen resolution # rect = QtGui.QDesktopWidget().screenGeometry() FIXME: where could # this be needed? # Get metadata.desktop files from shared wallpaper directory lst = KStandardDirs().findAllResources("wallpaper", "*metadata.desktop", KStandardDirs.Recursive) for desktopFiles in lst: parser = DesktopParser() parser.read(str(desktopFiles)) try: wallpaperTitle = parser.get_locale('Desktop Entry', 'Name[%s]' % self.catLang, '') except: wallpaperTitle = parser.get_locale('Desktop Entry', 'Name', '') try: wallpaperDesc = parser.get_locale('Desktop Entry', 'X-KDE-PluginInfo-Author', '') except: wallpaperDesc = "Unknown" # Get all files in the wallpaper's directory try: thumbFolder = os.listdir(os.path.join(os.path.split(str(desktopFiles))[0], "contents")) except OSError: thumbFolder = os.listdir(os.path.join(os.path.split(str(desktopFiles))[0], "content")) """ Appearantly the thumbnail names doesn't have a standard. So we get the file list from the contents folder and choose the file which has a name that starts with "scre". File names I've seen so far; screenshot.jpg, screnshot.jpg, screenshot.png, screnshot.png """ wallpaperThumb = "" for thumb in thumbFolder: if thumb.startswith('scre'): wallpaperThumb = os.path.join(os.path.split(str(desktopFiles))[0], "contents/" + thumb) wallpaperFile = os.path.split(str(desktopFiles))[0] # Insert wallpapers to listWidget. item = QtGui.QListWidgetItem(self.ui.listWallpaper) # Each wallpaper item is a widget. Look at widgets.py for more information. widget = WallpaperItemWidget(unicode(wallpaperTitle, "utf8", "replace"), unicode(wallpaperDesc, "utf8", "replace"), wallpaperThumb, self.ui.listWallpaper) item.setSizeHint(QSize(120, 170)) self.ui.listWallpaper.setItemWidget(item, widget) # Add a hidden value to each item for detecting selected wallpaper's path. item.setStatusTip(wallpaperFile) self.ui.listWallpaper.itemSelectionChanged.connect(self.setWallpaper) self.ui.checkBox.stateChanged.connect(self.disableWidgets) self.ui.buttonChooseWp.clicked.connect(self.selectWallpaper)
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/share/kde4/apps/kapudan/kapudan/kde-themes", "*.style") # Uncomment for local testing # lst2 = glob.glob1("data/kde-themes", "*.style") for desktopFiles in lst2: parser = DesktopParser() parser.read("/usr/share/kde4/apps/kapudan/kapudan/kde-themes/" + str(desktopFiles)) # Uncomment for local testing # parser.read("data/kde-themes/" +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', '')) windowDecoration = unicode( parser.get_locale('Style', 'windowDecoration', '')) styleThumb = unicode( os.path.join( "/usr/share/kde4/apps/kapudan/kapudan/kde-themes/", parser.get_locale('Style', 'thumbnail', ''))) # Uncomment for local testing # styleThumb = unicode(os.path.join("data/kde-themes/", parser.get_locale('Style', 'thumbnail',''))) colorDict = {} colorDir = "/usr/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, "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.itemSelectionChanged.connect(self.setStyle) self.ui.comboBoxDesktopType.activated.connect(self.setDesktopType) self.ui.spinBoxDesktopNumbers.valueChanged.connect(self.addDesktop)
def __init__(self, *args): QtGui.QWidget.__init__(self, None) self.ui = Ui_wallpaperWidget() self.ui.setupUi(self) # Get system locale self.catLang = KGlobal.locale().language() # Get screen resolution # rect = QtGui.QDesktopWidget().screenGeometry() FIXME: where could # this be needed? # Get metadata.desktop files from shared wallpaper directory lst = KStandardDirs().findAllResources("wallpaper", "*metadata.desktop", KStandardDirs.Recursive) for desktopFiles in lst: parser = DesktopParser() parser.read(str(desktopFiles)) try: wallpaperTitle = parser.get_locale('Desktop Entry', 'Name[%s]' % self.catLang, '') except: wallpaperTitle = parser.get_locale('Desktop Entry', 'Name', '') try: wallpaperDesc = parser.get_locale('Desktop Entry', 'X-KDE-PluginInfo-Author', '') except: wallpaperDesc = "Unknown" # Get all files in the wallpaper's directory try: thumbFolder = os.listdir( os.path.join( os.path.split(str(desktopFiles))[0], "contents")) except OSError: thumbFolder = os.listdir( os.path.join( os.path.split(str(desktopFiles))[0], "content")) """ Appearantly the thumbnail names doesn't have a standard. So we get the file list from the contents folder and choose the file which has a name that starts with "scre". File names I've seen so far; screenshot.jpg, screnshot.jpg, screenshot.png, screnshot.png """ wallpaperThumb = "" for thumb in thumbFolder: if thumb.startswith('scre'): wallpaperThumb = os.path.join( os.path.split(str(desktopFiles))[0], "contents/" + thumb) wallpaperFile = os.path.split(str(desktopFiles))[0] # Insert wallpapers to listWidget. item = QtGui.QListWidgetItem(self.ui.listWallpaper) # Each wallpaper item is a widget. Look at widgets.py for more information. widget = WallpaperItemWidget( unicode(wallpaperTitle, "utf8", "replace"), unicode(wallpaperDesc, "utf8", "replace"), wallpaperThumb, self.ui.listWallpaper) item.setSizeHint(QSize(120, 170)) self.ui.listWallpaper.setItemWidget(item, widget) # Add a hidden value to each item for detecting selected wallpaper's path. item.setStatusTip(wallpaperFile) self.ui.listWallpaper.itemSelectionChanged.connect(self.setWallpaper) self.ui.checkBox.stateChanged.connect(self.disableWidgets) self.ui.buttonChooseWp.clicked.connect(self.selectWallpaper)
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/share/kde4/apps/kapudan/kapudan/kde-themes", "*.style") # Uncomment for local testing # lst2 = glob.glob1("data/kde-themes", "*.style") for desktopFiles in lst2: parser = DesktopParser() parser.read("/usr/share/kde4/apps/kapudan/kapudan/kde-themes/" + str(desktopFiles)) # Uncomment for local testing # parser.read("data/kde-themes/" +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', '')) windowDecoration = unicode(parser.get_locale('Style', 'windowDecoration', '')) styleThumb = unicode(os.path.join("/usr/share/kde4/apps/kapudan/kapudan/kde-themes/", parser.get_locale('Style', 'thumbnail', ''))) # Uncomment for local testing # styleThumb = unicode(os.path.join("data/kde-themes/", parser.get_locale('Style', 'thumbnail',''))) colorDict = {} colorDir = "/usr/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, "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.itemSelectionChanged.connect(self.setStyle) self.ui.comboBoxDesktopType.activated.connect(self.setDesktopType) self.ui.spinBoxDesktopNumbers.valueChanged.connect(self.addDesktop)