From 59eaacc4228707f715be147350adb0a670de6985 Mon Sep 17 00:00:00 2001 From: mkaay Date: Mon, 21 Dec 2009 17:57:17 +0100 Subject: save window state --- pyLoadGui.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'pyLoadGui.py') diff --git a/pyLoadGui.py b/pyLoadGui.py index ccab8ba64..a21c27cb9 100755 --- a/pyLoadGui.py +++ b/pyLoadGui.py @@ -61,6 +61,7 @@ class main(QObject): def startMain(self): self.connector.start() sleep(1) + self.restoreMainWindow() self.mainWindow.show() self.initQueue() self.initPackageCollector() @@ -90,6 +91,7 @@ class main(QObject): self.connect(self.mainWindow, SIGNAL("addLinks"), self.slotAddLinks) self.connect(self.mainWindow, SIGNAL("addPackage"), self.slotAddPackage) self.connect(self.mainWindow, SIGNAL("setDownloadStatus"), self.slotSetDownloadStatus) + self.connect(self.mainWindow, SIGNAL("saveMainWindow"), self.slotSaveMainWindow) def slotShowConnector(self): self.stopMain() @@ -293,6 +295,33 @@ class main(QObject): for fileid in ids: self.connector.addFileToPackage(fileid, packid) + def slotSaveMainWindow(self, state, geo): + mainWindowNode = self.parser.xml.elementsByTagName("mainWindow").item(0) + if mainWindowNode.isNull(): + raise Exception("null") + stateNode = mainWindowNode.toElement().elementsByTagName("state").item(0) + geoNode = mainWindowNode.toElement().elementsByTagName("geometry").item(0) + newStateNode = self.parser.xml.createTextNode(state) + newGeoNode = self.parser.xml.createTextNode(geo) + + stateNode.removeChild(stateNode.firstChild()) + geoNode.removeChild(geoNode.firstChild()) + stateNode.appendChild(newStateNode) + geoNode.appendChild(newGeoNode) + + self.parser.saveData() + + def restoreMainWindow(self): + mainWindowNode = self.parser.xml.elementsByTagName("mainWindow").item(0) + if mainWindowNode.isNull(): + raise Exception("null") + nodes = self.parser.parseNode(mainWindowNode, "dict") + + state = str(nodes["state"].text()) + geo = str(nodes["geometry"].text()) + + self.mainWindow.restoreWindow(state, geo) + class Loop(QThread): def __init__(self, parent): QThread.__init__(self) -- cgit v1.2.3