Addon Manager: Set parent for most modals

This commit is contained in:
Chris Hennes
2023-01-11 21:55:37 -06:00
parent 4cddf5d1ae
commit 6c1d9701eb
5 changed files with 35 additions and 11 deletions

View File

@@ -451,3 +451,20 @@ def run_interruptable_subprocess(args) -> object:
if return_code is None or return_code != 0:
raise subprocess.CalledProcessError(return_code, args, stdout, stderr)
return subprocess.CompletedProcess(args, return_code, stdout, stderr)
def get_main_am_window():
windows = QtWidgets.QApplication.topLevelWidgets()
for widget in windows:
if widget.objectName() == "AddonManager_Main_Window":
return widget
# If there is no main AM window, we may be running unit tests: see if the Test Runner window
# exists:
for widget in windows:
if widget.objectName() == "TestGui__UnitTest":
return widget
# If we still didn't find it, try to locate the main FreeCAD window:
for widget in windows:
if hasattr(widget, "centralWidget"):
return widget.centralWidget()
# Why is this code even getting called?
return None