mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-30 17:01:34 +00:00
add a hook at the end of the gui constructor
This commit is contained in:
parent
06315dd911
commit
2c1ae1ba18
2 changed files with 25 additions and 9 deletions
|
@ -325,6 +325,9 @@ class ElectrumWindow(QMainWindow):
|
||||||
# set initial message
|
# set initial message
|
||||||
self.console.showMessage(self.wallet.banner)
|
self.console.showMessage(self.wallet.banner)
|
||||||
|
|
||||||
|
# plugins that need to change the GUI do it here
|
||||||
|
self.run_hook('init')
|
||||||
|
|
||||||
|
|
||||||
# plugins
|
# plugins
|
||||||
def init_plugins(self):
|
def init_plugins(self):
|
||||||
|
|
|
@ -103,6 +103,7 @@ def init(gui):
|
||||||
gui.requested_amounts = config.get('requested_amounts',{})
|
gui.requested_amounts = config.get('requested_amounts',{})
|
||||||
gui.merchant_name = config.get('merchant_name', 'Invoice')
|
gui.merchant_name = config.get('merchant_name', 'Invoice')
|
||||||
gui.qr_window = None
|
gui.qr_window = None
|
||||||
|
do_enable(gui, is_enabled())
|
||||||
|
|
||||||
def is_enabled():
|
def is_enabled():
|
||||||
return config.get('pointofsale') is True
|
return config.get('pointofsale') is True
|
||||||
|
@ -110,35 +111,47 @@ def is_enabled():
|
||||||
def is_available():
|
def is_available():
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def toggle(gui):
|
|
||||||
|
|
||||||
if not is_enabled():
|
def toggle(gui):
|
||||||
|
enabled = not is_enabled()
|
||||||
|
config.set_key('pointofsale', enabled, True)
|
||||||
|
do_enable(gui, enabled)
|
||||||
|
update_gui(gui)
|
||||||
|
return enabled
|
||||||
|
|
||||||
|
|
||||||
|
def do_enable(gui, enabled):
|
||||||
|
if enabled:
|
||||||
gui.expert_mode = True
|
gui.expert_mode = True
|
||||||
gui.receive_list.setHeaderLabels([ _('Address'), _('Label'), _('Balance'), _('Request')])
|
|
||||||
gui.set_hook('item_changed', item_changed)
|
gui.set_hook('item_changed', item_changed)
|
||||||
gui.set_hook('current_item_changed', recv_changed)
|
gui.set_hook('current_item_changed', recv_changed)
|
||||||
gui.set_hook('receive_menu', receive_menu)
|
gui.set_hook('receive_menu', receive_menu)
|
||||||
gui.set_hook('update_receive_item', update_receive_item)
|
gui.set_hook('update_receive_item', update_receive_item)
|
||||||
gui.set_hook('timer_actions', timer_actions)
|
gui.set_hook('timer_actions', timer_actions)
|
||||||
gui.set_hook('close_main_window', close_main_window)
|
gui.set_hook('close_main_window', close_main_window)
|
||||||
enabled = True
|
gui.set_hook('init', update_gui)
|
||||||
else:
|
else:
|
||||||
gui.receive_list.setHeaderLabels([ _('Address'), _('Label'), _('Balance'), _('Tx')])
|
|
||||||
gui.unset_hook('item_changed', item_changed)
|
gui.unset_hook('item_changed', item_changed)
|
||||||
gui.unset_hook('current_item_changed', recv_changed)
|
gui.unset_hook('current_item_changed', recv_changed)
|
||||||
gui.unset_hook('receive_menu', receive_menu)
|
gui.unset_hook('receive_menu', receive_menu)
|
||||||
gui.unset_hook('update_receive_item', update_receive_item)
|
gui.unset_hook('update_receive_item', update_receive_item)
|
||||||
gui.unset_hook('timer_actions', timer_actions)
|
gui.unset_hook('timer_actions', timer_actions)
|
||||||
gui.unset_hook('close_main_window', close_main_window)
|
gui.unset_hook('close_main_window', close_main_window)
|
||||||
enabled = False
|
gui.unset_hook('init', update_gui)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def update_gui(gui):
|
||||||
|
enabled = is_enabled()
|
||||||
|
if enabled:
|
||||||
|
gui.receive_list.setHeaderLabels([ _('Address'), _('Label'), _('Balance'), _('Request')])
|
||||||
|
else:
|
||||||
|
gui.receive_list.setHeaderLabels([ _('Address'), _('Label'), _('Balance'), _('Tx')])
|
||||||
|
|
||||||
config.set_key('pointofsale', enabled, True)
|
|
||||||
toggle_QR_window(gui, enabled)
|
toggle_QR_window(gui, enabled)
|
||||||
return enabled
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def toggle_QR_window(self, show):
|
def toggle_QR_window(self, show):
|
||||||
if show and not self.qr_window:
|
if show and not self.qr_window:
|
||||||
self.qr_window = QR_Window(self.exchanger)
|
self.qr_window = QR_Window(self.exchanger)
|
||||||
|
|
Loading…
Add table
Reference in a new issue