From 449a680d3226d44882090eef8fd740372bcd9cdd Mon Sep 17 00:00:00 2001 From: NinjaCheetah <58050615+NinjaCheetah@users.noreply.github.com> Date: Tue, 18 Feb 2025 20:10:27 -0500 Subject: [PATCH] Add safeguards to system Qt library loading on Linux Also made minor update for libWiiPy v0.6.0 compatibility --- NUSGet.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/NUSGet.py b/NUSGet.py index 6658118..d1e6e2a 100644 --- a/NUSGet.py +++ b/NUSGet.py @@ -502,11 +502,21 @@ if __name__ == "__main__": # it looks nice, but fallback on kvantum if it isn't, since kvantum is likely to exist. If all else fails, fusion. if platform.system() == "Linux": if os.path.isdir("/usr/lib/qt6/plugins"): - app.addLibraryPath("/usr/lib/qt6/plugins") - if "Breeze" in QStyleFactory.keys(): - app.setStyle("Breeze") - elif "kvantum" in QStyleFactory.keys(): - app.setStyle("kvantum") + import subprocess + try: + # This CANNOT be the best way to get the system Qt version, but it's what I came up with for now. + result = subprocess.run(['/usr/lib/qt6/bin/qtdiag'], stdout=subprocess.PIPE) + result_str = result.stdout.decode("utf-8").split("\n")[0] + sys_qt_ver = result_str.split(" ")[1].split(".") + pyside_qt_ver = version("PySide6").split(".") + if sys_qt_ver[0:2] == pyside_qt_ver[0:2]: + app.addLibraryPath("/usr/lib/qt6/plugins") + if "Breeze" in QStyleFactory.keys(): + app.setStyle("Breeze") + elif "kvantum" in QStyleFactory.keys(): + app.setStyle("kvantum") + except Exception as e: + print(e) # Load qtbase translations, and then apps-specific translations. path = QLibraryInfo.path(QLibraryInfo.LibraryPath.TranslationsPath)