Changeset View
Changeset View
Standalone View
Standalone View
dialer/package/contents/ui/Dialpad/PhoneNumberInput.qml
1 | import QtQuick 2.0 | 1 | import QtQuick 2.0 | ||
---|---|---|---|---|---|
2 | import QtQuick.Controls.Styles 1.4 | 2 | import QtQuick.Controls.Styles 1.4 | ||
3 | import QtQuick.Layouts 1.1 | 3 | import QtQuick.Layouts 1.1 | ||
4 | import org.kde.plasma.core 2.0 as PlasmaCore | 4 | import org.kde.plasma.core 2.0 as PlasmaCore | ||
5 | import org.kde.plasma.components 2.0 as PlasmaComponents | 5 | import org.kde.plasma.components 2.0 as PlasmaComponents | ||
6 | 6 | | |||
7 | // TODO: search through contacts while typing | ||||
7 | PlasmaComponents.TextField { | 8 | PlasmaComponents.TextField { | ||
8 | id: root | 9 | id: root | ||
9 | 10 | | |||
10 | horizontalAlignment: Qt.AlignHCenter | 11 | horizontalAlignment: Qt.AlignHCenter | ||
11 | verticalAlignment: Qt.AlignBottom | 12 | verticalAlignment: Qt.AlignBottom | ||
12 | 13 | | |||
13 | style: TextFieldStyle { | 14 | style: TextFieldStyle { | ||
14 | background: Rectangle { | 15 | background: Rectangle { | ||
15 | opacity: 0 | 16 | opacity: 0 | ||
16 | } | 17 | } | ||
17 | } | 18 | } | ||
18 | 19 | | |||
20 | // append some text to the end of this input | ||||
19 | signal append(string digit) | 21 | signal append(string digit) | ||
20 | onAppend: { | 22 | onAppend: { | ||
21 | text += digit | 23 | text += digit | ||
22 | } | 24 | } | ||
23 | onTextChanged: { | 25 | onTextChanged: { | ||
24 | text = dialerUtils.formatNumber(text); | 26 | text = dialerUtils.formatNumber(text); | ||
25 | } | 27 | } | ||
26 | 28 | | |||
27 | // TODO: search through contacts while typing | 29 | // remove last character from this text input | ||
28 | 30 | signal pop() | |||
29 | Row { | 31 | onPop: { | ||
30 | anchors { | 32 | text = text.slice(0, -1) | ||
31 | right: parent.right | | |||
32 | rightMargin: 6 | | |||
33 | verticalCenter: parent.verticalCenter | | |||
34 | } | | |||
35 | | ||||
36 | PlasmaCore.IconItem { | | |||
37 | id: delBtn | | |||
38 | // ltr confusingly refers to the direction of the arrow in the icon, | | |||
39 | // not the text direction which it should be used in. | | |||
40 | source: LayoutMirroring.enabled ? | | |||
41 | "edit-clear-locationbar-ltr" : "edit-clear-locationbar-rtl" | | |||
42 | height: Math.max(root.height * 0.8, units.iconSizes.small) | | |||
43 | width: height | | |||
44 | opacity: (root.length > 0 && root.enabled) ? 1 : 0 | | |||
45 | visible: opacity > 0 | | |||
46 | Behavior on opacity { | | |||
47 | NumberAnimation { | | |||
48 | duration: units.longDuration | | |||
49 | easing.type: Easing.InOutQuad | | |||
50 | } | | |||
51 | } | | |||
52 | MouseArea { | | |||
53 | anchors.fill: parent | | |||
54 | onClicked: { | | |||
55 | if (text.length > 0) { | | |||
56 | text = text.slice(0, -1); | | |||
57 | } | | |||
58 | } | | |||
59 | } | | |||
60 | } | | |||
61 | } | 33 | } | ||
62 | } | 34 | } |