From daaadff170f3cc0c826711cd1b14689a3eba17bb Mon Sep 17 00:00:00 2001 From: tsujan Date: Tue, 26 Mar 2024 14:20:42 +0330 Subject: [PATCH] Fixed localization of World Clock with Qt6 (#2039) `QDateTime::toString` returned a localized string with Qt5, but it doesn't with Qt6. --- plugin-worldclock/lxqtworldclock.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugin-worldclock/lxqtworldclock.cpp b/plugin-worldclock/lxqtworldclock.cpp index 3c504f93e..66b693218 100644 --- a/plugin-worldclock/lxqtworldclock.cpp +++ b/plugin-worldclock/lxqtworldclock.cpp @@ -135,7 +135,7 @@ void LXQtWorldClock::updateTimeText() if (!isUpToDate) { const QSize old_size = mContent->sizeHint(); - mContent->setText(tzNow.toString(preformat(mFormat, timeZone, tzNow))); + mContent->setText(QLocale::system().toString(tzNow, preformat(mFormat, timeZone, tzNow))); if (old_size != mContent->sizeHint()) mRotatedWidget->adjustContentSize(); mRotatedWidget->update(); @@ -447,7 +447,7 @@ QString LXQtWorldClock::formatDateTime(const QDateTime &datetime, const QString { QTimeZone timeZone(timeZoneName.toLatin1()); QDateTime tzNow = datetime.toTimeZone(timeZone); - return tzNow.toString(preformat(mFormat, timeZone, tzNow)); + return QLocale::system().toString(tzNow, preformat(mFormat, timeZone, tzNow)); } void LXQtWorldClock::updatePopupContent() @@ -652,7 +652,7 @@ bool LXQtWorldClock::eventFilter(QObject * watched, QEvent * event) timeZoneName = QString::fromLatin1(QTimeZone::systemTimeZoneId()); QTimeZone timeZone(timeZoneName.toLatin1()); QDateTime tzNow = now.toTimeZone(timeZone); - QToolTip::showText(helpEvent->globalPos(), tzNow.toString(QLocale{}.dateTimeFormat(QLocale::ShortFormat))); + QToolTip::showText(helpEvent->globalPos(), QLocale::system().toString(tzNow, QLocale::ShortFormat)); return false; } return QObject::eventFilter(watched, event);