def saveConfig(self): self.saveRequired(False) # Reset save button state # Disable quit button self.ui.btnQuit.setEnabled(False) # Save button icon & text s_btnIcon = self.ui.btnSave.icon() s_btnText = self.ui.btnSave.text() self.ui.btnSave.setText(u"Saving...") self.ui.btnSave.setIcon(QIcon()) self.repaint() qApp.processEvents() tools.msgDebug(u"Saving configuration...", __name__) config = Config() # Save Data config.setShows(self.myShows) config.setColors(self.myColors) if self.ui.radioDispFixedLines.isChecked(): value = "Fixed" else: value = "Automatic" config.set("display", "type", value) config.set("display", "past_days", str(self.ui.spinNumPastDays.value())) config.set("display", "lines_fixed", str(self.ui.spinFixedDispLines.value())) config.set("display", "lines_min", str(self.ui.spinMinDispLines.value())) config.set("display", "lines_max", str(self.ui.spinMaxDispLines.value())) config.set("display", "format", str(self.ui.leditFormat.text())) sep = self.ui.leditDateSeparator.text() list = self.ui.comboDateFormat.itemData( self.ui.comboDateFormat.currentIndex()).toStringList() dateFormat = list.join(sep) config.set("display", "date_separator", str(sep)) config.set("display", "date_format", str(dateFormat)) config.set("misc", "cache_expiration", str(self.ui.spinCacheExpiration.value())) config.set("misc", "browser", str(self.ui.leditBrowser.text())) config.set("misc", "theme", str(self.ui.comboTheme.currentText())) # Set this so that the widget knows something changed config.set("main", "config_changed", "True") tools.msgDebug(u"Saving done!", __name__) config.close() # Destroy Config() # Restore buttons self.ui.btnSave.setIcon(s_btnIcon) self.ui.btnSave.setText(s_btnText) self.ui.btnQuit.setEnabled(True)
def storeNewWhenFormat(dummy): config = Config() config.set( "misc", "when_format", str( applet.whenFormat ) ) config.close()
def initWidget(widget): global g_nextCacheRefresh, g_showList, g_showIds, g_cacheExpiration, g_pastDays, g_linesMin, g_linesMax # Pass the widget reference Applet.widget = widget # Init splash splash = Applet().Splash() splash.show() # Create dir structure splash.setText("Checking config dirs...") createConfigDirs() # Read config splash.setText("Reading config...") config = Config() # Check whether we want DEBUG messages enabled or not if config.getboolean("main", "debug") == False: tools.msgDebug("Disabling debug messages !", __name__) Globals.DEBUG = False # Copy GUI files (if necessary) if Globals().versions['nextShows'] != config.get("main", "version") \ or not "launchGUI" in os.listdir( Globals().nsCGuiBaseDir ): # Init dir structures and copy files splash.setText("Setup GUI...") copyThemeFilesToConfigDir(widget) config.set("main", "version", Globals().versions['nextShows']) # Get other useful infos from config splash.setText("Reading config...") displayType = config.get("display", "type") if displayType == "Fixed": g_linesMax = config.getint("display", "lines_fixed") g_linesMin = g_linesMax else: g_linesMin = config.getint("display", "lines_min") g_linesMax = config.getint("display", "lines_max") g_cacheExpiration = config.getint("misc", "cache_expiration") g_pastDays = config.getint("display", "past_days") applet.colorList = config.getColors() applet.episodeFormatString = config.get( "display", "format") applet.browser = config.get( "misc", "browser") applet.dateFormat = config.get( "display", "date_format") applet.whenFormat = config.getint("misc", "when_format") # Getting the show list splash.setText("Getting show list....") g_showList = config.getShows() # Extract IDs g_showIds = [ show['id'] for show in g_showList ] # Init cache cache.setExpiration( g_cacheExpiration ) cache.showIds = g_showIds # Refresh cache if necessary staledList = cache.getStaledCacheFiles() for id in staledList: for show in g_showList: if show['id'] == id: showName = show['name'] splash.setText("Updating cache: '%s'..." % showName) cache.cacheEpisodeList( id ) # Fetch data to display splash.setText("Filtering episodes...") data = Data() episodeList = data.getEpisodeList( g_showIds, g_pastDays, g_linesMax ) applet.episodeList = episodeList # Close the splash splash.setText("Done!") splash.hide() # Init widget # Fallback (for compatibility reasons) # "[display] theme=" was moved to "[misc] theme=" try: applet.themeName = config.get("misc", "theme") except: applet.themeName = Globals().defaultThemeName numReturnedEpisode = len( episodeList ) if numReturnedEpisode < g_linesMin: themeLines = g_linesMin elif numReturnedEpisode > g_linesMax: themeLines = g_linesMax else: themeLines = numReturnedEpisode applet.themeLines = themeLines applet.drawBackground() applet.printEpisodeList() # Store next cache refresh g_nextCacheRefresh = cache.getNextRefreshTS() # Setup menu entry for config GUI karamba.addMenuConfigOption(widget, "config_gui", "Configure...") karamba.setMenuConfigOption(widget, "config_gui", 0)
def storeNewWhenFormat(dummy): config = Config() config.set("misc", "when_format", str(applet.whenFormat)) config.close()
def initWidget(widget): global g_nextCacheRefresh, g_showList, g_showIds, g_cacheExpiration, g_pastDays, g_linesMin, g_linesMax # Pass the widget reference Applet.widget = widget # Init splash splash = Applet().Splash() splash.show() # Create dir structure splash.setText("Checking config dirs...") createConfigDirs() # Read config splash.setText("Reading config...") config = Config() # Check whether we want DEBUG messages enabled or not if config.getboolean("main", "debug") == False: tools.msgDebug("Disabling debug messages !", __name__) Globals.DEBUG = False # Copy GUI files (if necessary) if Globals().versions['nextShows'] != config.get("main", "version") \ or not "launchGUI" in os.listdir( Globals().nsCGuiBaseDir ): # Init dir structures and copy files splash.setText("Setup GUI...") copyThemeFilesToConfigDir(widget) config.set("main", "version", Globals().versions['nextShows']) # Get other useful infos from config splash.setText("Reading config...") displayType = config.get("display", "type") if displayType == "Fixed": g_linesMax = config.getint("display", "lines_fixed") g_linesMin = g_linesMax else: g_linesMin = config.getint("display", "lines_min") g_linesMax = config.getint("display", "lines_max") g_cacheExpiration = config.getint("misc", "cache_expiration") g_pastDays = config.getint("display", "past_days") applet.colorList = config.getColors() applet.episodeFormatString = config.get("display", "format") applet.browser = config.get("misc", "browser") applet.dateFormat = config.get("display", "date_format") applet.whenFormat = config.getint("misc", "when_format") # Getting the show list splash.setText("Getting show list....") g_showList = config.getShows() # Extract IDs g_showIds = [show['id'] for show in g_showList] # Init cache cache.setExpiration(g_cacheExpiration) cache.showIds = g_showIds # Refresh cache if necessary staledList = cache.getStaledCacheFiles() for id in staledList: for show in g_showList: if show['id'] == id: showName = show['name'] splash.setText("Updating cache: '%s'..." % showName) cache.cacheEpisodeList(id) # Fetch data to display splash.setText("Filtering episodes...") data = Data() episodeList = data.getEpisodeList(g_showIds, g_pastDays, g_linesMax) applet.episodeList = episodeList # Close the splash splash.setText("Done!") splash.hide() # Init widget # Fallback (for compatibility reasons) # "[display] theme=" was moved to "[misc] theme=" try: applet.themeName = config.get("misc", "theme") except: applet.themeName = Globals().defaultThemeName numReturnedEpisode = len(episodeList) if numReturnedEpisode < g_linesMin: themeLines = g_linesMin elif numReturnedEpisode > g_linesMax: themeLines = g_linesMax else: themeLines = numReturnedEpisode applet.themeLines = themeLines applet.drawBackground() applet.printEpisodeList() # Store next cache refresh g_nextCacheRefresh = cache.getNextRefreshTS() # Setup menu entry for config GUI karamba.addMenuConfigOption(widget, "config_gui", "Configure...") karamba.setMenuConfigOption(widget, "config_gui", 0)
def saveConfig(self): self.saveRequired( False ) # Reset save button state # Disable quit button self.ui.btnQuit.setEnabled( False ) # Save button icon & text s_btnIcon = self.ui.btnSave.icon() s_btnText = self.ui.btnSave.text() self.ui.btnSave.setText(u"Saving...") self.ui.btnSave.setIcon(QIcon()) self.repaint() qApp.processEvents() tools.msgDebug(u"Saving configuration...", __name__) config = Config() # Save Data config.setShows( self.myShows ) config.setColors( self.myColors ) if self.ui.radioDispFixedLines.isChecked(): value = "Fixed" else: value = "Automatic" config.set( "display", "type", value ) config.set( "display", "past_days", str( self.ui.spinNumPastDays.value() ) ) config.set( "display", "lines_fixed", str( self.ui.spinFixedDispLines.value() ) ) config.set( "display", "lines_min", str( self.ui.spinMinDispLines.value() ) ) config.set( "display", "lines_max", str( self.ui.spinMaxDispLines.value() ) ) config.set( "display", "format", str( self.ui.leditFormat.text() ) ) sep = self.ui.leditDateSeparator.text() list = self.ui.comboDateFormat.itemData( self.ui.comboDateFormat.currentIndex() ).toStringList() dateFormat = list.join(sep) config.set( "display", "date_separator",str( sep ) ) config.set( "display", "date_format", str( dateFormat ) ) config.set( "misc", "cache_expiration", str( self.ui.spinCacheExpiration.value() ) ) config.set( "misc", "browser", str( self.ui.leditBrowser.text() ) ) config.set( "misc", "theme", str( self.ui.comboTheme.currentText() ) ) # Set this so that the widget knows something changed config.set( "main", "config_changed", "True" ) tools.msgDebug(u"Saving done!", __name__) config.close() # Destroy Config() # Restore buttons self.ui.btnSave.setIcon( s_btnIcon ) self.ui.btnSave.setText( s_btnText ) self.ui.btnQuit.setEnabled( True )