kivy: improve settings dialog
This commit is contained in:
@@ -7,25 +7,25 @@ Builder.load_string('''
|
|||||||
<CheckBoxDialog@Popup>
|
<CheckBoxDialog@Popup>
|
||||||
id: popup
|
id: popup
|
||||||
title: ''
|
title: ''
|
||||||
size_hint: 0.8, 0.5
|
size_hint: 0.8, 0.8
|
||||||
pos_hint: {'top':0.9}
|
pos_hint: {'top':0.9}
|
||||||
BoxLayout:
|
BoxLayout:
|
||||||
orientation: 'vertical'
|
orientation: 'vertical'
|
||||||
Label:
|
ScrollView:
|
||||||
id: description
|
|
||||||
text: ''
|
|
||||||
size_hint: 1, 1
|
size_hint: 1, 1
|
||||||
halign: 'left'
|
Label:
|
||||||
text_size: self.width, None
|
id: description
|
||||||
|
text: ''
|
||||||
|
size_hint: 1, None
|
||||||
|
halign: 'left'
|
||||||
|
text_size: self.width, None
|
||||||
BoxLayout:
|
BoxLayout:
|
||||||
orientation: 'horizontal'
|
orientation: 'horizontal'
|
||||||
size_hint: 1, 1
|
size_hint: 1, 0.5
|
||||||
Label:
|
Label:
|
||||||
text: _('Enable')
|
text: _('Enable')
|
||||||
CheckBox:
|
CheckBox:
|
||||||
id:cb
|
id:cb
|
||||||
Widget:
|
|
||||||
size_hint: 1, 1
|
|
||||||
BoxLayout:
|
BoxLayout:
|
||||||
orientation: 'horizontal'
|
orientation: 'horizontal'
|
||||||
size_hint: 1, 0.5
|
size_hint: 1, 0.5
|
||||||
|
|||||||
@@ -46,9 +46,11 @@ class ChoiceDialog(Factory.Popup):
|
|||||||
|
|
||||||
def __init__(self, title, choices, key, callback):
|
def __init__(self, title, choices, key, callback):
|
||||||
Factory.Popup.__init__(self)
|
Factory.Popup.__init__(self)
|
||||||
|
if type(choices) is list:
|
||||||
|
choices = dict(map(lambda x: (x,x), choices))
|
||||||
layout = self.ids.choices
|
layout = self.ids.choices
|
||||||
layout.bind(minimum_height=layout.setter('height'))
|
layout.bind(minimum_height=layout.setter('height'))
|
||||||
for k, v in choices.items():
|
for k, v in sorted(choices.items()):
|
||||||
l = Label(text=v)
|
l = Label(text=v)
|
||||||
l.height = '48dp'
|
l.height = '48dp'
|
||||||
cb = CheckBox(group='choices')
|
cb = CheckBox(group='choices')
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ Builder.load_string('''
|
|||||||
orientation: 'vertical'
|
orientation: 'vertical'
|
||||||
title: ''
|
title: ''
|
||||||
description: ''
|
description: ''
|
||||||
size_hint: 1, 1
|
size_hint: 1, None
|
||||||
Label:
|
Label:
|
||||||
id: title
|
id: title
|
||||||
text: self.parent.title
|
text: self.parent.title
|
||||||
@@ -27,79 +27,72 @@ Builder.load_string('''
|
|||||||
size_hint: 1, 1
|
size_hint: 1, 1
|
||||||
halign: 'left'
|
halign: 'left'
|
||||||
text_size: self.width, None
|
text_size: self.width, None
|
||||||
|
CardSeparator
|
||||||
|
|
||||||
<PluginItem@ButtonBehavior+BoxLayout>
|
|
||||||
orientation: 'vertical'
|
|
||||||
title: ''
|
|
||||||
description: ''
|
|
||||||
size_hint: 1, 1
|
|
||||||
BoxLayout:
|
|
||||||
orientation: 'horizontal'
|
|
||||||
Label:
|
|
||||||
id: title
|
|
||||||
text: self.parent.title
|
|
||||||
size_hint: 1, 1
|
|
||||||
bold: True
|
|
||||||
text_size: self.size
|
|
||||||
halign: 'left'
|
|
||||||
Switch:
|
|
||||||
id: sw
|
|
||||||
name: ''
|
|
||||||
Label:
|
|
||||||
text: self.parent.description
|
|
||||||
size_hint: 1, 1
|
|
||||||
text_size: self.width, None
|
|
||||||
color: 0.8, 0.8, 0.8, 1
|
|
||||||
halign: 'left'
|
|
||||||
|
|
||||||
<SettingsDialog@Popup>
|
<SettingsDialog@Popup>
|
||||||
id: settings
|
id: settings
|
||||||
title: _('Electrum Settings')
|
title: _('Electrum Settings')
|
||||||
BoxLayout:
|
BoxLayout:
|
||||||
orientation: 'vertical'
|
orientation: 'vertical'
|
||||||
SettingsItem:
|
ScrollView:
|
||||||
lang: settings.get_language_name()
|
size_hint: 1, 0.8
|
||||||
title: _('Language') + ': %s'%self.lang
|
GridLayout:
|
||||||
description: _("Language")
|
row_default_height: '68dp'
|
||||||
on_release:
|
cols:1
|
||||||
settings.language_dialog(self)
|
id: scrollviewlayout
|
||||||
CardSeparator
|
size_hint: 1, None
|
||||||
SettingsItem:
|
SettingsItem:
|
||||||
status: 'ON' if app.wallet.use_encryption else 'OFF'
|
lang: settings.get_language_name()
|
||||||
title: _('PIN code') + ': ' + self.status
|
title: _('Language') + ': %s'%self.lang
|
||||||
description: _("Change your PIN code.")
|
description: _("Language")
|
||||||
on_release:
|
on_release:
|
||||||
app.change_password()
|
settings.language_dialog(self)
|
||||||
self.status = 'ON' if app.wallet.use_encryption else 'OFF'
|
height: '48dp'
|
||||||
CardSeparator
|
SettingsItem:
|
||||||
SettingsItem:
|
status: 'ON' if app.wallet.use_encryption else 'OFF'
|
||||||
bu: app.base_unit
|
title: _('PIN code') + ': ' + self.status
|
||||||
title: _('Denomination') + ': ' + self.bu
|
description: _("Change your PIN code.")
|
||||||
description: _("Base unit for Bitcoin amounts.")
|
on_release:
|
||||||
on_release:
|
app.change_password()
|
||||||
settings.unit_dialog(self)
|
self.status = 'ON' if app.wallet.use_encryption else 'OFF'
|
||||||
CardSeparator
|
SettingsItem:
|
||||||
SettingsItem:
|
bu: app.base_unit
|
||||||
title: _('Fiat Currency') + ': ' + app.fiat_unit
|
title: _('Denomination') + ': ' + self.bu
|
||||||
description: "Select the local fiat currency."
|
description: _("Base unit for Bitcoin amounts.")
|
||||||
on_release:
|
on_release:
|
||||||
settings.fiat_dialog(self)
|
settings.unit_dialog(self)
|
||||||
CardSeparator
|
SettingsItem:
|
||||||
SettingsItem:
|
status: 'ON' if bool(app.plugins.get('exchange_rate')) else 'OFF'
|
||||||
status: 'ON' if bool(app.plugins.get('labels')) else 'OFF'
|
title: _('Fiat Exchange rates') + ': ' + self.status
|
||||||
title: _('Labels Sync') + ': ' + self.status
|
description: _("Display amounts in fiat currency.")
|
||||||
description: "Synchronize labels."
|
on_release:
|
||||||
on_release:
|
settings.plugin_dialog('exchange_rate', self)
|
||||||
settings.labelsync_dialog(self)
|
SettingsItem:
|
||||||
CardSeparator
|
status: app.fiat_unit
|
||||||
SettingsItem:
|
title: _('Fiat Currency') + ': ' + self.status
|
||||||
title: _('OpenAlias')
|
description: _("Select the local fiat currency.")
|
||||||
description: "DNS record that stores one of your Bitcoin addresses."
|
on_release:
|
||||||
on_release:
|
settings.fiat_currency_dialog(self)
|
||||||
settings.openalias_dialog()
|
SettingsItem:
|
||||||
Widget:
|
status: root.fiat_source()
|
||||||
size_hint: 1, 1
|
title: _('Fiat source') + ': ' + self.status
|
||||||
|
description: _("Source for fiat currency exchange rate.")
|
||||||
|
on_release:
|
||||||
|
settings.fiat_source_dialog(self)
|
||||||
|
SettingsItem:
|
||||||
|
status: 'ON' if bool(app.plugins.get('labels')) else 'OFF'
|
||||||
|
title: _('Labels Sync') + ': ' + self.status
|
||||||
|
description: "Synchronize labels."
|
||||||
|
on_release:
|
||||||
|
settings.plugin_dialog('labels', self)
|
||||||
|
SettingsItem:
|
||||||
|
title: _('OpenAlias')
|
||||||
|
description: "DNS record that stores one of your Bitcoin addresses."
|
||||||
|
on_release:
|
||||||
|
settings.openalias_dialog()
|
||||||
BoxLayout:
|
BoxLayout:
|
||||||
|
size_hint: 1, 0.1
|
||||||
Widget:
|
Widget:
|
||||||
size_hint: 0.5, None
|
size_hint: 0.5, None
|
||||||
Button:
|
Button:
|
||||||
@@ -117,6 +110,8 @@ class SettingsDialog(Factory.Popup):
|
|||||||
self.plugins = self.app.plugins
|
self.plugins = self.app.plugins
|
||||||
self.config = self.app.electrum_config
|
self.config = self.app.electrum_config
|
||||||
Factory.Popup.__init__(self)
|
Factory.Popup.__init__(self)
|
||||||
|
layout = self.ids.scrollviewlayout
|
||||||
|
layout.bind(minimum_height=layout.setter('height'))
|
||||||
|
|
||||||
def get_language_name(self):
|
def get_language_name(self):
|
||||||
return languages.get(self.config.get('language', 'en_UK'), '')
|
return languages.get(self.config.get('language', 'en_UK'), '')
|
||||||
@@ -136,20 +131,35 @@ class SettingsDialog(Factory.Popup):
|
|||||||
def cb(text):
|
def cb(text):
|
||||||
self.app._set_bu(text)
|
self.app._set_bu(text)
|
||||||
item.bu = self.app.base_unit
|
item.bu = self.app.base_unit
|
||||||
d = ChoiceDialog(_('Denomination'), dict(map(lambda x: (x,x), base_units)), self.app.base_unit, cb)
|
d = ChoiceDialog(_('Denomination'), base_units, self.app.base_unit, cb)
|
||||||
d.open()
|
d.open()
|
||||||
|
|
||||||
def fiat_dialog(self, item):
|
def fiat_currency_dialog(self, item):
|
||||||
from choice_dialog import ChoiceDialog
|
from choice_dialog import ChoiceDialog
|
||||||
|
p = self.app.plugins.get('exchange_rate')
|
||||||
|
if not p:
|
||||||
|
return
|
||||||
def cb(text):
|
def cb(text):
|
||||||
if text == 'None':
|
self.config.set_key('currency', text, True)
|
||||||
self.plugins.disable('exchange_rate')
|
item.status = text
|
||||||
else:
|
l = sorted(p.exchange.quotes.keys()) if p else []
|
||||||
self.config.set_key('currency', text, True)
|
d = ChoiceDialog(_('Fiat Currency'), l, '', cb)
|
||||||
p = self.app.plugins.enable('exchange_rate')
|
d.open()
|
||||||
p.init_kivy(self.app)
|
|
||||||
|
|
||||||
d = ChoiceDialog(_('Fiat Currency'), { 'None': 'None', 'USD':'USD', 'EUR':'EUR'}, '', cb)
|
def fiat_source(self):
|
||||||
|
p = self.app.plugins.get('exchange_rate')
|
||||||
|
return p.exchange.name() if p else 'None'
|
||||||
|
|
||||||
|
def fiat_source_dialog(self, item):
|
||||||
|
from choice_dialog import ChoiceDialog
|
||||||
|
p = self.plugins.get('exchange_rate')
|
||||||
|
if not p:
|
||||||
|
return
|
||||||
|
def cb(text):
|
||||||
|
p.set_exchange(text)
|
||||||
|
item.status = text
|
||||||
|
l = sorted(p.exchanges.keys())
|
||||||
|
d = ChoiceDialog(_('Exchange rate source'), l, self.fiat_source(), cb)
|
||||||
d.open()
|
d.open()
|
||||||
|
|
||||||
def openalias_dialog(self):
|
def openalias_dialog(self):
|
||||||
@@ -159,22 +169,15 @@ class SettingsDialog(Factory.Popup):
|
|||||||
d = LabelDialog(_('OpenAlias'), '', callback)
|
d = LabelDialog(_('OpenAlias'), '', callback)
|
||||||
d.open()
|
d.open()
|
||||||
|
|
||||||
def labelsync_dialog(self, label):
|
def plugin_dialog(self, name, label):
|
||||||
from checkbox_dialog import CheckBoxDialog
|
from checkbox_dialog import CheckBoxDialog
|
||||||
def callback(status):
|
def callback(status):
|
||||||
self.plugins.enable('labels') if status else self.plugins.disable('labels')
|
print 'z', status
|
||||||
status = bool(self.plugins.get('labels'))
|
self.plugins.enable(name) if status else self.plugins.disable(name)
|
||||||
label.status = 'ON' if status else 'OFF'
|
label.status = 'ON' if status else 'OFF'
|
||||||
status = bool(self.plugins.get('labels'))
|
status = bool(self.plugins.get(name))
|
||||||
descr = _('Save your labels on a remote server, and synchronizes them between various instances of your wallet.')
|
dd = self.plugins.descriptions.get(name)
|
||||||
d = CheckBoxDialog(_('Labels Sync'), descr, status, callback)
|
descr = dd.get('description')
|
||||||
|
fullname = dd.get('fullname')
|
||||||
|
d = CheckBoxDialog(fullname, descr, status, callback)
|
||||||
d.open()
|
d.open()
|
||||||
|
|
||||||
|
|
||||||
class PluginItem():
|
|
||||||
def __init__(self, name):
|
|
||||||
p = self.plugins.get(name)
|
|
||||||
sw.active = (p is not None) and p.is_enabled()
|
|
||||||
sw.bind(active=on_active)
|
|
||||||
plugins_list.add_widget(sw)
|
|
||||||
|
|
||||||
|
|||||||
@@ -2909,7 +2909,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
|
|||||||
enable_settings_widget(p, name, i)
|
enable_settings_widget(p, name, i)
|
||||||
run_hook('init_qt', self.gui_object)
|
run_hook('init_qt', self.gui_object)
|
||||||
|
|
||||||
for i, descr in enumerate(plugins.descriptions):
|
for i, descr in enumerate(plugins.descriptions.values()):
|
||||||
name = descr['__name__']
|
name = descr['__name__']
|
||||||
p = plugins.get(name)
|
p = plugins.get(name)
|
||||||
if descr.get('registers_wallet_type'):
|
if descr.get('registers_wallet_type'):
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ class Plugins(DaemonThread):
|
|||||||
self.hw_wallets = {}
|
self.hw_wallets = {}
|
||||||
self.plugins = {}
|
self.plugins = {}
|
||||||
self.gui_name = gui_name
|
self.gui_name = gui_name
|
||||||
self.descriptions = []
|
self.descriptions = {}
|
||||||
self.device_manager = DeviceMgr()
|
self.device_manager = DeviceMgr()
|
||||||
|
|
||||||
for loader, name, ispkg in pkgutil.iter_modules([self.pkgpath]):
|
for loader, name, ispkg in pkgutil.iter_modules([self.pkgpath]):
|
||||||
@@ -55,7 +55,7 @@ class Plugins(DaemonThread):
|
|||||||
self.register_plugin_wallet(name, gui_good, details)
|
self.register_plugin_wallet(name, gui_good, details)
|
||||||
if not gui_good:
|
if not gui_good:
|
||||||
continue
|
continue
|
||||||
self.descriptions.append(d)
|
self.descriptions[name] = d
|
||||||
if not d.get('requires_wallet_type') and config.get('use_' + name):
|
if not d.get('requires_wallet_type') and config.get('use_' + name):
|
||||||
self.load_plugin(name)
|
self.load_plugin(name)
|
||||||
|
|
||||||
@@ -103,10 +103,8 @@ class Plugins(DaemonThread):
|
|||||||
return self.disable(name) if p else self.enable(name)
|
return self.disable(name) if p else self.enable(name)
|
||||||
|
|
||||||
def is_available(self, name, w):
|
def is_available(self, name, w):
|
||||||
for d in self.descriptions:
|
d = self.descriptions.get(name)
|
||||||
if d.get('__name__') == name:
|
if not d:
|
||||||
break
|
|
||||||
else:
|
|
||||||
return False
|
return False
|
||||||
deps = d.get('requires', [])
|
deps = d.get('requires', [])
|
||||||
for dep, s in deps:
|
for dep, s in deps:
|
||||||
|
|||||||
Reference in New Issue
Block a user