New config (Ignore download times: yes/no)
[enigma2-plugins.git] / rsdownloader / src / RSConfig.py
1 ##\r
2 ## RS Downloader\r
3 ## by AliAbdul\r
4 ##\r
5 from Components.ActionMap import ActionMap\r
6 from Components.config import config, ConfigText, ConfigYesNo, ConfigClock, ConfigSubsection, getConfigListEntry\r
7 from Components.ConfigList import ConfigListScreen\r
8 from Components.Label import Label
9 from RSTranslation import _, TitleScreen\r
10 from time import time\r
11 \r
12 ##############################################################################\r
13 \r
14 config.plugins.RSDownloader = ConfigSubsection()\r
15 config.plugins.RSDownloader.username = ConfigText(default="", fixed_size=False)\r
16 config.plugins.RSDownloader.password = ConfigText(default="", fixed_size=False)\r
17 config.plugins.RSDownloader.lists_directory = ConfigText(default="/media/cf/rs/lists/", fixed_size=False)\r
18 config.plugins.RSDownloader.downloads_directory = ConfigText(default="/media/cf/rs/downloads", fixed_size=False)
19 config.plugins.RSDownloader.ignore_time = ConfigYesNo(default = False)\r
20 config.plugins.RSDownloader.start_time = ConfigClock(default = time())\r
21 config.plugins.RSDownloader.end_time = ConfigClock(default = time())\r
22 config.plugins.RSDownloader.write_log = ConfigYesNo(default = True)
23 config.plugins.RSDownloader.reconnect_fritz = ConfigYesNo(default = False)\r
24 \r
25 ##############################################################################\r
26 \r
27 class RSConfig(ConfigListScreen, TitleScreen):\r
28         skin = """\r
29                 <screen position="80,170" size="560,270" title="RS Downloader">\r
30                         <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" transparent="1" alphatest="on" />\r
31                         <ePixmap pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" transparent="1" alphatest="on" />\r
32                         <ePixmap pixmap="skin_default/buttons/yellow.png" position="280,0" size="140,40" transparent="1" alphatest="on" />\r
33                         <ePixmap pixmap="skin_default/buttons/blue.png" position="420,0" size="140,40" transparent="1" alphatest="on" />\r
34                         <widget name="key_green" position="140,0" zPosition="1" size="140,40" font="Regular;20" valign="center" halign="center" backgroundColor="#1f771f" transparent="1" />\r
35                         <widget name="config" position="0,45" size="560,220" scrollbarMode="showOnDemand" />\r
36                 </screen>"""\r
37 \r
38         def __init__(self, session):\r
39                 TitleScreen.__init__(self, session)\r
40                 \r
41                 self["key_green"] = Label(_("Save"))\r
42                 \r
43                 list = []\r
44                 list.append(getConfigListEntry(_("Username:"), config.plugins.RSDownloader.username))\r
45                 list.append(getConfigListEntry(_("Password:"), config.plugins.RSDownloader.password))\r
46                 list.append(getConfigListEntry(_("Lists directory:"), config.plugins.RSDownloader.lists_directory))\r
47                 list.append(getConfigListEntry(_("Downloads directory:"), config.plugins.RSDownloader.downloads_directory))\r
48                 list.append(getConfigListEntry(_("Ignore download times:"), config.plugins.RSDownloader.ignore_time))\r
49                 list.append(getConfigListEntry(_("Don't download before:"), config.plugins.RSDownloader.start_time))\r
50                 list.append(getConfigListEntry(_("Don't download after:"), config.plugins.RSDownloader.end_time))\r
51                 list.append(getConfigListEntry(_("Write log:"), config.plugins.RSDownloader.write_log))
52                 list.append(getConfigListEntry(_("Reconnect fritz.Box before downloading:"), config.plugins.RSDownloader.reconnect_fritz))\r
53                 ConfigListScreen.__init__(self, list)\r
54                 \r
55                 self["actions"] = ActionMap(["OkCancelActions", "ColorActions"], {"green": self.save, "cancel": self.exit}, -1)\r
56 \r
57         def save(self):\r
58                 for x in self["config"].list:\r
59                         x[1].save()\r
60                 self.close()\r
61 \r
62         def exit(self):\r
63                 for x in self["config"].list:\r
64                         x[1].cancel()\r
65                 self.close()\r