summaryrefslogtreecommitdiffstats
path: root/examples/declarative/ui-components/searchbox
diff options
context:
space:
mode:
Diffstat (limited to 'examples/declarative/ui-components/searchbox')
-rw-r--r--examples/declarative/ui-components/searchbox/SearchBox.qml65
-rw-r--r--examples/declarative/ui-components/searchbox/images/edit-clear-locationbar-rtl.pngbin0 -> 429 bytes
-rw-r--r--examples/declarative/ui-components/searchbox/images/lineedit-bg-focus.pngbin0 -> 526 bytes
-rw-r--r--examples/declarative/ui-components/searchbox/images/lineedit-bg.pngbin0 -> 426 bytes
-rw-r--r--examples/declarative/ui-components/searchbox/main.qml15
-rw-r--r--examples/declarative/ui-components/searchbox/searchbox.qmlproject16
6 files changed, 96 insertions, 0 deletions
diff --git a/examples/declarative/ui-components/searchbox/SearchBox.qml b/examples/declarative/ui-components/searchbox/SearchBox.qml
new file mode 100644
index 0000000..aae7ee9
--- /dev/null
+++ b/examples/declarative/ui-components/searchbox/SearchBox.qml
@@ -0,0 +1,65 @@
+import Qt 4.7
+
+FocusScope {
+ id: focusScope
+ width: 250; height: 28
+
+ BorderImage {
+ source: "images/lineedit-bg.png"
+ width: parent.width; height: parent.height
+ border { left: 4; top: 4; right: 4; bottom: 4 }
+ }
+
+ BorderImage {
+ source: "images/lineedit-bg-focus.png"
+ width: parent.width; height: parent.height
+ border { left: 4; top: 4; right: 4; bottom: 4 }
+ visible: parent.wantsFocus ? true : false
+ }
+
+ Text {
+ id: typeSomething
+ anchors.fill: parent; anchors.leftMargin: 8
+ verticalAlignment: Text.AlignVCenter
+ text: "Type something..."
+ color: "gray"
+ font.italic: true
+ }
+
+ MouseArea { anchors.fill: parent; onClicked: focusScope.focus = true }
+
+ TextInput {
+ id: textInput
+ anchors { left: parent.left; leftMargin: 8; verticalCenter: parent.verticalCenter }
+ focus: true
+ }
+
+ Image {
+ id: clear
+ anchors { right: parent.right; rightMargin: 8; verticalCenter: parent.verticalCenter }
+ source: "images/edit-clear-locationbar-rtl.png"
+ opacity: 0
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: { textInput.text = ''; focusScope.focus = true }
+ }
+ }
+
+ states: State {
+ name: "hasText"; when: textInput.text != ''
+ PropertyChanges { target: typeSomething; opacity: 0 }
+ PropertyChanges { target: clear; opacity: 1 }
+ }
+
+ transitions: [
+ Transition {
+ from: ""; to: "hasText"
+ NumberAnimation { exclude: typeSomething; properties: "opacity" }
+ },
+ Transition {
+ from: "hasText"; to: ""
+ NumberAnimation { properties: "opacity" }
+ }
+ ]
+}
diff --git a/examples/declarative/ui-components/searchbox/images/edit-clear-locationbar-rtl.png b/examples/declarative/ui-components/searchbox/images/edit-clear-locationbar-rtl.png
new file mode 100644
index 0000000..91eb270
--- /dev/null
+++ b/examples/declarative/ui-components/searchbox/images/edit-clear-locationbar-rtl.png
Binary files differ
diff --git a/examples/declarative/ui-components/searchbox/images/lineedit-bg-focus.png b/examples/declarative/ui-components/searchbox/images/lineedit-bg-focus.png
new file mode 100644
index 0000000..bbfac38
--- /dev/null
+++ b/examples/declarative/ui-components/searchbox/images/lineedit-bg-focus.png
Binary files differ
diff --git a/examples/declarative/ui-components/searchbox/images/lineedit-bg.png b/examples/declarative/ui-components/searchbox/images/lineedit-bg.png
new file mode 100644
index 0000000..9044226
--- /dev/null
+++ b/examples/declarative/ui-components/searchbox/images/lineedit-bg.png
Binary files differ
diff --git a/examples/declarative/ui-components/searchbox/main.qml b/examples/declarative/ui-components/searchbox/main.qml
new file mode 100644
index 0000000..9f73473
--- /dev/null
+++ b/examples/declarative/ui-components/searchbox/main.qml
@@ -0,0 +1,15 @@
+import Qt 4.7
+
+Rectangle {
+ width: 500; height: 250
+ color: "#edecec"
+
+ Column {
+ anchors { horizontalCenter: parent.horizontalCenter; verticalCenter: parent.verticalCenter }
+ spacing: 10
+
+ SearchBox { id: search1; KeyNavigation.tab: search2; KeyNavigation.backtab: search3; focus: true }
+ SearchBox { id: search2; KeyNavigation.tab: search3; KeyNavigation.backtab: search1 }
+ SearchBox { id: search3; KeyNavigation.tab: search1; KeyNavigation.backtab: search2 }
+ }
+}
diff --git a/examples/declarative/ui-components/searchbox/searchbox.qmlproject b/examples/declarative/ui-components/searchbox/searchbox.qmlproject
new file mode 100644
index 0000000..d4909f8
--- /dev/null
+++ b/examples/declarative/ui-components/searchbox/searchbox.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.0
+
+Project {
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+ /* List of plugin directories passed to QML runtime */
+ // importPaths: [ " ../exampleplugin " ]
+}