mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-09-13 14:09:50 +00:00
QT handler improvements
Now we have the top_level_window() function, stop using the window stack.
This commit is contained in:
parent
83cc5e2001
commit
9cf0a9720f
2 changed files with 12 additions and 19 deletions
|
@ -159,7 +159,8 @@ class MessageBoxMixin(object):
|
||||||
def top_level_window(self, window=None):
|
def top_level_window(self, window=None):
|
||||||
window = window or self
|
window = window or self
|
||||||
for n, child in enumerate(window.children()):
|
for n, child in enumerate(window.children()):
|
||||||
if isinstance(child, WindowModalDialog):
|
# Test for visibility as old closed dialogs may not be GC-ed
|
||||||
|
if isinstance(child, WindowModalDialog) and child.isVisible():
|
||||||
return self.top_level_window(child)
|
return self.top_level_window(child)
|
||||||
return window
|
return window
|
||||||
|
|
||||||
|
|
|
@ -31,13 +31,15 @@ class QtHandler(PrintError):
|
||||||
win.connect(win, SIGNAL('pin_dialog'), self.pin_dialog)
|
win.connect(win, SIGNAL('pin_dialog'), self.pin_dialog)
|
||||||
win.connect(win, SIGNAL('passphrase_dialog'), self.passphrase_dialog)
|
win.connect(win, SIGNAL('passphrase_dialog'), self.passphrase_dialog)
|
||||||
win.connect(win, SIGNAL('word_dialog'), self.word_dialog)
|
win.connect(win, SIGNAL('word_dialog'), self.word_dialog)
|
||||||
self.window_stack = [win]
|
|
||||||
self.win = win
|
self.win = win
|
||||||
self.pin_matrix_widget_class = pin_matrix_widget_class
|
self.pin_matrix_widget_class = pin_matrix_widget_class
|
||||||
self.device = device
|
self.device = device
|
||||||
self.dialog = None
|
self.dialog = None
|
||||||
self.done = threading.Event()
|
self.done = threading.Event()
|
||||||
|
|
||||||
|
def top_level_window(self):
|
||||||
|
return self.win.top_level_window()
|
||||||
|
|
||||||
def watching_only_changed(self):
|
def watching_only_changed(self):
|
||||||
self.win.emit(SIGNAL('watching_only_changed'))
|
self.win.emit(SIGNAL('watching_only_changed'))
|
||||||
|
|
||||||
|
@ -71,7 +73,7 @@ class QtHandler(PrintError):
|
||||||
def pin_dialog(self, msg):
|
def pin_dialog(self, msg):
|
||||||
# Needed e.g. when resetting a device
|
# Needed e.g. when resetting a device
|
||||||
self.clear_dialog()
|
self.clear_dialog()
|
||||||
dialog = WindowModalDialog(self.window_stack[-1], _("Enter PIN"))
|
dialog = WindowModalDialog(self.top_level_window(), _("Enter PIN"))
|
||||||
matrix = self.pin_matrix_widget_class()
|
matrix = self.pin_matrix_widget_class()
|
||||||
vbox = QVBoxLayout()
|
vbox = QVBoxLayout()
|
||||||
vbox.addWidget(QLabel(msg))
|
vbox.addWidget(QLabel(msg))
|
||||||
|
@ -83,7 +85,7 @@ class QtHandler(PrintError):
|
||||||
self.done.set()
|
self.done.set()
|
||||||
|
|
||||||
def passphrase_dialog(self, msg):
|
def passphrase_dialog(self, msg):
|
||||||
d = PasswordDialog(self.window_stack[-1], None, msg,
|
d = PasswordDialog(self.top_level_window(), None, msg,
|
||||||
PasswordDialog.PW_PASSPHRASE)
|
PasswordDialog.PW_PASSPHRASE)
|
||||||
confirmed, p, passphrase = d.run()
|
confirmed, p, passphrase = d.run()
|
||||||
if confirmed:
|
if confirmed:
|
||||||
|
@ -92,7 +94,7 @@ class QtHandler(PrintError):
|
||||||
self.done.set()
|
self.done.set()
|
||||||
|
|
||||||
def word_dialog(self, msg):
|
def word_dialog(self, msg):
|
||||||
dialog = WindowModalDialog(self.window_stack[-1], "")
|
dialog = WindowModalDialog(self.top_level_window(), "")
|
||||||
hbox = QHBoxLayout(dialog)
|
hbox = QHBoxLayout(dialog)
|
||||||
hbox.addWidget(QLabel(msg))
|
hbox.addWidget(QLabel(msg))
|
||||||
text = QLineEdit()
|
text = QLineEdit()
|
||||||
|
@ -100,7 +102,7 @@ class QtHandler(PrintError):
|
||||||
text.returnPressed.connect(dialog.accept)
|
text.returnPressed.connect(dialog.accept)
|
||||||
hbox.addWidget(text)
|
hbox.addWidget(text)
|
||||||
hbox.addStretch(1)
|
hbox.addStretch(1)
|
||||||
if not self.exec_dialog(dialog):
|
if not dialog.exec_():
|
||||||
return None
|
return None
|
||||||
self.word = unicode(text.text())
|
self.word = unicode(text.text())
|
||||||
self.done.set()
|
self.done.set()
|
||||||
|
@ -109,8 +111,7 @@ class QtHandler(PrintError):
|
||||||
# Called more than once during signing, to confirm output and fee
|
# Called more than once during signing, to confirm output and fee
|
||||||
self.clear_dialog()
|
self.clear_dialog()
|
||||||
title = _('Please check your %s device') % self.device
|
title = _('Please check your %s device') % self.device
|
||||||
self.dialog = dialog = WindowModalDialog(self.window_stack[-1], title)
|
self.dialog = dialog = WindowModalDialog(self.top_level_window(), title)
|
||||||
self.window_stack.append(dialog)
|
|
||||||
l = QLabel(msg)
|
l = QLabel(msg)
|
||||||
vbox = QVBoxLayout(dialog)
|
vbox = QVBoxLayout(dialog)
|
||||||
if cancel_callback:
|
if cancel_callback:
|
||||||
|
@ -120,21 +121,13 @@ class QtHandler(PrintError):
|
||||||
dialog.show()
|
dialog.show()
|
||||||
|
|
||||||
def error_dialog(self, msg):
|
def error_dialog(self, msg):
|
||||||
self.win.show_error(msg, parent=self.window_stack[-1])
|
self.win.show_error(msg, parent=self.top_level_window())
|
||||||
|
|
||||||
def clear_dialog(self):
|
def clear_dialog(self):
|
||||||
if self.dialog:
|
if self.dialog:
|
||||||
self.dialog.accept()
|
self.dialog.accept()
|
||||||
self.window_stack.remove(self.dialog)
|
|
||||||
self.dialog = None
|
self.dialog = None
|
||||||
|
|
||||||
def exec_dialog(self, dialog):
|
|
||||||
self.window_stack.append(dialog)
|
|
||||||
try:
|
|
||||||
return dialog.exec_()
|
|
||||||
finally:
|
|
||||||
assert dialog == self.window_stack.pop()
|
|
||||||
|
|
||||||
def query_choice(self, msg, labels):
|
def query_choice(self, msg, labels):
|
||||||
return self.win.query_choice(msg, labels)
|
return self.win.query_choice(msg, labels)
|
||||||
|
|
||||||
|
@ -263,8 +256,7 @@ def qt_plugin_class(base_plugin_class):
|
||||||
def settings_dialog(self, window):
|
def settings_dialog(self, window):
|
||||||
hid_id = self.choose_device(window)
|
hid_id = self.choose_device(window)
|
||||||
if hid_id:
|
if hid_id:
|
||||||
dialog = SettingsDialog(window, self, hid_id)
|
SettingsDialog(window, self, hid_id).exec_()
|
||||||
window.wallet.handler.exec_dialog(dialog)
|
|
||||||
|
|
||||||
def choose_device(self, window):
|
def choose_device(self, window):
|
||||||
'''This dialog box should be usable even if the user has
|
'''This dialog box should be usable even if the user has
|
||||||
|
|
Loading…
Add table
Reference in a new issue