summaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
authorGravatar mkaay <mkaay@mkaay.de> 2009-12-21 18:52:51 +0100
committerGravatar mkaay <mkaay@mkaay.de> 2009-12-21 18:52:51 +0100
commit9a435f166b8d70fa2e61351b1d84db77c5b42472 (patch)
tree0b0fc9193e8666721b880351d9a5a5ac31f78cb8 /module
parenttotal progressbar bullshit (diff)
parentmerged Wugy (diff)
downloadpyload-9a435f166b8d70fa2e61351b1d84db77c5b42472.tar.xz
merged Wugy, 2nd try
Diffstat (limited to 'module')
-rw-r--r--module/config/gui_default.xml4
-rw-r--r--module/gui/Collector.py21
-rw-r--r--module/gui/LinkDock.py1
-rw-r--r--module/gui/MainWindow.py31
-rw-r--r--module/gui/PackageDock.py29
-rw-r--r--module/gui/connector.py20
-rw-r--r--module/web/pyload.dbbin44032 -> 44032 bytes
7 files changed, 102 insertions, 4 deletions
diff --git a/module/config/gui_default.xml b/module/config/gui_default.xml
index af38eda4c..9b6d75936 100644
--- a/module/config/gui_default.xml
+++ b/module/config/gui_default.xml
@@ -4,4 +4,8 @@
<name>Local</name>
</connection>
</connections>
+ <mainWindow>
+ <state></state>
+ <geometry></geometry>
+ </mainWindow>
</root>
diff --git a/module/gui/Collector.py b/module/gui/Collector.py
index 0dbccab1f..28cac097b 100644
--- a/module/gui/Collector.py
+++ b/module/gui/Collector.py
@@ -102,8 +102,8 @@ class PackageCollector(QThread):
except:
self.children.append(newChild)
pos = self.children.index(newChild)
- ppos = self.queue.queue.index(self)
- parent = self.queue.view.topLevelItem(ppos)
+ ppos = self.collector.collector.index(self)
+ parent = self.collector.view.topLevelItem(ppos)
item = parent.child(pos)
if not item:
item = QTreeWidgetItem()
@@ -172,6 +172,7 @@ class LinkCollector(QThread):
file = self.LinkCollectorFile(self)
file.setData(data)
self.addFile(id, file)
+ self.clear(ids)
def addFile(self, pid, newFile):
pos = None
@@ -192,12 +193,28 @@ class LinkCollector(QThread):
self.view.insertTopLevelItem(pos, item)
item.setData(0, Qt.DisplayRole, QVariant(newFile.getData()["filename"]))
item.setData(0, Qt.UserRole, QVariant(pid))
+ flags = Qt.ItemIsSelectable | Qt.ItemIsDragEnabled | Qt.ItemIsEnabled
+ item.setFlags(flags)
def getFile(self, pid):
for k, file in enumerate(self.collector):
if file.getData()["id"] == pid:
return file
return None
+
+ def clear(self, ids):
+ toremove = []
+ for k, file in enumerate(self.collector):
+ id = file.getData()["id"]
+ if not id in ids:
+ toremove.append(k)
+ if not toremove:
+ return
+ toremove.sort()
+ toremove.reverse()
+ for pos in toremove:
+ del self.collector[k]
+ self.view.takeTopLevelItem(k)
class LinkCollectorFile():
def __init__(self, collector):
diff --git a/module/gui/LinkDock.py b/module/gui/LinkDock.py
index 01a0cc193..99429d04b 100644
--- a/module/gui/LinkDock.py
+++ b/module/gui/LinkDock.py
@@ -22,6 +22,7 @@ from PyQt4.QtGui import *
class NewLinkDock(QDockWidget):
def __init__(self):
QDockWidget.__init__(self, "New Links")
+ self.setObjectName("New Links Dock")
self.widget = NewLinkWindow(self)
self.setWidget(self.widget)
self.setAllowedAreas(Qt.RightDockWidgetArea|Qt.LeftDockWidgetArea)
diff --git a/module/gui/MainWindow.py b/module/gui/MainWindow.py
index 6d68f4d7a..4f92f68a9 100644
--- a/module/gui/MainWindow.py
+++ b/module/gui/MainWindow.py
@@ -33,12 +33,16 @@ class MainWindow(QMainWindow):
self.setWindowIcon(QIcon("icons/logo.png"))
self.resize(750,500)
+ #layout version
+ self.version = 1
+
#init docks
self.newPackDock = NewPackageDock()
self.addDockWidget(Qt.RightDockWidgetArea, self.newPackDock)
self.newLinkDock = NewLinkDock()
self.addDockWidget(Qt.RightDockWidgetArea, self.newLinkDock)
self.connect(self.newLinkDock, SIGNAL("done"), self.slotAddLinks)
+ self.connect(self.newPackDock, SIGNAL("done"), self.slotAddPackage)
#central widget, layout
self.masterlayout = QVBoxLayout()
@@ -88,7 +92,8 @@ class MainWindow(QMainWindow):
self.connect(self.mactions["exit"], SIGNAL("triggered()"), self.close)
def init_toolbar(self):
- self.toolbar = self.addToolBar("main")
+ self.toolbar = self.addToolBar("Main Toolbar")
+ self.toolbar.setObjectName("Main Toolbar")
self.toolbar.setIconSize(QSize(40,40))
self.actions["toggle_status"] = self.toolbar.addAction("Toggle Pause/Resume")
pricon = QIcon()
@@ -156,3 +161,27 @@ class MainWindow(QMainWindow):
def slotAddLinks(self, links):
self.emit(SIGNAL("addLinks"), links)
+
+ def slotAddPackage(self, name, ids):
+ self.emit(SIGNAL("addPackage"), name, ids)
+
+ def closeEvent(self, event):
+ state_raw = self.saveState(self.version)
+ geo_raw = self.saveGeometry()
+
+ state = str(state_raw.toBase64())
+ geo = str(geo_raw.toBase64())
+
+ self.emit(SIGNAL("saveMainWindow"), state, geo)
+ event.accept()
+
+ def restoreWindow(self, state, geo):
+ state = QByteArray(state)
+ geo = QByteArray(geo)
+
+ state_raw = QByteArray.fromBase64(state)
+ geo_raw = QByteArray.fromBase64(geo)
+
+ self.restoreState(state_raw, self.version)
+ self.restoreGeometry(geo_raw)
+
diff --git a/module/gui/PackageDock.py b/module/gui/PackageDock.py
index c97e9d645..b90e3533d 100644
--- a/module/gui/PackageDock.py
+++ b/module/gui/PackageDock.py
@@ -22,10 +22,23 @@ from PyQt4.QtGui import *
class NewPackageDock(QDockWidget):
def __init__(self):
QDockWidget.__init__(self, "New Package")
+ self.setObjectName("New Package Dock")
self.widget = NewPackageWindow(self)
self.setWidget(self.widget)
self.setAllowedAreas(Qt.RightDockWidgetArea|Qt.LeftDockWidgetArea)
self.hide()
+
+ def slotDone(self):
+ view = self.widget.view
+ count = view.topLevelItemCount()
+ ids = []
+ for i in range(count):
+ item = view.topLevelItem(i)
+ if item:
+ ids.append(item.data(0, Qt.UserRole).toInt()[0])
+ self.emit(SIGNAL("done"), self.widget.nameInput.text(), ids)
+ view.clear()
+ self.hide()
class NewPackageWindow(QWidget):
def __init__(self, dock):
@@ -38,7 +51,19 @@ class NewPackageWindow(QWidget):
nameInput = QLineEdit()
linksLabel = QLabel("Links in this Package")
- linkView = QListWidget()
+ linkView = QTreeWidget()
+ linkView.setSelectionBehavior(QAbstractItemView.SelectRows)
+ linkView.setSelectionMode(QAbstractItemView.SingleSelection)
+ linkView.setColumnCount(1)
+ linkView.setHeaderLabels(["Name"])
+ linkView.setDragEnabled(True)
+ linkView.setDragDropMode(QAbstractItemView.DragDrop)
+ linkView.setDropIndicatorShown(True)
+ linkView.setAcceptDrops(True)
+ linkView.setDragDropOverwriteMode(True)
+
+ self.view = linkView
+ self.nameInput = nameInput
save = QPushButton("Create")
@@ -47,3 +72,5 @@ class NewPackageWindow(QWidget):
layout.addWidget(linksLabel, 1, 0, 1, 2)
layout.addWidget(linkView, 2, 0, 1, 2)
layout.addWidget(save, 3, 0, 1, 2)
+
+ self.connect(save, SIGNAL("clicked()"), self.dock.slotDone)
diff --git a/module/gui/connector.py b/module/gui/connector.py
index 32da29bba..e7a151c5e 100644
--- a/module/gui/connector.py
+++ b/module/gui/connector.py
@@ -177,3 +177,23 @@ class connector(QThread):
self.proxy.unpause_server()
finally:
self.mutex.unlock()
+
+ def newPackage(self, name):
+ """
+ create a new package and return id
+ """
+ self.mutex.lock()
+ try:
+ return self.proxy.new_package(name)
+ finally:
+ self.mutex.unlock()
+
+ def addFileToPackage(self, fileid, packid):
+ """
+ add a file from collector to package
+ """
+ self.mutex.lock()
+ try:
+ self.proxy.move_file_2_package(fileid, packid)
+ finally:
+ self.mutex.unlock()
diff --git a/module/web/pyload.db b/module/web/pyload.db
index 013c8607d..e5e224850 100644
--- a/module/web/pyload.db
+++ b/module/web/pyload.db
Binary files differ