SomberNight 7 years ago
parent
commit
985fe24f18
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 8
      gui/qt/main_window.py
  2. 16
      gui/qt/util.py

8
gui/qt/main_window.py

@ -254,10 +254,12 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
def pop_top_level_window(self, window):
self.tl_windows.remove(window)
def top_level_window(self):
def top_level_window(self, test_func=None):
'''Do the right thing in the presence of tx dialog windows'''
override = self.tl_windows[-1] if self.tl_windows else None
return self.top_level_window_recurse(override)
if override and test_func and not test_func(override):
override = None # only override if ok for test_func
return self.top_level_window_recurse(override, test_func)
def diagnostic_name(self):
return "%s/%s" % (PrintError.diagnostic_name(self),
@ -1613,7 +1615,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
return status, msg
# Capture current TL window; override might be removed on return
parent = self.top_level_window()
parent = self.top_level_window(lambda win: isinstance(win, MessageBoxMixin))
def broadcast_done(result):
# GUI thread

16
gui/qt/util.py

@ -165,17 +165,21 @@ class CancelButton(QPushButton):
self.clicked.connect(dialog.reject)
class MessageBoxMixin(object):
def top_level_window_recurse(self, window=None):
def top_level_window_recurse(self, window=None, test_func=None):
window = window or self
classes = (WindowModalDialog, QMessageBox)
if test_func is None:
test_func = lambda x: True
for n, child in enumerate(window.children()):
# Test for visibility as old closed dialogs may not be GC-ed
if isinstance(child, classes) and child.isVisible():
return self.top_level_window_recurse(child)
# Test for visibility as old closed dialogs may not be GC-ed.
# Only accept children that confirm to test_func.
if isinstance(child, classes) and child.isVisible() \
and test_func(child):
return self.top_level_window_recurse(child, test_func=test_func)
return window
def top_level_window(self):
return self.top_level_window_recurse()
def top_level_window(self, test_func=None):
return self.top_level_window_recurse(test_func)
def question(self, msg, parent=None, title=None, icon=None):
Yes, No = QMessageBox.Yes, QMessageBox.No

Loading…
Cancel
Save