Skip to content

Commit

Permalink
Fixed localization of World Clock with Qt6
Browse files Browse the repository at this point in the history
`QDateTime::toString` returned a localized string with Qt5, but it doesn't with Qt6.
  • Loading branch information
tsujan committed Mar 25, 2024
1 parent 64f8a5a commit c7c62b0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions plugin-worldclock/lxqtworldclock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit c7c62b0

Please sign in to comment.