guis: reintroduce suggest button
This commit is contained in:
@@ -71,6 +71,11 @@ Builder.load_string('''
|
|||||||
size_hint: 0.5, None
|
size_hint: 0.5, None
|
||||||
height: '48dp'
|
height: '48dp'
|
||||||
on_release: app.scan_qr(on_complete=s.on_qr)
|
on_release: app.scan_qr(on_complete=s.on_qr)
|
||||||
|
Button:
|
||||||
|
text: _('Suggest')
|
||||||
|
size_hint: 1, None
|
||||||
|
height: '48dp'
|
||||||
|
on_release: s.suggest_node()
|
||||||
Button:
|
Button:
|
||||||
text: _('Clear')
|
text: _('Clear')
|
||||||
size_hint: 1, None
|
size_hint: 1, None
|
||||||
@@ -97,6 +102,18 @@ class LightningOpenChannelDialog(Factory.Popup, Logger):
|
|||||||
d = LabelDialog(_('IP/port in format:\n[host]:[port]'), self.ipport, callback)
|
d = LabelDialog(_('IP/port in format:\n[host]:[port]'), self.ipport, callback)
|
||||||
d.open()
|
d.open()
|
||||||
|
|
||||||
|
def suggest_node(self):
|
||||||
|
self.app.wallet.network.start_gossip()
|
||||||
|
suggested = self.app.wallet.lnworker.lnrater.suggest_peer()
|
||||||
|
_, _, percent = self.app.wallet.network.lngossip.get_sync_progress_estimate()
|
||||||
|
|
||||||
|
if suggested:
|
||||||
|
self.pubkey = suggested.hex()
|
||||||
|
else:
|
||||||
|
if percent is None:
|
||||||
|
percent = "??"
|
||||||
|
self.pubkey = f"Please wait, graph is updating ({percent}% / 30% done)."
|
||||||
|
|
||||||
def __init__(self, app, lnaddr=None, msg=None):
|
def __init__(self, app, lnaddr=None, msg=None):
|
||||||
Factory.Popup.__init__(self)
|
Factory.Popup.__init__(self)
|
||||||
Logger.__init__(self)
|
Logger.__init__(self)
|
||||||
|
|||||||
@@ -356,8 +356,20 @@ class ChannelsList(MyTreeView):
|
|||||||
max_button = EnterButton(_("Max"), spend_max)
|
max_button = EnterButton(_("Max"), spend_max)
|
||||||
max_button.setFixedWidth(100)
|
max_button.setFixedWidth(100)
|
||||||
max_button.setCheckable(True)
|
max_button.setCheckable(True)
|
||||||
|
|
||||||
|
suggest_button = QPushButton(d, text=_('Suggest Peer'))
|
||||||
|
def on_suggest():
|
||||||
|
self.parent.wallet.network.start_gossip()
|
||||||
|
nodeid = bh2u(lnworker.lnrater.suggest_peer() or b'')
|
||||||
|
if not nodeid:
|
||||||
|
remote_nodeid.setText(
|
||||||
|
"Please wait until the graph is synchronized to 30%.")
|
||||||
|
else:
|
||||||
|
remote_nodeid.setText(nodeid)
|
||||||
|
remote_nodeid.repaint() # macOS hack for #6269
|
||||||
|
suggest_button.clicked.connect(on_suggest)
|
||||||
|
|
||||||
clear_button = QPushButton(d, text=_('Clear'))
|
clear_button = QPushButton(d, text=_('Clear'))
|
||||||
clear_button.setFixedWidth(100)
|
|
||||||
def on_clear():
|
def on_clear():
|
||||||
amount_e.setText('')
|
amount_e.setText('')
|
||||||
amount_e.setFrozen(False)
|
amount_e.setFrozen(False)
|
||||||
@@ -367,16 +379,16 @@ class ChannelsList(MyTreeView):
|
|||||||
max_button.setChecked(False)
|
max_button.setChecked(False)
|
||||||
max_button.repaint() # macOS hack for #6269
|
max_button.repaint() # macOS hack for #6269
|
||||||
clear_button.clicked.connect(on_clear)
|
clear_button.clicked.connect(on_clear)
|
||||||
|
|
||||||
h = QGridLayout()
|
h = QGridLayout()
|
||||||
h.addWidget(QLabel(_('Your Node ID')), 0, 0)
|
h.addWidget(QLabel(_('Your Node ID')), 0, 0)
|
||||||
h.addWidget(local_nodeid, 0, 1, 1, 4)
|
h.addWidget(local_nodeid, 0, 1, 1, 3)
|
||||||
h.addWidget(QLabel(_('Remote Node ID')), 1, 0)
|
h.addWidget(QLabel(_('Remote Node ID')), 1, 0)
|
||||||
h.addWidget(remote_nodeid, 1, 1, 1, 4)
|
h.addWidget(remote_nodeid, 1, 1, 1, 3)
|
||||||
|
h.addWidget(suggest_button, 2, 1)
|
||||||
|
h.addWidget(clear_button, 2, 2)
|
||||||
h.addWidget(QLabel('Amount'), 3, 0)
|
h.addWidget(QLabel('Amount'), 3, 0)
|
||||||
h.addWidget(amount_e, 3, 1)
|
h.addWidget(amount_e, 3, 1)
|
||||||
h.addWidget(max_button, 3, 2)
|
h.addWidget(max_button, 3, 2)
|
||||||
h.addWidget(clear_button, 3, 3)
|
|
||||||
vbox.addLayout(h)
|
vbox.addLayout(h)
|
||||||
ok_button = OkButton(d)
|
ok_button = OkButton(d)
|
||||||
ok_button.setDefault(True)
|
ok_button.setDefault(True)
|
||||||
|
|||||||
Reference in New Issue
Block a user