Browse Source

Qt: fix dialogs/wizards parent/modality

add_frost_channel_encryption
zebra-lucky 2 months ago
parent
commit
d6953f2ca4
  1. 15
      scripts/joinmarket-qt.py
  2. 22
      scripts/qtsupport.py

15
scripts/joinmarket-qt.py

@ -132,14 +132,15 @@ class JMOpenWalletDialog(QDialog, Ui_OpenWalletDialog):
DEFAULT_WALLET_FILE_TEXT = "wallet.jmdat" DEFAULT_WALLET_FILE_TEXT = "wallet.jmdat"
def __init__(self, *args, **kwargs): def __init__(self, parent, *args, **kwargs):
super().__init__(*args, **kwargs) super().__init__(parent, *args, **kwargs)
self.result_fut = asyncio.get_event_loop().create_future() self.result_fut = asyncio.get_event_loop().create_future()
self.setupUi(self) self.setupUi(self)
self.errorMessageLabel.setWordWrap(True); self.errorMessageLabel.setWordWrap(True);
self.passphraseEdit.setFocus() self.passphraseEdit.setFocus()
self.chooseWalletButton.clicked.connect(lambda: self.chooseWalletButton.clicked.connect(lambda:
asyncio.ensure_future(self.chooseWalletFile())) asyncio.ensure_future(self.chooseWalletFile()))
self.setModal(True)
async def chooseWalletFile(self, error_text: str = ""): async def chooseWalletFile(self, error_text: str = ""):
d = JMFileDialog(self) d = JMFileDialog(self)
@ -473,7 +474,7 @@ class SpendTab(QWidget):
return return
#needs a set of tumbler options and destination addresses, so needs #needs a set of tumbler options and destination addresses, so needs
#a wizard #a wizard
wizard = ScheduleWizard() wizard = ScheduleWizard(mainWindow)
wizard.open() wizard.open()
wizard_return = await wizard.result() wizard_return = await wizard.result()
if wizard_return == QDialog.Rejected: if wizard_return == QDialog.Rejected:
@ -785,7 +786,7 @@ class SpendTab(QWidget):
#which needs new dynamic option values. The rationale for using input #which needs new dynamic option values. The rationale for using input
#is in case the user can increase success probability by changing them. #is in case the user can increase success probability by changing them.
if self.tumbler_options == True: if self.tumbler_options == True:
wizard = TumbleRestartWizard() wizard = TumbleRestartWizard(mainWindow)
wizard.open() wizard.open()
wizard_return = await wizard.result() wizard_return = await wizard.result()
if wizard_return == QDialog.Rejected: if wizard_return == QDialog.Rejected:
@ -1872,7 +1873,7 @@ class JMMainWindow(QMainWindow):
title="Error")) title="Error"))
return return
self.receiver_bip78_dialog = ReceiveBIP78Dialog( self.receiver_bip78_dialog = ReceiveBIP78Dialog(
self.startReceiver, self.stopReceiver) self, self.startReceiver, self.stopReceiver)
async def startReceiver(self): async def startReceiver(self):
""" Initializes BIP78 Receiving object and """ Initializes BIP78 Receiving object and
@ -2059,7 +2060,7 @@ class JMMainWindow(QMainWindow):
async def seedEntry(self) -> Tuple[Optional[str], Optional[str]]: async def seedEntry(self) -> Tuple[Optional[str], Optional[str]]:
d = QDialog(self) d = QDialog(self)
d.setModal(1) d.setModal(True)
d.setWindowTitle('Recover from mnemonic phrase') d.setWindowTitle('Recover from mnemonic phrase')
layout = QGridLayout(d) layout = QGridLayout(d)
message_e = QTextEdit() message_e = QTextEdit()
@ -2161,7 +2162,7 @@ class JMMainWindow(QMainWindow):
filename_text = JMOpenWalletDialog.DEFAULT_WALLET_FILE_TEXT filename_text = JMOpenWalletDialog.DEFAULT_WALLET_FILE_TEXT
while not wallet_loaded: while not wallet_loaded:
openWalletDialog = JMOpenWalletDialog() openWalletDialog = JMOpenWalletDialog(self)
openWalletDialog.finished.connect(openWalletDialog.on_finished) openWalletDialog.finished.connect(openWalletDialog.on_finished)
# Set default wallet file name and verify its lock status # Set default wallet file name and verify its lock status
openWalletDialog.walletFileEdit.setText(filename_text) openWalletDialog.walletFileEdit.setText(filename_text)

22
scripts/qtsupport.py

