From d3ab2bfd27718b1bc7ba2dbe7c85b2ad1d18ffca Mon Sep 17 00:00:00 2001 From: zhangkun Date: Fri, 4 Sep 2026 10:59:22 +0800 Subject: [PATCH] fix(power): fix scheduled shutdown notifications MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Restore legacy notification action keys to keep notification sounds enabled. 2. Parse calendar service fields using the actual lowercase D-Bus response names. 3. Use uint32-compatible arguments for the calendar D-Bus method. Log: Fix scheduled shutdown notification sound and workday scheduling. Influence: Scheduled shutdown works correctly on working days. fix(power): 修复定时关机通知问题 1. 恢复旧版通知动作键,避免通知音效被错误抑制。 2. 按日历服务实际返回的字段名解析工作日信息。 3. 使用与日历 D-Bus 方法兼容的 uint32 参数类型。 Log: 修复定时关机通知音效和工作日定时关机调度问题。 PMS: BUG-375825 PMS: BUG-375829 Influence: 工作日定时关机和通知音效恢复正常。 Change-Id: I8cb56dcb8b0e0ec9c2a71977087356e2b7692777 --- src/plugin-qt/power/session/powermanager.cpp | 13 +++++++------ src/plugin-qt/power/session/sessiondbusproxy.cpp | 2 +- src/plugin-qt/power/session/sessiondbusproxy.h | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/plugin-qt/power/session/powermanager.cpp b/src/plugin-qt/power/session/powermanager.cpp index 1a26f8a3..a7f5b95a 100644 --- a/src/plugin-qt/power/session/powermanager.cpp +++ b/src/plugin-qt/power/session/powermanager.cpp @@ -1297,9 +1297,9 @@ void PowerManager::onNotifyActionInvoked(uint id, const QString &actionKey) qDebug(logPowerSession) << "Notification action invoked: id=" << id << " key=" << actionKey; if (id != m_shutdownNotifyId) return; int nextStatus; - if (actionKey == "cancel") { + if (actionKey == "Cancle") { nextStatus = SchedCancel; - } else if (actionKey == "shutdown") { + } else if (actionKey == "Shutdown") { nextStatus = SchedShutdown; } else { nextStatus = SchedCancel; @@ -1362,7 +1362,7 @@ void PowerManager::shutdownCountdownNotify(int count, bool playSound) { QString body = tr("The system will shut down automatically after %1 s").arg(count); QString title = tr("Scheduled Shutdown"); - QStringList actions = {"cancel", tr("Cancel"), "shutdown", tr("Shut down")}; + QStringList actions = {"Cancle", tr("Cancel"), "Shutdown", tr("Shut down")}; QVariantMap hints = { {"x-deepin-PlaySound", playSound}, {"urgency", 2}, @@ -1515,7 +1515,7 @@ bool PowerManager::isWorkday(const QDateTime &date) const return dow != Qt::Saturday && dow != Qt::Sunday; } QJsonObject root = doc.array().first().toObject(); - QJsonArray list = root["List"].toArray(); + QJsonArray list = root[QStringLiteral("list")].toArray(); if (list.isEmpty()) { int dow = date.date().dayOfWeek(); return dow != Qt::Saturday && dow != Qt::Sunday; @@ -1525,8 +1525,9 @@ bool PowerManager::isWorkday(const QDateTime &date) const QString dateStr2 = date.toString("yyyy-MM-dd"); for (const auto &item : list) { QJsonObject obj = item.toObject(); - if (obj["Date"].toString() == dateStr1 || obj["Date"].toString() == dateStr2) { - return obj["Status"].toInt() == 2; + if (obj[QStringLiteral("date")].toString() == dateStr1 + || obj[QStringLiteral("date")].toString() == dateStr2) { + return obj[QStringLiteral("status")].toInt() == 2; } } int dow = date.date().dayOfWeek(); diff --git a/src/plugin-qt/power/session/sessiondbusproxy.cpp b/src/plugin-qt/power/session/sessiondbusproxy.cpp index 7c027b2b..827a9e82 100644 --- a/src/plugin-qt/power/session/sessiondbusproxy.cpp +++ b/src/plugin-qt/power/session/sessiondbusproxy.cpp @@ -327,7 +327,7 @@ void SessionDBusProxy::closeNotification(uint id) m_notificationsInter->asyncCall("CloseNotification", id); } -QString SessionDBusProxy::getFestivalMonth(int year, int month) +QString SessionDBusProxy::getFestivalMonth(uint year, uint month) { QDBusReply r = m_calendarInter->call("getFestivalMonth", year, month); return r.isValid() ? r.value() : QString(); diff --git a/src/plugin-qt/power/session/sessiondbusproxy.h b/src/plugin-qt/power/session/sessiondbusproxy.h index 983e5772..901f18f2 100644 --- a/src/plugin-qt/power/session/sessiondbusproxy.h +++ b/src/plugin-qt/power/session/sessiondbusproxy.h @@ -102,7 +102,7 @@ class SessionDBusProxy : public QObject { void closeNotification(uint id); // ── Calendar ── - QString getFestivalMonth(int year, int month); + QString getFestivalMonth(uint year, uint month); signals: // Forwarded from org.freedesktop.DBus.PropertiesChanged by DDBusInterface.