summaryrefslogtreecommitdiffstats
path: root/examples/declarative
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-03-05 03:31:45 (GMT)
committerMartin Jones <martin.jones@nokia.com>2010-03-05 03:31:45 (GMT)
commitad1621773b7096732d226ea4c13c6f9cf41fe141 (patch)
treedceb6d027154b77c7b01e0aec1a605e9720b20d0 /examples/declarative
parent8fa8dcd33f5395060a84f6b7062c927aa675cde6 (diff)
parentae6f59d8dffc1a0569640e374dde01ed84f9c542 (diff)
downloadQt-ad1621773b7096732d226ea4c13c6f9cf41fe141.zip
Qt-ad1621773b7096732d226ea4c13c6f9cf41fe141.tar.gz
Qt-ad1621773b7096732d226ea4c13c6f9cf41fe141.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
Diffstat (limited to 'examples/declarative')
-rw-r--r--examples/declarative/dynamic/dynamic.qml42
-rw-r--r--examples/declarative/tabwidget/TabWidget.qml44
-rw-r--r--examples/declarative/tabwidget/tab.pngbin0 -> 507 bytes
-rw-r--r--examples/declarative/tabwidget/tabs.qml49
-rw-r--r--examples/declarative/velocity/Day.qml2
5 files changed, 84 insertions, 53 deletions
diff --git a/examples/declarative/dynamic/dynamic.qml b/examples/declarative/dynamic/dynamic.qml
index 2831b0c..6af3e81 100644
--- a/examples/declarative/dynamic/dynamic.qml
+++ b/examples/declarative/dynamic/dynamic.qml
@@ -17,15 +17,17 @@ Item {
}
// stars (when there's no sun)
- Particles { id: stars
- x: 0; y: 0; width: parent.width; height: parent.height/2
+ Particles {
+ id: stars
+ x: 0; y: 0; width: parent.width; height: parent.height / 2
source: "images/star.png"; angleDeviation: 360; velocity: 0
velocityDeviation: 0; count: parent.width / 10; fadeInDuration: 2800
opacity: 1
}
// ground, which has a z such that the sun can set behind it
- Rectangle { id: ground
+ Rectangle {
+ id: ground
z: 2
anchors { left: parent.left; top: parent.verticalCenter; right: toolbox.right; bottom: parent.bottom }
gradient: Gradient {
@@ -35,7 +37,8 @@ Item {
}
//Day state, for when you place a sun
- states: State { name: "Day"; when: window.activeSuns > 0
+ states: State {
+ name: "Day"; when: window.activeSuns > 0
PropertyChanges { target: stopA; color: "DeepSkyBlue"}
PropertyChanges { target: stopB; color: "SkyBlue"}
PropertyChanges { target: stars; opacity: 0 }
@@ -56,56 +59,57 @@ Item {
width: 480
anchors { right: parent.right; top:parent.top; bottom: parent.bottom }
Rectangle { //Not a child of any positioner
- color: "white"; border.color: "black";
+ color: "white"; border.color: "black";
width: toolRow.width + 4
height: toolRow.height + 4
x: toolboxPositioner.x + toolRow.x - 2
y: toolboxPositioner.y + toolRow.y - 2
}
- Column{
+ Column {
id: toolboxPositioner
anchors.centerIn: parent
spacing: 8
- Text{ text: "Drag an item into the scene." }
- Row{ id: toolRow
- spacing: 8;
- PaletteItem{
+ Text { text: "Drag an item into the scene." }
+ Row {
+ id: toolRow
+ spacing: 8;
+ PaletteItem {
anchors.verticalCenter: parent.verticalCenter
file: "Sun.qml";
image: "../images/sun.png"
}
- PaletteItem{
+ PaletteItem {
file: "GenericItem.qml"
image: "../images/moon.png"
}
- PaletteItem{
+ PaletteItem {
anchors.verticalCenter: parent.verticalCenter
file: "PerspectiveItem.qml"
image: "../images/tree_s.png"
}
- PaletteItem{
+ PaletteItem {
anchors.verticalCenter: parent.verticalCenter
file: "PerspectiveItem.qml"
image: "../images/rabbit_brown.png"
}
- PaletteItem{
+ PaletteItem {
anchors.verticalCenter: parent.verticalCenter
file: "PerspectiveItem.qml"
image: "../images/rabbit_bw.png"
}
}
- Text{ text: "Active Suns: " + activeSuns }
+ Text { text: "Active Suns: " + activeSuns }
Rectangle { width: 440; height: 1; color: "black" }
- Text{ text: "Arbitrary QML: " }
+ Text { text: "Arbitrary QML: " }
TextEdit {
id: qmlText
width: 460
height: 220
readOnly: false
focusOnPress: true
- font.pixelSize: 16
-
- text: "import Qt 4.6\nImage { id: smile;\n x: 500*Math.random();\n y: 200*Math.random(); \n source: 'images/face-smile.png';\n opacity: NumberAnimation{ \n to: 0; duration: 1500;\n }\n Component.onCompleted: smile.destroy(1500);\n}"
+ font.pixelSize: 14
+
+ text: "import Qt 4.6\nImage {\n id: smile;\n x: 500*Math.random();\n y: 200*Math.random(); \n source: 'images/face-smile.png';\n NumberAnimation on opacity { \n to: 0; duration: 1500;\n }\n Component.onCompleted: smile.destroy(1500);\n}"
}
Button {
text: "Create"
diff --git a/examples/declarative/tabwidget/TabWidget.qml b/examples/declarative/tabwidget/TabWidget.qml
index f0dfee8..f0f7164 100644
--- a/examples/declarative/tabwidget/TabWidget.qml
+++ b/examples/declarative/tabwidget/TabWidget.qml
@@ -1,42 +1,50 @@
import Qt 4.6
Item {
- id: page
+ id: tabWidget
property int current: 0
default property alias content: stack.children
+
onCurrentChanged: setOpacities()
Component.onCompleted: setOpacities()
+
function setOpacities()
{
- for (var i=0; i<stack.children.length; ++i) {
- stack.children[i].opacity = i==current ? 1 : 0
+ for (var i = 0; i < stack.children.length; ++i) {
+ stack.children[i].opacity = i == current ? 1 : 0
}
}
+
Row {
id: header
Repeater {
delegate:
+ Rectangle {
+ width: tabWidget.width / stack.children.length; height: 36
Rectangle {
- width: page.width / stack.children.length
- height: 15
- color: page.current == index ? "grey" : "lightGrey"
- Text {
- anchors.fill: parent
- text: stack.children[index].title
- elide: Text.ElideRight
- }
- MouseArea {
- anchors.fill: parent
- onClicked: page.current = index
- }
+ color: "#acb2c2"; width: parent.width; height: 1
+ anchors { bottom: parent.bottom; bottomMargin: 1 }
+ }
+ BorderImage {
+ source: "tab.png"; visible: tabWidget.current == index; border.left: 7; border.right: 7
+ anchors { fill: parent; leftMargin: 2; topMargin: 5; rightMargin: 1 }
}
+ Text {
+ horizontalAlignment: Qt.AlignHCenter; verticalAlignment: Qt.AlignVCenter
+ anchors.fill: parent; text: stack.children[index].title
+ elide: Text.ElideRight; font.bold: tabWidget.current == index
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: tabWidget.current = index
+ }
+ }
model: stack.children.length
}
}
+
Item {
id: stack
- anchors.top: header.bottom
- anchors.bottom: page.bottom
- width: page.width
+ anchors.top: header.bottom; anchors.bottom: tabWidget.bottom; width: tabWidget.width
}
}
diff --git a/examples/declarative/tabwidget/tab.png b/examples/declarative/tabwidget/tab.png
new file mode 100644
index 0000000..ad80216
--- /dev/null
+++ b/examples/declarative/tabwidget/tab.png
Binary files differ
diff --git a/examples/declarative/tabwidget/tabs.qml b/examples/declarative/tabwidget/tabs.qml
index 54ed7df..1d11b03 100644
--- a/examples/declarative/tabwidget/tabs.qml
+++ b/examples/declarative/tabwidget/tabs.qml
@@ -2,28 +2,47 @@ import Qt 4.6
TabWidget {
id: tabs
- width: 200
- height: 200
- current: 2
+ width: 640; height: 480
+
Rectangle {
property string title: "Red"
- color: "red"
- anchors.fill: parent
- Text { anchors.centerIn: parent; text: "<div align=center>Roses are red"; font.pixelSize: 24
- wrap: true; width: parent.width-20 }
+ anchors.fill: parent; color: "#e3e3e3"
+ Rectangle {
+ anchors { fill: parent; topMargin: 20; leftMargin: 20; rightMargin: 20; bottomMargin: 20 }
+ color: "#ff7f7f"
+ Text {
+ anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter
+ text: "Roses are red"; font.pixelSize: 20
+ wrap: true; width: parent.width - 20
+ }
+ }
}
+
Rectangle {
property string title: "Green"
- color: "green"
- anchors.fill: parent
- Text { anchors.centerIn: parent; text: "<div align=center>Flower stems are green"; font.pixelSize: 24;
- wrap: true; width: parent.width-20 }
+ anchors.fill: parent; color: "#e3e3e3"
+ Rectangle {
+ anchors { fill: parent; topMargin: 20; leftMargin: 20; rightMargin: 20; bottomMargin: 20 }
+ color: "#7fff7f"
+ Text {
+ anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter
+ text: "Flower stems are green"; font.pixelSize: 20
+ wrap: true; width: parent.width - 20
+ }
+ }
}
+
Rectangle {
property string title: "Blue"
- color: "blue"
- anchors.fill: parent
- Text { anchors.centerIn: parent; text: "<div align=center>Violets are blue"; color: "white"; font.pixelSize: 24
- wrap: true; width: parent.width-20 }
+ anchors.fill: parent; color: "#e3e3e3"
+ Rectangle {
+ anchors { fill: parent; topMargin: 20; leftMargin: 20; rightMargin: 20; bottomMargin: 20 }
+ color: "#7f7fff"
+ Text {
+ anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter
+ text: "Violets are blue"; font.pixelSize: 20
+ wrap: true; width: parent.width - 20
+ }
+ }
}
}
diff --git a/examples/declarative/velocity/Day.qml b/examples/declarative/velocity/Day.qml
index 8a7364e..f4c24a5 100644
--- a/examples/declarative/velocity/Day.qml
+++ b/examples/declarative/velocity/Day.qml
@@ -52,7 +52,7 @@ Rectangle {
id: mouse
onClicked: { myText.focus = true }
anchors.fill: parent
- drag.target: stickyPage; drag.axis: "XandYAxis"; drag.minimumY: 0; drag.maximumY: 500
+ drag.target: stickyPage; drag.axis: MouseArea.XandYAxis; drag.minimumY: 0; drag.maximumY: 500
drag.minimumX: 0; drag.maximumX: 400
}
}