diff --git a/src/services/status_notifier/item.cpp b/src/services/status_notifier/item.cpp index 51047786..8d55ba2a 100644 --- a/src/services/status_notifier/item.cpp +++ b/src/services/status_notifier/item.cpp @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -175,9 +176,44 @@ QPixmap StatusNotifierItem::createPixmap(const QSize& size) const { return pixmap; } -void StatusNotifierItem::activate() { this->item->Activate(0, 0); } +void StatusNotifierItem::activate() { + auto pendingCall = this->item->Activate(0, 0); + auto* call = new QDBusPendingCallWatcher(pendingCall, this); -void StatusNotifierItem::secondaryActivate() { this->item->SecondaryActivate(0, 0); } + auto responseCallback = [this](QDBusPendingCallWatcher* call) { + const QDBusPendingReply<> reply = *call; + + if (reply.isError()) { + qCWarning(logStatusNotifierItem).noquote() + << "Error calling Activate method of StatusNotifierItem" << this->properties.toString(); + qCWarning(logStatusNotifierItem) << reply.error(); + } + + delete call; + }; + + QObject::connect(call, &QDBusPendingCallWatcher::finished, this, responseCallback); +} + +void StatusNotifierItem::secondaryActivate() { + auto pendingCall = this->item->SecondaryActivate(0, 0); + auto* call = new QDBusPendingCallWatcher(pendingCall, this); + + auto responseCallback = [this](QDBusPendingCallWatcher* call) { + const QDBusPendingReply<> reply = *call; + + if (reply.isError()) { + qCWarning(logStatusNotifierItem).noquote() + << "Error calling SecondaryActivate method of StatusNotifierItem" + << this->properties.toString(); + qCWarning(logStatusNotifierItem) << reply.error(); + } + + delete call; + }; + + QObject::connect(call, &QDBusPendingCallWatcher::finished, this, responseCallback); +} void StatusNotifierItem::scroll(qint32 delta, bool horizontal) { this->item->Scroll(delta, horizontal ? "horizontal" : "vertical");