|
7 | 7 | #include <QQmlEngine> |
8 | 8 | #include <QGuiApplication> |
9 | 9 | #include <QLoggingCategory> |
10 | | -#include <QDBusInterface> |
11 | | -#include <QDBusPendingReply> |
12 | 10 | #include <QProcess> |
13 | | -#include <QDBusReply> |
14 | 11 |
|
15 | 12 | #include <DConfig> |
16 | 13 |
|
17 | 14 | #include "dataaccessor.h" |
| 15 | +#include <wayland/xdgactivation.h> |
18 | 16 |
|
19 | 17 | DCORE_USE_NAMESPACE |
20 | 18 |
|
@@ -210,21 +208,21 @@ bool NotifyAccessor::applicationPin(const QString &appId) const |
210 | 208 |
|
211 | 209 | void NotifyAccessor::openNotificationSetting() |
212 | 210 | { |
213 | | - qDebug(notifyLog) << "Open notification setting"; |
214 | | - QDBusMessage msg = QDBusMessage::createMethodCall("org.deepin.dde.ControlCenter1", |
215 | | - "/org/deepin/dde/ControlCenter1", |
216 | | - "org.deepin.dde.ControlCenter1", |
217 | | - "ShowPage"); |
218 | | - msg << "notification"; |
219 | | - QDBusPendingCall call = QDBusConnection::sessionBus().asyncCall(msg); |
220 | | - QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this); |
221 | | - connect(watcher, &QDBusPendingCallWatcher::finished, this, [this](QDBusPendingCallWatcher *self) { |
222 | | - QDBusReply<void> reply = *self; |
223 | | - if (!reply.isValid()) { |
224 | | - qWarning(notifyLog) << "Failed to open notification setting:" << reply.error().message(); |
| 211 | + qDebug(notifyLog) << "openNotificationSetting"; |
| 212 | + auto *activation = new ds::XdgActivation(this); |
| 213 | + connect(activation, &ds::XdgActivation::tokenReady, this, [activation](const QString &token) { |
| 214 | + QStringList args = {"--by-user", "org.deepin.dde.control-center"}; |
| 215 | + if (!token.isEmpty()) { |
| 216 | + qDebug(notifyLog) << "Passing XDG_ACTIVATION_TOKEN to dde-am"; |
| 217 | + args << "-e" << QStringLiteral("XDG_ACTIVATION_TOKEN=") + token; |
225 | 218 | } |
226 | | - self->deleteLater(); |
| 219 | + args << "--" |
| 220 | + << "-p" |
| 221 | + << "notification"; |
| 222 | + QProcess::startDetached("dde-am", args); |
| 223 | + activation->deleteLater(); |
227 | 224 | }); |
| 225 | + activation->requestToken(); |
228 | 226 | } |
229 | 227 |
|
230 | 228 | void NotifyAccessor::onNotificationStateChanged(qint64 id, int processedType) |
|
0 commit comments