Пример #1
0
    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()

        # 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
            thumbFolder = os.listdir(os.path.join(os.path.split(str(desktopFiles))[0], "contents"))

            """
            Appearantly the thumbnail names doesn't have a standart.
            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), unicode(wallpaperDesc), 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.connect(self.ui.listWallpaper, SIGNAL("itemSelectionChanged()"), self.setWallpaper)
        self.ui.checkBox.connect(self.ui.checkBox, SIGNAL("stateChanged(int)"), self.disableWidgets)
        self.ui.buttonChooseWp.connect(self.ui.buttonChooseWp, SIGNAL("clicked()"), self.selectWallpaper)
Пример #2
0
    def getWallpaperSettings(self):
        lst = KStandardDirs().findAllResources("wallpaper",
                                               "*metadata.desktop",
                                               KStandardDirs.Recursive)

        items = []
        for desktopFiles in lst:
            wallpaper = {}
            parser = DesktopParser()
            parser.read(str(desktopFiles))

            try:
                wallpaper["wallpaperTitle"] = parser.get_locale(
                    'Desktop Entry', 'Name[%s]' % self.catLang, '')
            except:
                wallpaper["wallpaperTitle"] = parser.get_locale(
                    'Desktop Entry', 'Name', '')

            try:
                wallpaper["wallpaperDesc"] = parser.get_locale(
                    'Desktop Entry', 'X-KDE-PluginInfo-Author', '')
            except:
                wallpaper["wallpaperDesc"] = "Unknown"

                # Get all files in the wallpaper's directory
            thumbFolder = os.listdir(
                os.path.join(os.path.split(str(desktopFiles))[0], "contents"))

            #    """
            #    Appearantly the thumbnail names doesn't have a standart.
            #    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
            #    """

            wallpaper["wallpaperThumb"] = ""

            for thumb in thumbFolder:
                if thumb.startswith('scre'):
                    wallpaper["wallpaperThumb"] = os.path.join(
                        os.path.split(str(desktopFiles))[0],
                        "contents/" + thumb)

            wallpaper["wallpaperFile"] = os.path.split(str(desktopFiles))[0]

            items.append(wallpaper)

        return items
Пример #3
0
    def getWallpaperSettings(self):
        lst = KStandardDirs().findAllResources("wallpaper", "*metadata.desktop", KStandardDirs.Recursive)

        items = []
        for desktopFiles in lst:
            wallpaper = {}
            parser = DesktopParser()
            parser.read(str(desktopFiles))

            try:
                wallpaper["wallpaperTitle"] = parser.get_locale('Desktop Entry', 'Name[%s]'%self.catLang, '')
            except:
                wallpaper["wallpaperTitle"] = parser.get_locale('Desktop Entry', 'Name', '')

            try:
                wallpaper["wallpaperDesc"] = parser.get_locale('Desktop Entry', 'X-KDE-PluginInfo-Author', '')
            except:
                wallpaper["wallpaperDesc"] = "Unknown"

                # Get all files in the wallpaper's directory
            thumbFolder = os.listdir(os.path.join(os.path.split(str(desktopFiles))[0], "contents"))

            #    """
            #    Appearantly the thumbnail names doesn't have a standart.
            #    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
            #    """

            wallpaper["wallpaperThumb"] = ""

            for thumb in thumbFolder:
                if thumb.startswith('scre'):
                    wallpaper["wallpaperThumb"] = os.path.join(os.path.split(str(desktopFiles))[0], "contents/" + thumb)

            wallpaper["wallpaperFile"] = os.path.split(str(desktopFiles))[0]

            items.append(wallpaper)

        return items
Пример #4
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/share/kde4/apps/kaptan/kaptan/kde-themes",
                          "*.style")

        for desktopFiles in lst2:
            parser = DesktopParser()
            parser.read("/usr/share/kde4/apps/kaptan/kaptan/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', ''))

                self.iconTheme = unicode(
                    self.ui.listIcon.selectedItems()[0].text())
                self.iconTheme = str(self.iconTheme.split()[0]).lower()
                self.__class__.screenSettings["iconTheme"] = self.iconTheme

                windowDecoration = unicode(
                    parser.get_locale('Style', 'windowDecoration', ''))
                styleThumb = unicode(
                    os.path.join(
                        "/usr/share/kde4/apps/kaptan/kaptan/kde-themes/",
                        parser.get_locale('Style', 'thumbnail', '')))

                colorDict = {}
                colorDir = "/usr/share/kde4/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": self.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.listIcon.connect(self.ui.listIcon,
                                 SIGNAL("itemClicked(QListWidgetItem *)"),
                                 self.setIcon)
        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)
Пример #5
0
    def getThemeDetails(self, desktopFiles):

        self.styleDetails = {}
        parser = DesktopParser()
        parser.read("/usr/share/kde4/apps/kaptan/kaptan/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', ''))

        self.styleName = styleName
        self.styleDesc = styleDesc

        # 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 = parser.get_locale('Style', 'widgetStyle', '')
        desktopTheme = unicode(parser.get_locale('Style', 'desktopTheme', ''))
        colorScheme = unicode(parser.get_locale('Style', 'colorScheme', ''))

        #FIXME : Make me dynamic
        self.iconTheme = "oxygen"

        windowDecoration = unicode(
            parser.get_locale('Style', 'windowDecoration', ''))
        styleThumb = unicode(
            os.path.join("/usr/share/kde4/apps/kaptan/kaptan/kde_themes/",
                         parser.get_locale('Style', 'thumbnail', '')))

        colorDict = {}
        colorDir = "/usr/share/kde4/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": self.iconTheme,
            "windowDecoration": windowDecoration,
            "panelPosition": panelPosition
        }
        return self.styleDetails[styleName]
Пример #6
0
    def getThemeDetails(self,desktopFiles):

        self.styleDetails = {}
        parser = DesktopParser()
        parser.read("/usr/share/kde4/apps/kaptan/kaptan/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', ''))

        self.styleName = styleName
        self.styleDesc = styleDesc

        # 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 = parser.get_locale('Style', 'widgetStyle', '')
        desktopTheme = unicode(parser.get_locale('Style', 'desktopTheme', ''))
        colorScheme = unicode(parser.get_locale('Style', 'colorScheme', ''))

        #FIXME : Make me dynamic
        self.iconTheme = "oxygen"

        windowDecoration = unicode(parser.get_locale('Style', 'windowDecoration', ''))
        styleThumb = unicode(os.path.join("/usr/share/kde4/apps/kaptan/kaptan/kde_themes/",  parser.get_locale('Style', 'thumbnail','')))

        colorDict = {}
        colorDir = "/usr/share/kde4/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": self.iconTheme,
                "windowDecoration": windowDecoration,
                "panelPosition": panelPosition
                }
        return self.styleDetails[styleName]
Пример #7
0
    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()

        # 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
            thumbFolder = os.listdir(
                os.path.join(os.path.split(str(desktopFiles))[0], "contents"))
            """
            Appearantly the thumbnail names doesn't have a standart.
            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),
                                         unicode(wallpaperDesc),
                                         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.connect(self.ui.listWallpaper,
                                      SIGNAL("itemSelectionChanged()"),
                                      self.setWallpaper)
        self.ui.checkBox.connect(self.ui.checkBox, SIGNAL("stateChanged(int)"),
                                 self.disableWidgets)
        self.ui.buttonChooseWp.connect(self.ui.buttonChooseWp,
                                       SIGNAL("clicked()"),
                                       self.selectWallpaper)
Пример #8
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/share/kde4/apps/kaptan/kaptan/kde-themes", "*.style")

        for desktopFiles in lst2:
            parser = DesktopParser()
            parser.read("/usr/share/kde4/apps/kaptan/kaptan/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', ''))

                self.iconTheme =  unicode(self.ui.listIcon.selectedItems()[0].text())
                self.iconTheme = str(self.iconTheme.split()[0]).lower()
                self.__class__.screenSettings["iconTheme"] = self.iconTheme

                windowDecoration = unicode(parser.get_locale('Style', 'windowDecoration', ''))
                styleThumb = unicode(os.path.join("/usr/share/kde4/apps/kaptan/kaptan/kde-themes/",  parser.get_locale('Style', 'thumbnail','')))

                colorDict = {}
                colorDir = "/usr/share/kde4/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": self.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.listIcon.connect(self.ui.listIcon, SIGNAL("itemClicked(QListWidgetItem *)"), self.setIcon)
        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)