Example #1
0
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
Example #2
0
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
Example #3
0
    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__)
Example #4
0
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)
Example #5
0
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)
Example #6
0
    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__)