diff --git a/panels/notification/common/notifyentity.cpp b/panels/notification/common/notifyentity.cpp index 8e9d4354b..9171d799d 100644 --- a/panels/notification/common/notifyentity.cpp +++ b/panels/notification/common/notifyentity.cpp @@ -14,6 +14,7 @@ Q_LOGGING_CATEGORY(notifyLog, "dde.shell.notification") #define ACTION_SEGMENT ("|") #define HINT_SEGMENT ("|") #define KEY_VALUE_SEGMENT ("!!!") +#define LIST_VALUE_SEGMENT (":::") static const uint NoReplaceId = 0; @@ -294,7 +295,13 @@ QString NotifyEntity::convertHintsToString(const QVariantMap &map) QString key = it.key(); text += key; text += KEY_VALUE_SEGMENT; - QString value = it.value().toString(); + QString value; + if (it.value().typeId() == QMetaType::QStringList) { + QStringList tmp = it.value().toStringList(); + value = tmp.join(LIST_VALUE_SEGMENT); + } else { + value = it.value().toString(); + } text += value; text += HINT_SEGMENT; } @@ -328,7 +335,13 @@ QVariantMap NotifyEntity::parseHint(const QString &hint) if (list.size() != 2) continue; const QString &key = list[0]; - QVariant value = QVariant::fromValue(list[1]); + QVariant value; + auto listValue = list[1].split(LIST_VALUE_SEGMENT); + if (listValue.size() > 1) { + value = QVariant::fromValue(listValue); + } else { + value = QVariant::fromValue(list[1]); + } map.insert(key, value); } diff --git a/panels/notification/server/notificationmanager.cpp b/panels/notification/server/notificationmanager.cpp index a9c0eb173..0af7f5b0a 100644 --- a/panels/notification/server/notificationmanager.cpp +++ b/panels/notification/server/notificationmanager.cpp @@ -512,7 +512,14 @@ void NotificationManager::doActionInvoked(const NotifyEntity &entity, const QStr QMap::const_iterator i = hints.constBegin(); while (i != hints.constEnd()) { if (i.key() == "x-deepin-action-" + actionId) { - QStringList args = i.value().toString().split(","); + QStringList args; + if (i.value().typeId() == QMetaType::QStringList) { + args = i.value().toStringList(); + } else { + qDebug(notifyLog) << "Deprecate hint format, use string list instead of string." + << "actionId:" << actionId << ", value:" << i.value(); + args = i.value().toString().split(","); + } if (!args.isEmpty()) { QString cmd = args.takeFirst(); // 命令