summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar mkaay <mkaay@mkaay.de> 2010-11-06 15:39:28 +0100
committerGravatar mkaay <mkaay@mkaay.de> 2010-11-06 15:39:28 +0100
commit761a4104baaaa863ade8ca1aa0bda249557a0f80 (patch)
treee5a74cb97865bad7d327c7d910c2bb792c55a77d
parentcache fix (diff)
downloadpyload-761a4104baaaa863ade8ca1aa0bda249557a0f80.tar.xz
account editing + fixes
-rw-r--r--module/AccountManager.py10
-rw-r--r--module/gui/MainWindow.py65
-rwxr-xr-xpyLoadCore.py3
3 files changed, 70 insertions, 8 deletions
diff --git a/module/AccountManager.py b/module/AccountManager.py
index d1733585f..a76a9915a 100644
--- a/module/AccountManager.py
+++ b/module/AccountManager.py
@@ -36,6 +36,7 @@ class AccountManager():
self.accounts = {} # key = ( plugin )
self.plugins = {}
+ self.accountInfoCache = {}
self.initAccountPlugins()
@@ -144,6 +145,7 @@ class AccountManager():
self.saveAccounts()
p.getAllAccounts(force=True)
+ self.core.scheduler.addJob(0, self.core.accountManager.getAccountInfos)
#----------------------------------------------------------------------
def removeAccount(self, plugin, user):
@@ -153,13 +155,13 @@ class AccountManager():
p = self.getAccountPlugin(plugin)
p.removeAccount(user)
- cache = self.accountInfoCache
- if self.cache.has_key(p.__name__):
- if cache[p].has_key(user):
- del cache[p][user]
+ if self.accounts.has_key(p):
+ if self.accounts[p].has_key(user):
+ del self.accounts[p][user]
self.saveAccounts()
p.getAllAccounts(force=True)
+ self.core.scheduler.addJob(0, self.core.accountManager.getAccountInfos)
def getCachedAccountInfos(self, refresh=True):
if refresh:
diff --git a/module/gui/MainWindow.py b/module/gui/MainWindow.py
index 12f883287..255f562a1 100644
--- a/module/gui/MainWindow.py
+++ b/module/gui/MainWindow.py
@@ -29,6 +29,7 @@ from module.gui.SettingsWidget import SettingsWidget
from module.gui.Collector import CollectorView, Package, Link
from module.gui.Queue import QueueView
from module.gui.Accounts import AccountView
+from module.gui.AccountEdit import AccountEdit
class MainWindow(QMainWindow):
def __init__(self, connector):
@@ -129,10 +130,13 @@ class MainWindow(QMainWindow):
self.connect(self.tabs["queue"]["view"], SIGNAL('customContextMenuRequested(const QPoint &)'), self.slotQueueContextMenu)
self.connect(self.tabs["collector"]["package_view"], SIGNAL('customContextMenuRequested(const QPoint &)'), self.slotCollectorContextMenu)
+ self.connect(self.tabs["accounts"]["view"], SIGNAL('customContextMenuRequested(const QPoint &)'), self.slotAccountContextMenu)
self.connect(self.tabw, SIGNAL("currentChanged(int)"), self.slotTabChanged)
self.lastAddedID = None
+
+ self.connector = connector
def init_toolbar(self):
"""
@@ -196,8 +200,12 @@ class MainWindow(QMainWindow):
#accounts
self.tabs["accounts"]["view"] = AccountView(connector)
- self.tabs["accounts"]["w"].setLayout(QHBoxLayout())
+ self.tabs["accounts"]["w"].setLayout(QVBoxLayout())
self.tabs["accounts"]["w"].layout().addWidget(self.tabs["accounts"]["view"])
+ newbutton = QPushButton(_("New Account"))
+ self.tabs["accounts"]["w"].layout().addWidget(newbutton)
+ self.connect(newbutton, SIGNAL("clicked()"), self.slotNewAccount)
+ self.tabs["accounts"]["view"].setContextMenuPolicy(Qt.CustomContextMenu)
def init_context(self):
"""
@@ -250,15 +258,27 @@ class MainWindow(QMainWindow):
self.collectorContext.buttons["remove"] = QAction(QIcon(join(pypath, "icons","remove_small.png")), _("Remove"), self.collectorContext)
self.collectorContext.buttons["push"] = QAction(QIcon(join(pypath, "icons","push_small.png")), _("Push to queue"), self.collectorContext)
self.collectorContext.buttons["edit"] = QAction(QIcon(join(pypath, "icons","edit_small.png")), _("Edit Name"), self.collectorContext)
- self.collectorContext.buttons["refresh"] = QAction(QIcon(join(pypath, "icons","refresh_small.png")), _("Refresh Status"), self.collectorContext)
+ self.collectorContext.buttons["restart"] = QAction(QIcon(join(pypath, "icons","refresh_small.png")), _("Refresh Status"), self.collectorContext)
+ self.collectorContext.buttons["refresh"] = QAction(_("Refresh Status"), self.collectorContext)
self.collectorContext.addAction(self.collectorContext.buttons["push"])
self.collectorContext.addAction(self.collectorContext.buttons["edit"])
self.collectorContext.addAction(self.collectorContext.buttons["remove"])
+ self.collectorContext.addAction(self.collectorContext.buttons["restart"])
self.collectorContext.addAction(self.collectorContext.buttons["refresh"])
self.connect(self.collectorContext.buttons["remove"], SIGNAL("triggered()"), self.slotRemoveDownload)
self.connect(self.collectorContext.buttons["push"], SIGNAL("triggered()"), self.slotPushPackageToQueue)
self.connect(self.collectorContext.buttons["edit"], SIGNAL("triggered()"), self.slotEditPackage)
+ self.connect(self.collectorContext.buttons["restart"], SIGNAL("triggered()"), self.slotRestartDownload)
self.connect(self.collectorContext.buttons["refresh"], SIGNAL("triggered()"), self.slotRefreshPackage)
+
+ self.accountContext = QMenu()
+ self.accountContext.buttons = {}
+ self.accountContext.buttons["remove"] = QAction(QIcon(join(pypath, "icons","remove_small.png")), _("Remove"), self.accountContext)
+ self.accountContext.buttons["edit"] = QAction(QIcon(join(pypath, "icons","edit_small.png")), _("Edit"), self.accountContext)
+ self.accountContext.addAction(self.accountContext.buttons["edit"])
+ self.accountContext.addAction(self.accountContext.buttons["remove"])
+ self.connect(self.accountContext.buttons["edit"], SIGNAL("triggered()"), self.slotEditAccount)
+ self.connect(self.accountContext.buttons["remove"], SIGNAL("triggered()"), self.slotRemoveAccount)
def slotToggleStatus(self, status):
"""
@@ -512,6 +532,47 @@ class MainWindow(QMainWindow):
pid = item.package.id
self.emit(SIGNAL("refreshStatus"), pid)
+ def slotNewAccount(self):
+ types = self.connector.proxy.get_accounts(False, False).keys()
+ self.accountEdit = AccountEdit.newAccount(types)
+
+ def save(data):
+ if data["password"]:
+ self.accountEdit.close()
+ self.connector.proxy.update_account(data["acctype"], data["login"], data["password"])
+
+ self.accountEdit.connect(self.accountEdit, SIGNAL("done"), save)
+ self.accountEdit.show()
+
+ def slotEditAccount(self):
+ types = self.connector.proxy.get_accounts(False, False).keys()
+
+ data = self.tabs["accounts"]["view"].selectedIndexes()[0].internalPointer()
+
+ self.accountEdit = AccountEdit.editAccount(types, data)
+
+ def save(data):
+ self.accountEdit.close()
+ self.connector.proxy.update_account(data["acctype"], data["login"], data["password"] if data["password"] else None)
+
+ self.accountEdit.connect(self.accountEdit, SIGNAL("done"), save)
+ self.accountEdit.show()
+
+ def slotRemoveAccount(self):
+ data = self.tabs["accounts"]["view"].selectedIndexes()[0].internalPointer()
+
+ self.connector.proxy.remove_account(data["type"], data["login"])
+
+ def slotAccountContextMenu(self, pos):
+ globalPos = self.tabs["accounts"]["view"].mapToGlobal(pos)
+ i = self.tabs["accounts"]["view"].indexAt(pos)
+ if not i:
+ return
+ data = i.internalPointer()
+ menuPos = QCursor.pos()
+ menuPos.setX(menuPos.x()+2)
+ self.accountContext.exec_(menuPos)
+
class Priorty():
def __init__(self, win):
self.w = win
diff --git a/pyLoadCore.py b/pyLoadCore.py
index 297bb8c59..7818e7312 100755
--- a/pyLoadCore.py
+++ b/pyLoadCore.py
@@ -753,8 +753,7 @@ class ServerMethods():
return self.core.pullManager.getEvents(uuid)
def get_accounts(self, force=False, refresh=True):
- print force, refresh
- if refresh:
+ if force:
return self.core.accountManager.getAccountInfos()
else:
return self.core.accountManager.getCachedAccountInfos(refresh)