From fbd212abb05fee0ff9c9faf00c40136f0b901707 Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Fri, 16 Oct 2009 17:30:45 +1000 Subject: Add simple examples --- examples/declarative/progressbar/ProgressBar.qml | 36 ++++++++++++++++ .../declarative/progressbar/images/lineedit-bg.png | Bin 0 -> 426 bytes .../progressbar/images/progressbar-background.png | Bin 0 -> 541 bytes .../progressbar/images/progressbar-highlight.png | Bin 0 -> 1015 bytes examples/declarative/progressbar/main.qml | 23 ++++++++++ examples/declarative/searchbox/SearchBox.qml | 47 +++++++++++++++++++++ .../images/edit-clear-locationbar-rtl.png | Bin 0 -> 859 bytes .../searchbox/images/lineedit-bg-focus.png | Bin 0 -> 526 bytes .../declarative/searchbox/images/lineedit-bg.png | Bin 0 -> 426 bytes examples/declarative/searchbox/main.qml | 13 ++++++ 10 files changed, 119 insertions(+) create mode 100644 examples/declarative/progressbar/ProgressBar.qml create mode 100644 examples/declarative/progressbar/images/lineedit-bg.png create mode 100644 examples/declarative/progressbar/images/progressbar-background.png create mode 100644 examples/declarative/progressbar/images/progressbar-highlight.png create mode 100644 examples/declarative/progressbar/main.qml create mode 100644 examples/declarative/searchbox/SearchBox.qml create mode 100644 examples/declarative/searchbox/images/edit-clear-locationbar-rtl.png create mode 100644 examples/declarative/searchbox/images/lineedit-bg-focus.png create mode 100644 examples/declarative/searchbox/images/lineedit-bg.png create mode 100644 examples/declarative/searchbox/main.qml diff --git a/examples/declarative/progressbar/ProgressBar.qml b/examples/declarative/progressbar/ProgressBar.qml new file mode 100644 index 0000000..48346ac --- /dev/null +++ b/examples/declarative/progressbar/ProgressBar.qml @@ -0,0 +1,36 @@ +import Qt 4.6 + +Item { + id: progressbar + width: 250; height: 23; clip: true + + property int minimum: 0 + property int maximum: 100 + property int value: 0 + property alias color: g1.color + property alias secondColor: g2.color + + BorderImage { + source: "images/lineedit-bg.png" + width: parent.width; height: parent.height + border.left: 4; border.top: 4; border.right: 4; border.bottom: 4 + } + + Rectangle { + property int widthDest: (progressbar.width * (value - minimum)) / (maximum - minimum) - 6 + id: highlight; radius: 2 + anchors.left: parent.left; anchors.top: parent.top; anchors.bottom: parent.bottom + anchors.leftMargin: 3; anchors.topMargin: 3; anchors.bottomMargin: 3 + width: EaseFollow { source: highlight.widthDest; duration: 100 } + gradient: Gradient { + GradientStop { id: g1; position: 0.0 } + GradientStop { id: g2; position: 1.0 } + } + } + Text { + anchors.right: highlight.right; anchors.rightMargin: 6 + color: "white"; font.bold: true + anchors.verticalCenter: parent.verticalCenter + text: Math.floor((value - minimum) / (maximum - minimum) * 100) + '%' + } +} diff --git a/examples/declarative/progressbar/images/lineedit-bg.png b/examples/declarative/progressbar/images/lineedit-bg.png new file mode 100644 index 0000000..9044226 Binary files /dev/null and b/examples/declarative/progressbar/images/lineedit-bg.png differ diff --git a/examples/declarative/progressbar/images/progressbar-background.png b/examples/declarative/progressbar/images/progressbar-background.png new file mode 100644 index 0000000..e36bcfc Binary files /dev/null and b/examples/declarative/progressbar/images/progressbar-background.png differ diff --git a/examples/declarative/progressbar/images/progressbar-highlight.png b/examples/declarative/progressbar/images/progressbar-highlight.png new file mode 100644 index 0000000..987d455 Binary files /dev/null and b/examples/declarative/progressbar/images/progressbar-highlight.png differ diff --git a/examples/declarative/progressbar/main.qml b/examples/declarative/progressbar/main.qml new file mode 100644 index 0000000..32353fc --- /dev/null +++ b/examples/declarative/progressbar/main.qml @@ -0,0 +1,23 @@ +import Qt 4.6 + +Rectangle { + id: main + width: 800; height: 580; color: "#edecec" + + Flickable { + anchors.fill: parent; viewportHeight: column.height + Column { + id: column; spacing: 4 + Repeater { + model: 50 + ProgressBar { + property int r: Math.floor(Math.random() * 4000 + 1000) + width: main.width + value: NumberAnimation { duration: r; from: 0; to: 100; running: true; repeat: true } + color: ColorAnimation { duration: r; from: "lightsteelblue"; to: "thistle"; running: true; repeat: true } + secondColor: ColorAnimation { duration: r; from: "steelblue"; to: "#CD96CD"; running: true; repeat: true } + } + } + } + } +} diff --git a/examples/declarative/searchbox/SearchBox.qml b/examples/declarative/searchbox/SearchBox.qml new file mode 100644 index 0000000..90d4367 --- /dev/null +++ b/examples/declarative/searchbox/SearchBox.qml @@ -0,0 +1,47 @@ +import Qt 4.6 + +FocusScope { + id: focusScope + width: 250; height: 28 + + BorderImage { + source: "images/lineedit-bg.png" + width: parent.width; height: parent.height + border.left: 4; border.top: 4; border.right: 4; border.bottom: 4 + } + + BorderImage { + source: "images/lineedit-bg-focus.png" + width: parent.width; height: parent.height + border.left: 4; border.top: 4; border.right: 4; border.bottom: 4 + visible: parent.wantsFocus ? true : false + } + + Text { + anchors.fill: parent; anchors.leftMargin: 8 + verticalAlignment: Text.AlignVCenter + text: "Type something..."; color: "gray"; font.italic: true + opacity: textInput.text == "" ? 1 : 0 + //opacity: Behavior { NumberAnimation { duration: 200 } } + } + + MouseRegion { anchors.fill: parent; onClicked: focusScope.focus = true } + + + TextInput { + id: textInput + anchors.left: parent.left; anchors.leftMargin: 8 + //anchors.right: clear.left + anchors.verticalCenter: parent.verticalCenter + focus: if(1) true + } + Image { + id: clear + anchors.right: parent.right; anchors.rightMargin: 8 + anchors.verticalCenter: parent.verticalCenter + source: "images/edit-clear-locationbar-rtl.png" + opacity: textInput.text == "" ? 0 : 1 + //opacity: Behavior { NumberAnimation { duration: 200 } } + MouseRegion { anchors.fill: parent; onClicked: { textInput.text = ''; focusScope.focus = true } } + } +} diff --git a/examples/declarative/searchbox/images/edit-clear-locationbar-rtl.png b/examples/declarative/searchbox/images/edit-clear-locationbar-rtl.png new file mode 100644 index 0000000..45ae477 Binary files /dev/null and b/examples/declarative/searchbox/images/edit-clear-locationbar-rtl.png differ diff --git a/examples/declarative/searchbox/images/lineedit-bg-focus.png b/examples/declarative/searchbox/images/lineedit-bg-focus.png new file mode 100644 index 0000000..bbfac38 Binary files /dev/null and b/examples/declarative/searchbox/images/lineedit-bg-focus.png differ diff --git a/examples/declarative/searchbox/images/lineedit-bg.png b/examples/declarative/searchbox/images/lineedit-bg.png new file mode 100644 index 0000000..9044226 Binary files /dev/null and b/examples/declarative/searchbox/images/lineedit-bg.png differ diff --git a/examples/declarative/searchbox/main.qml b/examples/declarative/searchbox/main.qml new file mode 100644 index 0000000..39c3720 --- /dev/null +++ b/examples/declarative/searchbox/main.qml @@ -0,0 +1,13 @@ +import Qt 4.6 + +Rectangle { + width: 500; height: 250; color: "#edecec" + + Column { + anchors.horizontalCenter: parent.horizontalCenter; anchors.verticalCenter: parent.verticalCenter; spacing: 10 + + SearchBox { id: search1; KeyNavigation.down: search2; focus: true } + SearchBox { id: search2; KeyNavigation.up: search1; KeyNavigation.down: search3 } + SearchBox { id: search3; KeyNavigation.up: search2 } + } +} -- cgit v0.12 From 0fef8fe9390ddf3b0dff0a54f50a2f61c3449950 Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Fri, 16 Oct 2009 17:46:52 +1000 Subject: Remove unused files --- .../progressbar/images/progressbar-background.png | Bin 541 -> 0 bytes .../progressbar/images/progressbar-highlight.png | Bin 1015 -> 0 bytes 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 examples/declarative/progressbar/images/progressbar-background.png delete mode 100644 examples/declarative/progressbar/images/progressbar-highlight.png diff --git a/examples/declarative/progressbar/images/progressbar-background.png b/examples/declarative/progressbar/images/progressbar-background.png deleted file mode 100644 index e36bcfc..0000000 Binary files a/examples/declarative/progressbar/images/progressbar-background.png and /dev/null differ diff --git a/examples/declarative/progressbar/images/progressbar-highlight.png b/examples/declarative/progressbar/images/progressbar-highlight.png deleted file mode 100644 index 987d455..0000000 Binary files a/examples/declarative/progressbar/images/progressbar-highlight.png and /dev/null differ -- cgit v0.12