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 de30261
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/session-widgets/lockcontent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include <QLocalSocket>
#include <QMouseEvent>
#include <qlocale.h>

using namespace dss;
using namespace dss::module;
Expand Down Expand Up @@ -78,6 +79,10 @@ LockContent::LockContent(SessionBaseModel *const model, QWidget *parent)
}
}
once = true;

auto localeName = regionValue(localeName_key);
QLocale locale = localeName.isEmpty()? QLocale::system() : QLocale(localeName);
m_timeWidget->updateLocale(locale);
}

void LockContent::initUI()
Expand Down Expand Up @@ -217,7 +222,8 @@ void LockContent::onValueChanged(const QDBusMessage &dbusMessage)
} else if (interfaceName == longDateFormat_key) {
m_longDateFormat = regionValue(longDateFormat_key);
}
m_timeWidget->updateLocale(QLocale(m_localeName), m_shortTimeFormat, m_longDateFormat);
QLocale locale = m_localeName.isEmpty() ? QLocale::system() : QLocale(m_localeName);
m_timeWidget->updateLocale(locale, m_shortTimeFormat, m_longDateFormat);
}

QString LockContent::configPath(std::shared_ptr<User> user) const
Expand Down Expand Up @@ -294,7 +300,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

0 comments on commit de30261

Please sign in to comment.