diff --git a/interfaces/notificationsmodel.cpp b/interfaces/notificationsmodel.cpp index 71f6e051e..b22a4c4e3 100644 --- a/interfaces/notificationsmodel.cpp +++ b/interfaces/notificationsmodel.cpp @@ -60,6 +60,8 @@ QHash NotificationsModel::roleNames() const 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 @@ QVariant NotificationsModel::data(const QModelIndex& index, int role) const 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/interfaces/notificationsmodel.h b/interfaces/notificationsmodel.h index b3b9005a3..092356702 100644 --- a/interfaces/notificationsmodel.h +++ b/interfaces/notificationsmodel.h @@ -44,7 +44,9 @@ public: AppNameModelRole = Qt::UserRole + 1, IdModelRole, DismissableModelRole, - DbusInterfaceRole, + RepliableModelRole, + IconPathModelRole, + DbusInterfaceRole }; explicit NotificationsModel(QObject* parent = nullptr); diff --git a/plasmoid/package/contents/ui/DeviceDelegate.qml b/plasmoid/package/contents/ui/DeviceDelegate.qml index cd01ad251..a42e5bb7d 100644 --- a/plasmoid/package/contents/ui/DeviceDelegate.qml +++ b/plasmoid/package/contents/ui/DeviceDelegate.qml @@ -238,14 +238,29 @@ PlasmaComponents.ListItem 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; diff --git a/plugins/notifications/notification.cpp b/plugins/notifications/notification.cpp index df1b6df62..6d0483dde 100644 --- a/plugins/notifications/notification.cpp +++ b/plugins/notifications/notification.cpp @@ -120,7 +120,7 @@ KNotification* Notification::createKNotification(bool update, const NetworkPacka 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); @@ -128,6 +128,11 @@ KNotification* Notification::createKNotification(bool update, const NetworkPacka return mNotification; } +void Notification::reply() +{ + Q_EMIT replyRequested(); +} + void Notification::closed() { mClosed = true; diff --git a/plugins/notifications/notification.h b/plugins/notifications/notification.h index 967f46308..420347bbb 100644 --- a/plugins/notifications/notification.h +++ b/plugins/notifications/notification.h @@ -65,6 +65,7 @@ public: public Q_SLOTS: Q_SCRIPTABLE void dismiss(); Q_SCRIPTABLE void applyIconAndShow(); + Q_SCRIPTABLE void reply(); void closed(); Q_SIGNALS: