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
18 changes: 3 additions & 15 deletions panels/notification/center/notifyaccessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,22 +196,10 @@ void NotifyAccessor::invokeAction(const NotifyEntity &entity, const QString &act
{
qDebug(notifyLog) << "Invoke action for the notify" << entity.id() << actionId;

QMap<QString, QVariant> hints = entity.hints();
if (hints.isEmpty())
if (!m_dataUpdater)
return;
QMap<QString, QVariant>::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)
Expand Down
10 changes: 8 additions & 2 deletions panels/notification/server/notificationmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,16 +113,22 @@ 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);

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);
Expand Down
1 change: 1 addition & 0 deletions panels/notification/server/notificationmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions panels/notification/server/notifyserverapplet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nitpick (bug_risk): Consistency in QMetaObject::invokeMethod argument types.

Use Q_ARG(const QString&, actionKey) instead of Q_ARG(QString, actionKey) so the meta-object invocation exactly matches the method signature.

{
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));
Expand Down
1 change: 1 addition & 0 deletions panels/notification/server/notifyserverapplet.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
Q_SIGNALS:
void notificationStateChanged(qint64 id, int processedType);

public Q_SLOTS:

Check warning on line 25 in panels/notification/server/notifyserverapplet.h

View workflow job for this annotation

GitHub Actions / cppcheck

There is an unknown macro here somewhere. Configuration is required. If Q_SLOTS is a macro then please configure it.
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);
Expand Down