settings dialog

This commit is contained in:
ecdsa 2013-03-17 11:52:58 +01:00
parent c5747484b2
commit a10455f685
3 changed files with 17 additions and 13 deletions

View File

@ -2015,7 +2015,7 @@ class ElectrumWindow(QMainWindow):
cb.setChecked(p.is_enabled())
cb.clicked.connect(mk_toggle(cb,p))
grid_plugins.addWidget(cb, i, 0)
if p.requires_settings:
if p.requires_settings():
grid_plugins.addWidget(EnterButton(_('Settings'), p.settings_dialog), i, 1)
grid_plugins.addWidget(HelpButton(description), i, 2)
except:

View File

@ -11,7 +11,9 @@ class BasePlugin:
self.description = description
self.gui = gui
self.config = gui.config
self.requires_settings = False
def requires_settings(self):
return False
def toggle(self):
enabled = not self.is_enabled()

View File

@ -65,15 +65,13 @@ To get started visit http://labelectrum.herokuapp.com/ to sign up for an account
return
response = json.loads(response.read())
def close_settings_dialog(self):
# When you enable the plugin for the first time this won't exist.
if self.is_enabled():
if hasattr(self, 'auth_token_edit'):
self.config.set_key("plugin_label_api_key", str(self.auth_token_edit.text()))
else:
QMessageBox.information(None, _("Label sync loaded"), _("Please open the settings again to configure the label sync plugin."))
def create_settings_tab(self, tabs):
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()))
@ -83,8 +81,7 @@ To get started visit http://labelectrum.herokuapp.com/ to sign up for an account
self.upload.setEnabled(False)
self.download.setEnabled(False)
cloud_tab = QWidget()
layout = QGridLayout(cloud_tab)
layout = QGridLayout()
layout.addWidget(QLabel("API Key: "),0,0)
self.auth_token_edit = QLineEdit(self.auth_token())
@ -103,7 +100,12 @@ To get started visit http://labelectrum.herokuapp.com/ to sign up for an account
check_for_api_key(self.auth_token())
tabs.addTab(cloud_tab, "Label sync")
dialog.setLayout(layout)
dialog.exec_()
self.config.set_key("plugin_label_api_key", str(self.auth_token_edit.text()))
def full_push(self):
if self.do_full_push():