diff --git a/panels/notification/center/notifyaccessor.cpp b/panels/notification/center/notifyaccessor.cpp index 7f4cd5bf7..4c4456dc5 100644 --- a/panels/notification/center/notifyaccessor.cpp +++ b/panels/notification/center/notifyaccessor.cpp @@ -196,22 +196,10 @@ void NotifyAccessor::invokeAction(const NotifyEntity &entity, const QString &act { qDebug(notifyLog) << "Invoke action for the notify" << entity.id() << actionId; - QMap hints = entity.hints(); - if (hints.isEmpty()) + if (!m_dataUpdater) return; - QMap::const_iterator i = hints.constBegin(); - while (i != hints.constEnd()) { - QStringList args = i.value().toString().split(","); - if (!args.isEmpty()) { - QString cmd = args.first(); - args.removeFirst(); - if (i.key() == "x-deepin-action-" + actionId) { - qDebug(notifyLog) << "Invoke action" << cmd; - QProcess::startDetached(cmd, args); - } - } - ++i; - } + const auto id = entity.id(); + QMetaObject::invokeMethod(m_dataUpdater, "actionInvoked", Qt::DirectConnection, Q_ARG(qint64, id), Q_ARG(const QString &, actionId)); } void NotifyAccessor::pinApplication(const QString &appId, bool pin) diff --git a/panels/notification/server/notificationmanager.cpp b/panels/notification/server/notificationmanager.cpp index bceab4ced..a9c0eb173 100644 --- a/panels/notification/server/notificationmanager.cpp +++ b/panels/notification/server/notificationmanager.cpp @@ -113,9 +113,9 @@ uint NotificationManager::recordCount() const return m_persistence->fetchEntityCount(DataAccessor::AllApp(), NotifyEntity::Processed); } -void NotificationManager::actionInvoked(qint64 id, uint bubbleId, const QString &actionKey) +void NotificationManager::actionInvoked(qint64 id, const QString &actionKey) { - qInfo(notifyLog) << "Action invoked, bubbleId:" << bubbleId << ", id:" << id << ", actionKey" << actionKey; + qInfo(notifyLog) << "Action invoked, id:" << id << ", actionKey" << actionKey; auto entity = m_persistence->fetchEntity(id); if (entity.isValid()) { doActionInvoked(entity, actionKey); @@ -123,6 +123,12 @@ void NotificationManager::actionInvoked(qint64 id, uint bubbleId, const QString entity.setProcessedType(NotifyEntity::Removed); updateEntityProcessed(entity); } +} + +void NotificationManager::actionInvoked(qint64 id, uint bubbleId, const QString &actionKey) +{ + qInfo(notifyLog) << "Action invoked, bubbleId:" << bubbleId << ", id:" << id << ", actionKey" << actionKey; + actionInvoked(id, actionKey); Q_EMIT ActionInvoked(bubbleId, actionKey); Q_EMIT NotificationClosed(bubbleId, NotifyEntity::Closed); diff --git a/panels/notification/server/notificationmanager.h b/panels/notification/server/notificationmanager.h index f208d4738..efa114ed4 100644 --- a/panels/notification/server/notificationmanager.h +++ b/panels/notification/server/notificationmanager.h @@ -26,6 +26,7 @@ class NotificationManager : public QObject, public QDBusContext bool registerDbusService(); uint recordCount() const; + Q_INVOKABLE void actionInvoked(qint64 id, const QString &actionKey); Q_INVOKABLE void actionInvoked(qint64 id, uint bubbleId, const QString &actionKey); Q_INVOKABLE void notificationClosed(qint64 id, uint bubbleId, uint reason); Q_INVOKABLE void notificationReplaced(qint64 id); diff --git a/panels/notification/server/notifyserverapplet.cpp b/panels/notification/server/notifyserverapplet.cpp index d7abd2431..44dbeb72d 100644 --- a/panels/notification/server/notifyserverapplet.cpp +++ b/panels/notification/server/notifyserverapplet.cpp @@ -67,6 +67,11 @@ void NotifyServerApplet::actionInvoked(qint64 id, uint bubbleId, const QString & QMetaObject::invokeMethod(m_manager, "actionInvoked", Qt::DirectConnection, Q_ARG(qint64, id), Q_ARG(uint, bubbleId), Q_ARG(QString, actionKey)); } +void NotifyServerApplet::actionInvoked(qint64 id, const QString &actionKey) +{ + QMetaObject::invokeMethod(m_manager, "actionInvoked", Qt::DirectConnection, Q_ARG(qint64, id), Q_ARG(QString, actionKey)); +} + void NotifyServerApplet::notificationClosed(qint64 id, uint bubbleId, uint reason) { QMetaObject::invokeMethod(m_manager, "notificationClosed", Qt::DirectConnection, Q_ARG(qint64, id), Q_ARG(uint, bubbleId), Q_ARG(uint, reason)); diff --git a/panels/notification/server/notifyserverapplet.h b/panels/notification/server/notifyserverapplet.h index 9d809b721..2365be050 100644 --- a/panels/notification/server/notifyserverapplet.h +++ b/panels/notification/server/notifyserverapplet.h @@ -24,6 +24,7 @@ class NotifyServerApplet : public DS_NAMESPACE::DApplet public Q_SLOTS: void actionInvoked(qint64 id, uint bubbleId, const QString &actionKey); + void actionInvoked(qint64 id, const QString &actionKey); void notificationClosed(qint64 id, uint bubbleId, uint reason); QVariant appValue(const QString &appId, int configItem); void removeNotification(qint64 id);