commit 4458a1c81b28dc2a800bae3ac7005989bbe4b789
parent a10455f6857bd7c8d57e160cecf72d60f99465a7
Author: Maran <maran.hidskes@gmail.com>
Date: Sun, 17 Mar 2013 12:08:12 +0100
Worked in new settings dialog for label sync plugin.
Diffstat:
1 file changed, 32 insertions(+), 11 deletions(-)
diff --git a/plugins/labels.py b/plugins/labels.py
@@ -50,6 +50,9 @@ To get started visit http://labelectrum.herokuapp.com/ to sign up for an account
def is_available(self):
return True
+ def requires_settings(self):
+ return True
+
def set_label(self, item,label, changed):
if not changed:
return
@@ -65,23 +68,20 @@ To get started visit http://labelectrum.herokuapp.com/ to sign up for an account
return
response = json.loads(response.read())
-
- def requires_settings(self):
- return True
-
def settings_dialog(self):
- dialog = QDialog(self.gui)
-
def check_for_api_key(api_key):
if api_key and len(api_key) > 12:
self.config.set_key("plugin_label_api_key", str(self.auth_token_edit.text()))
self.upload.setEnabled(True)
self.download.setEnabled(True)
+ self.accept.setEnabled(True)
else:
self.upload.setEnabled(False)
self.download.setEnabled(False)
+ self.accept.setEnabled(False)
- layout = QGridLayout()
+ d = QDialog(self.gui)
+ layout = QGridLayout(d)
layout.addWidget(QLabel("API Key: "),0,0)
self.auth_token_edit = QLineEdit(self.auth_token())
@@ -98,14 +98,35 @@ To get started visit http://labelectrum.herokuapp.com/ to sign up for an account
self.download.clicked.connect(lambda: self.full_pull(True))
layout.addWidget(self.download, 1,2)
- check_for_api_key(self.auth_token())
+ c = QPushButton(_("Cancel"))
+ c.clicked.connect(d.reject)
+
+ self.accept = QPushButton(_("Done"))
+ self.accept.clicked.connect(d.accept)
- dialog.setLayout(layout)
+ layout.addWidget(c,2,1)
+ layout.addWidget(self.accept,2,2)
- dialog.exec_()
- self.config.set_key("plugin_label_api_key", str(self.auth_token_edit.text()))
+ check_for_api_key(self.auth_token())
+
+ if d.exec_():
+ return True
+ else:
+ return False
+ def toggle(self):
+ enabled = not self.is_enabled()
+ self.set_enabled(enabled)
+ self.init_gui()
+ if not self.auth_token() and enabled: # First run, throw plugin settings in your face
+ if self.settings_dialog():
+ self.set_enabled(True)
+ return True
+ else:
+ self.set_enabled(False)
+ return False
+ return enabled
def full_push(self):
if self.do_full_push():