From 941807c85d9c3993fefbe8503dcdffe45f4a513d Mon Sep 17 00:00:00 2001 From: zhaoyingzhen Date: Mon, 7 Jul 2025 14:30:59 +0800 Subject: [PATCH] fix: update short date and week format as title Log: as title Pms: BUG-323177 --- src/widgets/centertopwidget.cpp | 8 ++++---- src/widgets/timewidget.cpp | 10 +++++----- src/widgets/timewidget.h | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/widgets/centertopwidget.cpp b/src/widgets/centertopwidget.cpp index d6ff6b36..84eaadb8 100644 --- a/src/widgets/centertopwidget.cpp +++ b/src/widgets/centertopwidget.cpp @@ -19,7 +19,7 @@ const int TOP_TIP_SPACING = 10; #ifdef ENABLE_DSS_SNIPE static const QString localeNameKey = "localeName"; -static const QString longDateFormatKey = "longDateFormat"; +static const QString shortDateFormatKey = "shortDateFormat"; static const QString shortTimeFormatKey = "shortTimeFormat"; #endif // ENABLE_DSS_SNIPE @@ -178,7 +178,7 @@ void CenterTopWidget::onUserRegionFormatValueChanged(const QDBusMessage &dbusMes return; QString key = dbusMessage.arguments().at(0).toString(); - if (key == localeNameKey || key == shortTimeFormatKey || key == longDateFormatKey) { + if (key == localeNameKey || key == shortTimeFormatKey || key == shortDateFormatKey) { updateUserDateTimeFormat(); } } @@ -251,8 +251,8 @@ void CenterTopWidget::updateUserDateTimeFormat() QString localeName = qApp->applicationName() == "dde-lock" ? QLocale::system().name() : getRegionFormatValue(userConfigDbusPath, localeNameKey); QString shortTimeFormat = getRegionFormatValue(userConfigDbusPath, shortTimeFormatKey); - QString longDateFormat = getRegionFormatValue(userConfigDbusPath, longDateFormatKey); + QString shortDateFormat = getRegionFormatValue(userConfigDbusPath, shortDateFormatKey); - m_timeWidget->updateLocale(localeName, shortTimeFormat, longDateFormat); + m_timeWidget->updateLocale(localeName, shortTimeFormat, shortDateFormat); } #endif // ENABLE_DSS_SNIPE diff --git a/src/widgets/timewidget.cpp b/src/widgets/timewidget.cpp index e9af307c..96b2dbf8 100644 --- a/src/widgets/timewidget.cpp +++ b/src/widgets/timewidget.cpp @@ -82,9 +82,9 @@ void TimeWidget::refreshTime() m_dateLabel->setText(m_locale.toString(QDateTime::currentDateTime(), date_format)); #ifdef ENABLE_DSS_SNIPE - if (!m_shortTimeFormat.isEmpty() && !m_longDateFormat.isEmpty()) { + if (!m_shortTimeFormat.isEmpty() && !m_shortDateFormat.isEmpty()) { m_timeLabel->setText(m_locale.toString(QTime::currentTime(), m_shortTimeFormat)); - m_dateLabel->setText(m_locale.toString(QDate::currentDate(), m_longDateFormat)); + m_dateLabel->setText(m_locale.toString(QDate::currentDate(), m_shortDateFormat + " " + weekdayFormat.at(m_weekdayIndex))); } #endif // ENABLE_DSS_SNIPE } @@ -131,13 +131,13 @@ QSize TimeWidget::sizeHint() const } #ifdef ENABLE_DSS_SNIPE -void TimeWidget::updateLocale(const QString &locale, const QString &shortTimeFormat, const QString &longDateFormat) +void TimeWidget::updateLocale(const QString &locale, const QString &shortTimeFormat, const QString &shortDateFormat) { m_locale = QLocale(locale); if (!shortTimeFormat.isEmpty()) m_shortTimeFormat = shortTimeFormat; - if (!longDateFormat.isEmpty()) - m_longDateFormat = longDateFormat; + if (!shortDateFormat.isEmpty()) + m_shortDateFormat = shortDateFormat; refreshTime(); } diff --git a/src/widgets/timewidget.h b/src/widgets/timewidget.h index bc5eff25..e24dba85 100644 --- a/src/widgets/timewidget.h +++ b/src/widgets/timewidget.h @@ -24,7 +24,7 @@ class TimeWidget : public QWidget QSize sizeHint() const override; #ifdef ENABLE_DSS_SNIPE - void updateLocale(const QString &locale, const QString &shortTimeFormat = "", const QString &longDateFormat = ""); + void updateLocale(const QString &locale, const QString &shortTimeFormat = "", const QString &shortDateFormat = ""); #endif // ENABLE_DSS_SNIPE public Q_SLOTS: @@ -49,7 +49,7 @@ public Q_SLOTS: #ifdef ENABLE_DSS_SNIPE QString m_shortTimeFormat; - QString m_longDateFormat; + QString m_shortDateFormat; #endif // ENABLE_DSS_SNIPE };