mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-30 17:01:34 +00:00
kivy:cleanup
This commit is contained in:
parent
65ecbf990d
commit
28ffe32718
6 changed files with 33 additions and 139 deletions
|
@ -95,27 +95,6 @@
|
||||||
size: root.size
|
size: root.size
|
||||||
pos: root.pos
|
pos: root.pos
|
||||||
|
|
||||||
<Butt_star@ActionToggleButton>:
|
|
||||||
important: True
|
|
||||||
size_hint_x: None
|
|
||||||
width: '32dp'
|
|
||||||
mipmap: True
|
|
||||||
state: 'down' if app.expert_mode else 'normal'
|
|
||||||
background_down: self.background_normal
|
|
||||||
foreground_color: (.466, .466, .466, 1)
|
|
||||||
color_active: (0.235, .588, .89, 1)
|
|
||||||
on_release: app.expert_mode = True if self.state == 'down' else False
|
|
||||||
Image:
|
|
||||||
source: 'atlas://gui/kivy/theming/light/star_big_inactive'
|
|
||||||
center: root.center
|
|
||||||
size: root.width/1.5, self.width
|
|
||||||
color:
|
|
||||||
root.foreground_color if root.state == 'normal' else root.color_active
|
|
||||||
canvas.after:
|
|
||||||
Color:
|
|
||||||
rgba: 1, 1, 1, 1
|
|
||||||
source:
|
|
||||||
allow_stretch: True
|
|
||||||
|
|
||||||
<ELTextInput>
|
<ELTextInput>
|
||||||
padding: '10dp', '4dp'
|
padding: '10dp', '4dp'
|
||||||
|
@ -262,20 +241,20 @@
|
||||||
text: _("Select Your address")
|
text: _("Select Your address")
|
||||||
|
|
||||||
|
|
||||||
<ElectrumScreen>
|
#<ElectrumScreen>
|
||||||
ScrollView:
|
# ScrollView:
|
||||||
do_scroll_x: False
|
# do_scroll_x: False
|
||||||
do_scroll_y: False if root.fullscreen else (content.height > root.height - dp(16))
|
# do_scroll_y: False if root.fullscreen else (content.height > root.height - dp(16))
|
||||||
AnchorLayout:
|
# AnchorLayout:
|
||||||
size_hint_y: None
|
# size_hint_y: None
|
||||||
height: root.height if root.fullscreen else max(root.height, content.height)
|
# height: root.height if root.fullscreen else max(root.height, content.height)
|
||||||
GridLayout:
|
# GridLayout:
|
||||||
id: content
|
# id: content
|
||||||
cols: 1
|
# cols: 1
|
||||||
spacing: '8dp'
|
# spacing: '8dp'
|
||||||
padding: '8dp'
|
# padding: '8dp'
|
||||||
size_hint: (1, 1) if root.fullscreen else (.8, None)
|
# size_hint: (1, 1) if root.fullscreen else (.8, None)
|
||||||
height: self.height if root.fullscreen else self.minimum_height
|
# height: self.height if root.fullscreen else self.minimum_height
|
||||||
|
|
||||||
|
|
||||||
<TabbedCarousel>
|
<TabbedCarousel>
|
||||||
|
|
|
@ -41,13 +41,6 @@ Cache.register('electrum_widgets', timeout=0)
|
||||||
from kivy.uix.screenmanager import Screen
|
from kivy.uix.screenmanager import Screen
|
||||||
from kivy.uix.tabbedpanel import TabbedPanel
|
from kivy.uix.tabbedpanel import TabbedPanel
|
||||||
|
|
||||||
class ElectrumScreen(Screen):
|
|
||||||
fullscreen = BooleanProperty(False)
|
|
||||||
#def add_widget(self, *args):
|
|
||||||
# if 'content' in self.ids:
|
|
||||||
# return self.ids.content.add_widget(*args)
|
|
||||||
# return super(ElectrumScreen, self).add_widget(*args)
|
|
||||||
|
|
||||||
|
|
||||||
Factory.register('TabbedCarousel', module='electrum_gui.kivy.uix.screens')
|
Factory.register('TabbedCarousel', module='electrum_gui.kivy.uix.screens')
|
||||||
|
|
||||||
|
@ -79,12 +72,6 @@ class ElectrumWindow(App):
|
||||||
:attr:`currencies` is a `ListProperty` default to ['Eur', 'GBP'. 'USD'].
|
:attr:`currencies` is a `ListProperty` default to ['Eur', 'GBP'. 'USD'].
|
||||||
'''
|
'''
|
||||||
|
|
||||||
expert_mode = BooleanProperty(False)
|
|
||||||
'''This defines whether expert mode options are available in the ui.
|
|
||||||
|
|
||||||
:attr:`expert_mode` is a `BooleanProperty` defaults to `False`.
|
|
||||||
'''
|
|
||||||
|
|
||||||
def _get_decimal(self):
|
def _get_decimal(self):
|
||||||
try:
|
try:
|
||||||
return self.electrum_config.get('decimal_point', 8)
|
return self.electrum_config.get('decimal_point', 8)
|
||||||
|
@ -417,22 +404,10 @@ class ElectrumWindow(App):
|
||||||
Cache.append('electrum_widgets', 'CSpinner', Factory.CSpinner())
|
Cache.append('electrum_widgets', 'CSpinner', Factory.CSpinner())
|
||||||
|
|
||||||
# load and focus the ui
|
# load and focus the ui
|
||||||
#Load mainscreen
|
|
||||||
|
|
||||||
#dr = Builder.load_file('gui/kivy/uix/ui_screens/mainscreen.kv')
|
|
||||||
#self.root.add_widget(dr)
|
|
||||||
#self.root.manager = manager = dr.ids.manager
|
|
||||||
#self.root.main_screen = m = manager.screens[0]
|
|
||||||
#self.tabs = m.ids.tabs
|
|
||||||
|
|
||||||
self.root.manager = self.root.ids['manager']
|
self.root.manager = self.root.ids['manager']
|
||||||
self.recent_activity_card = None
|
self.recent_activity_card = None
|
||||||
self.history_screen = None
|
self.history_screen = None
|
||||||
self.contacts_screen = None
|
self.contacts_screen = None
|
||||||
self.wallet_screen = None
|
|
||||||
|
|
||||||
#TODO
|
|
||||||
# load left_menu
|
|
||||||
|
|
||||||
self.icon = "icons/electrum.png"
|
self.icon = "icons/electrum.png"
|
||||||
|
|
||||||
|
@ -710,18 +685,6 @@ class ElectrumWindow(App):
|
||||||
#Logger.info('orientation: {}'.format(self._orientation))
|
#Logger.info('orientation: {}'.format(self._orientation))
|
||||||
#Logger.info('ui_mode: {}'.format(self._ui_mode))
|
#Logger.info('ui_mode: {}'.format(self._ui_mode))
|
||||||
|
|
||||||
def load_screen(self, name, direction='left', manager=None):
|
|
||||||
screen = self.screens.get(name)
|
|
||||||
if screen is None:
|
|
||||||
screen = Builder.load_file('gui/kivy/uix/ui_screens/' + name + '.kv')
|
|
||||||
screen.name = name
|
|
||||||
self.screens[name] = screen
|
|
||||||
manager = manager or self.root.manager
|
|
||||||
manager.switch_to(screen, direction=direction)
|
|
||||||
|
|
||||||
def load_history(self):
|
|
||||||
#Builder.load_file('gui/kivy/uix/ui_screens/history.kv')
|
|
||||||
print "load history", self.root.manager.ids.history
|
|
||||||
|
|
||||||
def save_new_contact(self, address, label):
|
def save_new_contact(self, address, label):
|
||||||
address = unicode(address)
|
address = unicode(address)
|
||||||
|
@ -730,7 +693,6 @@ class ElectrumWindow(App):
|
||||||
if not is_valid:
|
if not is_valid:
|
||||||
from electrum.bitcoin import is_valid
|
from electrum.bitcoin import is_valid
|
||||||
|
|
||||||
|
|
||||||
if is_valid(address):
|
if is_valid(address):
|
||||||
if label:
|
if label:
|
||||||
self.set_label(address, text=label)
|
self.set_label(address, text=label)
|
||||||
|
|
|
@ -4,8 +4,9 @@
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
from kivy.uix.floatlayout import FloatLayout
|
import qrcode
|
||||||
|
|
||||||
|
from kivy.uix.floatlayout import FloatLayout
|
||||||
from kivy.graphics.texture import Texture
|
from kivy.graphics.texture import Texture
|
||||||
from kivy.properties import StringProperty
|
from kivy.properties import StringProperty
|
||||||
from kivy.properties import ObjectProperty, StringProperty, ListProperty,\
|
from kivy.properties import ObjectProperty, StringProperty, ListProperty,\
|
||||||
|
@ -13,12 +14,6 @@ from kivy.properties import ObjectProperty, StringProperty, ListProperty,\
|
||||||
from kivy.lang import Builder
|
from kivy.lang import Builder
|
||||||
from kivy.clock import Clock
|
from kivy.clock import Clock
|
||||||
|
|
||||||
try:
|
|
||||||
import qrcode
|
|
||||||
except ImportError:
|
|
||||||
import sys
|
|
||||||
sys.exit("Error: qrcode does not seem to be installed. Try 'sudo pip install qrcode'")
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Builder.load_string('''
|
Builder.load_string('''
|
||||||
|
@ -77,11 +72,12 @@ class QRCodeWidget(FloatLayout):
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
super(QRCodeWidget, self).__init__(**kwargs)
|
super(QRCodeWidget, self).__init__(**kwargs)
|
||||||
self.addr = None
|
self.data = None
|
||||||
self.qr = None
|
self.qr = None
|
||||||
self._qrtexture = None
|
self._qrtexture = None
|
||||||
|
|
||||||
def on_data(self, instance, value):
|
def on_data(self, instance, value):
|
||||||
|
print "on data"
|
||||||
if not (self.canvas or value):
|
if not (self.canvas or value):
|
||||||
return
|
return
|
||||||
img = self.ids.get('qrimage', None)
|
img = self.ids.get('qrimage', None)
|
||||||
|
@ -95,31 +91,30 @@ class QRCodeWidget(FloatLayout):
|
||||||
Thread(target=partial(self.generate_qr, value)).start()
|
Thread(target=partial(self.generate_qr, value)).start()
|
||||||
|
|
||||||
def generate_qr(self, value):
|
def generate_qr(self, value):
|
||||||
self.set_addr(value)
|
self.set_data(value)
|
||||||
self.update_qr()
|
self.update_qr()
|
||||||
|
|
||||||
def set_addr(self, addr):
|
def set_data(self, data):
|
||||||
if self.addr == addr:
|
if self.data == data:
|
||||||
return
|
return
|
||||||
MinSize = 210 if len(addr) < 128 else 500
|
MinSize = 210 if len(addr) < 128 else 500
|
||||||
self.setMinimumSize((MinSize, MinSize))
|
self.setMinimumSize((MinSize, MinSize))
|
||||||
self.addr = addr
|
self.data = data
|
||||||
self.qr = None
|
self.qr = None
|
||||||
|
|
||||||
def update_qr(self):
|
def update_qr(self):
|
||||||
if not self.addr and self.qr:
|
if not self.data and self.qr:
|
||||||
return
|
return
|
||||||
QRCode = qrcode.QRCode
|
|
||||||
L = qrcode.constants.ERROR_CORRECT_L
|
L = qrcode.constants.ERROR_CORRECT_L
|
||||||
addr = self.addr
|
data = self.data
|
||||||
try:
|
try:
|
||||||
self.qr = qr = QRCode(
|
self.qr = qr = qrcode.QRCode(
|
||||||
version=None,
|
version=None,
|
||||||
error_correction=L,
|
error_correction=L,
|
||||||
box_size=10,
|
box_size=10,
|
||||||
border=0,
|
border=0,
|
||||||
)
|
)
|
||||||
qr.add_data(addr)
|
qr.add_data(data)
|
||||||
qr.make(fit=True)
|
qr.make(fit=True)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print e
|
print e
|
||||||
|
|
|
@ -50,10 +50,6 @@ class CScreen(Factory.Screen):
|
||||||
self.update()
|
self.update()
|
||||||
setattr(self.app, self.kvname + '_screen', self)
|
setattr(self.app, self.kvname + '_screen', self)
|
||||||
|
|
||||||
#app.history_screen = screen
|
|
||||||
#app.recent_activity_card = screen.ids.recent_activity_card
|
|
||||||
#app.update_history_tab()
|
|
||||||
|
|
||||||
#Clock.schedule_once(lambda dt: self._change_action_view())
|
#Clock.schedule_once(lambda dt: self._change_action_view())
|
||||||
|
|
||||||
def on_leave(self):
|
def on_leave(self):
|
||||||
|
|
|
@ -107,9 +107,9 @@ ReceiveScreen:
|
||||||
AddressSelector:
|
AddressSelector:
|
||||||
id: address_selection
|
id: address_selection
|
||||||
foreground_color: blue_bottom.foreground_color
|
foreground_color: blue_bottom.foreground_color
|
||||||
opacity: 1 if app.expert_mode else 0
|
opacity: 1
|
||||||
size_hint: 1, None
|
size_hint: 1, None
|
||||||
height: blue_bottom.item_height if app.expert_mode else 0
|
height: blue_bottom.item_height
|
||||||
on_text:
|
on_text:
|
||||||
if not args[1].startswith('Select'):\
|
if not args[1].startswith('Select'):\
|
||||||
qr.data = app.encode_uri(args[1],\
|
qr.data = app.encode_uri(args[1],\
|
||||||
|
@ -161,11 +161,3 @@ ReceiveScreen:
|
||||||
.format(app.base_unit, app.status)
|
.format(app.base_unit, app.status)
|
||||||
font_size: '22dp'
|
font_size: '22dp'
|
||||||
minimum_width: '1dp'
|
minimum_width: '1dp'
|
||||||
Butt_star:
|
|
||||||
id: but_star
|
|
||||||
on_release:
|
|
||||||
if self.state == 'down':\
|
|
||||||
app.show_info_bubble(\
|
|
||||||
text='[b]Expert mode on[/b]\n you can now select your address',\
|
|
||||||
icon='atlas://gui/kivy/theming/light/star_big_inactive',\
|
|
||||||
duration=1, arrow_pos='', width='250dp')
|
|
||||||
|
|
|
@ -6,36 +6,6 @@
|
||||||
#:set mbtc_symbol unichr(187)
|
#:set mbtc_symbol unichr(187)
|
||||||
#:set font_light 'data/fonts/Roboto-Condensed.ttf'
|
#:set font_light 'data/fonts/Roboto-Condensed.ttf'
|
||||||
|
|
||||||
<SendActionView@ActionView>
|
|
||||||
foreground_color: (.466, .466, .466, 1)
|
|
||||||
color_active: (0.235, .588, .89, 1)
|
|
||||||
WalletActionPrevious:
|
|
||||||
id: action_previous
|
|
||||||
width: but_star.width
|
|
||||||
ActionButton:
|
|
||||||
id: action_logo
|
|
||||||
important: True
|
|
||||||
size_hint: 1, 1
|
|
||||||
markup: True
|
|
||||||
mipmap: True
|
|
||||||
bold: True
|
|
||||||
markup: True
|
|
||||||
color: 1, 1, 1, 1
|
|
||||||
text:
|
|
||||||
"[color=#777777][sub] [sup][size=9dp]{}[/size][/sup][/sub]{}[/color]"\
|
|
||||||
.format(app.base_unit, app.status)
|
|
||||||
font_size: '22dp'
|
|
||||||
minimum_width: '1dp'
|
|
||||||
Butt_star:
|
|
||||||
id: but_star
|
|
||||||
on_release:
|
|
||||||
if self.state == 'down':\
|
|
||||||
app.show_info_bubble(\
|
|
||||||
text='[b]Expert mode on[/b]\n you can now select your address',\
|
|
||||||
icon='atlas://gui/kivy/theming/light/star_big_inactive',\
|
|
||||||
duration=1, arrow_pos='', width='250dp')
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<TextInputSendBlue@TextInput>
|
<TextInputSendBlue@TextInput>
|
||||||
|
@ -55,7 +25,7 @@ SendScreen:
|
||||||
|
|
||||||
mode: 'address'
|
mode: 'address'
|
||||||
name: 'send'
|
name: 'send'
|
||||||
action_view: Factory.SendActionView()
|
#action_view: Factory.SendActionView()
|
||||||
#on_deactivate:
|
#on_deactivate:
|
||||||
# self.ids.amount_e.focus = False
|
# self.ids.amount_e.focus = False
|
||||||
# self.ids.payto_e.focus = False
|
# self.ids.payto_e.focus = False
|
||||||
|
@ -206,9 +176,9 @@ SendScreen:
|
||||||
color: blue_bottom.foreground_color
|
color: blue_bottom.foreground_color
|
||||||
BoxLayout:
|
BoxLayout:
|
||||||
id: message_selection
|
id: message_selection
|
||||||
opacity: 1 if app.expert_mode else 0
|
opacity: 1
|
||||||
size_hint: 1, None
|
size_hint: 1, None
|
||||||
height: blue_bottom.item_height if app.expert_mode else 0
|
height: blue_bottom.item_height
|
||||||
spacing: '5dp'
|
spacing: '5dp'
|
||||||
Image:
|
Image:
|
||||||
source: 'atlas://gui/kivy/theming/light/pen'
|
source: 'atlas://gui/kivy/theming/light/pen'
|
||||||
|
@ -228,9 +198,9 @@ SendScreen:
|
||||||
AddressSelector:
|
AddressSelector:
|
||||||
id: address_selection
|
id: address_selection
|
||||||
foreground_color: blue_bottom.foreground_color
|
foreground_color: blue_bottom.foreground_color
|
||||||
opacity: 1 if app.expert_mode else 0
|
opacity: 1
|
||||||
size_hint: 1, None
|
size_hint: 1, None
|
||||||
height: blue_bottom.item_height if app.expert_mode else 0
|
height: blue_bottom.item_height
|
||||||
Button:
|
Button:
|
||||||
#background_color: (1, 1, 1, 1) if self.disabled else ((.258, .80, .388, 1) if self.state == 'normal' else (.203, .490, .741, 1))
|
#background_color: (1, 1, 1, 1) if self.disabled else ((.258, .80, .388, 1) if self.state == 'normal' else (.203, .490, .741, 1))
|
||||||
text: _('Send')
|
text: _('Send')
|
||||||
|
|
Loading…
Add table
Reference in a new issue