X-Git-Url: https://git.cweiske.de/enigma2-curlytx.git/blobdiff_plain/728b0ee7036ca15d0e22573827b4330b6a91f36a..70a718833dc18d1f589def81ab4d5fbbf330a53b:/src/CurlyTxSettings.py diff --git a/src/CurlyTxSettings.py b/src/CurlyTxSettings.py index 2fc7d4a..154bf37 100644 --- a/src/CurlyTxSettings.py +++ b/src/CurlyTxSettings.py @@ -1,13 +1,16 @@ +from . import _ + from Screens.Screen import Screen +from Screens.HelpMenu import HelpableScreen from Components.ActionMap import ActionMap, NumberActionMap from Components.Sources.StaticText import StaticText from . import config -from config import createPage -from Components.config import config, getConfigListEntry +from config import createPage, loadDefaultPageOptions +from Components.config import config, getConfigListEntry, ConfigSelection from Components.ConfigList import ConfigList, ConfigListScreen -class CurlyTxSettings(ConfigListScreen, Screen): +class CurlyTxSettings(ConfigListScreen, HelpableScreen, Screen): skin = """ @@ -24,6 +27,7 @@ class CurlyTxSettings(ConfigListScreen, Screen): def __init__(self, session): self.skin = CurlyTxSettings.skin Screen.__init__(self, session) + HelpableScreen.__init__(self) #self.skinName = [ "CurlyTxSettings", "Setup" ] self.setup_title = _("Settings") @@ -31,9 +35,9 @@ class CurlyTxSettings(ConfigListScreen, Screen): { "cancel": self.keyCancel, "save": self.keySave, - #"ok": self.ok, - "blue": self.deletePage, - "yellow": self.newPage + "ok": self.editPage, + "yellow": self.newPage, + "blue": self.deletePage }, -2) self["key_red"] = StaticText(_("Cancel")) @@ -43,15 +47,41 @@ class CurlyTxSettings(ConfigListScreen, Screen): ConfigListScreen.__init__(self, self.getConfigList(), session = self.session) + self.loadHelp() + self.onClose.append(self.abort) + def getConfigList(self): + #reload titles + loadDefaultPageOptions() + list = [ - getConfigListEntry(_("Page"), x.uri) + getConfigListEntry(_("Page:") + " " + x.title.value, x.uri) for x in config.plugins.CurlyTx.pages ] + if len(config.plugins.CurlyTx.pages): + list.append(getConfigListEntry(_("Default page"), config.plugins.CurlyTx.defaultPage)) list.append(getConfigListEntry(_("Show in main menu"), config.plugins.CurlyTx.menuMain)) + list.append(getConfigListEntry(_("Show in extensions menu"), config.plugins.CurlyTx.menuExtensions)) list.append(getConfigListEntry(_("Menu title"), config.plugins.CurlyTx.menuTitle)) return list + def loadHelp(self): + self.helpList.append(( + self["actions"], "SetupActions", + [("cancel", _("Dismiss all setting changes"))])) + self.helpList.append(( + self["actions"], "SetupActions", + [("save", _("Save settings and close screen"))])) + self.helpList.append(( + self["actions"], "SetupActions", + [("ok", _("Edit selected page"))])) + self.helpList.append(( + self["actions"], "ColorActions", + [("yellow", _("Add new page"))])) + self.helpList.append(( + self["actions"], "ColorActions", + [("blue", _("Delete selected page"))])) + def keyLeft(self): ConfigListScreen.keyLeft(self) @@ -59,12 +89,15 @@ class CurlyTxSettings(ConfigListScreen, Screen): ConfigListScreen.keyRight(self) def deletePage(self): + if len(config.plugins.CurlyTx.pages) == 0: + return + from Screens.MessageBox import MessageBox self.session.openWithCallback( self.deletePageConfirm, MessageBox, _("Really delete this page?\nIt cannot be recovered!") - ) + ) def deletePageConfirm(self, result): if not result: @@ -73,24 +106,41 @@ class CurlyTxSettings(ConfigListScreen, Screen): id = self["config"].getCurrentIndex() del config.plugins.CurlyTx.pages[id] + config.plugins.CurlyTx.pages.save() + self["config"].setList(self.getConfigList()) def newPage(self): from CurlyTxSettings import CurlyTxSettings - self.session.openWithCallback(self.newPageCreated, CurlyTxPageEdit, createPage(), True) + self.session.openWithCallback(self.pageEdited, CurlyTxPageEdit, createPage(), True) - def newPageCreated(self, page, new): + def editPage(self): + id = self["config"].getCurrentIndex() + if id < len(config.plugins.CurlyTx.pages): + self.session.openWithCallback( + self.pageEdited, CurlyTxPageEdit, + config.plugins.CurlyTx.pages[id], False + ) + + def pageEdited(self, page, new): if not page: return if new: - num = len(config.plugins.CurlyTx.pages) config.plugins.CurlyTx.pages.append(page) - config.plugins.CurlyTx.pages[num].save() + self["config"].setList(self.getConfigList()) + + + def keySave(self): + for i in range(0, len(config.plugins.CurlyTx.pages)): + config.plugins.CurlyTx.pages[i].save() + config.plugins.CurlyTx.pages.save() + ConfigListScreen.keySave(self) - self["config"].setList(self.getConfigList()) + def abort(self): + pass @@ -118,7 +168,6 @@ class CurlyTxPageEdit(Screen, ConfigListScreen): def save(self): self.close(self.page, self.new) - #FIXME: pass page to parent def keyCancel(self): self.close(None, self.new)