Changeset View
Changeset View
Standalone View
Standalone View
applets/notifications/package/contents/ui/NotificationReplyField.qml
Show All 20 Lines | |||||
21 | import QtQuick 2.8 | 21 | import QtQuick 2.8 | ||
22 | import QtQuick.Layouts 1.1 | 22 | import QtQuick.Layouts 1.1 | ||
23 | 23 | | |||
24 | import org.kde.plasma.components 2.0 as PlasmaComponents | 24 | import org.kde.plasma.components 2.0 as PlasmaComponents | ||
25 | 25 | | |||
26 | RowLayout { | 26 | RowLayout { | ||
27 | id: replyRow | 27 | id: replyRow | ||
28 | 28 | | |||
29 | signal beginReplyRequested | ||||
29 | signal replied(string text) | 30 | signal replied(string text) | ||
30 | 31 | | |||
32 | property bool replying: false | ||||
33 | | ||||
31 | property alias text: replyTextField.text | 34 | property alias text: replyTextField.text | ||
32 | property string placeholderText | 35 | property string placeholderText | ||
33 | property string buttonIconName | 36 | property string buttonIconName | ||
34 | property string buttonText | 37 | property string buttonText | ||
35 | 38 | | |||
36 | spacing: units.smallSpacing | 39 | spacing: units.smallSpacing | ||
37 | 40 | | |||
38 | function activate() { | 41 | function activate() { | ||
39 | replyTextField.forceActiveFocus(); | 42 | replyTextField.forceActiveFocus(); | ||
40 | } | 43 | } | ||
41 | 44 | | |||
42 | PlasmaComponents.TextField { | 45 | PlasmaComponents.TextField { | ||
43 | id: replyTextField | 46 | id: replyTextField | ||
44 | Layout.fillWidth: true | 47 | Layout.fillWidth: true | ||
45 | placeholderText: replyRow.replyPlaceholderText | 48 | placeholderText: replyRow.replyPlaceholderText | ||
46 | || i18ndc("plasma_applet_org.kde.plasma.notifications", "Text field placeholder", "Type a reply...") | 49 | || i18ndc("plasma_applet_org.kde.plasma.notifications", "Text field placeholder", "Type a reply...") | ||
47 | onAccepted: { | 50 | onAccepted: { | ||
48 | if (replyButton.enabled) { | 51 | if (replyButton.enabled) { | ||
49 | replyRow.replied(text); | 52 | replyRow.replied(text); | ||
50 | } | 53 | } | ||
51 | } | 54 | } | ||
55 | | ||||
56 | // Catches mouse click when reply field is already shown to start a reply | ||||
57 | MouseArea { | ||||
58 | anchors.fill: parent | ||||
59 | cursorShape: Qt.IBeamCursor | ||||
60 | visible: !replyRow.replying | ||||
61 | onPressed: replyRow.beginReplyRequested() | ||||
62 | } | ||||
52 | } | 63 | } | ||
53 | 64 | | |||
54 | PlasmaComponents.Button { | 65 | PlasmaComponents.Button { | ||
55 | id: replyButton | 66 | id: replyButton | ||
56 | Layout.preferredWidth: minimumWidth | 67 | Layout.preferredWidth: minimumWidth | ||
57 | iconName: replyRow.buttonIconName || "document-send" | 68 | iconName: replyRow.buttonIconName || "document-send" | ||
58 | text: replyRow.buttonText | 69 | text: replyRow.buttonText | ||
59 | || i18ndc("plasma_applet_org.kde.plasma.notifications", "@action:button", "Send") | 70 | || i18ndc("plasma_applet_org.kde.plasma.notifications", "@action:button", "Send") | ||
60 | enabled: replyTextField.length > 0 | 71 | enabled: replyTextField.length > 0 | ||
61 | onClicked: replyRow.replied(replyTextField.text) | 72 | onClicked: replyRow.replied(replyTextField.text) | ||
62 | } | 73 | } | ||
63 | } | 74 | } |