mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-27 15:31:31 +00:00
plugins: define is_available()
This commit is contained in:
parent
0d143e074a
commit
7bf87bc189
2 changed files with 17 additions and 14 deletions
|
@ -2012,6 +2012,7 @@ class ElectrumWindow(QMainWindow):
|
||||||
try:
|
try:
|
||||||
name, description = p.get_info()
|
name, description = p.get_info()
|
||||||
cb = QCheckBox(name)
|
cb = QCheckBox(name)
|
||||||
|
cb.setDisabled(not p.is_available())
|
||||||
cb.setChecked(p.is_enabled())
|
cb.setChecked(p.is_enabled())
|
||||||
cb.clicked.connect(mk_toggle(cb,p))
|
cb.clicked.connect(mk_toggle(cb,p))
|
||||||
grid_plugins.addWidget(cb, i, 0)
|
grid_plugins.addWidget(cb, i, 0)
|
||||||
|
|
|
@ -92,38 +92,36 @@ class QR_Window(QWidget):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
config = {}
|
||||||
|
|
||||||
def get_info():
|
def get_info():
|
||||||
return 'Point of Sale', _('Show QR code window and amounts requested for each address. Add menu item to request amount.')
|
return 'Point of Sale', _('Show QR code window and amounts requested for each address. Add menu item to request amount.')
|
||||||
|
|
||||||
def init(gui):
|
def init(gui):
|
||||||
gui.requested_amounts = gui.config.get('requested_amounts',{})
|
global config
|
||||||
gui.merchant_name = gui.config.get('merchant_name', 'Invoice')
|
config = gui.config
|
||||||
|
gui.requested_amounts = config.get('requested_amounts',{})
|
||||||
|
gui.merchant_name = config.get('merchant_name', 'Invoice')
|
||||||
gui.qr_window = None
|
gui.qr_window = None
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
enabled = False
|
|
||||||
|
|
||||||
def is_enabled():
|
def is_enabled():
|
||||||
return False
|
return config.get('pointofsale') is True
|
||||||
|
|
||||||
|
def is_available():
|
||||||
|
return True
|
||||||
|
|
||||||
def toggle(gui):
|
def toggle(gui):
|
||||||
global enabled
|
|
||||||
enabled = not enabled
|
|
||||||
toggle_QR_window(gui, enabled)
|
|
||||||
|
|
||||||
if enabled:
|
if not is_enabled():
|
||||||
gui.expert_mode = True
|
gui.expert_mode = True
|
||||||
gui.receive_list.setHeaderLabels([ _('Address'), _('Label'), _('Balance'), _('Request')])
|
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
|
||||||
else:
|
else:
|
||||||
gui.receive_list.setHeaderLabels([ _('Address'), _('Label'), _('Balance'), _('Tx')])
|
gui.receive_list.setHeaderLabels([ _('Address'), _('Label'), _('Balance'), _('Tx')])
|
||||||
gui.unset_hook('item_changed', item_changed)
|
gui.unset_hook('item_changed', item_changed)
|
||||||
|
@ -132,11 +130,15 @@ def toggle(gui):
|
||||||
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
|
||||||
|
|
||||||
|
config.set_key('pointofsale', enabled, True)
|
||||||
|
toggle_QR_window(gui, enabled)
|
||||||
return 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