Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion plugins/dde-dock/datetime/datetimeplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,15 @@ const QString DatetimePlugin::itemContextMenu(const QString &itemKey)
QList<QVariant> items;

QMap<QString, QVariant> settings;
#if 0 // 隐藏时间设置:BUG-303071
settings["itemId"] = "settings";
if (m_centralWidget->is24HourFormat())
settings["itemText"] = tr("12-hour time");
else
settings["itemText"] = tr("24-hour time");
settings["isActive"] = true;
items.push_back(settings);

#endif
Comment on lines 180 to +183

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Avoid using #if 0 to hide code; prefer code removal or runtime flags

Preprocessor guards create dead code and hinder maintainability. Use a runtime flag or remove the code to keep the codebase clean.

Suggested change
settings["itemText"] = tr("24-hour time");
settings["isActive"] = true;
items.push_back(settings);
#endif

if (!QFile::exists(ICBC_CONF_FILE)) {
QMap<QString, QVariant> open;
open["itemId"] = "open";
Expand Down
9 changes: 6 additions & 3 deletions plugins/dde-dock/datetime/datetimewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ void DatetimeWidget::updateDateTimeString()
const auto position = qApp->property(PROP_POSITION).value<Dock::Position>();
QString timeStr, dateString;
if (position == Dock::Bottom || position == Dock::Top) {
QString timeFormat = m_24HourFormat ? "hh:mm" : m_regionFormat->getShortTimeFormat();
QString timeFormat = m_regionFormat->getShortTimeFormat();
timeStr = locale.toString(current, timeFormat);
dateString = current.toString(m_regionFormat->getShortDateFormat());

Expand All @@ -124,9 +124,12 @@ void DatetimeWidget::updateDateTimeString()
QString apText = locale.toString(current, "AP");
m_apLabel->setText(apText);

timeStr = current.toString("h:mm");
QString timeFormat = m_regionFormat->getShortTimeFormat();
timeFormat.replace("AP", "");
timeFormat.replace(" ", "");
timeStr = current.toString(timeFormat);
} else {
timeStr = current.toString("hh:mm");
timeStr = current.toString(m_regionFormat->getShortTimeFormat());
}

m_timeLabel->setText(timeStr);
Expand Down