summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2010-09-24 22:26:50 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2010-09-24 22:26:50 +0200
commit986781b21929d64a4b9a1a15bb55b97421aa3511 (patch)
treebcacfedf270dcefe226fdf1a41ac1b1b725d61f8
parentyouporn fix and YourfilesTo support (diff)
downloadpyload-986781b21929d64a4b9a1a15bb55b97421aa3511.tar.xz
gui minimize fix, settings saveable, utf8 in config
-rw-r--r--module/ConfigParser.py20
-rw-r--r--module/config/default.conf1
-rw-r--r--module/gui/MainWindow.py2
-rw-r--r--module/gui/SettingsWidget.py105
-rw-r--r--module/plugins/Plugin.py2
-rw-r--r--module/web/ajax/views.py2
-rwxr-xr-xpyLoadGui.py6
7 files changed, 115 insertions, 23 deletions
diff --git a/module/ConfigParser.py b/module/ConfigParser.py
index 7e1af042e..20d807b2a 100644
--- a/module/ConfigParser.py
+++ b/module/ConfigParser.py
@@ -93,6 +93,7 @@ class ConfigParser:
try:
homeconf = self.parseConfig("pyload.conf")
+ print homeconf
self.updateValues(homeconf, self.config)
except Exception, e:
@@ -114,7 +115,7 @@ class ConfigParser:
config = f.read()
- config = config.split("\n")[1:]
+ config = config.splitlines()[1:]
conf = {}
@@ -185,8 +186,9 @@ class ConfigParser:
"value" : value}
except:
- pass
-
+ import traceback
+ traceback.print_exc()
+
f.close()
return conf
@@ -233,7 +235,10 @@ class ConfigParser:
value += "\t\t" + str(x) + ",\n"
value += "\t\t]\n"
else:
- value = str(data["value"]) + "\n"
+ if type(data["value"]) in (str,unicode):
+ value = data["value"] + "\n"
+ else:
+ value = str(data["value"]) + "\n"
f.write('\t%s %s : "%s" = %s' % (data["type"], option, data["desc"], value) )
#----------------------------------------------------------------------
@@ -242,12 +247,15 @@ class ConfigParser:
if type(value) not in (str, unicode):
return value
- if typ == "int":
+ elif typ == "int":
return int(value)
elif typ == "bool":
return True if value.lower() in ("1","true", "on", "an","yes") else False
elif typ == "str":
- return str(value)
+ try:
+ return value.encode("utf8")
+ except:
+ return value
else:
return value
diff --git a/module/config/default.conf b/module/config/default.conf
index 6b089d487..407b709f1 100644
--- a/module/config/default.conf
+++ b/module/config/default.conf
@@ -39,6 +39,7 @@ permission - "Permissions":
str file : "Filemode for Downloads" = 0644
bool change_group : "Change group of running process" = False
str group : "Groupname" = users
+ bool change_dl : "Change Group and User of Downloads" = False
reconnect - "Reconnect":
bool activated : "Use Reconnect" = False
str method : "Method" = None
diff --git a/module/gui/MainWindow.py b/module/gui/MainWindow.py
index d6d6c1eb9..e457c984f 100644
--- a/module/gui/MainWindow.py
+++ b/module/gui/MainWindow.py
@@ -39,7 +39,7 @@ class MainWindow(QMainWindow):
#window stuff
self.setWindowTitle(_("pyLoad Client"))
self.setWindowIcon(QIcon(join(pypath, "icons","logo.png")))
- self.resize(850,500)
+ self.resize(900,500)
#layout version
self.version = 3
diff --git a/module/gui/SettingsWidget.py b/module/gui/SettingsWidget.py
index 6197cee6c..ddfb45994 100644
--- a/module/gui/SettingsWidget.py
+++ b/module/gui/SettingsWidget.py
@@ -32,38 +32,120 @@ class SettingsWidget(QWidget):
def setConnector(self, connector):
self.connector = connector
-
+
def loadConfig(self):
+ if self.sections and self.psections:
+ self.data = self.connector.proxy.get_config()
+ self.pdata = self.connector.proxy.get_plugin_config()
+
+ self.reloadSection(self.sections, self.data)
+ self.reloadSection(self.psections, self.pdata)
+
+ return
+
if self.layout():
delete(self.layout())
+
for s in self.sections.values()+self.psections.values():
delete(s)
+
self.sections = {}
self.setLayout(QVBoxLayout())
self.clearConfig()
layout = self.layout()
layout.setSizeConstraint(QLayout.SetMinAndMaxSize)
-
+
+ general = QTabWidget()
+ self.general = general
+
+ plugins = QTabWidget()
+ self.plugins = plugins
+
+ tab = QTabWidget()
+ self.tab = tab
+ tab.addTab(general, _("General"))
+ tab.addTab(plugins, _("Plugins"))
+
+ layout.addWidget(tab)
+
self.data = self.connector.proxy.get_config()
self.pdata = self.connector.proxy.get_plugin_config()
for k, section in self.data.items():
- s = Section(section, self)
+ s = Section(section, general)
self.sections[k] = s
- layout.addWidget(s)
+
for k, section in self.pdata.items():
- s = Section(section, self, "plugin")
+ s = Section(section, plugins, "plugin")
self.psections[k] = s
- layout.addWidget(s)
-
+
rel = QPushButton(_("Reload"))
- layout.addWidget(rel)
save = QPushButton(_("Save"))
- #layout.addWidget(save)
+
+ layout.addWidget(save)
+
+ cont = QHBoxLayout()
+ cont.addWidget(rel)
+ cont.addWidget(save)
+
+ layout.addLayout(cont)
+
+ self.connect(save, SIGNAL("clicked()"), self.saveConfig)
self.connect(rel, SIGNAL("clicked()"), self.loadConfig)
-
+
def clearConfig(self):
self.sections = {}
+ def reloadSection(self, sections, pdata):
+
+ for k, section in pdata.iteritems():
+ if sections.has_key(k):
+ widget = sections[k]
+ for option,data in section.iteritems():
+ if widget.inputs.has_key(option):
+ i = widget.inputs[option]
+
+ if data["type"] == "int":
+ i.setValue(int(data["value"]))
+ elif not data["type"].find(";") == -1:
+ i.setCurrentIndex(i.findText(data["value"]))
+ elif data["type"] == "bool":
+ if data["value"]:
+ i.setCurrentIndex(0)
+ else:
+ i.setCurrentIndex(1)
+ else:
+ i.setText(data["value"])
+
+
+ def saveConfig(self):
+ self.data = self.connector.proxy.get_config()
+ self.pdata = self.connector.proxy.get_plugin_config()
+
+ self.saveSection(self.sections, self.data)
+ self.saveSection(self.psections, self.pdata, "plugin")
+
+
+ def saveSection(self, sections, pdata, sec="core"):
+ for k, section in pdata.iteritems():
+ if sections.has_key(k):
+ widget = sections[k]
+ for option,data in section.iteritems():
+ if widget.inputs.has_key(option):
+ i = widget.inputs[option]
+
+ if data["type"] == "int":
+ if i.value() != data["value"]:
+ self.connector.proxy.set_conf_val(k, option, i.value(), sec)
+ elif not data["type"].find(";") == -1:
+ if i.currentText() != data["value"]:
+ self.connector.proxy.set_conf_val(k, option, i.currentText(), sec)
+ elif data["type"] == "bool":
+ if (data["value"] ^ (not i.currentIndex())):
+ self.connector.proxy.set_conf_val(k, option, not i.currentIndex(), sec)
+ else:
+ if i.text() != data["value"]:
+ self.connector.proxy.set_conf_val(k, option, str(i.text()), sec)
+
class Section(QGroupBox):
def __init__(self, data, parent, ctype="core"):
self.data = data
@@ -73,9 +155,10 @@ class Section(QGroupBox):
self.ctype = ctype
layout = QGridLayout(self)
self.setLayout(layout)
+ parent.addTab(self, data["desc"])
row = 0
- for k, option in self.data.items():
+ for k, option in self.data.iteritems():
if k == "desc":
continue
l = QLabel(option["desc"], self)
diff --git a/module/plugins/Plugin.py b/module/plugins/Plugin.py
index d197ec1a3..e7914c287 100644
--- a/module/plugins/Plugin.py
+++ b/module/plugins/Plugin.py
@@ -279,7 +279,7 @@ class Plugin(object):
if self.core.config["permission"]["change_file"]:
chmod(join(location, name), int(self.core.config["permission"]["file"],8))
- if self.core.config["permission"]["change_user"] and self.core.config["permission"]["change_group"] and os.name != "nt":
+ if self.core.config["permission"]["change_dl"] and os.name != "nt":
try:
uid = getpwnam(self.config["permission"]["user"])[2]
gid = getgrnam(self.config["permission"]["group"])[2]
diff --git a/module/web/ajax/views.py b/module/web/ajax/views.py
index 0ca42c0c2..5e911e0ba 100644
--- a/module/web/ajax/views.py
+++ b/module/web/ajax/views.py
@@ -78,7 +78,7 @@ def add_package(request):
links = map(lambda x: x.strip(), links)
links = filter(lambda x: x != "", links)
-
+
settings.PYLOAD.add_package(name, links, queue)
diff --git a/pyLoadGui.py b/pyLoadGui.py
index 6501fccb4..e03843054 100755
--- a/pyLoadGui.py
+++ b/pyLoadGui.py
@@ -91,9 +91,9 @@ class main(QObject):
self.serverStatus = {"pause":True, "speed":0, "freespace":0}
self.core = None # pyLoadCore if started
-
-
- if first:
+
+
+ if True: # when used if first, minimizing not working correctly..
self.tray = TrayIcon()
self.tray.show()
self.notification = Notification(self.tray)