Skip to content

Commit

Permalink
fix: no translation for time in greeter
Browse files Browse the repository at this point in the history
Set locale to the current user's locale when firstly entering system

Issue: linuxdeepin/developer-center#6994
  • Loading branch information
FeiWang1119 committed Jan 22, 2024
1 parent 8444939 commit 7beddef
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/session-widgets/lockcontent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ LockContent::LockContent(SessionBaseModel *const model, QWidget *parent)
}
}
once = true;

QString localeName = regionValue(localeName_key);
m_timeWidget->updateLocale(QLocale(localeName));
}

void LockContent::initUI()
Expand Down Expand Up @@ -294,7 +297,7 @@ void LockContent::onCurrentUserChanged(std::shared_ptr<User> user)
m_user = user;

m_localeName = regionValue(localeName_key);
QLocale locale = m_localeName.isEmpty()? QLocale::system() : QLocale(m_localeName);
QLocale locale = m_localeName.isEmpty()? user->locale() : QLocale(m_localeName);
m_shortTimeFormat = regionValue(shortTimeFormat_key);
m_longDateFormat = regionValue(longDateFormat_key);
buildConnect();
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/timewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void TimeWidget::set24HourFormat(bool use24HourFormat)

void TimeWidget::updateLocale(const QLocale &locale, const QString &shortTimeFormat, const QString &longDateFormat)
{
m_locale = locale;
m_locale = locale.name().isEmpty() ? QLocale::system() : locale;
if (!shortTimeFormat.isEmpty())
m_shortTimeFormat = shortTimeFormat;
if (!longDateFormat.isEmpty())
Expand Down

0 comments on commit 7beddef

Please sign in to comment.