Commit 1f5fd069 authored by Bharadwaj Raju's avatar Bharadwaj Raju
Browse files

[plasmoid] Add inline reply for notifications instead of opening a dialog

Instead of opening the reply dialog when clicking Reply in the plasmoid, it opens an inline reply UI.
parent ae0815ea
Pipeline #237215 passed with stage
in 4 minutes and 56 seconds
......@@ -275,6 +275,8 @@ PlasmaComponents.ListItem
enabled: true
onClicked: checked = !checked
property bool replying: false
PlasmaCore.IconItem {
id: notificationIcon
source: appIcon
......@@ -283,6 +285,7 @@ PlasmaComponents.ListItem
anchors.left: parent.left
}
PlasmaComponents.Label {
id: notificationLabel
text: appName + ": " + (title.length>0 ? (appName==title?notitext:title+": "+notitext) : model.name)
anchors.right: replyButton.left
anchors.left: notificationIcon.right
......@@ -293,11 +296,11 @@ PlasmaComponents.ListItem
PlasmaComponents.ToolButton {
id: replyButton
visible: repliable
enabled: repliable
enabled: repliable && !replying
anchors.right: dismissButton.left
iconSource: "mail-reply-sender"
tooltip: i18n("Reply")
onClicked: dbusInterface.reply();
onClicked: { replying = true; replyTextField.forceActiveFocus(); }
}
PlasmaComponents.ToolButton {
id: dismissButton
......@@ -308,6 +311,53 @@ PlasmaComponents.ListItem
tooltip: i18n("Dismiss")
onClicked: dbusInterface.dismiss();
}
RowLayout {
visible: replying
anchors.top: notificationLabel.bottom
anchors.left: notificationIcon.right
width: notificationLabel.width + replyButton.width + dismissButton.width
PlasmaComponents3.Button {
Layout.alignment: Qt.AlignBottom
id: replyCancelButton
text: i18n("Cancel")
display: PlasmaComponents3.AbstractButton.IconOnly
PlasmaComponents3.ToolTip {
text: parent.text
}
icon.name: "dialog-cancel"
onClicked: {
replyTextField.text = "";
replying = false;
}
}
PlasmaComponents3.TextArea {
id: replyTextField
placeholderText: i18nc("@info:placeholder", "Reply to %1…", appName)
Layout.fillWidth: true
Keys.onPressed: {
if ((event.key == Qt.Key_Return || event.key == Qt.Key_Enter) && !(event.modifiers & Qt.ShiftModifier)) {
replySendButton.clicked();
event.accepted = true;
}
if (event.key == Qt.Key_Escape) {
replyCancelButton.clicked();
event.accepted = true;
}
}
}
PlasmaComponents3.Button {
Layout.alignment: Qt.AlignBottom
id: replySendButton
text: i18n("Send")
icon.name: "document-send"
enabled: replyTextField.text
onClicked: {
dbusInterface.sendReply(replyTextField.text);
replyTextField.text = "";
replying = false;
}
}
}
}
}
......
......@@ -187,7 +187,12 @@ void Notification::reply()
Q_EMIT replyRequested();
}
void Notification::parseNetworkPacket(const NetworkPacket &np)
void Notification::sendReply(const QString& message)
{
Q_EMIT replied(message);
}
void Notification::parseNetworkPacket(const NetworkPacket& np)
{
m_internalId = np.get<QString>(QStringLiteral("id"));
m_appName = np.get<QString>(QStringLiteral("appName"));
......
......@@ -86,6 +86,7 @@ public:
public Q_SLOTS:
Q_SCRIPTABLE void dismiss();
Q_SCRIPTABLE void reply();
Q_SCRIPTABLE void sendReply(const QString& message);
Q_SIGNALS:
void dismissRequested(const QString &m_internalId);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment