diff options
| author | 2009-12-29 16:50:13 +0100 | |
|---|---|---|
| committer | 2009-12-29 16:50:13 +0100 | |
| commit | fa9cce4987da585f5bf21274cfbe5f046f46f703 (patch) | |
| tree | 94fa0f16d8b72b09c1e59d27d2bb70aeed3c09ff | |
| parent | UploadedTo indirect download fix (diff) | |
| download | pyload-fa9cce4987da585f5bf21274cfbe5f046f46f703.tar.xz | |
: Bitte gib eine Versions-Meldung ein. Zeilen beginnend mit 'HG:' werden entfernt.
| -rw-r--r-- | icons/gui/clipboard.png | bin | 0 -> 1344 bytes | |||
| -rw-r--r-- | icons/gui/edit_small.png | bin | 0 -> 570 bytes | |||
| -rw-r--r-- | icons/gui/pull_small.png | bin | 0 -> 614 bytes | |||
| -rw-r--r-- | icons/gui/push_small.png | bin | 0 -> 618 bytes | |||
| -rw-r--r-- | module/gui/Collector.py | 9 | ||||
| -rw-r--r-- | module/gui/ConnectionManager.py | 42 | ||||
| -rw-r--r-- | module/gui/MainWindow.py | 15 | ||||
| -rw-r--r-- | module/gui/connector.py | 24 | ||||
| -rwxr-xr-x | pyLoadCore.py | 5 | ||||
| -rwxr-xr-x | pyLoadGui.py | 30 | 
10 files changed, 107 insertions, 18 deletions
| diff --git a/icons/gui/clipboard.png b/icons/gui/clipboard.pngBinary files differ new file mode 100644 index 000000000..9ba608eba --- /dev/null +++ b/icons/gui/clipboard.png diff --git a/icons/gui/edit_small.png b/icons/gui/edit_small.pngBinary files differ new file mode 100644 index 000000000..eb76e21b4 --- /dev/null +++ b/icons/gui/edit_small.png diff --git a/icons/gui/pull_small.png b/icons/gui/pull_small.pngBinary files differ new file mode 100644 index 000000000..432ad321f --- /dev/null +++ b/icons/gui/pull_small.png diff --git a/icons/gui/push_small.png b/icons/gui/push_small.pngBinary files differ new file mode 100644 index 000000000..701fc69e3 --- /dev/null +++ b/icons/gui/push_small.png diff --git a/module/gui/Collector.py b/module/gui/Collector.py index 8b421001e..356ab36ec 100644 --- a/module/gui/Collector.py +++ b/module/gui/Collector.py @@ -112,6 +112,15 @@ class PackageCollector(QThread):          remove.reverse()          for k in remove:              self.rootItem.takeChild(k) +        for pack in ItemIterator(self.rootItem): +            if pack.getPackData()["id"] == "fixed": +                return +        item = self.PackageCollectorPack(self) +        item.setPackData({"id":"fixed"}) +        item.setData(0, Qt.DisplayRole, QVariant("Single Links")) +        item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable) +        self.rootItem.addChild(item) +        self.linkCollector = item      def pauseItemUpdate(self, pid, pause=True):          locker = QMutexLocker(self.mutex) diff --git a/module/gui/ConnectionManager.py b/module/gui/ConnectionManager.py index c997eee19..57aed3a18 100644 --- a/module/gui/ConnectionManager.py +++ b/module/gui/ConnectionManager.py @@ -53,6 +53,8 @@ class ConnectionManager(QWidget):          self.connList = connList          self.edit = self.EditWindow()          self.connectSignals() +         +        self.defaultStates = {}      def connectSignals(self):          self.connect(self, SIGNAL("setConnections(connections)"), self.setConnections) @@ -61,6 +63,7 @@ class ConnectionManager(QWidget):          self.connect(self.remove, SIGNAL("clicked()"), self.slotRemove)          self.connect(self.connectb, SIGNAL("clicked()"), self.slotConnect)          self.connect(self.edit, SIGNAL("save"), self.slotSave) +        self.connect(self.connList, SIGNAL("itemDoubleClicked(QListWidgetItem *)"), self.slotItemDoubleClicked)      def setConnections(self, connections):          self.connList.clear() @@ -70,6 +73,7 @@ class ConnectionManager(QWidget):              item.setData(Qt.UserRole, QVariant(conn))              self.connList.addItem(item)              if conn["default"]: +                item.setData(Qt.DisplayRole, QVariant("%s (Default)" % conn["name"]))                  self.connList.setCurrentItem(item)      def slotNew(self): @@ -80,34 +84,51 @@ class ConnectionManager(QWidget):      def slotEdit(self):          item = self.connList.currentItem()          data = item.data(Qt.UserRole).toPyObject() -        tmp = {} -        for k, d in data.items(): -            tmp[str(k)] = d -        data = tmp +        data = self.cleanDict(data)          self.edit.setData(data)          self.edit.show()      def slotRemove(self):          item = self.connList.currentItem()          data = item.data(Qt.UserRole).toPyObject() -        tmp = {} -        for k, d in data.items(): -            tmp[str(k)] = d -        data = tmp +        data = self.cleanDict(data)          self.emit(SIGNAL("removeConnection"), data)      def slotConnect(self):          item = self.connList.currentItem()          data = item.data(Qt.UserRole).toPyObject() +        data = self.cleanDict(data) +        self.emit(SIGNAL("connect"), data) +     +    def cleanDict(self, data):          tmp = {}          for k, d in data.items():              tmp[str(k)] = d -        data = tmp -        self.emit(SIGNAL("connect"), data) +        return tmp      def slotSave(self, data):          self.emit(SIGNAL("saveConnection"), data) +    def slotItemDoubleClicked(self, defaultItem): +        data = defaultItem.data(Qt.UserRole).toPyObject() +        self.setDefault(data, True) +        did = self.cleanDict(data)["id"] +        allItems = self.connList.findItems("*", Qt.MatchWildcard) +        count = self.connList.count() +        for i in range(count): +            item = self.connList.item(i) +            data = item.data(Qt.UserRole).toPyObject() +            if self.cleanDict(data)["id"] == did: +                continue +            self.setDefault(data, False) +     +    def setDefault(self, data, state): +        data = self.cleanDict(data) +        self.edit.setData(data) +        data = self.edit.getData() +        data["default"] = state +        self.edit.emit(SIGNAL("save"), data) +          class EditWindow(QWidget):          def __init__(self):              QWidget.__init__(self) @@ -225,3 +246,4 @@ class ConnectionManager(QWidget):              data = self.getData()              self.hide()              self.emit(SIGNAL("save"), data) + diff --git a/module/gui/MainWindow.py b/module/gui/MainWindow.py index 5237436f0..6daa0aa55 100644 --- a/module/gui/MainWindow.py +++ b/module/gui/MainWindow.py @@ -187,10 +187,13 @@ class MainWindow(QMainWindow):          self.queueContext.item = (None, None)          self.queueContext.buttons["remove"] = QAction(QIcon("icons/gui/remove_small.png"), "Remove", self.queueContext)          self.queueContext.buttons["restart"] = QAction(QIcon("icons/gui/refresh_small.png"), "Restart", self.queueContext) +        self.queueContext.buttons["pull"] = QAction(QIcon("icons/gui/pull_small.png"), "Pull out", self.queueContext) +        self.queueContext.addAction(self.queueContext.buttons["pull"])          self.queueContext.addAction(self.queueContext.buttons["remove"])          self.queueContext.addAction(self.queueContext.buttons["restart"])          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)          #collector          self.collectorContext = QMenu() @@ -341,6 +344,10 @@ class MainWindow(QMainWindow):          menuPos = QCursor.pos()          menuPos.setX(menuPos.x()+2)          self.activeMenu = self.queueContext +        if hasattr(i, "getPackData"): +            self.queueContext.buttons["pull"].setVisible(True) +        else: +            self.queueContext.buttons["pull"].setVisible(False)          self.queueContext.exec_(menuPos)      def slotCollectorContextMenu(self, pos): @@ -402,4 +409,12 @@ class MainWindow(QMainWindow):          print type(pid)          self.emit(SIGNAL("changePackageName"), pid, editor.text())          self.emit(SIGNAL("pauseItemUpdate"), pid, False) +     +    def slotPullOutPackage(self): +        """ +            pull package out of the queue +        """ +        id, isTopLevel = self.activeMenu.item +        if not id == None: +            self.emit(SIGNAL("pullOutPackage"), id, isTopLevel) diff --git a/module/gui/connector.py b/module/gui/connector.py index 8a2909c5e..2915cf568 100644 --- a/module/gui/connector.py +++ b/module/gui/connector.py @@ -51,11 +51,14 @@ class connector(QThread):              start thread              (called from thread.start())          """ -        self.connectProxy(self.addr) +        self.canConnect()          while self.running:              sleep(1)              self.getError() +    def canConnect(self): +        return self.connectProxy(self.addr) +          def stop(self):          """              stop thread @@ -67,9 +70,14 @@ class connector(QThread):              connect to remote server          """          self.proxy = ServerProxy(addr, allow_none=True) -        server_version = self.proxy.get_server_version() +        try: +            server_version = self.proxy.get_server_version() +        except: +            return False          if not server_version == SERVER_VERSION:              self.emit(SIGNAL("error_box"), "server is version %s client accepts version %s" % (server_version, SERVER_VERSION)) +            return False +        return True      def _proxyError(self, func, e):          """ @@ -365,4 +373,16 @@ class connector(QThread):              self.emit(SIGNAL("proxy_error"), "setPackageName", e)          finally:              self.mutex.unlock() +     +    def slotPullOutPackage(self, pid): +        """ +            pull out package +        """ +        self.mutex.lock() +        try: +            return self.proxy.pull_out_package(pid) +        except Exception, e: +            self.emit(SIGNAL("proxy_error"), "slotPullOutPackage", e) +        finally: +            self.mutex.unlock() diff --git a/pyLoadCore.py b/pyLoadCore.py index 8bd9a3995..6b38d425c 100755 --- a/pyLoadCore.py +++ b/pyLoadCore.py @@ -553,7 +553,10 @@ class ServerMethods():          return self.core.update_available      def set_package_name(self, pid, name): -        self.core.file_list.packager.setPackageData(pid, package_name=name)
 +        self.core.file_list.packager.setPackageData(pid, package_name=name) +     +    def pull_out_package(self, pid): +        self.core.file_list.packager.pullOutPackage(pid)
      #def move_urls_up(self, ids):
      #    for id in ids:
 diff --git a/pyLoadGui.py b/pyLoadGui.py index 38013cd4c..9db4e5630 100755 --- a/pyLoadGui.py +++ b/pyLoadGui.py @@ -45,9 +45,9 @@ class main(QObject):          """          QObject.__init__(self)          self.app = QApplication(sys.argv) -        self.init() +        self.init(True) -    def init(self): +    def init(self, first=False):          """              set main things up          """ @@ -60,14 +60,22 @@ class main(QObject):          self.parser = XMLParser("module/config/gui.xml", "module/config/gui_default.xml")          self.checkClipboard = False -        self.refreshConnections() +        default = self.refreshConnections()          self.connData = None -        self.connWindow.show() +        if not first: +            self.connWindow.show() +        else: +            self.connWindow.edit.setData(default) +            data = self.connWindow.edit.getData() +            self.slotConnect(data)      def startMain(self):          """              start all refresh threads and show main window          """ +        if not self.connector.canConnect(): +            self.init() +            return          self.connector.start()          sleep(1)          self.restoreMainWindow() @@ -122,6 +130,7 @@ class main(QObject):          self.connect(self.mainWindow, SIGNAL("stopAllDownloads"), self.slotStopAllDownloads)          self.connect(self.mainWindow, SIGNAL("setClipboardStatus"), self.slotSetClipboardStatus)          self.connect(self.mainWindow, SIGNAL("changePackageName"), self.slotChangePackageName) +        self.connect(self.mainWindow, SIGNAL("pullOutPackage"), self.slotPullOutPackage)      def slotShowConnector(self):          """ @@ -405,7 +414,7 @@ class main(QObject):          else:              data["ssl"] = ""          server_url = "http%(ssl)s://%(user)s:%(password)s@%(host)s:%(port)s/" % data -        self.connector.setAddr(server_url) +        self.connector.setAddr(str(server_url))          self.startMain()      def refreshConnections(self): @@ -415,6 +424,10 @@ class main(QObject):          self.parser.loadData()          conns = self.getConnections()          self.connWindow.emit(SIGNAL("setConnections(connections)"), conns) +        for conn in conns: +            if conn["default"]: +                return conn +        return None      def slotAddLinks(self, links):          """ @@ -548,6 +561,13 @@ class main(QObject):          """          self.connector.setPackageName(pid, str(name)) +    def slotPullOutPackage(self, pid, isPack): +        """ +            pull package out of the queue +        """ +        if isPack: +            self.connector.slotPullOutPackage(pid) +          class Loop(QThread):          """              main loop (not application loop) | 
