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