fixes bug #380
[enigma2.git] / lib / python / Screens / MovieSelection.py
index 5951653ffc38d5bd249e38146d80a79cd6e49d3c..0468f8a010fc72f5f12b869cdfb8cb55a9626361 100644 (file)
@@ -7,8 +7,9 @@ from Components.DiskInfo import DiskInfo
 from Components.Pixmap import Pixmap
 from Components.Label import Label
 from Components.PluginComponent import plugins
-from Components.config import config, ConfigSubsection, ConfigText, ConfigInteger, ConfigLocations
+from Components.config import config, ConfigSubsection, ConfigText, ConfigInteger, ConfigLocations, ConfigSet
 from Components.Sources.ServiceEvent import ServiceEvent
+from Components.UsageConfig import defaultMoviePath
 
 from Plugins.Plugin import PluginDescriptor
 
@@ -31,6 +32,7 @@ config.movielist.last_timer_videodir = ConfigText(default=resolveFilename(SCOPE_
 config.movielist.videodirs = ConfigLocations(default=[resolveFilename(SCOPE_HDD)])
 config.movielist.first_tags = ConfigText(default="")
 config.movielist.second_tags = ConfigText(default="")
+config.movielist.last_selected_tags = ConfigSet([], default=[])
 
 
 def setPreferredTagEditor(te):
@@ -65,20 +67,20 @@ class MovieContextMenu(Screen):
                        })
 
                menu = [(_("delete..."), self.delete)]
-               
-               for p in plugins.getPlugins(PluginDescriptor.WHERE_MOVIELIST):
-                       menu.append((p.description, boundFunction(self.execPlugin, p)))
-               
+               menu.extend([(p.description, boundFunction(self.execPlugin, p)) for p in plugins.getPlugins(PluginDescriptor.WHERE_MOVIELIST)])
+
                if config.movielist.moviesort.value == MovieList.SORT_ALPHANUMERIC:
                        menu.append((_("sort by date"), boundFunction(self.sortBy, MovieList.SORT_RECORDED)))
                else:
                        menu.append((_("alphabetic sort"), boundFunction(self.sortBy, MovieList.SORT_ALPHANUMERIC)))
                
-               menu.append((_("list style default"), boundFunction(self.listType, MovieList.LISTTYPE_ORIGINAL)))
-               menu.append((_("list style compact with description"), boundFunction(self.listType, MovieList.LISTTYPE_COMPACT_DESCRIPTION)))
-               menu.append((_("list style compact"), boundFunction(self.listType, MovieList.LISTTYPE_COMPACT)))
-               menu.append((_("list style single line"), boundFunction(self.listType, MovieList.LISTTYPE_MINIMAL)))
-               
+               menu.extend((
+                       (_("list style default"), boundFunction(self.listType, MovieList.LISTTYPE_ORIGINAL)),
+                       (_("list style compact with description"), boundFunction(self.listType, MovieList.LISTTYPE_COMPACT_DESCRIPTION)),
+                       (_("list style compact"), boundFunction(self.listType, MovieList.LISTTYPE_COMPACT)),
+                       (_("list style single line"), boundFunction(self.listType, MovieList.LISTTYPE_MINIMAL))
+               ))
+
                if config.movielist.description.value == MovieList.SHOW_DESCRIPTION:
                        menu.append((_("hide extended description"), boundFunction(self.showDescription, MovieList.HIDE_DESCRIPTION)))
                else:
@@ -168,7 +170,10 @@ class MovieSelection(Screen, HelpableScreen, SelectionEventInfo):
                HelpableScreen.__init__(self)
 
                self.tags = [ ]
-               self.selected_tags = None
+               if selectedmovie:
+                       self.selected_tags = config.movielist.last_selected_tags.value
+               else:
+                       self.selected_tags = None
                self.selected_tags_ele = None
 
                self.movemode = False
@@ -183,8 +188,8 @@ class MovieSelection(Screen, HelpableScreen, SelectionEventInfo):
                self["DescriptionBorder"] = Pixmap()
                self["DescriptionBorder"].hide()
 
-               if not pathExists(config.movielist.last_videodir.value):
-                       config.movielist.last_videodir.value = resolveFilename(SCOPE_HDD)
+               if not fileExists(config.movielist.last_videodir.value):
+                       config.movielist.last_videodir.value = defaultMoviePath()
                        config.movielist.last_videodir.save()
                self.current_ref = eServiceReference("2:0:1:0:0:0:0:0:0:0:" + config.movielist.last_videodir.value)
 
@@ -292,6 +297,7 @@ class MovieSelection(Screen, HelpableScreen, SelectionEventInfo):
                self.close(None)
 
        def saveconfig(self):
+               config.movielist.last_selected_tags.value = self.selected_tags
                config.movielist.moviesort.save()
                config.movielist.listtype.save()
                config.movielist.description.save()
@@ -339,8 +345,8 @@ class MovieSelection(Screen, HelpableScreen, SelectionEventInfo):
                self["list"].setSortType(type)
 
        def reloadList(self, sel = None, home = False):
-               if not pathExists(config.movielist.last_videodir.value):
-                       path = resolveFilename(SCOPE_HDD)
+               if not fileExists(config.movielist.last_videodir.value):
+                       path = defaultMoviePath()
                        config.movielist.last_videodir.value = path
                        config.movielist.last_videodir.save()
                        self.current_ref = eServiceReference("2:0:1:0:0:0:0:0:0:0:" + path)
@@ -370,7 +376,7 @@ class MovieSelection(Screen, HelpableScreen, SelectionEventInfo):
 
        def gotFilename(self, res):
                if res is not None and res is not config.movielist.last_videodir.value:
-                       if pathExists(res):
+                       if fileExists(res):
                                config.movielist.last_videodir.value = res
                                config.movielist.last_videodir.save()
                                self.current_ref = eServiceReference("2:0:1:0:0:0:0:0:0:0:" + res)
@@ -392,7 +398,7 @@ class MovieSelection(Screen, HelpableScreen, SelectionEventInfo):
        def showTagsN(self, tagele):
                if not self.tags:
                        self.showTagWarning()
-               elif not tagele or self.selected_tags_ele == tagele or not tagele.value in self.tags:
+               elif not tagele or (self.selected_tags and tagele.value in self.selected_tags) or not tagele.value in self.tags:
                        self.showTagsMenu(tagele)
                else:
                        self.selected_tags_ele = tagele