show icon and reply toolbutton in plasmoid
Summary: Show an icon for each notification which has an icon. Show a toolbutton which can be used to reply to notifications which offer a quick reply. Reviewers: #kde_connect, albertvaka Reviewed By: #kde_connect, albertvaka Subscribers: albertvaka Maniphest Tasks: T4674, T4658 Differential Revision: https://phabricator.kde.org/D6058
This commit is contained in:
parent
4eeb329014
commit
8aaa18848e
5 changed files with 33 additions and 4 deletions
|
@ -60,6 +60,8 @@ QHash<int, QByteArray> 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<QObject*>(notification);
|
||||
case DismissableModelRole:
|
||||
return notification->dismissable();
|
||||
case RepliableModelRole:
|
||||
return !notification->replyId().isEmpty();
|
||||
case IconPathModelRole:
|
||||
return notification->iconPath();
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
|
|
|
@ -44,7 +44,9 @@ public:
|
|||
AppNameModelRole = Qt::UserRole + 1,
|
||||
IdModelRole,
|
||||
DismissableModelRole,
|
||||
DbusInterfaceRole,
|
||||
RepliableModelRole,
|
||||
IconPathModelRole,
|
||||
DbusInterfaceRole
|
||||
};
|
||||
|
||||
explicit NotificationsModel(QObject* parent = nullptr);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -65,6 +65,7 @@ public:
|
|||
public Q_SLOTS:
|
||||
Q_SCRIPTABLE void dismiss();
|
||||
Q_SCRIPTABLE void applyIconAndShow();
|
||||
Q_SCRIPTABLE void reply();
|
||||
void closed();
|
||||
|
||||
Q_SIGNALS:
|
||||
|
|
Loading…
Reference in a new issue