mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-09-01 09:45:18 +00:00
Two fixes for main_window.py
- initialize r when getting status text - fix so settings widgets appear and are enabled appropriately
This commit is contained in:
parent
f9047c6df0
commit
93b964f11d
1 changed files with 17 additions and 15 deletions
|
@ -24,6 +24,7 @@ import webbrowser
|
||||||
import csv
|
import csv
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
import base64
|
import base64
|
||||||
|
from functools import partial
|
||||||
|
|
||||||
import PyQt4
|
import PyQt4
|
||||||
from PyQt4.QtGui import *
|
from PyQt4.QtGui import *
|
||||||
|
@ -518,7 +519,7 @@ class ElectrumWindow(QMainWindow):
|
||||||
if x:
|
if x:
|
||||||
text += " [%s unmatured]"%(self.format_amount(x, True).strip())
|
text += " [%s unmatured]"%(self.format_amount(x, True).strip())
|
||||||
# append fiat balance and price from exchange rate plugin
|
# append fiat balance and price from exchange rate plugin
|
||||||
r = {}
|
r = {'text': ''}
|
||||||
run_hook('get_fiat_status_text', c + u + x, r)
|
run_hook('get_fiat_status_text', c + u + x, r)
|
||||||
text += r['text']
|
text += r['text']
|
||||||
icon = QIcon(":icons/status_connected.png")
|
icon = QIcon(":icons/status_connected.png")
|
||||||
|
@ -2822,14 +2823,20 @@ class ElectrumWindow(QMainWindow):
|
||||||
grid.setColumnStretch(0,1)
|
grid.setColumnStretch(0,1)
|
||||||
w.setLayout(grid)
|
w.setLayout(grid)
|
||||||
|
|
||||||
def do_toggle(cb, name, w):
|
settings_widgets = {}
|
||||||
p = plugins.toggle_enabled(self.config, name)
|
|
||||||
enabled = p is not None
|
|
||||||
cb.setChecked(enabled)
|
|
||||||
if w: w.setEnabled(enabled)
|
|
||||||
|
|
||||||
def mk_toggle(cb, name, w):
|
def enable_settings_widget(p, name, i):
|
||||||
return lambda: do_toggle(cb, name, w)
|
widget = settings_widgets.get(name)
|
||||||
|
if not widget and p and p.requires_settings():
|
||||||
|
widget = settings_widgets[name] = p.settings_widget(self)
|
||||||
|
grid.addWidget(widget, i, 1)
|
||||||
|
if widget:
|
||||||
|
widget.setEnabled(bool(p and p.is_enabled()))
|
||||||
|
|
||||||
|
def do_toggle(cb, name, i):
|
||||||
|
p = plugins.toggle_enabled(self.config, name)
|
||||||
|
cb.setChecked(bool(p))
|
||||||
|
enable_settings_widget(p, name, i)
|
||||||
|
|
||||||
for i, descr in enumerate(plugins.descriptions):
|
for i, descr in enumerate(plugins.descriptions):
|
||||||
name = descr['name']
|
name = descr['name']
|
||||||
|
@ -2841,13 +2848,8 @@ class ElectrumWindow(QMainWindow):
|
||||||
cb.setEnabled(plugins.is_available(name, self.wallet))
|
cb.setEnabled(plugins.is_available(name, self.wallet))
|
||||||
cb.setChecked(p is not None and p.is_enabled())
|
cb.setChecked(p is not None and p.is_enabled())
|
||||||
grid.addWidget(cb, i, 0)
|
grid.addWidget(cb, i, 0)
|
||||||
if p and p.requires_settings():
|
enable_settings_widget(p, name, i)
|
||||||
w = p.settings_widget(self)
|
cb.clicked.connect(partial(do_toggle, cb, name, i))
|
||||||
w.setEnabled(p.is_enabled())
|
|
||||||
grid.addWidget(w, i, 1)
|
|
||||||
else:
|
|
||||||
w = None
|
|
||||||
cb.clicked.connect(mk_toggle(cb, name, w))
|
|
||||||
msg = descr['description']
|
msg = descr['description']
|
||||||
if descr.get('requires'):
|
if descr.get('requires'):
|
||||||
msg += '\n\n' + _('Requires') + ':\n' + '\n'.join(map(lambda x: x[1], descr.get('requires')))
|
msg += '\n\n' + _('Requires') + ':\n' + '\n'.join(map(lambda x: x[1], descr.get('requires')))
|
||||||
|
|
Loading…
Add table
Reference in a new issue