Color-Code Addresses in Kivy UI (#5774)
* Added static coloring of the TX output dialog. Coloring was suggested in #5750
This commit is contained in:
@@ -67,6 +67,17 @@
|
||||
size_hint_x: None
|
||||
size: '30dp', '30dp'
|
||||
|
||||
|
||||
<BackgroundColor@Widget>
|
||||
background_color: 0, 0, 0, 1
|
||||
canvas.before:
|
||||
Color:
|
||||
rgba: root.background_color
|
||||
Rectangle:
|
||||
size: self.size
|
||||
pos: self.pos
|
||||
<BackgroundTopLabel@TopLabel+BackgroundColor>
|
||||
background_color: 0, 0, 0, 1
|
||||
|
||||
|
||||
#########################
|
||||
@@ -88,11 +99,15 @@
|
||||
<OutputItem>
|
||||
address: ''
|
||||
value: ''
|
||||
background_color: 0, 0, 0, 1
|
||||
color: 1, 1, 1, 1
|
||||
size_hint_y: None
|
||||
height: max(lbl1.height, lbl2.height)
|
||||
TopLabel
|
||||
BackgroundTopLabel
|
||||
id: lbl1
|
||||
text: '[ref=%s]%s[/ref]'%(root.address, root.address)
|
||||
color: root.color
|
||||
background_color: root.background_color
|
||||
font_size: '6pt'
|
||||
shorten: True
|
||||
size_hint_x: 0.65
|
||||
|
||||
@@ -10,6 +10,7 @@ from kivy.clock import Clock
|
||||
from kivy.uix.label import Label
|
||||
from kivy.uix.dropdown import DropDown
|
||||
from kivy.uix.button import Button
|
||||
from kivy.utils import get_color_from_hex
|
||||
|
||||
from .question import Question
|
||||
from electrum.gui.kivy.i18n import _
|
||||
@@ -181,6 +182,31 @@ class TxDialog(Factory.Popup):
|
||||
self.fee_str = _('unknown')
|
||||
self.feerate_str = _('unknown')
|
||||
self.ids.output_list.update(self.tx.outputs())
|
||||
|
||||
def text_format(addr):
|
||||
"""
|
||||
Chooses the appropriate text color and background color to
|
||||
mark receiving, change and billing addresses.
|
||||
|
||||
Returns: color, background_color
|
||||
"""
|
||||
|
||||
# modified colors (textcolor, background_color) from electrum/gui/qt/util.py
|
||||
GREEN = ("#000000", "#8af296")
|
||||
YELLOW = ("#000000", "#ffff00")
|
||||
BLUE = ("#000000", "#8cb3f2")
|
||||
DEFAULT = ('#ffffff', '#4c4c4c')
|
||||
|
||||
colors = DEFAULT
|
||||
if self.wallet.is_mine(addr):
|
||||
colors = YELLOW if self.wallet.is_change(addr) else GREEN
|
||||
elif self.wallet.is_billing_address(addr):
|
||||
colors = BLUE
|
||||
return (get_color_from_hex(color) for color in colors)
|
||||
|
||||
for dict_entry in self.ids.output_list.data:
|
||||
dict_entry['color'], dict_entry['background_color'] = text_format(dict_entry['address'])
|
||||
|
||||
self.is_local_tx = tx_mined_status.height == TX_HEIGHT_LOCAL
|
||||
self.update_action_button()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user