@ -158,6 +158,7 @@ async def JMInputDialog(parent, title, label, echo_mode=QLineEdit.Normal,
def __init__(self, parent): def __init__(self, parent):
QInputDialog.__init__(self, parent) QInputDialog.__init__(self, parent)
self.result_fut = asyncio.get_event_loop().create_future() self.result_fut = asyncio.get_event_loop().create_future()
self.setModal(True)
@QtCore.Slot(QMessageBox.StandardButton) @QtCore.Slot(QMessageBox.StandardButton)
def on_finished(self, button): def on_finished(self, button):
@ -195,6 +196,7 @@ async def JMQtMessageBox(parent, msg, mbtype='info', title='',
self.setSizeGripEnabled(True) self.setSizeGripEnabled(True)
self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
self.layout().setSizeConstraint(QLayout.SetMaximumSize) self.layout().setSizeConstraint(QLayout.SetMaximumSize)
self.setModal(True)
def resizeEvent(self, event): def resizeEvent(self, event):
self.setMinimumHeight(0) self.setMinimumHeight(0)
@ -434,6 +436,7 @@ class JMExportPrivkeysDialog(QDialog):
super().__init__(parent=parent) super().__init__(parent=parent)
self.result_fut = asyncio.get_event_loop().create_future() self.result_fut = asyncio.get_event_loop().create_future()
self.initUI() self.initUI()
self.setModal(True)
def initUI(self): def initUI(self):
self.setWindowTitle('Private keys') self.setWindowTitle('Private keys')
@ -470,6 +473,7 @@ async def JMPasswordDialog(parent):
super().__init__(parent=parent) super().__init__(parent=parent)
self.result_fut = asyncio.get_event_loop().create_future() self.result_fut = asyncio.get_event_loop().create_future()
self.initUI() self.initUI()
self.setModal(True)
def initUI(self): def initUI(self):
@ -949,9 +953,8 @@ class SchIntroPage(QWizardPage):
class ScheduleWizard(QWizard): class ScheduleWizard(QWizard):
def __init__(self): def __init__(self, parent, *args, **kwargs):
super().__init__() super().__init__(parent, *args, **kwargs)
self.setModal(True)
self.result_fut = asyncio.get_event_loop().create_future() self.result_fut = asyncio.get_event_loop().create_future()
self.finished.connect(self.on_finished) self.finished.connect(self.on_finished)
self.setWindowTitle("Joinmarket schedule generator") self.setWindowTitle("Joinmarket schedule generator")
@ -960,6 +963,7 @@ class ScheduleWizard(QWizard):
self.setPage(2, SchDynamicPage2(self)) self.setPage(2, SchDynamicPage2(self))
#self.setPage(3, SchStaticPage(self)) #self.setPage(3, SchStaticPage(self))
self.setPage(3, SchFinishPage(self)) self.setPage(3, SchFinishPage(self))
self.setModal(True)
@QtCore.Slot(QMessageBox.StandardButton) @QtCore.Slot(QMessageBox.StandardButton)
def on_finished(self, button): def on_finished(self, button):
@ -1011,13 +1015,13 @@ class ScheduleWizard(QWizard):
class TumbleRestartWizard(QWizard): class TumbleRestartWizard(QWizard):
def __init__(self): def __init__(self, parent, *args, **kwargs):
super().__init__() super().__init__(parent, *args, **kwargs)
self.setModal(True)
self.result_fut = asyncio.get_event_loop().create_future() self.result_fut = asyncio.get_event_loop().create_future()
self.finished.connect(self.on_finished) self.finished.connect(self.on_finished)
self.setWindowTitle("Restart tumbler schedule") self.setWindowTitle("Restart tumbler schedule")
self.setPage(0, RestartSettingsPage(self)) self.setPage(0, RestartSettingsPage(self))
self.setModal(True)
@QtCore.Slot(QMessageBox.StandardButton) @QtCore.Slot(QMessageBox.StandardButton)
def on_finished(self, button): def on_finished(self, button):
@ -1136,14 +1140,14 @@ class ReceiveBIP78Dialog(QDialog):
parameter_types = ["btc", int] parameter_types = ["btc", int]
parameter_settings = ["", 0] parameter_settings = ["", 0]
def __init__(self, action_fn, cancel_fn, parameter_settings=None): def __init__(self, parent, action_fn, cancel_fn, parameter_settings=None):
""" Parameter action_fn: """ Parameter action_fn:
each time the user opens the dialog they will each time the user opens the dialog they will
pass a function to be connected to the action-button. pass a function to be connected to the action-button.
Signature: no arguments, return value False if action initiation Signature: no arguments, return value False if action initiation
is aborted, otherwise True. is aborted, otherwise True.
""" """
super().__init__() super().__init__(parent)
if parameter_settings: if parameter_settings:
self.parameter_settings = parameter_settings self.parameter_settings = parameter_settings
# these QLineEdit or QLabel objects will contain the # these QLineEdit or QLabel objects will contain the
@ -1154,9 +1158,9 @@ class ReceiveBIP78Dialog(QDialog):
self.cancel_fn = cancel_fn self.cancel_fn = cancel_fn
self.updates_final = False self.updates_final = False
self.initUI() self.initUI()
self.setModal(True)
def initUI(self): def initUI(self):
self.setModal(1)
self.setWindowTitle("Receive Payjoin") self.setWindowTitle("Receive Payjoin")
self.setLayout(self.get_receive_bip78_dialog()) self.setLayout(self.get_receive_bip78_dialog())
self.show() self.show()

Loading…
Cancel
Save