Changeset View
Changeset View
Standalone View
Standalone View
plasmoid/package/contents/ui/SearchField.qml
Show All 20 Lines | |||||
21 | */ | 21 | */ | ||
22 | 22 | | |||
23 | import QtQuick 2.1 | 23 | import QtQuick 2.1 | ||
24 | 24 | | |||
25 | import org.kde.plasma.components 2.0 as PlasmaComponents | 25 | import org.kde.plasma.components 2.0 as PlasmaComponents | ||
26 | import "globals.js" as Globals | 26 | import "globals.js" as Globals | ||
27 | 27 | | |||
28 | /* | 28 | /* | ||
29 | * The SearchField is a simple " Search |___input___|" widget. | 29 | * The SearchField is a simple text field widget. The only complex part | ||
30 | * The only complex part is aligning the "Search" text on the right | 30 | * is the internal timer to reduce the number of textChanged signals | ||
31 | * and an internal timer to reduce the number of textChanged signals | | |||
32 | * using searchTextChanged. | 31 | * using searchTextChanged. | ||
33 | */ | 32 | */ | ||
34 | Item { | 33 | Item { | ||
35 | signal searchTextChanged() | 34 | signal searchTextChanged() | ||
36 | property alias text: textField.text | 35 | property alias text: textField.text | ||
37 | 36 | | |||
38 | height: childrenRect.height | 37 | height: childrenRect.height | ||
39 | width: Globals.PlasmoidWidth | 38 | width: Globals.PlasmoidWidth | ||
40 | 39 | | |||
41 | PlasmaComponents.Label { | | |||
42 | id: searchText | | |||
43 | anchors { | | |||
44 | left: parent.left | | |||
45 | top: parent.top | | |||
46 | } | | |||
47 | // We cannot use anchors.rightMargin as this has an anchor on | | |||
48 | // left, so the rightMargin has no effect. | | |||
49 | // Because of this we also need to apply an appropriate leftMargin | | |||
50 | // on the textField below | | |||
51 | width: Globals.CategoryWidth - Globals.CategoryRightMargin | | |||
52 | | ||||
53 | horizontalAlignment: Text.AlignRight | | |||
54 | text: i18n("Search") | | |||
55 | } | | |||
56 | | ||||
57 | PlasmaComponents.TextField { | 40 | PlasmaComponents.TextField { | ||
58 | id: textField | 41 | id: textField | ||
59 | clearButtonShown: true | 42 | clearButtonShown: true | ||
43 | placeholderText: i18n("Search...") | ||||
60 | anchors { | 44 | anchors { | ||
61 | left: searchText.right | 45 | left: parent.left | ||
62 | right: parent.right | 46 | right: parent.right | ||
63 | top: parent.top | 47 | top: parent.top | ||
64 | | ||||
65 | leftMargin: Globals.CategoryRightMargin | | |||
66 | } | 48 | } | ||
67 | 49 | | |||
68 | focus: true | 50 | focus: true | ||
69 | Keys.forwardTo: listView | 51 | Keys.forwardTo: listView | ||
70 | 52 | | |||
71 | // We do not want to send the text instantly as that would result | 53 | // We do not want to send the text instantly as that would result | ||
72 | // in too many queries. Therefore we add a small 200msec delay | 54 | // in too many queries. Therefore we add a small 200msec delay | ||
73 | Timer { | 55 | Timer { | ||
Show All 20 Lines |