mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-09-08 11:39:53 +00:00
add more features to settings dialog
This commit is contained in:
parent
30ace570d3
commit
b3ef2249b5
6 changed files with 128 additions and 62 deletions
|
@ -355,7 +355,6 @@
|
||||||
<ActionOvrButton@ActionButton>
|
<ActionOvrButton@ActionButton>
|
||||||
on_release:
|
on_release:
|
||||||
if self.parent: self.parent.parent.dismiss()
|
if self.parent: self.parent.parent.dismiss()
|
||||||
app.popup_dialog(self.name)
|
|
||||||
|
|
||||||
|
|
||||||
<SettingsItem@ButtonBehavior+BoxLayout>
|
<SettingsItem@ButtonBehavior+BoxLayout>
|
||||||
|
@ -417,21 +416,25 @@ BoxLayout:
|
||||||
ActionOverflow:
|
ActionOverflow:
|
||||||
id: ao
|
id: ao
|
||||||
ActionOvrButton:
|
ActionOvrButton:
|
||||||
text: _('Network')
|
|
||||||
name: 'network'
|
name: 'network'
|
||||||
|
text: _('Network')
|
||||||
on_parent:
|
on_parent:
|
||||||
# when widget overflow drop down is shown, adjust the width
|
# when widget overflow drop down is shown, adjust the width
|
||||||
parent = args[1]
|
parent = args[1]
|
||||||
if parent: ao._dropdown.width = sp(200)
|
if parent: ao._dropdown.width = sp(200)
|
||||||
|
on_release: app.popup_dialog(self.name)
|
||||||
ActionOvrButton:
|
ActionOvrButton:
|
||||||
name: 'settings'
|
name: 'settings'
|
||||||
text: _('Settings')
|
text: _('Settings')
|
||||||
|
on_release: app.settings_dialog()
|
||||||
ActionOvrButton:
|
ActionOvrButton:
|
||||||
name: 'wallets'
|
name: 'wallets'
|
||||||
text: _('Wallets')
|
text: _('Wallets')
|
||||||
|
on_release: app.popup_dialog(self.name)
|
||||||
ActionOvrButton:
|
ActionOvrButton:
|
||||||
name: 'plugins'
|
name: 'plugins'
|
||||||
text: _('Plugins')
|
text: _('Plugins')
|
||||||
|
on_release: app.popup_dialog(self.name)
|
||||||
|
|
||||||
ScreenManager:
|
ScreenManager:
|
||||||
id: manager
|
id: manager
|
||||||
|
|
|
@ -57,8 +57,8 @@ from kivy.core.clipboard import Clipboard
|
||||||
Factory.register('TabbedCarousel', module='electrum_gui.kivy.uix.screens')
|
Factory.register('TabbedCarousel', module='electrum_gui.kivy.uix.screens')
|
||||||
|
|
||||||
|
|
||||||
|
from electrum.util import base_units
|
||||||
|
|
||||||
base_units = {'BTC':8, 'mBTC':5, 'uBTC':2}
|
|
||||||
|
|
||||||
class ElectrumWindow(App):
|
class ElectrumWindow(App):
|
||||||
|
|
||||||
|
@ -75,11 +75,6 @@ class ElectrumWindow(App):
|
||||||
self.history_screen.update()
|
self.history_screen.update()
|
||||||
|
|
||||||
base_unit = AliasProperty(_get_bu, _set_bu)
|
base_unit = AliasProperty(_get_bu, _set_bu)
|
||||||
|
|
||||||
def _rotate_bu(self):
|
|
||||||
keys = sorted(base_units.keys())
|
|
||||||
self.base_unit = keys[ (keys.index(self.base_unit) + 1) % len(keys)]
|
|
||||||
|
|
||||||
status = StringProperty('')
|
status = StringProperty('')
|
||||||
fiat_unit = StringProperty('')
|
fiat_unit = StringProperty('')
|
||||||
|
|
||||||
|
@ -341,12 +336,9 @@ class ElectrumWindow(App):
|
||||||
d = LabelDialog(_('Enter wallet name'), '', self.load_wallet_by_name)
|
d = LabelDialog(_('Enter wallet name'), '', self.load_wallet_by_name)
|
||||||
d.open()
|
d.open()
|
||||||
|
|
||||||
def unit_dialog(self, item):
|
def settings_dialog(self):
|
||||||
from uix.dialogs.choice_dialog import ChoiceDialog
|
from uix.dialogs.settings import SettingsDialog
|
||||||
def cb(text):
|
d = SettingsDialog(self)
|
||||||
self._set_bu(text)
|
|
||||||
item.bu = self.base_unit
|
|
||||||
d = ChoiceDialog(_('Denomination'), sorted(base_units.keys()), self.base_unit, cb)
|
|
||||||
d.open()
|
d.open()
|
||||||
|
|
||||||
def on_stop(self):
|
def on_stop(self):
|
||||||
|
|
|
@ -4,6 +4,7 @@ from kivy.properties import ObjectProperty
|
||||||
from kivy.lang import Builder
|
from kivy.lang import Builder
|
||||||
from kivy.uix.checkbox import CheckBox
|
from kivy.uix.checkbox import CheckBox
|
||||||
from kivy.uix.label import Label
|
from kivy.uix.label import Label
|
||||||
|
from kivy.uix.widget import Widget
|
||||||
|
|
||||||
Builder.load_string('''
|
Builder.load_string('''
|
||||||
<ChoiceDialog@Popup>
|
<ChoiceDialog@Popup>
|
||||||
|
@ -14,17 +15,19 @@ Builder.load_string('''
|
||||||
BoxLayout:
|
BoxLayout:
|
||||||
orientation: 'vertical'
|
orientation: 'vertical'
|
||||||
Widget:
|
Widget:
|
||||||
size_hint: 1, 0.2
|
size_hint: 1, 0.1
|
||||||
GridLayout:
|
ScrollView:
|
||||||
orientation: 'vertical'
|
orientation: 'vertical'
|
||||||
id: choices
|
|
||||||
cols: 2
|
|
||||||
size_hint: 1, 0.8
|
|
||||||
Widget:
|
|
||||||
size_hint: 1, 0.8
|
size_hint: 1, 0.8
|
||||||
|
GridLayout:
|
||||||
|
row_default_height: '48dp'
|
||||||
|
orientation: 'vertical'
|
||||||
|
id: choices
|
||||||
|
cols: 2
|
||||||
|
size_hint: 1, 1
|
||||||
BoxLayout:
|
BoxLayout:
|
||||||
orientation: 'horizontal'
|
orientation: 'horizontal'
|
||||||
size_hint: 1, 0.5
|
size_hint: 1, 0.2
|
||||||
Button:
|
Button:
|
||||||
text: 'Cancel'
|
text: 'Cancel'
|
||||||
size_hint: 0.5, None
|
size_hint: 0.5, None
|
||||||
|
@ -41,22 +44,22 @@ Builder.load_string('''
|
||||||
|
|
||||||
class ChoiceDialog(Factory.Popup):
|
class ChoiceDialog(Factory.Popup):
|
||||||
|
|
||||||
def __init__(self, title, choices, value, callback):
|
def __init__(self, title, choices, key, callback):
|
||||||
Factory.Popup.__init__(self)
|
Factory.Popup.__init__(self)
|
||||||
for k in choices:
|
for k, v in choices.items():
|
||||||
l = Label(text=k)
|
l = Label(text=v)
|
||||||
l.height = '48dp'
|
l.height = '48dp'
|
||||||
l.size_hint_y = 1
|
|
||||||
cb = CheckBox(group='choices')
|
cb = CheckBox(group='choices')
|
||||||
cb.value = k
|
cb.value = k
|
||||||
cb.size_hint_y = 1
|
cb.height = '48dp'
|
||||||
def f(cb, x):
|
def f(cb, x):
|
||||||
if x: self.value = cb.value
|
if x: self.value = cb.value
|
||||||
cb.bind(active=f)
|
cb.bind(active=f)
|
||||||
if k == value:
|
if k == key:
|
||||||
cb.active = True
|
cb.active = True
|
||||||
self.ids.choices.add_widget(l)
|
self.ids.choices.add_widget(l)
|
||||||
self.ids.choices.add_widget(cb)
|
self.ids.choices.add_widget(cb)
|
||||||
|
self.ids.choices.add_widget(Widget(size_hint_y=1))
|
||||||
self.callback = callback
|
self.callback = callback
|
||||||
self.title = title
|
self.title = title
|
||||||
self.value = value
|
self.value = key
|
||||||
|
|
100
gui/kivy/uix/dialogs/settings.py
Normal file
100
gui/kivy/uix/dialogs/settings.py
Normal file
|
@ -0,0 +1,100 @@
|
||||||
|
from kivy.app import App
|
||||||
|
from kivy.factory import Factory
|
||||||
|
from kivy.properties import ObjectProperty
|
||||||
|
from kivy.lang import Builder
|
||||||
|
|
||||||
|
from electrum.i18n import _
|
||||||
|
from electrum.util import base_units
|
||||||
|
from electrum.i18n import languages, set_language
|
||||||
|
|
||||||
|
Builder.load_string('''
|
||||||
|
<SettingsDialog@Popup>
|
||||||
|
id: settings
|
||||||
|
title: _('Settings')
|
||||||
|
BoxLayout:
|
||||||
|
orientation: 'vertical'
|
||||||
|
SettingsItem:
|
||||||
|
lang: settings.get_language_name()
|
||||||
|
title: _('Language') + ' (%s)'%self.lang
|
||||||
|
description: _("Language")
|
||||||
|
on_release:
|
||||||
|
settings.language_dialog(self)
|
||||||
|
CardSeparator
|
||||||
|
SettingsItem:
|
||||||
|
title: _('PIN Code') + ' (%s)'%('ON' if app.wallet.use_encryption else 'OFF')
|
||||||
|
description: _("Your PIN code will be required in order to spend bitcoins.")
|
||||||
|
on_release:
|
||||||
|
app.change_password()
|
||||||
|
self.title = _('PIN Code') + ' (%s)'%('ON' if app.wallet.use_encryption else 'OFF')
|
||||||
|
CardSeparator
|
||||||
|
SettingsItem:
|
||||||
|
bu: app.base_unit
|
||||||
|
title: _('Denomination') + ' (' + self.bu + ')'
|
||||||
|
description: _("Base unit for Bitcoin amounts.")
|
||||||
|
on_release:
|
||||||
|
settings.unit_dialog(self)
|
||||||
|
CardSeparator
|
||||||
|
SettingsItem:
|
||||||
|
title: _('Fiat Currency')
|
||||||
|
description: "Select the local fiat currency."
|
||||||
|
on_release:
|
||||||
|
settings.fiat_dialog(self)
|
||||||
|
CardSeparator
|
||||||
|
SettingsItem:
|
||||||
|
title: _('OpenAlias')
|
||||||
|
description: "Email-like address."
|
||||||
|
on_release:
|
||||||
|
settings.openalias_dialog()
|
||||||
|
Widget:
|
||||||
|
size_hint: 1, 1
|
||||||
|
BoxLayout:
|
||||||
|
Widget:
|
||||||
|
size_hint: 0.5, None
|
||||||
|
Button:
|
||||||
|
size_hint: 0.5, None
|
||||||
|
height: '48dp'
|
||||||
|
text: _('OK')
|
||||||
|
on_release:
|
||||||
|
settings.dismiss()
|
||||||
|
''')
|
||||||
|
|
||||||
|
class SettingsDialog(Factory.Popup):
|
||||||
|
|
||||||
|
def __init__(self, app):
|
||||||
|
self.app = app
|
||||||
|
Factory.Popup.__init__(self)
|
||||||
|
|
||||||
|
def get_language_name(self):
|
||||||
|
return languages.get(self.app.electrum_config.get('language', 'en_UK'), '')
|
||||||
|
|
||||||
|
def language_dialog(self, item):
|
||||||
|
from choice_dialog import ChoiceDialog
|
||||||
|
l = self.app.electrum_config.get('language', 'en_UK')
|
||||||
|
def cb(key):
|
||||||
|
set_language(key)
|
||||||
|
self.app.electrum_config.set_key("language", key, True)
|
||||||
|
item.lang = self.get_language_name()
|
||||||
|
d = ChoiceDialog(_('Language'), languages, l, cb)
|
||||||
|
d.open()
|
||||||
|
|
||||||
|
def unit_dialog(self, item):
|
||||||
|
from choice_dialog import ChoiceDialog
|
||||||
|
def cb(text):
|
||||||
|
self.app._set_bu(text)
|
||||||
|
item.bu = self.app.base_unit
|
||||||
|
d = ChoiceDialog(_('Denomination'), dict(map(lambda x: (x,x), base_units)), self.app.base_unit, cb)
|
||||||
|
d.open()
|
||||||
|
|
||||||
|
def fiat_dialog(self, item):
|
||||||
|
from choice_dialog import ChoiceDialog
|
||||||
|
def cb(text):
|
||||||
|
pass
|
||||||
|
d = ChoiceDialog(_('Fiat Currency'), {}, '', cb)
|
||||||
|
d.open()
|
||||||
|
|
||||||
|
def openalias_dialog(self):
|
||||||
|
from label_dialog import LabelDialog
|
||||||
|
def callback(text):
|
||||||
|
pass
|
||||||
|
d = LabelDialog(_('OpenAlias'), '', callback)
|
||||||
|
d.open()
|
|
@ -1,34 +0,0 @@
|
||||||
Popup:
|
|
||||||
id: settings
|
|
||||||
title: _('Settings')
|
|
||||||
BoxLayout:
|
|
||||||
orientation: 'vertical'
|
|
||||||
SettingsItem:
|
|
||||||
title: _('PIN Code') + ' (%s)'%('ON' if app.wallet.use_encryption else 'OFF')
|
|
||||||
description: _("Your PIN code will be required in order to spend bitcoins.")
|
|
||||||
on_release:
|
|
||||||
app.change_password()
|
|
||||||
self.title = _('PIN Code') + ' (%s)'%('ON' if app.wallet.use_encryption else 'OFF')
|
|
||||||
CardSeparator
|
|
||||||
SettingsItem:
|
|
||||||
bu: app.base_unit
|
|
||||||
title: _('Denomination') + ' (' + self.bu + ')'
|
|
||||||
description: _("Base unit for Bitcoin amounts.")
|
|
||||||
on_release:
|
|
||||||
app.unit_dialog(self)
|
|
||||||
CardSeparator
|
|
||||||
SettingsItem:
|
|
||||||
title: _('OpenAlias')
|
|
||||||
description: "Email-like address."
|
|
||||||
Widget:
|
|
||||||
size_hint: 1, 1
|
|
||||||
BoxLayout:
|
|
||||||
Widget:
|
|
||||||
size_hint: 0.5, None
|
|
||||||
Button:
|
|
||||||
size_hint: 0.5, None
|
|
||||||
height: '48dp'
|
|
||||||
text: _('OK')
|
|
||||||
on_release:
|
|
||||||
settings.dismiss()
|
|
||||||
|
|
|
@ -10,6 +10,8 @@ import urllib
|
||||||
import threading
|
import threading
|
||||||
from i18n import _
|
from i18n import _
|
||||||
|
|
||||||
|
base_units = {'BTC':8, 'mBTC':5, 'uBTC':2}
|
||||||
|
|
||||||
def normalize_version(v):
|
def normalize_version(v):
|
||||||
return [int(x) for x in re.sub(r'(\.0+)*$','', v).split(".")]
|
return [int(x) for x in re.sub(r'(\.0+)*$','', v).split(".")]
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue