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 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 commandOutput(widget, pid, output): global g_configGuiPid if pid == g_configGuiPid: config = Config() # Check whether config was changed or not try: configChanged = config.getboolean("main", "config_changed") config.remove_option("main", "config_changed") except: configChanged = False config.close() if configChanged: karamba.reloadTheme(widget) return else: g_configGuiPid = None
def commandOutput(widget, pid, output): global g_configGuiPid if pid == g_configGuiPid: config = Config() # Check whether config was changed or not try: configChanged = config.getboolean("main", "config_changed") config.remove_option("main", "config_changed") except: configChanged = False config.close() if configChanged: karamba.reloadTheme(widget) return else: g_configGuiPid = None
def initForm(self): # 1st tab labels self.ui.lblResultsDisplayed.setText(u"Displayed results: 0/0") self.ui.lblTrackedShows.setText(u"Tracked shows: 0") # Format Sample fmtSample = u"<u><b>Sample:</b></u> <b>show:</b> %s, <b>title:</b> %s, <b>season</b>: %d, <b>episode</b>: %d" % ( Globals().sampleEpisode['show'], Globals().sampleEpisode['title'], Globals().sampleEpisode['season'], Globals().sampleEpisode['episode']) self.ui.lblFormatSample.setText(fmtSample) #### Versions version = Globals().versions # nextShows Footer Release labelContent = str(self.ui.lblFooterRelease.text()) self.ui.lblFooterRelease.setText(labelContent % version['nextShows']) # nextShows Release (About tab) labelContent = str(self.ui.lblNextShowsVersion.text()) self.ui.lblNextShowsVersion.setText(labelContent % version['nextShows']) # Libs releases (About tab) # Python version a, b, c, d, e = sys.version_info pythonVersion = "%d.%d.%d" % (a, b, c) # labelContent = str(self.ui.lblLibsVersion.text()) self.ui.lblLibsVersion.setText( labelContent % (pythonVersion, QT_VERSION_STR, PYQT_VERSION_STR, version["KDE"])) #### Default values self.ui.spinNumPastDays.setMinimum(0) self.ui.spinNumPastDays.setMaximum(99) #self.ui.spinNumPastDays.setValue(1) self.ui.spinFixedDispLines.setMinimum(1) self.ui.spinFixedDispLines.setMaximum(50) #self.ui.spinFixedDispLines.setValue(10) self.ui.spinMinDispLines.setMinimum(1) self.ui.spinMinDispLines.setMaximum(49) #self.ui.spinMinDispLines.setValue(1) self.ui.spinMaxDispLines.setMinimum(2) self.ui.spinMaxDispLines.setMaximum(50) #self.ui.spinMaxDispLines.setValue(10) # self.ui.spinColorsSingleDay.setMinimum(-99) self.ui.spinColorsSingleDay.setMaximum(99) self.ui.spinColorsSingleDay.setValue(0) self.ui.spinColorsFrom.setMinimum(-99) self.ui.spinColorsFrom.setMaximum(98) self.ui.spinColorsFrom.setValue(0) self.ui.spinColorsTo.setMinimum(-98) self.ui.spinColorsTo.setMaximum(99) self.ui.spinColorsTo.setValue(10) # default color for "Select color" self.ui.lblSelectColor.setPixmap( self.drawPreviewColor(self.lastColorUsed, 36, 36)) # Theme combo self.ui.comboTheme.addItems(Globals().availableThemes) #### #### Read config #### tools.msgDebug(u"Reading config...", __name__) config = Config() # Enable/Disable DEBUG if config.getboolean("main", "debug") == False: tools.msgDebug("Disabling debug messages !", __name__) Globals.DEBUG = False # Get Data self.myShows = config.getShows() self.displayMyShows() self.myColors = config.getColors() self.ui.lblDefaultColor.setPixmap( self.drawPreviewColor(self.myColors['default'], 36, 36)) self.displayMyColors() if config.get("display", "type") == "Fixed": self.ui.radioDispFixedLines.setChecked(True) else: self.ui.radioDispAutoResize.setChecked(True) self.ui.spinNumPastDays.setValue( int(config.get("display", "past_days"))) self.ui.spinFixedDispLines.setValue( int(config.get("display", "lines_fixed"))) self.ui.spinMinDispLines.setValue( int(config.get("display", "lines_min"))) self.ui.spinMaxDispLines.setValue( int(config.get("display", "lines_max"))) self.ui.leditFormat.setText(config.get("display", "format")) self.refreshFormatPreview(str(self.ui.leditFormat.text())) self.ui.spinCacheExpiration.setValue( int(config.get("misc", "cache_expiration"))) self.ui.leditBrowser.setText(config.get("misc", "browser")) # Fallback code since the "theme" key was located in the [display] section # in versions < 2.1.0 try: idx = int(Globals().availableThemes.index( config.get("misc", "theme"))) except: idx = 0 self.ui.comboTheme.setCurrentIndex(idx) # Date Separator # Fallback code since the "date_separator" key doesn't exist in version < 2.1.0 try: sep = config.get("display", "date_separator") except: sep = "/" self.ui.leditDateSeparator.setText(sep) # Date Format dateFormat = config.get("display", "date_format") data = ["%" + a for a in dateFormat.split(sep)] idx = self.ui.comboDateFormat.findData(QVariant(data)) if idx == -1: idx = 0 self.ui.comboDateFormat.setCurrentIndex(idx) config.close() # Reset "Save" button state self.saveRequired(False) tools.msgDebug(u"Done!", __name__)
def storeNewWhenFormat(dummy): config = Config() config.set( "misc", "when_format", str( applet.whenFormat ) ) config.close()
def storeNewWhenFormat(dummy): config = Config() config.set("misc", "when_format", str(applet.whenFormat)) config.close()
def initForm(self): # 1st tab labels self.ui.lblResultsDisplayed.setText( u"Displayed results: 0/0" ) self.ui.lblTrackedShows.setText( u"Tracked shows: 0" ) # Format Sample fmtSample = u"<u><b>Sample:</b></u> <b>show:</b> %s, <b>title:</b> %s, <b>season</b>: %d, <b>episode</b>: %d" % ( Globals().sampleEpisode['show'], Globals().sampleEpisode['title'], Globals().sampleEpisode['season'], Globals().sampleEpisode['episode'] ) self.ui.lblFormatSample.setText( fmtSample ) #### Versions version = Globals().versions # nextShows Footer Release labelContent=str(self.ui.lblFooterRelease.text()) self.ui.lblFooterRelease.setText(labelContent % version['nextShows']) # nextShows Release (About tab) labelContent=str(self.ui.lblNextShowsVersion.text()) self.ui.lblNextShowsVersion.setText(labelContent % version['nextShows']) # Libs releases (About tab) # Python version a,b,c,d,e = sys.version_info pythonVersion = "%d.%d.%d" % (a, b, c) # labelContent=str(self.ui.lblLibsVersion.text()) self.ui.lblLibsVersion.setText(labelContent % ( pythonVersion, QT_VERSION_STR, PYQT_VERSION_STR, version["KDE"]) ) #### Default values self.ui.spinNumPastDays.setMinimum(0) self.ui.spinNumPastDays.setMaximum(99) #self.ui.spinNumPastDays.setValue(1) self.ui.spinFixedDispLines.setMinimum(1) self.ui.spinFixedDispLines.setMaximum(50) #self.ui.spinFixedDispLines.setValue(10) self.ui.spinMinDispLines.setMinimum(1) self.ui.spinMinDispLines.setMaximum(49) #self.ui.spinMinDispLines.setValue(1) self.ui.spinMaxDispLines.setMinimum(2) self.ui.spinMaxDispLines.setMaximum(50) #self.ui.spinMaxDispLines.setValue(10) # self.ui.spinColorsSingleDay.setMinimum(-99) self.ui.spinColorsSingleDay.setMaximum(99) self.ui.spinColorsSingleDay.setValue(0) self.ui.spinColorsFrom.setMinimum(-99) self.ui.spinColorsFrom.setMaximum(98) self.ui.spinColorsFrom.setValue(0) self.ui.spinColorsTo.setMinimum(-98) self.ui.spinColorsTo.setMaximum(99) self.ui.spinColorsTo.setValue(10) # default color for "Select color" self.ui.lblSelectColor.setPixmap( self.drawPreviewColor( self.lastColorUsed, 36, 36 ) ) # Theme combo self.ui.comboTheme.addItems( Globals().availableThemes ) #### #### Read config #### tools.msgDebug(u"Reading config...", __name__) config = Config() # Enable/Disable DEBUG if config.getboolean("main", "debug") == False: tools.msgDebug("Disabling debug messages !", __name__) Globals.DEBUG = False # Get Data self.myShows = config.getShows() self.displayMyShows() self.myColors = config.getColors() self.ui.lblDefaultColor.setPixmap( self.drawPreviewColor( self.myColors['default'], 36, 36 ) ) self.displayMyColors() if config.get("display", "type") == "Fixed": self.ui.radioDispFixedLines.setChecked( True ) else: self.ui.radioDispAutoResize.setChecked( True ) self.ui.spinNumPastDays.setValue( int( config.get( "display", "past_days" ) ) ) self.ui.spinFixedDispLines.setValue( int( config.get( "display", "lines_fixed" ) ) ) self.ui.spinMinDispLines.setValue( int( config.get( "display", "lines_min" ) ) ) self.ui.spinMaxDispLines.setValue( int( config.get( "display", "lines_max" ) ) ) self.ui.leditFormat.setText( config.get( "display", "format" ) ) self.refreshFormatPreview( str(self.ui.leditFormat.text()) ) self.ui.spinCacheExpiration.setValue( int( config.get( "misc", "cache_expiration" ) ) ) self.ui.leditBrowser.setText( config.get( "misc", "browser" ) ) # Fallback code since the "theme" key was located in the [display] section # in versions < 2.1.0 try: idx = int( Globals().availableThemes.index( config.get( "misc", "theme" ) ) ) except: idx = 0 self.ui.comboTheme.setCurrentIndex( idx ) # Date Separator # Fallback code since the "date_separator" key doesn't exist in version < 2.1.0 try: sep = config.get( "display", "date_separator" ) except: sep = "/" self.ui.leditDateSeparator.setText( sep ) # Date Format dateFormat = config.get( "display", "date_format" ) data = [ "%"+a for a in dateFormat.split( sep ) ] idx = self.ui.comboDateFormat.findData( QVariant( data ) ) if idx==-1: idx = 0 self.ui.comboDateFormat.setCurrentIndex( idx ) config.close() # Reset "Save" button state self.saveRequired(False) tools.msgDebug(u"Done!", __name__)