Beispiel #1
0
    def get_theme_data(self, theme_level=None):
        """
        Get the theme appropriate for this item

        :param theme_level: The theme_level to use,
                            the value in Settings is used when this value is missinig
        """
        if theme_level is None:
            theme_level = self.settings.value('themes/theme level')
        theme_manager = Registry().get('theme_manager')
        # Just assume we use the global theme.
        theme = theme_manager.global_theme
        if theme_level != ThemeLevel.Global:
            service_theme = self.settings.value('servicemanager/service theme')
            # Service or Song level, so assume service theme (if it exists and item in service)
            # but use song theme if level is song (and it exists)
            if service_theme and self.from_service:
                theme = service_theme
            if theme_level == ThemeLevel.Song and self.theme:
                theme = self.theme
        theme = theme_manager.get_theme_data(theme)
        # Clean up capabilities and reload from the theme.
        if self.is_text():
            if self.is_capable(ItemCapabilities.CanStream):
                self.remove_capability(ItemCapabilities.CanStream)
            if self.is_capable(ItemCapabilities.HasBackgroundVideo):
                self.remove_capability(ItemCapabilities.HasBackgroundVideo)
            if theme.background_type == BackgroundType.to_string(BackgroundType.Stream):
                self.add_capability(ItemCapabilities.CanStream)
            if theme.background_type == BackgroundType.to_string(BackgroundType.Video):
                self.video_file_name = theme.background_filename
                self.add_capability(ItemCapabilities.HasBackgroundVideo)
        return theme