diff --git a/interfaces/notificationsmodel.h b/interfaces/notificationsmodel.h --- a/interfaces/notificationsmodel.h +++ b/interfaces/notificationsmodel.h @@ -44,7 +44,9 @@ AppNameModelRole = Qt::UserRole + 1, IdModelRole, DismissableModelRole, - DbusInterfaceRole, + RepliableModelRole, + IconPathModelRole, + DbusInterfaceRole }; explicit NotificationsModel(QObject* parent = nullptr); diff --git a/interfaces/notificationsmodel.cpp b/interfaces/notificationsmodel.cpp --- a/interfaces/notificationsmodel.cpp +++ b/interfaces/notificationsmodel.cpp @@ -60,6 +60,8 @@ names.insert(AppNameModelRole, "appName"); names.insert(IdModelRole, "notificationId"); names.insert(DismissableModelRole, "dismissable"); + names.insert(RepliableModelRole, "repliable"); + names.insert(IconPathModelRole, "appIcon"); return names; } @@ -192,6 +194,10 @@ return qVariantFromValue(notification); case DismissableModelRole: return notification->dismissable(); + case RepliableModelRole: + return !notification->replyId().isEmpty(); + case IconPathModelRole: + return notification->iconPath(); default: return QVariant(); } diff --git a/plasmoid/package/contents/ui/DeviceDelegate.qml b/plasmoid/package/contents/ui/DeviceDelegate.qml --- a/plasmoid/package/contents/ui/DeviceDelegate.qml +++ b/plasmoid/package/contents/ui/DeviceDelegate.qml @@ -238,15 +238,30 @@ enabled: true onClicked: checked = !checked + PlasmaCore.IconItem { + id: notificationIcon + source: appIcon + width: (valid && appIcon.length) ? dismissButton.width : 0 + height: width + anchors.left: parent.left + } PlasmaComponents.Label { text: appName + ": " + display - anchors.right: dismissButton.left - anchors.left: parent.left + anchors.right: replyButton.left + anchors.left: notificationIcon.right elide: listitem.checked ? Text.ElideNone : Text.ElideRight maximumLineCount: listitem.checked ? 0 : 1 wrapMode: Text.WordWrap } PlasmaComponents.ToolButton { + id: replyButton + visible: repliable + enabled: repliable + anchors.right: dismissButton.left + iconSource: "mail-reply-sender" + onClicked: dbusInterface.reply(); + } + PlasmaComponents.ToolButton { id: dismissButton visible: notificationsModel.isAnyDimissable; enabled: dismissable diff --git a/plugins/notifications/notification.h b/plugins/notifications/notification.h --- a/plugins/notifications/notification.h +++ b/plugins/notifications/notification.h @@ -65,6 +65,7 @@ public Q_SLOTS: Q_SCRIPTABLE void dismiss(); Q_SCRIPTABLE void applyIconAndShow(); + Q_SCRIPTABLE void reply(); void closed(); Q_SIGNALS: diff --git a/plugins/notifications/notification.cpp b/plugins/notifications/notification.cpp --- a/plugins/notifications/notification.cpp +++ b/plugins/notifications/notification.cpp @@ -120,14 +120,19 @@ if(!mRequestReplyId.isEmpty()) { mNotification->setActions( QStringList(i18n("Reply")) ); - connect(mNotification, &KNotification::action1Activated, this, &Notification::replyRequested); + connect(mNotification, &KNotification::action1Activated, this, &Notification::reply); } connect(mNotification, &KNotification::closed, this, &Notification::closed); return mNotification; } +void Notification::reply() +{ + Q_EMIT replyRequested(); +} + void Notification::closed() { mClosed = true;