From 62c3836c97a56db24e3ef567a31eba2d0893b945 Mon Sep 17 00:00:00 2001 From: Ladislav Michl Date: Tue, 23 Jan 2024 12:46:32 +0100 Subject: [PATCH] Addon Manager: Qt6 fixes --- src/Mod/AddonManager/addonmanager_utilities.py | 4 ++-- src/Mod/AddonManager/change_branch.py | 2 +- src/Mod/AddonManager/package_details.py | 7 +++---- src/Mod/AddonManager/package_list.py | 7 +++---- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/Mod/AddonManager/addonmanager_utilities.py b/src/Mod/AddonManager/addonmanager_utilities.py index 9ceabc2e9add..183a2047b086 100644 --- a/src/Mod/AddonManager/addonmanager_utilities.py +++ b/src/Mod/AddonManager/addonmanager_utilities.py @@ -36,7 +36,7 @@ from urllib.parse import urlparse try: - from PySide import QtCore, QtWidgets + from PySide import QtCore, QtGui, QtWidgets except ImportError: QtCore = None QtWidgets = None @@ -245,7 +245,7 @@ def get_readme_html_url(repo): def is_darkmode() -> bool: """Heuristics to determine if we are in a darkmode stylesheet""" pl = fci.FreeCADGui.getMainWindow().palette() - return pl.color(pl.Background).lightness() < 128 + return pl.color(QtGui.QPalette.Window).lightness() < 128 def warning_color_string() -> str: diff --git a/src/Mod/AddonManager/change_branch.py b/src/Mod/AddonManager/change_branch.py index 332795a22afc..ebe1819bc755 100644 --- a/src/Mod/AddonManager/change_branch.py +++ b/src/Mod/AddonManager/change_branch.py @@ -216,7 +216,7 @@ def data(self, index: QtCore.QModelIndex, role: int = QtCore.Qt.DisplayRole): dd = self.display_data[row] if column == 3 or column == 4: if dd[column] is not None: - qdate = QtCore.QDateTime.fromTime_t(dd[column]) + qdate = QtCore.QDateTime.fromSecsSinceEpoch(dd[column]) return QtCore.QLocale().toString(qdate, QtCore.QLocale.ShortFormat) elif column < len(dd): return dd[column] diff --git a/src/Mod/AddonManager/package_details.py b/src/Mod/AddonManager/package_details.py index 93dfb8bee962..8310b5e90343 100644 --- a/src/Mod/AddonManager/package_details.py +++ b/src/Mod/AddonManager/package_details.py @@ -133,10 +133,9 @@ def display_repo_status(self, status): date = "" installed_version_string = "

" if repo.updated_timestamp: - date = ( - QtCore.QDateTime.fromTime_t(repo.updated_timestamp) - .date() - .toString(QtCore.Qt.SystemLocaleShortDate) + date = QtCore.QLocale().toString( + QtCore.QDateTime.fromSecsSinceEpoch(int(round(repo.updated_timestamp, 0))), + QtCore.QLocale.ShortFormat, ) if version and date: installed_version_string += ( diff --git a/src/Mod/AddonManager/package_list.py b/src/Mod/AddonManager/package_list.py index a9dd3dc59856..d26b4f5489c3 100644 --- a/src/Mod/AddonManager/package_list.py +++ b/src/Mod/AddonManager/package_list.py @@ -465,10 +465,9 @@ def get_expanded_update_string(repo: Addon) -> str: installed_date_string = ( "
" + translate("AddonsInstaller", "Installed on") + ": " ) - installed_date_string += ( - QtCore.QDateTime.fromTime_t(repo.updated_timestamp) - .date() - .toString(QtCore.Qt.SystemLocaleShortDate) + installed_date_string += QtCore.QLocale().toString( + QtCore.QDateTime.fromSecsSinceEpoch(int(round(repo.updated_timestamp, 0))), + QtCore.QLocale.ShortFormat, ) available_version_string = ""