Browse Source

Qt: add JMInputDialog with open/async support

add_frost_channel_encryption
zebra-lucky 2 months ago
parent
commit
3bc8a4acb3
  1. 13
      scripts/joinmarket-qt.py
  2. 33
      scripts/qtsupport.py

13
scripts/joinmarket-qt.py

@ -78,11 +78,12 @@ from jmclient import load_program_config, get_network, update_persist_config,\
ScheduleGenerationErrorNoFunds, Storage
from jmclient.wallet import BaseWallet
from qtsupport import ScheduleWizard, TumbleRestartWizard, config_tips,\
config_types, QtHandler, XStream, Buttons, OkButton, CancelButton,\
JMPasswordDialog, MyTreeWidget, JMQtMessageBox, BLUE_FG,\
donation_more_message, BitcoinAmountEdit, JMIntValidator,\
ReceiveBIP78Dialog, QRCodePopup, JMExportPrivkeysDialog
from qtsupport import (ScheduleWizard, TumbleRestartWizard, config_tips,
config_types, QtHandler, XStream, Buttons, OkButton, CancelButton,
JMPasswordDialog, MyTreeWidget, JMQtMessageBox, BLUE_FG,
donation_more_message, BitcoinAmountEdit, JMIntValidator,
ReceiveBIP78Dialog, QRCodePopup, JMExportPrivkeysDialog,
JMInputDialog)
from twisted.internet import task
@ -2378,7 +2379,7 @@ class JMMainWindow(QMainWindow):
title="Passphrase changed")
async def getTestnetSeed(self):
text, ok = QInputDialog.getText(
text, ok = await JMInputDialog(
self, 'Testnet seed', 'Enter a 32 char hex string as seed:')
text = text.strip()
if not ok or not text:

33
scripts/qtsupport.py

@ -149,6 +149,39 @@ donation_more_message = '\n'.join(
"""
async def JMInputDialog(parent, title, label, echo_mode=QLineEdit.Normal,
text='', finished_cb=None):
title = "JoinmarketQt - " + title
class QtInputDialog(QInputDialog):
def __init__(self, parent):
QInputDialog.__init__(self, parent)
self.result_fut = asyncio.get_event_loop().create_future()
@QtCore.Slot(QMessageBox.StandardButton)
def on_finished(self, button):
self.result_fut.set_result(button)
async def result(self):
await self.result_fut
return self.result_fut.result()
d = QtInputDialog(parent)
d.setWindowTitle(title)
d.setLabelText(label)
d.setTextEchoMode(echo_mode)
d.setTextValue(text)
d.finished.connect(d.on_finished)
d.open()
result = await d.result()
if finished_cb is not None:
finished_cb(result)
if result != QDialog.Accepted:
return '', False
return d.textValue(), True
async def JMQtMessageBox(parent, msg, mbtype='info', title='',
detailed_text=None, informative_text=None,
finished_cb=None):

Loading…
Cancel
Save