summaryrefslogtreecommitdiffstats
path: root/demos
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@nokia.com>2010-03-25 07:42:21 (GMT)
committerMorten Johan Sørvig <morten.sorvig@nokia.com>2010-03-25 07:42:21 (GMT)
commit20779098f4eb73f8789d704e1a2818ddbbf5b4d2 (patch)
treeb1c4e3edb447ee47f9bc724f106d1bbefcff5456 /demos
parent8cc346604ed1e1504964772613ed9fe531361f69 (diff)
parent194013d9db1b3e4ba6f56a864f3b64f523202948 (diff)
downloadQt-20779098f4eb73f8789d704e1a2818ddbbf5b4d2.zip
Qt-20779098f4eb73f8789d704e1a2818ddbbf5b4d2.tar.gz
Qt-20779098f4eb73f8789d704e1a2818ddbbf5b4d2.tar.bz2
Merge remote branch 'main/4.7' into 4.7
Conflicts: demos/declarative/minehunt/minehunt.cpp src/declarative/qml/qdeclarativecompiler.cpp
Diffstat (limited to 'demos')
-rw-r--r--demos/declarative/calculator/calculator.js2
-rw-r--r--demos/declarative/calculator/calculator.qml4
-rw-r--r--demos/declarative/flickr/common/Loading.qml4
-rw-r--r--demos/declarative/flickr/flickr-desktop.qml38
-rw-r--r--demos/declarative/flickr/mobile/GridDelegate.qml34
-rw-r--r--demos/declarative/flickr/mobile/TitleBar.qml14
-rw-r--r--demos/declarative/minehunt/README2
-rw-r--r--demos/declarative/minehunt/minehunt.cpp24
-rw-r--r--demos/declarative/photoviewer/PhotoViewerCore/AlbumDelegate.qml37
-rw-r--r--demos/declarative/photoviewer/PhotoViewerCore/BusyIndicator.qml2
-rw-r--r--demos/declarative/photoviewer/PhotoViewerCore/Button.qml6
-rw-r--r--demos/declarative/photoviewer/PhotoViewerCore/EditableButton.qml53
-rw-r--r--demos/declarative/photoviewer/PhotoViewerCore/PhotoDelegate.qml15
-rw-r--r--demos/declarative/photoviewer/PhotoViewerCore/Tag.qml11
-rw-r--r--demos/declarative/photoviewer/PhotoViewerCore/qmldir3
-rw-r--r--demos/declarative/photoviewer/PhotoViewerCore/script/script.js2
-rw-r--r--demos/declarative/photoviewer/photoviewer.qml14
-rwxr-xr-xdemos/declarative/samegame/SamegameCore/samegame.js5
-rw-r--r--demos/declarative/samegame/samegame.qml15
-rw-r--r--demos/declarative/snake/content/HighScoreModel.qml26
-rw-r--r--demos/declarative/snake/snake.qml27
-rw-r--r--demos/declarative/twitter/TwitterCore/Loading.qml4
-rw-r--r--demos/declarative/webbrowser/content/FlickableWebView.qml24
-rw-r--r--demos/declarative/webbrowser/content/fieldtext/FieldText.qml38
24 files changed, 246 insertions, 158 deletions
diff --git a/demos/declarative/calculator/calculator.js b/demos/declarative/calculator/calculator.js
index cd6490a..f172daf 100644
--- a/demos/declarative/calculator/calculator.js
+++ b/demos/declarative/calculator/calculator.js
@@ -14,7 +14,7 @@ function disabled(op) {
}
}
-function doOp(op) {
+function doOperation(op) {
if (disabled(op)) {
return;
}
diff --git a/demos/declarative/calculator/calculator.qml b/demos/declarative/calculator/calculator.qml
index 66705e2..1644968 100644
--- a/demos/declarative/calculator/calculator.qml
+++ b/demos/declarative/calculator/calculator.qml
@@ -1,10 +1,12 @@
import Qt 4.6
+import "calculator.js" as CalcEngine
Rectangle {
width: 320; height: 270; color: palette.window
+ function doOp(operation) { CalcEngine.doOperation(operation); }
+
SystemPalette { id: palette }
- Script { source: "calculator.js" }
Column {
x: 2; spacing: 10;
diff --git a/demos/declarative/flickr/common/Loading.qml b/demos/declarative/flickr/common/Loading.qml
index 938a080..4c41717 100644
--- a/demos/declarative/flickr/common/Loading.qml
+++ b/demos/declarative/flickr/common/Loading.qml
@@ -1,8 +1,8 @@
import Qt 4.6
Image {
- id: loading; source: "pics/loading.png"; transformOrigin: "Center"
+ id: loading; source: "pics/loading.png"
NumberAnimation on rotation {
- from: 0; to: 360; running: loading.visible == true; repeat: true; duration: 900
+ from: 0; to: 360; running: loading.visible == true; loops: Animation.Infinite; duration: 900
}
}
diff --git a/demos/declarative/flickr/flickr-desktop.qml b/demos/declarative/flickr/flickr-desktop.qml
index 99216cb..63b6ea2 100644
--- a/demos/declarative/flickr/flickr-desktop.qml
+++ b/demos/declarative/flickr/flickr-desktop.qml
@@ -31,21 +31,19 @@ Item {
}
}
- Script {
- function photoClicked() {
- imageDetails.photoTitle = title;
- imageDetails.photoDescription = description;
- imageDetails.photoTags = tags;
- imageDetails.photoWidth = photoWidth;
- imageDetails.photoHeight = photoHeight;
- imageDetails.photoType = photoType;
- imageDetails.photoAuthor = photoAuthor;
- imageDetails.photoDate = photoDate;
- imageDetails.photoUrl = url;
- imageDetails.rating = 0;
- wrapper.state = "Details";
- }
- }
+ function photoClicked() {
+ imageDetails.photoTitle = title;
+ imageDetails.photoDescription = description;
+ imageDetails.photoTags = tags;
+ imageDetails.photoWidth = photoWidth;
+ imageDetails.photoHeight = photoHeight;
+ imageDetails.photoType = photoType;
+ imageDetails.photoAuthor = photoAuthor;
+ imageDetails.photoDate = photoDate;
+ imageDetails.photoUrl = url;
+ imageDetails.rating = 0;
+ wrapper.state = "Details";
+ }
Rectangle {
id: whiteRect; anchors.fill: parent; color: "white"; radius: 5
@@ -85,15 +83,17 @@ Item {
Transition {
from: "*"; to: "Details"
SequentialAnimation {
- ParentAction { }
- NumberAnimation { properties: "x,y,scale,opacity,angle"; duration: 500; easing.type: "InOutQuad" }
+ ParentAnimation {
+ NumberAnimation { properties: "x,y,scale,opacity,angle"; duration: 500; easing.type: "InOutQuad" }
+ }
}
},
Transition {
from: "Details"; to: "*"
SequentialAnimation {
- ParentAction { }
- NumberAnimation { properties: "x,y,scale,opacity,angle"; duration: 500; easing.type: "InOutQuad" }
+ ParentAnimation {
+ NumberAnimation { properties: "x,y,scale,opacity,angle"; duration: 500; easing.type: "InOutQuad" }
+ }
PropertyAction { targets: wrapper; properties: "z" }
}
}
diff --git a/demos/declarative/flickr/mobile/GridDelegate.qml b/demos/declarative/flickr/mobile/GridDelegate.qml
index 291d874..b54585b 100644
--- a/demos/declarative/flickr/mobile/GridDelegate.qml
+++ b/demos/declarative/flickr/mobile/GridDelegate.qml
@@ -5,19 +5,17 @@
Item {
id: wrapper; width: 79; height: 79
- Script {
- function photoClicked() {
- imageDetails.photoTitle = title;
- imageDetails.photoTags = tags;
- imageDetails.photoWidth = photoWidth;
- imageDetails.photoHeight = photoHeight;
- imageDetails.photoType = photoType;
- imageDetails.photoAuthor = photoAuthor;
- imageDetails.photoDate = photoDate;
- imageDetails.photoUrl = url;
- imageDetails.rating = 0;
- scaleMe.state = "Details";
- }
+ function photoClicked() {
+ imageDetails.photoTitle = title;
+ imageDetails.photoTags = tags;
+ imageDetails.photoWidth = photoWidth;
+ imageDetails.photoHeight = photoHeight;
+ imageDetails.photoType = photoType;
+ imageDetails.photoAuthor = photoAuthor;
+ imageDetails.photoDate = photoDate;
+ imageDetails.photoUrl = url;
+ imageDetails.rating = 0;
+ scaleMe.state = "Details";
}
Item {
@@ -54,14 +52,16 @@
transitions: [
Transition {
from: "Show"; to: "Details"
- ParentAction { }
- NumberAnimation { properties: "x,y"; duration: 500; easing.type: "InOutQuad" }
+ ParentAnimation {
+ NumberAnimation { properties: "x,y"; duration: 500; easing.type: "InOutQuad" }
+ }
},
Transition {
from: "Details"; to: "Show"
SequentialAnimation {
- ParentAction { }
- NumberAnimation { properties: "x,y"; duration: 500; easing.type: "InOutQuad" }
+ ParentAnimation {
+ NumberAnimation { properties: "x,y"; duration: 500; easing.type: "InOutQuad" }
+ }
PropertyAction { targets: wrapper; properties: "z" }
}
}
diff --git a/demos/declarative/flickr/mobile/TitleBar.qml b/demos/declarative/flickr/mobile/TitleBar.qml
index 0a06771..e92ba59 100644
--- a/demos/declarative/flickr/mobile/TitleBar.qml
+++ b/demos/declarative/flickr/mobile/TitleBar.qml
@@ -11,12 +11,10 @@ Item {
id: container
width: (parent.width * 2) - 55 ; height: parent.height
- Script {
- function accept() {
- titleBar.state = ""
- background.state = ""
- rssModel.tags = editor.text
- }
+ function accept() {
+ titleBar.state = ""
+ background.state = ""
+ rssModel.tags = editor.text
}
Text {
@@ -32,7 +30,7 @@ Item {
Button {
id: tagButton; x: titleBar.width - 50; width: 45; height: 32; text: "..."
- onClicked: if (titleBar.state == "Tags") accept(); else titleBar.state = "Tags"
+ onClicked: if (titleBar.state == "Tags") container.accept(); else titleBar.state = "Tags"
anchors.verticalCenter: parent.verticalCenter
}
@@ -57,7 +55,7 @@ Item {
Item {
id: returnKey
- Keys.onReturnPressed: accept()
+ Keys.onReturnPressed: container.accept()
Keys.onEscapePressed: titleBar.state = ""
}
}
diff --git a/demos/declarative/minehunt/README b/demos/declarative/minehunt/README
index 7379dcf..1b6cf81 100644
--- a/demos/declarative/minehunt/README
+++ b/demos/declarative/minehunt/README
@@ -1,3 +1,5 @@
+To compile the C++ part, do 'qmake && make'. Minehunt will not run properly if the C++ plugin is not compiled.
+
To run, simply load the minehunt.qml file with the qml runtime.
Note that on X11, this demo has problems with the native graphicssystem. If you are using the X11 window system, please pass -graphicssystem raster to the qml binary.
diff --git a/demos/declarative/minehunt/minehunt.cpp b/demos/declarative/minehunt/minehunt.cpp
index e5f1ddb..a953c5a 100644
--- a/demos/declarative/minehunt/minehunt.cpp
+++ b/demos/declarative/minehunt/minehunt.cpp
@@ -92,7 +92,7 @@ public:
MinehuntGame();
Q_PROPERTY(QDeclarativeListProperty<Tile> tiles READ tiles CONSTANT)
- QDeclarativeListProperty<Tile> tiles() { return QDeclarativeListProperty<Tile>(this, _tiles); }
+ QDeclarativeListProperty<Tile> tiles();
Q_PROPERTY(bool isPlaying READ isPlaying NOTIFY isPlayingChanged)
bool isPlaying() {return playing;}
@@ -134,6 +134,28 @@ private:
int nFlags;
};
+void tilesPropAppend(QDeclarativeListProperty<Tile>* prop, Tile* value)
+{
+ Q_UNUSED(prop);
+ Q_UNUSED(value);
+ return; //Append not supported
+}
+
+int tilesPropCount(QDeclarativeListProperty<Tile>* prop)
+{
+ return static_cast<QList<Tile*>*>(prop->data)->count();
+}
+
+Tile* tilesPropAt(QDeclarativeListProperty<Tile>* prop, int index)
+{
+ return static_cast<QList<Tile*>*>(prop->data)->at(index);
+}
+
+QDeclarativeListProperty<Tile> MinehuntGame::tiles(){
+ return QDeclarativeListProperty<Tile>(this, &_tiles, &tilesPropAppend,
+ &tilesPropCount, &tilesPropAt, 0);
+}
+
MinehuntGame::MinehuntGame()
: numCols(9), numRows(9), playing(true), won(false)
{
diff --git a/demos/declarative/photoviewer/PhotoViewerCore/AlbumDelegate.qml b/demos/declarative/photoviewer/PhotoViewerCore/AlbumDelegate.qml
index fca7232..fb68cfc 100644
--- a/demos/declarative/photoviewer/PhotoViewerCore/AlbumDelegate.qml
+++ b/demos/declarative/photoviewer/PhotoViewerCore/AlbumDelegate.qml
@@ -25,8 +25,7 @@ Component {
Item {
Package.name: 'album'
- id: albumWrapper
- width: 210; height: 220
+ id: albumWrapper; width: 210; height: 220
VisualDataModel {
id: visualModel; delegate: PhotoDelegate { }
@@ -34,13 +33,15 @@ Component {
}
BusyIndicator {
+ id: busyIndicator
anchors { centerIn: parent; verticalCenterOffset: -20 }
on: rssModel.status != XmlListModel.Ready
}
PathView {
id: photosPathView; model: visualModel.parts.stack; pathItemCount: 5
- anchors.centerIn: parent; anchors.verticalCenterOffset: -20
+ visible: !busyIndicator.visible
+ anchors.centerIn: parent; anchors.verticalCenterOffset: -30
path: Path {
PathAttribute { name: 'z'; value: 9999.0 }
PathLine { x: 1; y: 1 }
@@ -48,21 +49,16 @@ Component {
}
}
- Tag {
- anchors.horizontalCenter: parent.horizontalCenter; anchors.bottom: parent.bottom
- frontLabel: tag; backLabel: "Delete"; rotation: Math.random() * (2 * 6 + 1) - 6
- flipped: mainWindow.editMode
- }
-
MouseArea {
anchors.fill: parent
- onClicked: {
- if (mainWindow.editMode) {
- photosModel.remove(index)
- } else {
- albumWrapper.state = 'inGrid'
- }
- }
+ onClicked: mainWindow.editMode ? photosModel.remove(index) : albumWrapper.state = 'inGrid'
+ }
+
+ Tag {
+ anchors { horizontalCenter: parent.horizontalCenter; bottom: parent.bottom; bottomMargin: 10 }
+ frontLabel: tag; backLabel: "Delete"; flipped: mainWindow.editMode
+ onTagChanged: rssModel.tags = tag
+ onBackClicked: if (mainWindow.editMode) photosModel.remove(index);
}
states: [
@@ -77,10 +73,17 @@ Component {
PropertyChanges { target: photosGridView; interactive: false }
PropertyChanges { target: photosListView; interactive: true }
PropertyChanges { target: photosShade; opacity: 1 }
- PropertyChanges { target: backButton; y: -backTag.height - 8 }
+ PropertyChanges { target: backButton; y: -backButton.height - 8 }
}
]
+ GridView.onAdd: NumberAnimation { target: albumWrapper; properties: "scale"; from: 0.0; to: 1.0 }
+ GridView.onRemove: SequentialAnimation {
+ PropertyAction { target: albumWrapper.GridView; property: "delayRemove"; value: true }
+ NumberAnimation { target: albumWrapper; property: "scale"; from: 1.0; to: 0.0 }
+ PropertyAction { target: albumWrapper.GridView; property: "delayRemove"; value: false }
+ }
+
transitions: [
Transition {
from: '*'; to: 'inGrid'
diff --git a/demos/declarative/photoviewer/PhotoViewerCore/BusyIndicator.qml b/demos/declarative/photoviewer/PhotoViewerCore/BusyIndicator.qml
index 919ac43..361659c 100644
--- a/demos/declarative/photoviewer/PhotoViewerCore/BusyIndicator.qml
+++ b/demos/declarative/photoviewer/PhotoViewerCore/BusyIndicator.qml
@@ -5,5 +5,5 @@ Image {
property bool on: false
source: "images/busy.png"; visible: container.on
- NumberAnimation on rotation { running: container.on; from: 0; to: 360; repeat: true; duration: 1200 }
+ NumberAnimation on rotation { running: container.on; from: 0; to: 360; loops: Animation.Infinite; duration: 1200 }
}
diff --git a/demos/declarative/photoviewer/PhotoViewerCore/Button.qml b/demos/declarative/photoviewer/PhotoViewerCore/Button.qml
index fb28314..cdf86af 100644
--- a/demos/declarative/photoviewer/PhotoViewerCore/Button.qml
+++ b/demos/declarative/photoviewer/PhotoViewerCore/Button.qml
@@ -4,6 +4,7 @@ Item {
id: container
property alias label: labelText.text
+ property string tint: ""
signal clicked
width: labelText.width + 70 ; height: labelText.height + 18
@@ -16,6 +17,11 @@ Item {
Image { anchors.fill: parent; source: "images/cardboard.png"; smooth: true }
+ Rectangle {
+ anchors.fill: container; color: container.tint; visible: container.tint != ""
+ opacity: 0.1; smooth: true
+ }
+
Text { id: labelText; font.pixelSize: 15; anchors.centerIn: parent; smooth: true }
MouseArea {
diff --git a/demos/declarative/photoviewer/PhotoViewerCore/EditableButton.qml b/demos/declarative/photoviewer/PhotoViewerCore/EditableButton.qml
new file mode 100644
index 0000000..5ea79a1
--- /dev/null
+++ b/demos/declarative/photoviewer/PhotoViewerCore/EditableButton.qml
@@ -0,0 +1,53 @@
+import Qt 4.6
+
+Item {
+ id: container
+
+ property string label
+ property string tint: ""
+ signal clicked
+ signal labelChanged(string label)
+
+ width: labelText.width + 70 ; height: labelText.height + 18
+
+ BorderImage {
+ anchors { fill: container; leftMargin: -6; topMargin: -6; rightMargin: -8; bottomMargin: -8 }
+ source: 'images/box-shadow.png'; smooth: true
+ border.left: 10; border.top: 10; border.right: 10; border.bottom: 10
+ }
+
+ Image { anchors.fill: parent; source: "images/cardboard.png"; smooth: true }
+
+ Rectangle {
+ anchors.fill: container; color: container.tint; visible: container.tint != ""
+ opacity: 0.1; smooth: true
+ }
+
+ Text { id: labelText; text: label; font.pixelSize: 15; anchors.centerIn: parent; smooth: true }
+
+ TextInput {
+ id: textInput; text: label; font.pixelSize: 15; anchors.centerIn: parent; smooth: true; visible: false
+ Keys.onReturnPressed: container.labelChanged(textInput.text)
+ Keys.onEscapePressed: {
+ textInput.text = labelText.text
+ container.state = ''
+ }
+ }
+
+ MouseArea {
+ anchors { fill: parent; leftMargin: -20; topMargin: -20; rightMargin: -20; bottomMargin: -20 }
+ onClicked: container.state = "editMode"
+ }
+
+ states: State {
+ name: "editMode"
+ PropertyChanges { target: container; width: textInput.width + 70; height: textInput.height + 17 }
+ PropertyChanges { target: textInput; visible: true; focus: true }
+ PropertyChanges { target: labelText; visible: false }
+ }
+
+ onLabelChanged: {
+ labelText.text = label
+ container.state = ''
+ }
+}
diff --git a/demos/declarative/photoviewer/PhotoViewerCore/PhotoDelegate.qml b/demos/declarative/photoviewer/PhotoViewerCore/PhotoDelegate.qml
index 89fe3e8..107aff1 100644
--- a/demos/declarative/photoviewer/PhotoViewerCore/PhotoDelegate.qml
+++ b/demos/declarative/photoviewer/PhotoViewerCore/PhotoDelegate.qml
@@ -1,4 +1,5 @@
import Qt 4.6
+import "script/script.js" as Script
Package {
Item { id: stackItem; Package.name: 'stack'; width: 160; height: 153; z: stackItem.PathView.z }
@@ -28,12 +29,16 @@ Package {
Rectangle {
id: placeHolder
- property int w: getWidth(content)
- property int h: getHeight(content)
- property double s: calculateScale(w, h, photoWrapper.width)
+ property int w: Script.getWidth(content)
+ property int h: Script.getHeight(content)
+ property double s: Script.calculateScale(w, h, photoWrapper.width)
- color: '#878787'; anchors.centerIn: parent; smooth: true; border.color: 'white'; border.width: 3
+ color: 'white'; anchors.centerIn: parent; smooth: true
width: w * s; height: h * s; visible: originalImage.status != Image.Ready
+ Rectangle {
+ color: "#878787"; smooth: true
+ anchors { fill: parent; topMargin: 3; bottomMargin: 3; leftMargin: 3; rightMargin: 3 }
+ }
}
Rectangle {
id: border; color: 'white'; anchors.centerIn: parent; smooth: true
@@ -42,7 +47,7 @@ Package {
}
BusyIndicator { anchors.centerIn: parent; on: originalImage.status != Image.Ready }
Image {
- id: originalImage; smooth: true; source: "http://" + getImagePath(content)
+ id: originalImage; smooth: true; source: "http://" + Script.getImagePath(content)
fillMode: Image.PreserveAspectFit; width: photoWrapper.width; height: photoWrapper.height
}
Image {
diff --git a/demos/declarative/photoviewer/PhotoViewerCore/Tag.qml b/demos/declarative/photoviewer/PhotoViewerCore/Tag.qml
index d32fcd0..bf02fac 100644
--- a/demos/declarative/photoviewer/PhotoViewerCore/Tag.qml
+++ b/demos/declarative/photoviewer/PhotoViewerCore/Tag.qml
@@ -7,18 +7,23 @@ Flipable {
property alias backLabel: backButton.label
property int angle: 0
+ property int randomAngle: Math.random() * (2 * 6 + 1) - 6
property bool flipped: false
signal frontClicked
signal backClicked
+ signal tagChanged(string tag)
- front: Button {
- id: frontButton; anchors.centerIn: parent; anchors.verticalCenterOffset: -20
+ front: EditableButton {
+ id: frontButton; rotation: flipable.randomAngle
+ anchors { centerIn: parent; verticalCenterOffset: -20 }
onClicked: flipable.frontClicked()
+ onLabelChanged: flipable.tagChanged(label)
}
back: Button {
- id: backButton; anchors.centerIn: parent; anchors.verticalCenterOffset: -20
+ id: backButton; tint: "red"; rotation: flipable.randomAngle
+ anchors { centerIn: parent; verticalCenterOffset: -20 }
onClicked: flipable.backClicked()
}
diff --git a/demos/declarative/photoviewer/PhotoViewerCore/qmldir b/demos/declarative/photoviewer/PhotoViewerCore/qmldir
index f94a560..d3c247f 100644
--- a/demos/declarative/photoviewer/PhotoViewerCore/qmldir
+++ b/demos/declarative/photoviewer/PhotoViewerCore/qmldir
@@ -2,6 +2,7 @@ AlbumDelegate AlbumDelegate.qml
PhotoDelegate PhotoDelegate.qml
ProgressBar ProgressBar.qml
RssModel RssModel.qml
+BusyIndicator BusyIndicator.qml
+EditableButton EditableButton.qml
Button Button.qml
Tag Tag.qml
-BusyIndicator BusyIndicator.qml
diff --git a/demos/declarative/photoviewer/PhotoViewerCore/script/script.js b/demos/declarative/photoviewer/PhotoViewerCore/script/script.js
index ae24ea1..e8ef93a 100644
--- a/demos/declarative/photoviewer/PhotoViewerCore/script/script.js
+++ b/demos/declarative/photoviewer/PhotoViewerCore/script/script.js
@@ -1,3 +1,5 @@
+.pragma library
+
function getWidth(string) {
return (string.match(/width=\"([0-9]+)\"/))[1]
}
diff --git a/demos/declarative/photoviewer/photoviewer.qml b/demos/declarative/photoviewer/photoviewer.qml
index 02134ac..8feee02 100644
--- a/demos/declarative/photoviewer/photoviewer.qml
+++ b/demos/declarative/photoviewer/photoviewer.qml
@@ -10,13 +10,11 @@ Rectangle {
width: 800; height: 480; color: "#d5d6d8"
- Script { source: "PhotoViewerCore/script/script.js" }
-
ListModel {
id: photosModel
ListElement { tag: "Flowers" }
- ListElement { tag: "Savanna" }
- ListElement { tag: "Central Park" }
+ ListElement { tag: "Wildlife" }
+ ListElement { tag: "Prague" }
}
VisualDataModel { id: albumVisualModel; model: photosModel; delegate: AlbumDelegate {} }
@@ -28,14 +26,20 @@ Rectangle {
Column {
spacing: 20; anchors { bottom: parent.bottom; right: parent.right; rightMargin: 20; bottomMargin: 20 }
- Button { id: deleteButton; label: "Edit"; rotation: -2; onClicked: mainWindow.editMode = !mainWindow.editMode }
Button {
id: newButton; label: "New"; rotation: 3
+ anchors.horizontalCenter: parent.horizontalCenter
onClicked: {
+ mainWindow.editMode = false
photosModel.append( { tag: "" } )
albumView.positionViewAtIndex(albumView.count - 1, GridView.Contain)
}
}
+ Button {
+ id: deleteButton; label: "Delete"; rotation: -2;
+ onClicked: mainWindow.editMode = !mainWindow.editMode
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
}
Rectangle {
diff --git a/demos/declarative/samegame/SamegameCore/samegame.js b/demos/declarative/samegame/SamegameCore/samegame.js
index 1214b79..a119a88 100755
--- a/demos/declarative/samegame/SamegameCore/samegame.js
+++ b/demos/declarative/samegame/SamegameCore/samegame.js
@@ -22,11 +22,6 @@ function timeStr(msecs) {
return ret;
}
-function getTileSize()
-{
- return tileSize;
-}
-
function initBoard()
{
for(var i = 0; i<maxIndex; i++){
diff --git a/demos/declarative/samegame/samegame.qml b/demos/declarative/samegame/samegame.qml
index 3b19cbe..f084ff6 100644
--- a/demos/declarative/samegame/samegame.qml
+++ b/demos/declarative/samegame/samegame.qml
@@ -1,5 +1,6 @@
import Qt 4.6
import SamegameCore 1.0
+import "SamegameCore/samegame.js" as Logic
Rectangle {
id: screen
@@ -22,15 +23,13 @@ Rectangle {
property int score: 0
property int tileSize: 40
- Script { source: "SamegameCore/samegame.js" }
-
z: 20; anchors.centerIn: parent
- width: parent.width - (parent.width % getTileSize());
- height: parent.height - (parent.height % getTileSize());
+ width: parent.width - (parent.width % tileSize);
+ height: parent.height - (parent.height % tileSize);
MouseArea {
id: gameMR
- anchors.fill: parent; onClicked: handleClick(mouse.x,mouse.y);
+ anchors.fill: parent; onClicked: Logic.handleClick(mouse.x,mouse.y);
}
}
}
@@ -57,7 +56,7 @@ Rectangle {
}
onAccepted: {
if(scoreName.opacity==1&&editor.text!="")
- saveHighScore(editor.text);
+ Logic.saveHighScore(editor.text);
scoreName.forceClose();
}
anchors.verticalCenter: parent.verticalCenter
@@ -73,13 +72,13 @@ Rectangle {
anchors.bottom: screen.bottom
Button {
- id: btnA; text: "New Game"; onClicked: {initBoard();}
+ id: btnA; text: "New Game"; onClicked: Logic.initBoard();
anchors.left: parent.left; anchors.leftMargin: 3
anchors.verticalCenter: parent.verticalCenter
}
Button {
- id: btnB; text: "Quit"; onClicked: {Qt.quit();}
+ id: btnB; text: "Quit"; onClicked: Qt.quit();
anchors.left: btnA.right; anchors.leftMargin: 3
anchors.verticalCenter: parent.verticalCenter
}
diff --git a/demos/declarative/snake/content/HighScoreModel.qml b/demos/declarative/snake/content/HighScoreModel.qml
index f585ce8..076e3ff 100644
--- a/demos/declarative/snake/content/HighScoreModel.qml
+++ b/demos/declarative/snake/content/HighScoreModel.qml
@@ -41,21 +41,19 @@ ListModel {
property string topPlayer: ""
property int maxScores: 10
- Script {
- function db()
- {
- return openDatabaseSync("HighScoreModel", "1.0", "Generic High Score Functionality for QML", 1000000);
- }
- function ensureTables(tx)
- {
- tx.executeSql('CREATE TABLE IF NOT EXISTS HighScores(game TEXT, score INT, player TEXT)', []);
- }
+ function __db()
+ {
+ return openDatabaseSync("HighScoreModel", "1.0", "Generic High Score Functionality for QML", 1000000);
+ }
+ function __ensureTables(tx)
+ {
+ tx.executeSql('CREATE TABLE IF NOT EXISTS HighScores(game TEXT, score INT, player TEXT)', []);
}
function fillModel() {
- db().transaction(
+ __db().transaction(
function(tx) {
- ensureTables(tx);
+ __ensureTables(tx);
var rs = tx.executeSql("SELECT score,player FROM HighScores WHERE game=? ORDER BY score DESC", [game]);
model.clear();
if (rs.rows.length > 0) {
@@ -74,9 +72,9 @@ ListModel {
}
function savePlayerScore(player,score) {
- db().transaction(
+ __db().transaction(
function(tx) {
- ensureTables(tx);
+ __ensureTables(tx);
tx.executeSql("INSERT INTO HighScores VALUES(?,?,?)", [game,score,player]);
fillModel();
}
@@ -88,7 +86,7 @@ ListModel {
}
function clearScores() {
- db().transaction(
+ __db().transaction(
function(tx) {
tx.executeSql("DELETE FROM HighScores WHERE game=?", [game]);
fillModel();
diff --git a/demos/declarative/snake/snake.qml b/demos/declarative/snake/snake.qml
index 317c7de..68c2b78 100644
--- a/demos/declarative/snake/snake.qml
+++ b/demos/declarative/snake/snake.qml
@@ -1,13 +1,12 @@
import Qt 4.6
import "content" as Content
+import "content/snake.js" as Logic
Rectangle {
id: screen;
SystemPalette { id: activePalette }
color: activePalette.window
- Script { source: "content/snake.js" }
-
property int gridSize : 34
property int margin: 4
property int numRowsAvailable: Math.floor((height-32-2*margin)/gridSize)
@@ -36,19 +35,19 @@ Rectangle {
id: heartbeat;
interval: heartbeatInterval;
repeat: true
- onTriggered: { move() }
+ onTriggered: { Logic.move() }
}
Timer {
id: halfbeat;
interval: halfbeatInterval;
repeat: true
running: heartbeat.running
- onTriggered: { moveSkull() }
+ onTriggered: { Logic.moveSkull() }
}
Timer {
interval: 700;
- onTriggered: {startNewGame(); }
+ onTriggered: { Logic.startNewGame(); }
}
Timer {
@@ -105,13 +104,13 @@ Rectangle {
anchors.fill: parent
onPressed: {
if (!head || !heartbeat.running) {
- startNewGame();
+ Logic.startNewGame();
return;
}
if (direction == 0 || direction == 2)
- scheduleDirection((mouseX > (head.x + head.width/2)) ? 1 : 3);
+ Logic.scheduleDirection((mouseX > (head.x + head.width/2)) ? 1 : 3);
else
- scheduleDirection((mouseY > (head.y + head.height/2)) ? 2 : 0);
+ Logic.scheduleDirection((mouseY > (head.y + head.height/2)) ? 2 : 0);
}
}
}
@@ -149,7 +148,7 @@ Rectangle {
anchors.bottom: screen.bottom
Content.Button {
- id: btnA; text: "New Game"; onClicked: {startNewGame();}
+ id: btnA; text: "New Game"; onClicked: Logic.startNewGame();
anchors.left: parent.left; anchors.leftMargin: 3
anchors.verticalCenter: parent.verticalCenter
}
@@ -163,11 +162,11 @@ Rectangle {
}
focus: true
- Keys.onSpacePressed: startNewGame();
- Keys.onLeftPressed: if (state == "starting" || direction != 1) scheduleDirection(3);
- Keys.onRightPressed: if (state == "starting" || direction != 3) scheduleDirection(1);
- Keys.onUpPressed: if (state == "starting" || direction != 2) scheduleDirection(0);
- Keys.onDownPressed: if (state == "starting" || direction != 0) scheduleDirection(2);
+ Keys.onSpacePressed: Logic.startNewGame();
+ Keys.onLeftPressed: if (state == "starting" || direction != 1) Logic.scheduleDirection(3);
+ Keys.onRightPressed: if (state == "starting" || direction != 3) Logic.scheduleDirection(1);
+ Keys.onUpPressed: if (state == "starting" || direction != 2) Logic.scheduleDirection(0);
+ Keys.onDownPressed: if (state == "starting" || direction != 0) Logic.scheduleDirection(2);
states: [
State {
diff --git a/demos/declarative/twitter/TwitterCore/Loading.qml b/demos/declarative/twitter/TwitterCore/Loading.qml
index 76bf64b..957de0f 100644
--- a/demos/declarative/twitter/TwitterCore/Loading.qml
+++ b/demos/declarative/twitter/TwitterCore/Loading.qml
@@ -1,8 +1,8 @@
import Qt 4.6
Image {
- id: loading; source: "images/loading.png"; transformOrigin: "Center"
+ id: loading; source: "images/loading.png"
NumberAnimation on rotation {
- from: 0; to: 360; running: loading.visible == true; repeat: true; duration: 900
+ from: 0; to: 360; running: loading.visible == true; loops: Animation.Infinite; duration: 900
}
}
diff --git a/demos/declarative/webbrowser/content/FlickableWebView.qml b/demos/declarative/webbrowser/content/FlickableWebView.qml
index 30a5d78..759cff6 100644
--- a/demos/declarative/webbrowser/content/FlickableWebView.qml
+++ b/demos/declarative/webbrowser/content/FlickableWebView.qml
@@ -25,21 +25,19 @@ Flickable {
pixelCacheSize: 4000000
transformOrigin: Item.TopLeft
- Script {
- function fixUrl(url)
- {
- if (url == "") return url
- if (url[0] == "/") return "file://"+url
- if (url.indexOf(":")<0) {
- if (url.indexOf(".")<0 || url.indexOf(" ")>=0) {
- // Fall back to a search engine; hard-code Wikipedia
- return "http://en.wikipedia.org/w/index.php?search="+url
- } else {
- return "http://"+url
- }
+ function fixUrl(url)
+ {
+ if (url == "") return url
+ if (url[0] == "/") return "file://"+url
+ if (url.indexOf(":")<0) {
+ if (url.indexOf(".")<0 || url.indexOf(" ")>=0) {
+ // Fall back to a search engine; hard-code Wikipedia
+ return "http://en.wikipedia.org/w/index.php?search="+url
+ } else {
+ return "http://"+url
}
- return url
}
+ return url
}
url: fixUrl(webBrowser.urlString)
diff --git a/demos/declarative/webbrowser/content/fieldtext/FieldText.qml b/demos/declarative/webbrowser/content/fieldtext/FieldText.qml
index d282209..1da9219 100644
--- a/demos/declarative/webbrowser/content/fieldtext/FieldText.qml
+++ b/demos/declarative/webbrowser/content/fieldtext/FieldText.qml
@@ -10,30 +10,26 @@ Item {
signal cancelled
signal startEdit
- Script {
-
- function edit() {
- if (!mouseGrabbed) {
- fieldText.startEdit();
- fieldText.state='editing';
- mouseGrabbed=true;
- }
- }
-
- function confirm() {
- fieldText.state='';
- fieldText.text = textEdit.text;
- mouseGrabbed=false;
- fieldText.confirmed();
+ function edit() {
+ if (!mouseGrabbed) {
+ fieldText.startEdit();
+ fieldText.state='editing';
+ mouseGrabbed=true;
}
+ }
- function reset() {
- textEdit.text = fieldText.text;
- fieldText.state='';
- mouseGrabbed=false;
- fieldText.cancelled();
- }
+ function confirm() {
+ fieldText.state='';
+ fieldText.text = textEdit.text;
+ mouseGrabbed=false;
+ fieldText.confirmed();
+ }
+ function reset() {
+ textEdit.text = fieldText.text;
+ fieldText.state='';
+ mouseGrabbed=false;
+ fieldText.cancelled();
}
Image {