call init_qt everytime a plugin is enabled

This commit is contained in:
ThomasV 2014-09-04 15:45:03 +02:00
parent a8f0e4310f
commit 6101abda5d
4 changed files with 26 additions and 33 deletions

View File

@ -467,6 +467,9 @@ class ElectrumWindow(QMainWindow):
raise Exception('Unknown base unit')
def update_status(self):
if not self.wallet:
return
if self.network is None or not self.network.is_running():
text = _("Offline")
icon = QIcon(":icons/status_disconnected.png")
@ -2719,7 +2722,13 @@ class ElectrumWindow(QMainWindow):
w.setLayout(grid)
def do_toggle(cb, p, w):
r = p.toggle()
if p.is_enabled():
if p.disable():
p.close()
else:
if p.enable():
p.init_qt(self.gui_object)
r = p.is_enabled()
cb.setChecked(r)
if w: w.setEnabled(r)

View File

@ -79,16 +79,6 @@ class BasePlugin:
def requires_settings(self):
return False
def toggle(self):
if self.is_enabled():
if self.disable():
self.close()
else:
if self.enable():
self.init()
return self.is_enabled()
def enable(self):
self.set_enabled(True)

View File

@ -81,10 +81,6 @@ class Plugin(BasePlugin):
def enable(self):
return BasePlugin.enable(self)
@hook
def init_qt(self, gui):
self.gui = gui
@hook
def load_wallet(self, wallet):
self.wallet = wallet

View File

@ -337,6 +337,7 @@ class Plugin(BasePlugin):
BasePlugin.__init__(self,a,b)
self.currencies = [self.fiat_unit()]
self.exchanges = [self.config.get('use_exchange', "Blockchain")]
self.exchanger = None
@hook
def init_qt(self, gui):
@ -344,11 +345,21 @@ class Plugin(BasePlugin):
self.win = self.gui.main_window
self.win.connect(self.win, SIGNAL("refresh_currencies()"), self.win.update_status)
self.btc_rate = Decimal("0.0")
# Do price discovery
self.exchanger = Exchanger(self)
self.exchanger.start()
self.gui.exchanger = self.exchanger #
self.add_fiat_edit()
if self.exchanger is None:
# Do price discovery
self.exchanger = Exchanger(self)
self.exchanger.start()
self.gui.exchanger = self.exchanger #
self.add_fiat_edit()
self.add_fiat_edit()
self.win.update_status()
def close(self):
self.exchanger.stop()
self.exchanger = None
self.win.tabs.removeTab(1)
self.win.tabs.insertTab(1, self.win.create_send_tab(), _('Send'))
self.win.update_status()
def set_currencies(self, currency_options):
self.currencies = sorted(currency_options)
@ -410,19 +421,6 @@ class Plugin(BasePlugin):
return True
def toggle(self):
enabled = BasePlugin.toggle(self)
self.win.update_status()
self.win.tabs.removeTab(1)
new_send_tab = self.gui.main_window.create_send_tab()
self.win.tabs.insertTab(1, new_send_tab, _('Send'))
if enabled:
self.add_fiat_edit()
return enabled
def close(self):
self.exchanger.stop()
def history_tab_update(self):
if self.config.get('history_rates', 'unchecked') == "checked":