From a5ff0482ede8bd7bd932482887f2f7cdae5039d9 Mon Sep 17 00:00:00 2001 From: mkaay Date: Wed, 23 Dec 2009 00:04:36 +0100 Subject: core: downloadlimit is not far away ;) gui: restart download action --- module/gui/MainWindow.py | 19 +++++++++++++++++-- module/gui/connector.py | 20 ++++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) (limited to 'module/gui') diff --git a/module/gui/MainWindow.py b/module/gui/MainWindow.py index f72ad97de..837125263 100644 --- a/module/gui/MainWindow.py +++ b/module/gui/MainWindow.py @@ -153,6 +153,9 @@ class MainWindow(QMainWindow): self.tabs["collector"]["l"].addWidget(groupPackage, 0, 0) self.tabs["collector"]["l"].addWidget(groupLinks, 0, 1) self.connect(toQueue, SIGNAL("clicked()"), self.slotPushPackageToQueue) + self.tabs["collector"]["package_view"].setContextMenuPolicy(Qt.CustomContextMenu) + self.tabs["collector"]["link_view"].setContextMenuPolicy(Qt.CustomContextMenu) + self.tabs["queue"]["view"].setContextMenuPolicy(Qt.CustomContextMenu) def init_context(self): """ @@ -160,8 +163,12 @@ class MainWindow(QMainWindow): """ self.queueContext = QMenu() self.queueContext.buttons = {} + self.queueContext.item = (None, None) self.queueContext.buttons["remove"] = QAction("Remove", self.queueContext) + self.queueContext.buttons["restart"] = QAction("Restart", self.queueContext) self.queueContext.addAction(self.queueContext.buttons["remove"]) + self.queueContext.addAction(self.queueContext.buttons["restart"]) + self.connect(self.queueContext.buttons["restart"], SIGNAL("triggered()"), self.slotRestartDownload) def slotToggleStatus(self, status): """ @@ -273,8 +280,8 @@ class MainWindow(QMainWindow): globalPos = self.tabs["queue"]["view"].mapToGlobal(pos) i = self.tabs["queue"]["view"].itemAt(pos) i.setSelected(True) - self.addFav.setData(QVariant(i)) - self.showContext.exec_(globalPos) + self.queueContext.item = (i.data(0, Qt.UserRole).toPyObject(), i.parent() == None) + self.queueContext.exec_(globalPos) def slotPackageCollectorContextMenu(self, pos): """ @@ -287,4 +294,12 @@ class MainWindow(QMainWindow): custom context menu in link collector view requested """ pass + + def slotRestartDownload(self): + """ + restart download action is triggered + """ + id, isTopLevel = self.queueContext.item + if not id == None: + self.emit(SIGNAL("restartDownload"), id, isTopLevel) diff --git a/module/gui/connector.py b/module/gui/connector.py index 2a1ce511e..75781ebb1 100644 --- a/module/gui/connector.py +++ b/module/gui/connector.py @@ -210,3 +210,23 @@ class connector(QThread): self.proxy.push_package_2_queue(packid) finally: self.mutex.unlock() + + def restartPackage(self, packid): + """ + restart a package + """ + self.mutex.lock() + try: + self.proxy.restart_package(packid) + finally: + self.mutex.unlock() + + def restartFile(self, fileid): + """ + restart a file + """ + self.mutex.lock() + try: + self.proxy.restart_file(fileid) + finally: + self.mutex.unlock() -- cgit v1.2.3