from Components.Pixmap import Pixmap
from Components.Label import Label
from Components.PluginComponent import plugins
-from Components.config import config, ConfigSubsection, ConfigInteger, configfile
+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
from Screens.MessageBox import MessageBox
from Screens.ChoiceBox import ChoiceBox
+from Screens.LocationBox import MovieLocationBox
from Screens.HelpMenu import HelpableScreen
from Tools.Directories import *
config.movielist.moviesort = ConfigInteger(default=MovieList.SORT_RECORDED)
config.movielist.listtype = ConfigInteger(default=MovieList.LISTTYPE_ORIGINAL)
config.movielist.description = ConfigInteger(default=MovieList.HIDE_DESCRIPTION)
+config.movielist.last_videodir = ConfigText(default=resolveFilename(SCOPE_HDD))
+config.movielist.last_timer_videodir = ConfigText(default=resolveFilename(SCOPE_HDD))
+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):
+ global preferredTagEditor
+ try:
+ if preferredTagEditor == None:
+ preferredTagEditor = te
+ print "Preferred tag editor changed to ", preferredTagEditor
+ else:
+ print "Preferred tag editor already set to ", preferredTagEditor
+ print "ignoring ", te
+ except:
+ preferredTagEditor = te
+ print "Preferred tag editor set to ", preferredTagEditor
+
+def getPreferredTagEditor():
+ global preferredTagEditor
+ return preferredTagEditor
+
+setPreferredTagEditor(None)
class MovieContextMenu(Screen):
def __init__(self, session, csel, service):
})
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:
self.close(False)
def sortBy(self, newType):
- self.csel.saveflag = True
config.movielist.moviesort.value = newType
- self.csel.selectedmovie = self.csel.getCurrent()
self.csel.setSortType(newType)
self.csel.reloadList()
- self.csel.moveTo()
self.close()
def listType(self, newType):
- self.csel.saveflag = True
config.movielist.listtype.value = newType
self.csel.setListType(newType)
self.csel.list.redrawList()
self.close()
def showDescription(self, newType):
- self.csel.saveflag = True
config.movielist.description.value = newType
self.csel.setDescriptionState(newType)
self.csel.updateDescription()
if result == False:
self.session.openWithCallback(self.close, MessageBox, _("Delete failed!"), MessageBox.TYPE_ERROR)
else:
- list = self.csel["list"].removeService(self.service)
+ self.csel["list"].removeService(self.service)
+ self.csel["freeDiskSpace"].update()
self.close()
class SelectionEventInfo:
self["Service"] = ServiceEvent()
self.list.connectSelChanged(self.__selectionChanged)
self.timer = eTimer()
- self.timer.timeout.get().append(self.updateEventInfo)
+ self.timer.callback.append(self.updateEventInfo)
self.onShown.append(self.__selectionChanged)
def __selectionChanged(self):
Screen.__init__(self, session)
HelpableScreen.__init__(self)
- self.saveflag = False
-
self.tags = [ ]
- self.selected_tags = None
-
- self.current_ref = eServiceReference("2:0:1:0:0:0:0:0:0:0:" + resolveFilename(SCOPE_HDD))
+ if selectedmovie:
+ self.selected_tags = config.movielist.last_selected_tags.value
+ else:
+ self.selected_tags = None
+ self.selected_tags_ele = None
self.movemode = False
self.bouquet_mark_edit = False
self.delayTimer = eTimer()
- self.delayTimer.timeout.get().append(self.updateHDDData)
+ self.delayTimer.callback.append(self.updateHDDData)
self["waitingtext"] = Label(_("Please wait... Loading list..."))
self["DescriptionBorder"] = Pixmap()
self["DescriptionBorder"].hide()
+ 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)
+
self["list"] = MovieList(None,
config.movielist.listtype.value,
config.movielist.moviesort.value,
# Need list for init
SelectionEventInfo.__init__(self)
- self["key_red"] = Button(_("All..."))
+ self["key_red"] = Button(_("All"))
self["key_green"] = Button("")
self["key_yellow"] = Button("")
self["key_blue"] = Button("")
- #self["freeDiskSpace"] = DiskInfo(resolveFilename(SCOPE_HDD), DiskInfo.FREE, update=False)
- self["freeDiskSpace"] = self.diskinfo = DiskInfo(resolveFilename(SCOPE_HDD), DiskInfo.FREE, update=False)
+ self["freeDiskSpace"] = self.diskinfo = DiskInfo(config.movielist.last_videodir.value, DiskInfo.FREE, update=False)
+
+ if config.usage.setup_level.index >= 2: # expert+
+ self["InfobarActions"] = HelpableActionMap(self, "InfobarActions",
+ {
+ "showMovies": (self.doPathSelect, _("select the movie path")),
+ })
+
self["MovieSelectionActions"] = HelpableActionMap(self, "MovieSelectionActions",
{
self["ColorActions"] = HelpableActionMap(self, "ColorActions",
{
"red": (self.showAll, _("show all")),
- "green": (self.showTagsFirst, _("show first tag")),
- "yellow": (self.showTagsSecond, _("show second tag")),
- "blue": (self.showTagsMenu, _("show tag menu")),
+ "green": (self.showTagsFirst, _("show first selected tag")),
+ "yellow": (self.showTagsSecond, _("show second selected tag")),
+ "blue": (self.showTagsSelect, _("show tag menu")),
})
self["OkCancelActions"] = HelpableActionMap(self, "OkCancelActions",
})
self.onShown.append(self.go)
+ self.onLayoutFinish.append(self.saveListsize)
self.inited = False
def updateDescription(self):
# this is of course not the right way to do this.
self.delayTimer.start(10, 1)
self.inited=True
- # as this workaround is here anyways we can wait until the skin is initialized
- # and afterwards read out the information we need to draw the dynamic style
+
+ def saveListsize(self):
listsize = self["list"].instance.size()
self.listWidth = listsize.width()
self.listHeight = listsize.height()
self.updateDescription()
def updateHDDData(self):
- self.reloadList()
- if self.selectedmovie is not None:
- self.moveTo()
+ self.reloadList(self.selectedmovie)
self["waitingtext"].visible = False
- self["freeDiskSpace"].update()
- self.updateTags()
def moveTo(self):
self["list"].moveTo(self.selectedmovie)
self.close(None)
def saveconfig(self):
- if self.saveflag == True:
- config.movielist.moviesort.save()
- config.movielist.listtype.save()
- config.movielist.description.save()
- configfile.save()
- self.saveflag = False
+ config.movielist.last_selected_tags.value = self.selected_tags
+ config.movielist.moviesort.save()
+ config.movielist.listtype.save()
+ config.movielist.description.save()
def getTagDescription(self, tag):
# TODO: access the tag database
def updateTags(self):
# get a list of tags available in this list
self.tags = list(self["list"].tags)
-
- # by default, we do not display any filtering options
- self.tag_first = ""
- self.tag_second = ""
-
- # when tags are present, however, the first two are
- # directly mapped to the second, third ("green", "yellow") buttons
- if len(self.tags) > 0:
- self.tag_first = self.getTagDescription(self.tags[0])
-
- if len(self.tags) > 1:
- self.tag_second = self.getTagDescription(self.tags[1])
-
+
+ if not self.tags:
+ # by default, we do not display any filtering options
+ self.tag_first = ""
+ self.tag_second = ""
+ else:
+ tmp = config.movielist.first_tags.value
+ if tmp in self.tags:
+ self.tag_first = tmp
+ else:
+ self.tag_first = "<"+_("Tag 1")+">"
+ tmp = config.movielist.second_tags.value
+ if tmp in self.tags:
+ self.tag_second = tmp
+ else:
+ self.tag_second = "<"+_("Tag 2")+">"
self["key_green"].text = self.tag_first
self["key_yellow"].text = self.tag_second
# the rest is presented in a list, available on the
# fourth ("blue") button
- if len(self.tags) > 2:
- self["key_blue"].text = _("Other...")
+ if self.tags:
+ self["key_blue"].text = _("Tags")+"..."
else:
self["key_blue"].text = ""
def setSortType(self, type):
self["list"].setSortType(type)
- def reloadList(self):
+ def reloadList(self, sel = None, home = False):
+ 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)
+ self["freeDiskSpace"].path = path
+ if sel is None:
+ sel = self.getCurrent()
self["list"].reload(self.current_ref, self.selected_tags)
title = _("Recorded files...")
+ if config.usage.setup_level.index >= 2: # expert+
+ title += " " + config.movielist.last_videodir.value
if self.selected_tags is not None:
title += " - " + ','.join(self.selected_tags)
self.setTitle(title)
+ if not (sel and self["list"].moveTo(sel)):
+ if home:
+ self["list"].moveToIndex(0)
+ self.updateTags()
+ self["freeDiskSpace"].update()
+
+ def doPathSelect(self):
+ self.session.openWithCallback(
+ self.gotFilename,
+ MovieLocationBox,
+ _("Please select the movie path..."),
+ config.movielist.last_videodir.value
+ )
+
+ def gotFilename(self, res):
+ if res is not None and res is not config.movielist.last_videodir.value:
+ 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)
+ self["freeDiskSpace"].path = res
+ self.reloadList(home = True)
+ else:
+ self.session.open(
+ MessageBox,
+ _("Directory %s nonexistent.") % (res),
+ type = MessageBox.TYPE_ERROR,
+ timeout = 5
+ )
def showAll(self):
+ self.selected_tags_ele = None
self.selected_tags = None
- self.reloadList()
+ self.reloadList(home = True)
- def showTagsN(self, n):
- if len(self.tags) < n:
+ def showTagsN(self, tagele):
+ if not self.tags:
self.showTagWarning()
+ 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:
- print "select tag #%d, %s, %s" % (n, self.tags[n - 1], ','.join(self.tags))
- self.selected_tags = set([self.tags[n - 1]])
- self.reloadList()
+ self.selected_tags_ele = tagele
+ self.selected_tags = set([tagele.value])
+ self.reloadList(home = True)
def showTagsFirst(self):
- self.showTagsN(1)
+ self.showTagsN(config.movielist.first_tags)
def showTagsSecond(self):
- self.showTagsN(2)
+ self.showTagsN(config.movielist.second_tags)
+
+ def showTagsSelect(self):
+ self.showTagsN(None)
def tagChosen(self, tag):
if tag is not None:
self.selected_tags = set([tag[0]])
- self.reloadList()
+ if self.selected_tags_ele:
+ self.selected_tags_ele.value = tag[0]
+ self.selected_tags_ele.save()
+ self.reloadList(home = True)
- def showTagsMenu(self):
- if len(self.tags) < 3:
- self.showTagWarning()
- else:
- list = [(tag, self.getTagDescription(tag)) for tag in self.tags ]
- self.session.openWithCallback(self.tagChosen, ChoiceBox, title=_("Please select keyword to filter..."), list = list)
+ def showTagsMenu(self, tagele):
+ self.selected_tags_ele = tagele
+ list = [(tag, self.getTagDescription(tag)) for tag in self.tags ]
+ self.session.openWithCallback(self.tagChosen, ChoiceBox, title=_("Please select tag to filter..."), list = list)
def showTagWarning(self):
- # TODO
- self.session.open(MessageBox, _("You need to define some keywords first!\nPress the menu-key to define keywords.\nDo you want to define keywords now?"), MessageBox.TYPE_ERROR)
+ self.session.open(MessageBox, _("No tags are set on these movies."), MessageBox.TYPE_ERROR)