diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2011-09-21 16:43:22 +0200 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2011-09-21 16:43:22 +0200 |
commit | 79ce6f862285f355455119d64d8aa1753cff0470 (patch) | |
tree | 238b2f309d2f90cb9c3d722b15748b45a6e5d6d1 /module/gui | |
parent | yourfiles.biz fix (diff) | |
download | pyload-79ce6f862285f355455119d64d8aa1753cff0470.tar.xz |
royflos GUI patches, prefix option for webinterface (
Diffstat (limited to 'module/gui')
-rw-r--r-- | module/gui/Collector.py | 22 | ||||
-rw-r--r-- | module/gui/ConnectionManager.py | 7 | ||||
-rw-r--r-- | module/gui/MainWindow.py | 68 | ||||
-rw-r--r-- | module/gui/Overview.py | 10 | ||||
-rw-r--r-- | module/gui/Queue.py | 47 | ||||
-rw-r--r-- | module/gui/SettingsWidget.py | 3 | ||||
-rw-r--r-- | module/gui/connector.py | 2 |
7 files changed, 44 insertions, 115 deletions
diff --git a/module/gui/Collector.py b/module/gui/Collector.py index 6b0a54d2f..c569785e2 100644 --- a/module/gui/Collector.py +++ b/module/gui/Collector.py @@ -19,25 +19,15 @@ from PyQt4.QtCore import * from PyQt4.QtGui import * -from module.remote.thriftbackend.thriftgen.pyload.ttypes import * from module.PyFile import statusMap +from module.utils import formatSize + +from module.remote.thriftbackend.ThriftClient import Destination, FileDoesNotExists, ElementType statusMapReverse = dict((v,k) for k, v in statusMap.iteritems()) translatedStatusMap = {} # -> CollectorModel.__init__ -def formatSize(size): - """formats size of bytes""" - size = int(size) - steps = 0 - sizes = ["B", "KiB", "MiB", "GiB", "TiB"] - - while size > 1000: - size /= 1024.0 - steps += 1 - - return "%.2f %s" % (size, sizes[steps]) - class CollectorModel(QAbstractItemModel): """ model for the collector view @@ -80,7 +70,7 @@ class CollectorModel(QAbstractItemModel): """ called from main loop, pass events to the correct methods """ - locker = QMutexLocker(self.mutex) + QMutexLocker(self.mutex) if event.event == "reload": self.fullReload() elif event.event == "remove": @@ -339,7 +329,6 @@ class Package(object): "site": pack.site, "password": pack.password, "order": pack.order, - "priority": pack.priority, } self.data.update(data) @@ -392,13 +381,12 @@ class Link(object): "name": f.name, "plugin": f.plugin, "size": f.size, - "forrmat_size": f.format_size, + "format_size": f.format_size, "status": f.status, "statusmsg": f.statusmsg, "package": f.packageID, "error": f.error, "order": f.order, - "progress": f.progress } self.data.update(data) diff --git a/module/gui/ConnectionManager.py b/module/gui/ConnectionManager.py index 8e355bfe1..930cbd889 100644 --- a/module/gui/ConnectionManager.py +++ b/module/gui/ConnectionManager.py @@ -28,10 +28,7 @@ class ConnectionManager(QWidget): QWidget.__init__(self) QMessageBox.warning(self, 'Warning', - "We are sorry but the GUI is not usable anymore. Please use the webinterface for much better experience. \n", QMessageBox.Ok) - - return - + "We are sorry but the GUI is not stable yet. Please use the webinterface for much better experience. \n", QMessageBox.Ok) mainLayout = QHBoxLayout() buttonLayout = QVBoxLayout() @@ -155,7 +152,7 @@ class ConnectionManager(QWidget): data = defaultItem.data(Qt.UserRole).toPyObject() self.setDefault(data, True) did = self.cleanDict(data)["id"] - allItems = self.connList.findItems("*", Qt.MatchWildcard) + #allItems = self.connList.findItems("*", Qt.MatchWildcard) count = self.connList.count() for i in range(count): item = self.connList.item(i) diff --git a/module/gui/MainWindow.py b/module/gui/MainWindow.py index a9ede10c5..9aea50b33 100644 --- a/module/gui/MainWindow.py +++ b/module/gui/MainWindow.py @@ -32,7 +32,7 @@ from module.gui.Overview import OverviewView from module.gui.Accounts import AccountView from module.gui.AccountEdit import AccountEdit -from module.remote.thriftbackend.thriftgen.pyload.ttypes import * +from module.remote.thriftbackend.ThriftClient import AccountInfo class MainWindow(QMainWindow): def __init__(self, connector): @@ -163,8 +163,6 @@ class MainWindow(QMainWindow): #init tabs self.init_tabs(connector) - self.setPriority = Priority(self) - #context menus self.init_context() @@ -189,9 +187,10 @@ class MainWindow(QMainWindow): """ create toolbar """ - self.toolbar = self.addToolBar(_("Main Toolbar")) + self.toolbar = self.addToolBar(_("Hide Toolbar")) self.toolbar.setObjectName("Main Toolbar") - self.toolbar.setIconSize(QSize(40,40)) + self.toolbar.setIconSize(QSize(30,30)) + self.toolbar.setMovable(False) self.actions["toggle_status"] = self.toolbar.addAction(_("Toggle Pause/Resume")) pricon = QIcon() pricon.addFile(join(pypath, "icons","toolbar_start.png"), QSize(), QIcon.Normal, QIcon.Off) @@ -278,36 +277,17 @@ class MainWindow(QMainWindow): self.queueContext.buttons["pull"] = QAction(QIcon(join(pypath, "icons","pull_small.png")), _("Pull out"), self.queueContext) self.queueContext.buttons["abort"] = QAction(QIcon(join(pypath, "icons","abort.png")), _("Abort"), self.queueContext) self.queueContext.buttons["edit"] = QAction(QIcon(join(pypath, "icons","edit_small.png")), _("Edit Name"), self.queueContext) - self.queuePriorityMenu = QMenu(_("Priority")) - self.queuePriorityMenu.actions = {} - self.queuePriorityMenu.actions["veryhigh"] = QAction(_("very high"), self.queuePriorityMenu) - self.queuePriorityMenu.addAction(self.queuePriorityMenu.actions["veryhigh"]) - self.queuePriorityMenu.actions["high"] = QAction(_("high"), self.queuePriorityMenu) - self.queuePriorityMenu.addAction(self.queuePriorityMenu.actions["high"]) - self.queuePriorityMenu.actions["normal"] = QAction(_("normal"), self.queuePriorityMenu) - self.queuePriorityMenu.addAction(self.queuePriorityMenu.actions["normal"]) - self.queuePriorityMenu.actions["low"] = QAction(_("low"), self.queuePriorityMenu) - self.queuePriorityMenu.addAction(self.queuePriorityMenu.actions["low"]) - self.queuePriorityMenu.actions["verylow"] = QAction(_("very low"), self.queuePriorityMenu) - self.queuePriorityMenu.addAction(self.queuePriorityMenu.actions["verylow"]) self.queueContext.addAction(self.queueContext.buttons["pull"]) self.queueContext.addAction(self.queueContext.buttons["edit"]) self.queueContext.addAction(self.queueContext.buttons["remove"]) self.queueContext.addAction(self.queueContext.buttons["restart"]) self.queueContext.addAction(self.queueContext.buttons["abort"]) - self.queueContext.addMenu(self.queuePriorityMenu) self.connect(self.queueContext.buttons["remove"], SIGNAL("triggered()"), self.slotRemoveDownload) self.connect(self.queueContext.buttons["restart"], SIGNAL("triggered()"), self.slotRestartDownload) self.connect(self.queueContext.buttons["pull"], SIGNAL("triggered()"), self.slotPullOutPackage) self.connect(self.queueContext.buttons["abort"], SIGNAL("triggered()"), self.slotAbortDownload) self.connect(self.queueContext.buttons["edit"], SIGNAL("triggered()"), self.slotEditPackage) - self.connect(self.queuePriorityMenu.actions["veryhigh"], SIGNAL("triggered()"), self.setPriority.veryHigh) - self.connect(self.queuePriorityMenu.actions["high"], SIGNAL("triggered()"), self.setPriority.high) - self.connect(self.queuePriorityMenu.actions["normal"], SIGNAL("triggered()"), self.setPriority.normal) - self.connect(self.queuePriorityMenu.actions["low"], SIGNAL("triggered()"), self.setPriority.low) - self.connect(self.queuePriorityMenu.actions["verylow"], SIGNAL("triggered()"), self.setPriority.veryLow) - #collector self.collectorContext = QMenu() self.collectorContext.buttons = {} @@ -509,7 +489,6 @@ class MainWindow(QMainWindow): #self.queueContext.buttons["restart"].setEnabled(True) self.queueContext.buttons["pull"].setEnabled(True) self.queueContext.buttons["edit"].setEnabled(True) - self.queuePriorityMenu.setEnabled(True) elif isinstance(item, Link): self.collectorContext.index = i self.collectorContext.buttons["edit"].setEnabled(False) @@ -522,7 +501,6 @@ class MainWindow(QMainWindow): #self.queueContext.buttons["restart"].setEnabled(False) self.queueContext.buttons["pull"].setEnabled(False) self.queueContext.buttons["edit"].setEnabled(False) - self.queuePriorityMenu.setEnabled(False) self.queueContext.exec_(menuPos) def slotCollectorContextMenu(self, pos): @@ -621,13 +599,14 @@ class MainWindow(QMainWindow): item = index.internalPointer() self.emit(SIGNAL("abortDownload"), item.id, isinstance(item, Package)) - def changeEvent(self, e): - if e.type() == QEvent.WindowStateChange and self.isMinimized(): - e.ignore() - self.hide() - self.emit(SIGNAL("hidden")) - else: - super(MainWindow, self).changeEvent(e) + # TODO disabled because changing desktop on linux, main window disappears + #def changeEvent(self, e): + # if e.type() == QEvent.WindowStateChange and self.isMinimized(): + # e.ignore() + # self.hide() + # self.emit(SIGNAL("hidden")) + # else: + # super(MainWindow, self).changeEvent(e) def slotTabChanged(self, index): if index == 2: @@ -710,26 +689,3 @@ class MainWindow(QMainWindow): menuPos = QCursor.pos() menuPos.setX(menuPos.x()+2) self.accountContext.exec_(menuPos) - -class Priority(): - def __init__(self, win): - self.w = win - - def setPriority(self, level): - if self.w.activeMenu == self.w.queueContext: - smodel = self.w.tabs["queue"]["view"].selectionModel() - else: - smodel = self.w.tabs["collector"]["package_view"].selectionModel() - for index in smodel.selectedRows(0): - item = index.internalPointer() - pid = item.id if isinstance(item, Package) else item.package.id - self.w.emit(SIGNAL("setPriority"), pid, level) - - def veryHigh(self): self.setPriority(2) - def high(self): self.setPriority(1) - def normal(self): self.setPriority(0) - def low(self): self.setPriority(-1) - def veryLow(self): self.setPriority(-2) - - - diff --git a/module/gui/Overview.py b/module/gui/Overview.py index 50e9dd618..ee05d92e9 100644 --- a/module/gui/Overview.py +++ b/module/gui/Overview.py @@ -19,16 +19,8 @@ from PyQt4.QtCore import * from PyQt4.QtGui import * -from time import sleep, time -def formatSpeed(speed): - speed = int(speed) - steps = 0 - sizes = ["B/s", "KiB/s", "MiB/s", "GiB/s"] - while speed > 1000: - speed /= 1024.0 - steps += 1 - return "%.2f %s" % (speed, sizes[steps]) +from module.utils import formatSpeed class OverviewModel(QAbstractListModel): PackageName = 10 diff --git a/module/gui/Queue.py b/module/gui/Queue.py index a4c0cf389..10ff9d84f 100644 --- a/module/gui/Queue.py +++ b/module/gui/Queue.py @@ -19,20 +19,11 @@ from PyQt4.QtCore import * from PyQt4.QtGui import * -from module.remote.thriftbackend.thriftgen.pyload.ttypes import * +from time import time -from time import sleep, time - -from module.gui.Collector import CollectorModel, Package, Link, CollectorView, statusMap, statusMapReverse, formatSize - -def formatSpeed(speed): - speed = int(speed) - steps = 0 - sizes = ["B/s", "KiB/s", "MiB/s", "GiB/s"] - while speed > 1000: - speed /= 1024.0 - steps += 1 - return "%.2f %s" % (speed, sizes[steps]) +from module.remote.thriftbackend.ThriftClient import Destination +from module.gui.Collector import CollectorModel, Package, Link, CollectorView, statusMapReverse +from module.utils import formatSize, formatSpeed class QueueModel(CollectorModel): """ @@ -163,8 +154,8 @@ class QueueModel(CollectorModel): return QVariant(_("Status")) elif section == 1: return QVariant(_("Plugin")) - elif section == 3: - return QVariant(_("Priority")) + #elif section == 3: + # return QVariant(_("Priority")) elif section == 4: return QVariant(_("Size")) elif section == 5: @@ -204,11 +195,14 @@ class QueueModel(CollectorModel): since it's used in already locked calls, it provides an option to not lock """ + # TODO when 1 link complete wrong progress state if locked: locker = QMutexLocker(self.mutex) if isinstance(item, Link): try: - return int(item.data["progress"]) + if item.data["status"] == 0: + return 100 + return int(item.data["downloading"]["percent"]) except: return 0 elif isinstance(item, Package): @@ -216,9 +210,9 @@ class QueueModel(CollectorModel): perc_sum = 0 for child in item.children: try: - if child.data["status"] == 13: #processing - return int(child.data["progress"]) - perc_sum += int(child.data["progress"]) + #if child.data["status"] == 13: #processing + # return int(child.data["progress"]) + perc_sum += int(child.data["downloading"]["percent"]) except: pass if count == 0: @@ -285,16 +279,17 @@ class QueueModel(CollectorModel): return QVariant(self.translateStatus(statusMapReverse[status])) else: return QVariant("%s (%s)" % (self.translateStatus(statusMapReverse[status]), formatSpeed(speed))) - elif index.column() == 3: - item = index.internalPointer() - if isinstance(item, Package): - return QVariant(item.data["priority"]) - else: - return QVariant(item.package.data["priority"]) + #elif index.column() == 3: + # item = index.internalPointer() + # if isinstance(item, Package): + # return QVariant(item.data["priority"]) + # else: + # return QVariant(item.package.data["priority"]) elif index.column() == 4: item = index.internalPointer() if isinstance(item, Link): - if self.getProgress(item, False) == 100: + if item.data["status"] == 0: #TODO needs change?? + #self.getProgress(item, False) == 100: return QVariant(formatSize(item.data["size"])) elif self.getProgress(item, False) == 0: try: diff --git a/module/gui/SettingsWidget.py b/module/gui/SettingsWidget.py index c50130b5c..cd22a7b9e 100644 --- a/module/gui/SettingsWidget.py +++ b/module/gui/SettingsWidget.py @@ -20,7 +20,6 @@ from PyQt4.QtCore import * from PyQt4.QtGui import * from sip import delete -from module.remote.thriftbackend.thriftgen.pyload.ttypes import * class SettingsWidget(QWidget): def __init__(self): @@ -142,6 +141,8 @@ class SettingsWidget(QWidget): if item.name in widget.inputs: i = widget.inputs[item.name] + #TODO : unresolved reference: option + if item.type == "int": if i.value() != int(item.value): self.connector.setConfigValue(k, option, i.value(), sec) diff --git a/module/gui/connector.py b/module/gui/connector.py index 8d2292aa3..91f23dafb 100644 --- a/module/gui/connector.py +++ b/module/gui/connector.py @@ -16,7 +16,7 @@ @author: mkaay """ -SERVER_VERSION = "0.4.6-dev" +SERVER_VERSION = "0.4.7" from time import sleep from uuid import uuid4 as uuid |