|
3 | 3 |
|
4 | 4 | #include <qdbusmetatype.h> |
5 | 5 | #include <qdbuspendingcall.h> |
| 6 | +#include <qdbuspendingreply.h> |
6 | 7 | #include <qicon.h> |
7 | 8 | #include <qlogging.h> |
8 | 9 | #include <qloggingcategory.h> |
@@ -175,9 +176,44 @@ QPixmap StatusNotifierItem::createPixmap(const QSize& size) const { |
175 | 176 | return pixmap; |
176 | 177 | } |
177 | 178 |
|
178 | | -void StatusNotifierItem::activate() { this->item->Activate(0, 0); } |
| 179 | +void StatusNotifierItem::activate() { |
| 180 | + auto pendingCall = this->item->Activate(0, 0); |
| 181 | + auto* call = new QDBusPendingCallWatcher(pendingCall, this); |
179 | 182 |
|
180 | | -void StatusNotifierItem::secondaryActivate() { this->item->SecondaryActivate(0, 0); } |
| 183 | + auto responseCallback = [this](QDBusPendingCallWatcher* call) { |
| 184 | + const QDBusPendingReply<> reply = *call; |
| 185 | + |
| 186 | + if (reply.isError()) { |
| 187 | + qCWarning(logStatusNotifierItem).noquote() |
| 188 | + << "Error calling Activate method of StatusNotifierItem" << this->properties.toString(); |
| 189 | + qCWarning(logStatusNotifierItem) << reply.error(); |
| 190 | + } |
| 191 | + |
| 192 | + delete call; |
| 193 | + }; |
| 194 | + |
| 195 | + QObject::connect(call, &QDBusPendingCallWatcher::finished, this, responseCallback); |
| 196 | +} |
| 197 | + |
| 198 | +void StatusNotifierItem::secondaryActivate() { |
| 199 | + auto pendingCall = this->item->SecondaryActivate(0, 0); |
| 200 | + auto* call = new QDBusPendingCallWatcher(pendingCall, this); |
| 201 | + |
| 202 | + auto responseCallback = [this](QDBusPendingCallWatcher* call) { |
| 203 | + const QDBusPendingReply<> reply = *call; |
| 204 | + |
| 205 | + if (reply.isError()) { |
| 206 | + qCWarning(logStatusNotifierItem).noquote() |
| 207 | + << "Error calling SecondaryActivate method of StatusNotifierItem" |
| 208 | + << this->properties.toString(); |
| 209 | + qCWarning(logStatusNotifierItem) << reply.error(); |
| 210 | + } |
| 211 | + |
| 212 | + delete call; |
| 213 | + }; |
| 214 | + |
| 215 | + QObject::connect(call, &QDBusPendingCallWatcher::finished, this, responseCallback); |
| 216 | +} |
181 | 217 |
|
182 | 218 | void StatusNotifierItem::scroll(qint32 delta, bool horizontal) { |
183 | 219 | this->item->Scroll(delta, horizontal ? "horizontal" : "vertical"); |
|
0 commit comments