Skip to content

Commit de193ab

Browse files
committed
fix: Fix the issue where the time does not follow the regional format
Fix the issue where the time does not follow the regional format Log: Fix the issue where the time does not follow the regional format pms: BUG-342705
1 parent 1eda0b5 commit de193ab

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/widgets/centertopwidget.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,17 @@ void CenterTopWidget::setCurrentUser(User *user)
8080
}
8181
}
8282

83+
#ifdef ENABLE_DSS_SNIPE
84+
QString userConfigDbusPath = getRegionFormatConfigPath(user);
85+
QString localeName = qApp->applicationName() == "dde-lock" ? QLocale::system().name() : getRegionFormatValue(userConfigDbusPath, localeNameKey);
86+
if (localeName.isEmpty()) {
87+
localeName = user->locale();
88+
}
89+
m_timeWidget->updateLocale(QLocale(localeName));
90+
#else
8391
auto locale = qApp->applicationName() == "dde-lock" ? QLocale::system().name() : user->locale();
8492
m_timeWidget->updateLocale(QLocale(locale));
93+
#endif // ENABLE_DSS_SNIPE
8594
m_timeWidget->set24HourFormat(user->isUse24HourFormat());
8695
m_timeWidget->setWeekdayFormatType(user->weekdayFormat());
8796
m_timeWidget->setShortDateFormat(user->shortDateFormat());
@@ -105,8 +114,17 @@ void CenterTopWidget::setCurrentUser(User *user)
105114
void CenterTopWidget::updateTimeFormat(bool use24)
106115
{
107116
if (!m_currentUser.isNull()) {
117+
#ifdef ENABLE_DSS_SNIPE
118+
QString userConfigDbusPath = getRegionFormatConfigPath(m_currentUser);
119+
QString localeName = qApp->applicationName() == "dde-lock" ? QLocale::system().name() : getRegionFormatValue(userConfigDbusPath, localeNameKey);
120+
if (localeName.isEmpty()) {
121+
localeName = m_currentUser->locale();
122+
}
123+
m_timeWidget->updateLocale(QLocale(localeName));
124+
#else
108125
auto locale = qApp->applicationName() == "dde-lock" ? QLocale::system().name() : m_currentUser->locale();
109126
m_timeWidget->updateLocale(QLocale(locale));
127+
#endif // ENABLE_DSS_SNIPE
110128
m_timeWidget->set24HourFormat(use24);
111129
m_timeWidget->setVisible(true);
112130
}

0 commit comments

Comments
 (0)