@@ -58,7 +58,8 @@ DBusNotifier::sendInteractiveNotification(const NotificationRequest &request)
5858 bool userInteracted = false ;
5959 QEventLoop loop;
6060
61- struct SignalGuard {
61+ struct SignalGuard
62+ {
6263 QMetaObject::Connection closeConn;
6364 QMetaObject::Connection actionConn;
6465
@@ -67,27 +68,29 @@ DBusNotifier::sendInteractiveNotification(const NotificationRequest &request)
6768 QObject::disconnect (closeConn);
6869 QObject::disconnect (actionConn);
6970 }
70- } signalGuard{{}, {}};
71+ } signalGuard{ {}, {} };
7172
7273 // 连接信号处理函数
73- signalGuard.closeConn = QObject::connect (this ,
74- &DBusNotifier::notificationClosed,
75- [&](quint32 id, quint32 closeReason) {
76- if (notificationID != 0 && id == notificationID) {
77- LogD (" Notification {} closed with reason: {}" , id, closeReason);
78- loop.quit ();
79- }
80- });
81-
82- signalGuard.actionConn = QObject::connect (this ,
83- &DBusNotifier::actionInvoked,
84- [&](quint32 id, const QString &actionKey) {
85- if (notificationID != 0 && id == notificationID) {
86- LogD (" Notification {} action invoked: {}" , id, actionKey.toStdString ());
87- choice = actionKey;
88- userInteracted = true ;
89- }
90- });
74+ signalGuard.closeConn =
75+ QObject::connect (this ,
76+ &DBusNotifier::notificationClosed,
77+ [&](quint32 id, quint32 closeReason) {
78+ if (notificationID != 0 && id == notificationID) {
79+ LogD (" Notification {} closed with reason: {}" , id, closeReason);
80+ loop.quit ();
81+ }
82+ });
83+
84+ signalGuard.actionConn = QObject::connect (
85+ this ,
86+ &DBusNotifier::actionInvoked,
87+ [&](quint32 id, const QString &actionKey) {
88+ if (notificationID != 0 && id == notificationID) {
89+ LogD (" Notification {} action invoked: {}" , id, actionKey.toStdString ());
90+ choice = actionKey;
91+ userInteracted = true ;
92+ }
93+ });
9194
9295 // 检查信号连接是否成功
9396 if (!signalGuard.closeConn || !signalGuard.actionConn ) {
0 commit comments