summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--demos/declarative/contacts/contacts.qml2
-rw-r--r--demos/declarative/samegame/SameGame.qml13
-rw-r--r--demos/declarative/samegame/content/Dialog.qml18
-rwxr-xr-xdemos/declarative/samegame/content/samegame.js31
-rw-r--r--demos/declarative/samegame/highscores/README1
-rwxr-xr-xdemos/declarative/samegame/highscores/score_data.xml2
-rwxr-xr-xdemos/declarative/samegame/highscores/score_style.xsl27
-rwxr-xr-xdemos/declarative/samegame/highscores/scores.php34
-rw-r--r--examples/declarative/listview/recipes.qml6
-rw-r--r--examples/declarative/tutorials/contacts/3_Collections/2/ContactView.qml2
-rw-r--r--examples/declarative/tutorials/contacts/3_Collections/3/ContactView.qml2
-rw-r--r--src/declarative/QmlChanges.txt3
-rw-r--r--src/declarative/fx/qfxflickable.cpp32
-rw-r--r--src/declarative/fx/qfxflickable.h6
-rw-r--r--src/declarative/fx/qfxflickable_p.h2
-rw-r--r--src/declarative/fx/qfxgridview.cpp2
-rw-r--r--src/declarative/fx/qfxitem.cpp2
-rw-r--r--src/declarative/fx/qfxlistview.cpp2
18 files changed, 151 insertions, 36 deletions
diff --git a/demos/declarative/contacts/contacts.qml b/demos/declarative/contacts/contacts.qml
index 81d8352..f009631 100644
--- a/demos/declarative/contacts/contacts.qml
+++ b/demos/declarative/contacts/contacts.qml
@@ -105,7 +105,7 @@ Rectangle {
}
PropertyChanges {
target: contactListView
- locked: 1
+ interactive: 0
}
PropertyChanges {
target: label
diff --git a/demos/declarative/samegame/SameGame.qml b/demos/declarative/samegame/SameGame.qml
index 0da5679..877c1cc 100644
--- a/demos/declarative/samegame/SameGame.qml
+++ b/demos/declarative/samegame/SameGame.qml
@@ -34,6 +34,19 @@ Rectangle {
}
Dialog { id: dialog; anchors.centerIn: parent; z: 21 }
+ Dialog {
+ id: scoreName; anchors.centerIn: parent; z: 22;
+ TextInput {
+ id: Editor
+ onAccepted: {
+ if(scoreName.opacity==1&&Editor.text!="")
+ sendHighScore(Editor.text);
+ scoreName.forceClose();
+ }
+ anchors.verticalCenter: parent.verticalCenter
+ x:160; width: 200; height:20; focus: true
+ }
+ }
Rectangle {
id: ToolBar
diff --git a/demos/declarative/samegame/content/Dialog.qml b/demos/declarative/samegame/content/Dialog.qml
index 72c7900..401d211 100644
--- a/demos/declarative/samegame/content/Dialog.qml
+++ b/demos/declarative/samegame/content/Dialog.qml
@@ -2,14 +2,20 @@ import Qt 4.6
Rectangle {
id: page
+ function forceClose() {
+ page.closed();
+ page.opacity = 0;
+ }
+ function show(txt) {
+ MyText.text = txt;
+ page.opacity = 1;
+ }
+ signal closed();
color: "white"; border.width: 1; width: MyText.width + 20; height: 60;
- property string text: "Hello World!"
opacity: 0
opacity: Behavior {
- SequentialAnimation {
- NumberAnimation {property: "opacity"; from: 0; duration: 1500 }
- NumberAnimation {property: "opacity"; to: 0; duration: 1500 }
- }
+ NumberAnimation { duration: 1000 }
}
- Text { id: MyText; anchors.centerIn: parent; text: parent.text }
+ Text { id: MyText; anchors.centerIn: parent; text: "Hello World!" }
+ MouseRegion { id: mr; anchors.fill: parent; onClicked: forceClose(); }
}
diff --git a/demos/declarative/samegame/content/samegame.js b/demos/declarative/samegame/content/samegame.js
index f04fb4c..9914edb 100755
--- a/demos/declarative/samegame/content/samegame.js
+++ b/demos/declarative/samegame/content/samegame.js
@@ -6,13 +6,22 @@ var tileSize = 40;
var maxIndex = maxX*maxY;
var board = new Array(maxIndex);
var tileSrc = "content/BoomBlock.qml";
+var scoresURL = "http://qtfx-nokia.trolltech.com.au/samegame/scores.php";
+var timer;
var component;
//Index function used instead of a 2D array
-function index(xIdx,yIdx){
+function index(xIdx,yIdx) {
return xIdx + (yIdx * maxX);
}
+function timeStr(msecs) {
+ var secs = Math.floor(msecs/1000);
+ var m = Math.floor(secs/60);
+ var ret = "" + m + "m " + (secs%60) + "s";
+ return ret;
+}
+
function initBoard()
{
for(i = 0; i<maxIndex; i++){
@@ -34,6 +43,7 @@ function initBoard()
startCreatingBlock(xIdx,yIdx);
}
}
+ timer = new Date();
}
var fillFound;//Set after a floodFill call to the number of tiles found
@@ -134,8 +144,10 @@ function victoryCheck()
gameCanvas.score += 500;
//Checks for game over
if(deservesBonus || !(floodMoveCheck(0,maxY-1, -1))){
- dialog.text = "Game Over. Your score is " + gameCanvas.score;
- dialog.opacity = 1;
+ dialog.show("Game Over. Your score is " + gameCanvas.score);
+ timer = new Date() - timer;
+ if(scoresURL != "")
+ scoreName.show("Please enter your name: ");
}
}
@@ -209,3 +221,16 @@ function startCreatingBlock(xIdx,yIdx){
component.statusChanged.connect(finishCreatingBlock());
return;
}
+
+function sendHighScore(name) {
+ var postman = new XMLHttpRequest()
+ var postData = "name="+name+"&score="+gameCanvas.score
+ +"&gridSize="+maxX+"x"+maxY +"&time="+Math.floor(timer/1000);
+ postman.open("POST", scoresURL, true);
+ postman.onreadystatechange = function() {
+ if (postman.readyState == postman.DONE) {
+ dialog.show("Your score has been uploaded.");
+ }
+ }
+ postman.send(postData);
+}
diff --git a/demos/declarative/samegame/highscores/README b/demos/declarative/samegame/highscores/README
new file mode 100644
index 0000000..eaa00fa
--- /dev/null
+++ b/demos/declarative/samegame/highscores/README
@@ -0,0 +1 @@
+The SameGame example can interface with a simple PHP script to store XML high score data on a remote server. We do not have a publically accessible server available for this use, but if you have access to a PHP capable webserver you can copy the files (score_data.xml, score.php, score_style.xsl) to it and alter the highscore_server variable at the top of the samegame.js file to point to it.
diff --git a/demos/declarative/samegame/highscores/score_data.xml b/demos/declarative/samegame/highscores/score_data.xml
new file mode 100755
index 0000000..c3fd90d
--- /dev/null
+++ b/demos/declarative/samegame/highscores/score_data.xml
@@ -0,0 +1,2 @@
+<record><score>1000000</score><name>Alan the Tester</name><gridSize>0x0</gridSize><seconds>0</seconds></record>
+<record><score>6213</score><name>Alan</name><gridSize>12x17</gridSize><seconds>51</seconds></record>
diff --git a/demos/declarative/samegame/highscores/score_style.xsl b/demos/declarative/samegame/highscores/score_style.xsl
new file mode 100755
index 0000000..7dcf07e
--- /dev/null
+++ b/demos/declarative/samegame/highscores/score_style.xsl
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+<xsl:template match="/">
+ <html>
+ <head><title>SameGame High Scores</title></head>
+ <body>
+ <h2>SameGame High Scores</h2>
+ <table border="1">
+ <tr bgcolor="lightsteelblue">
+ <th>Name</th>
+ <th>Score</th>
+ <th>Grid Size</th>
+ <th>Time, s</th>
+ </tr>
+ <xsl:for-each select="records/record">
+ <tr>
+ <td><xsl:value-of select="name"/></td>
+ <td><xsl:value-of select="score"/></td>
+ <td><xsl:value-of select="gridSize"/></td>
+ <td><xsl:value-of select="seconds"/></td>
+ </tr>
+ </xsl:for-each>
+ </table>
+ </body>
+ </html>
+</xsl:template>
+</xsl:stylesheet>
diff --git a/demos/declarative/samegame/highscores/scores.php b/demos/declarative/samegame/highscores/scores.php
new file mode 100755
index 0000000..3cceb2d
--- /dev/null
+++ b/demos/declarative/samegame/highscores/scores.php
@@ -0,0 +1,34 @@
+<?php
+ $score = $_POST["score"];
+ echo "<html>";
+ echo "<head><title>SameGame High Scores</title></head><body>";
+ if($score > 0){#Sending in a new high score
+ $name = $_POST["name"];
+ $grid = $_POST["gridSize"];
+ $time = $_POST["time"];
+ if($name == "")
+ $name = "Anonymous";
+ //if($grid != "10x10"){
+ //Need a standard, so as to reject others?
+ //}
+ $file = fopen("score_data.xml", "a"); #It's XML. Happy?
+ $ret = fwrite($file, "<record><score>". $score . "</score><name>"
+ . $name . "</name><gridSize>" . $grid . "</gridSize><seconds>"
+ . $time . "</seconds></record>\n");
+ echo "Your score has been recorded. Thanks for playing!";
+ if($ret == False)
+ echo "<br/> There was an error though, so don't expect to see that score again.";
+ }else{#Read high score list
+ #Now uses XSLT to display. So just print the file. With XML cruft added.
+ #Note that firefox at least won't apply the XSLT on a php file. So redirecting
+ $file = fopen("scores.xml", "w");
+ $ret = fwrite($file, '<?xml version="1.0" encoding="ISO-8859-1"?>' . "\n"
+ . '<?xml-stylesheet type="text/xsl" href="score_style.xsl"?>' . "\n"
+ . "<records>\n" . file_get_contents("score_data.xml") . "</records>\n");
+ if($ret == False)
+ echo "There was an internal error. Sorry.";
+ else
+ echo '<script type="text/javascript">window.location.replace("scores.xml")</script>';
+ }
+ echo "</body></html>";
+?>
diff --git a/examples/declarative/listview/recipes.qml b/examples/declarative/listview/recipes.qml
index eac8bb5..2148ef4 100644
--- a/examples/declarative/listview/recipes.qml
+++ b/examples/declarative/listview/recipes.qml
@@ -104,9 +104,9 @@ Rectangle {
// Make the detailed view fill the entire list area
PropertyChanges { target: wrapper; height: List.height }
// Move the list so that this item is at the top.
- PropertyChanges { target: wrapper.ListView.view; explicit: true; yPosition: wrapper.y }
+ PropertyChanges { target: wrapper.ListView.view; explicit: true; viewportY: wrapper.y }
// Disallow flicking while we're in detailed view
- PropertyChanges { target: wrapper.ListView.view; locked: 1 }
+ PropertyChanges { target: wrapper.ListView.view; interactive: false }
}
]
transitions: [
@@ -115,7 +115,7 @@ Rectangle {
ParallelAnimation {
ColorAnimation { property: "color"; duration: 500 }
NumberAnimation {
- duration: 300; properties: "detailsOpacity,x,yPosition,height,width"
+ duration: 300; properties: "detailsOpacity,x,viewportY,height,width"
}
}
}
diff --git a/examples/declarative/tutorials/contacts/3_Collections/2/ContactView.qml b/examples/declarative/tutorials/contacts/3_Collections/2/ContactView.qml
index d16e3ca..8ee51c3 100644
--- a/examples/declarative/tutorials/contacts/3_Collections/2/ContactView.qml
+++ b/examples/declarative/tutorials/contacts/3_Collections/2/ContactView.qml
@@ -84,7 +84,7 @@ Item {
}
PropertyChanges {
target: contactListView
- locked: 1
+ interactive: 0
}
PropertyChanges {
target: label
diff --git a/examples/declarative/tutorials/contacts/3_Collections/3/ContactView.qml b/examples/declarative/tutorials/contacts/3_Collections/3/ContactView.qml
index bf73367..76dc3e2 100644
--- a/examples/declarative/tutorials/contacts/3_Collections/3/ContactView.qml
+++ b/examples/declarative/tutorials/contacts/3_Collections/3/ContactView.qml
@@ -102,7 +102,7 @@ Item {
}
PropertyChanges {
target: contactListView
- locked: 1
+ interactive: 0
}
PropertyChanges {
target: label
diff --git a/src/declarative/QmlChanges.txt b/src/declarative/QmlChanges.txt
index 069bf49..a401a70 100644
--- a/src/declarative/QmlChanges.txt
+++ b/src/declarative/QmlChanges.txt
@@ -1,7 +1,7 @@
QML API Review
==============
-The QML API is being reviewed from 17 to 28 August 2009. This
+The QML API is being reviewed from 17 to 4 September 2009. This
file documents the changes. Note that the changes are incremental,
so a rename A->B for example may be follow by another subseqent
rename B->C, if later reviews override earlier reviews.
@@ -47,6 +47,7 @@ Flickable: yPosition -> viewportY
Flickable: xVelocity -> horizontalVelocity
Flickable: yVelocity -> verticalVelocity
Flickable: velocityDecay -> reportedVelocitySmoothing
+Flickable: locked -> interactive (note reversal of meaning)
WebView: idealWidth -> preferredWidth
WebView: idealHeight -> preferredHeight
WebView: status -> statusText
diff --git a/src/declarative/fx/qfxflickable.cpp b/src/declarative/fx/qfxflickable.cpp
index 27bfa27..0690df1 100644
--- a/src/declarative/fx/qfxflickable.cpp
+++ b/src/declarative/fx/qfxflickable.cpp
@@ -95,7 +95,7 @@ void ElasticValue::updateCurrentTime(int)
QFxFlickablePrivate::QFxFlickablePrivate()
: _flick(new QFxItem), _moveX(_flick, &QFxItem::setX), _moveY(_flick, &QFxItem::setY)
, vWidth(-1), vHeight(-1), overShoot(true), flicked(false), moving(false), stealMouse(false)
- , pressed(false), maxVelocity(-1), locked(false), dragMode(QFxFlickable::Hard)
+ , pressed(false), maxVelocity(-1), interactive(true), dragMode(QFxFlickable::Hard)
, elasticY(_moveY), elasticX(_moveX), reportedVelocitySmoothing(100), horizontalVelocity(this), verticalVelocity(this)
, vTime(0), atXEnd(false), atXBeginning(true), pageXPosition(0.), pageWidth(0.)
, atYEnd(false), atYBeginning(true), pageYPosition(0.), pageHeight(0.)
@@ -201,12 +201,12 @@ void QFxFlickablePrivate::fixupX()
vTime = _tl.time();
if (_moveX.value() > q->minXExtent() || (q->maxXExtent() > q->maxXExtent())) {
- _tl.clear();
+ _tl.reset(_moveY);
if (_moveX.value() != q->minXExtent())
_tl.move(_moveX, q->minXExtent(), QEasingCurve(QEasingCurve::InOutQuad), 200);
//emit flickingChanged();
} else if (_moveX.value() < q->maxXExtent()) {
- _tl.clear();
+ _tl.reset(_moveY);
_tl.move(_moveX, q->maxXExtent(), QEasingCurve(QEasingCurve::InOutQuad), 200);
//emit flickingChanged();
} else {
@@ -223,12 +223,12 @@ void QFxFlickablePrivate::fixupY()
vTime = _tl.time();
if (_moveY.value() > q->minYExtent() || (q->maxYExtent() > q->minYExtent())) {
- _tl.clear();
+ _tl.reset(_moveY);
if (_moveY.value() != q->minYExtent())
_tl.move(_moveY, q->minYExtent(), QEasingCurve(QEasingCurve::InOutQuad), 200);
//emit flickingChanged();
} else if (_moveY.value() < q->maxYExtent()) {
- _tl.clear();
+ _tl.reset(_moveY);
_tl.move(_moveY, q->maxYExtent(), QEasingCurve(QEasingCurve::InOutQuad), 200);
//emit flickingChanged();
} else {
@@ -411,24 +411,30 @@ void QFxFlickable::setViewportY(qreal pos)
}
/*!
- \qmlproperty bool Flickable::locked
+ \qmlproperty bool Flickable::interactive
- A user cannot drag or flick a Flickable that is locked.
+ A user cannot drag or flick a Flickable that is not interactive.
This property is useful for temporarily disabling flicking. This allows
special interaction with Flickable's children: for example, you might want to
freeze a flickable map while viewing detailed information on a location popup that is a child of the Flickable.
*/
-bool QFxFlickable::isLocked() const
+bool QFxFlickable::isInteractive() const
{
Q_D(const QFxFlickable);
- return d->locked;
+ return d->interactive;
}
-void QFxFlickable::setLocked(bool lock)
+void QFxFlickable::setInteractive(bool interactive)
{
Q_D(QFxFlickable);
- d->locked = lock;
+ d->interactive = interactive;
+ if (!interactive && d->flicked) {
+ d->_tl.clear();
+ d->flicked = false;
+ emit flickingChanged();
+ emit flickEnded();
+ }
}
/*!
@@ -577,7 +583,7 @@ qreal QFxFlickable::visibleY() const
void QFxFlickablePrivate::handleMousePressEvent(QGraphicsSceneMouseEvent *event)
{
- if (!locked && _tl.isActive() && (qAbs(velocityX) > 10 || qAbs(velocityY) > 10))
+ if (interactive && _tl.isActive() && (qAbs(velocityX) > 10 || qAbs(velocityY) > 10))
stealMouse = true; // If we've been flicked then steal the click.
else
stealMouse = false;
@@ -602,7 +608,7 @@ void QFxFlickablePrivate::handleMousePressEvent(QGraphicsSceneMouseEvent *event)
void QFxFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
Q_Q(QFxFlickable);
- if (locked || lastPosTime.isNull())
+ if (!interactive || lastPosTime.isNull())
return;
bool rejectY = false;
bool rejectX = false;
diff --git a/src/declarative/fx/qfxflickable.h b/src/declarative/fx/qfxflickable.h
index c27b29f..57a01d7 100644
--- a/src/declarative/fx/qfxflickable.h
+++ b/src/declarative/fx/qfxflickable.h
@@ -69,7 +69,7 @@ class Q_DECLARATIVE_EXPORT QFxFlickable : public QFxItem
Q_PROPERTY(bool moving READ isMoving NOTIFY movingChanged)
Q_PROPERTY(bool flicking READ isFlicking NOTIFY flickingChanged)
- Q_PROPERTY(bool locked READ isLocked WRITE setLocked) //### interactive, ensure flicking is stopped, etc.
+ Q_PROPERTY(bool interactive READ isInteractive WRITE setInteractive)
Q_PROPERTY(DragMode dragMode READ dragMode WRITE setDragMode) //### remove. Consider a better way to implement different drag behavior
Q_PROPERTY(bool atXEnd READ isAtXEnd NOTIFY isAtBoundaryChanged)
@@ -117,8 +117,8 @@ public:
qreal maximumFlickVelocity() const;
void setMaximumFlickVelocity(qreal);
- bool isLocked() const;
- void setLocked(bool);
+ bool isInteractive() const;
+ void setInteractive(bool);
Q_ENUMS(DragMode)
enum DragMode { Hard, Elastic };
diff --git a/src/declarative/fx/qfxflickable_p.h b/src/declarative/fx/qfxflickable_p.h
index a0ac011..ad9484f 100644
--- a/src/declarative/fx/qfxflickable_p.h
+++ b/src/declarative/fx/qfxflickable_p.h
@@ -121,7 +121,7 @@ public:
QmlTimeLineEvent fixupXEvent;
QmlTimeLineEvent fixupYEvent;
qreal maxVelocity;
- bool locked;
+ bool interactive;
QFxFlickable::DragMode dragMode;
ElasticValue elasticY;
ElasticValue elasticX;
diff --git a/src/declarative/fx/qfxgridview.cpp b/src/declarative/fx/qfxgridview.cpp
index 138a8ae..6fd080b 100644
--- a/src/declarative/fx/qfxgridview.cpp
+++ b/src/declarative/fx/qfxgridview.cpp
@@ -1069,7 +1069,7 @@ qreal QFxGridView::maxXExtent() const
void QFxGridView::keyPressEvent(QKeyEvent *event)
{
Q_D(QFxGridView);
- if (d->model && d->model->count() && !d->locked) {
+ if (d->model && d->model->count() && d->interactive) {
if ((d->flow == QFxGridView::LeftToRight && event->key() == Qt::Key_Up)
|| (d->flow == QFxGridView::TopToBottom && event->key() == Qt::Key_Left)) {
if (currentIndex() >= d->columns || d->wrap) {
diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp
index c436622..d28f531 100644
--- a/src/declarative/fx/qfxitem.cpp
+++ b/src/declarative/fx/qfxitem.cpp
@@ -928,7 +928,7 @@ private:
virtual void keyPressed(QKeyEvent *event);
virtual void keyReleased(QKeyEvent *event);
- const char *keyToSignal(int key) {
+ const QByteArray keyToSignal(int key) {
QByteArray keySignal;
if (key >= Qt::Key_0 && key <= Qt::Key_9) {
keySignal = "digit0Pressed";
diff --git a/src/declarative/fx/qfxlistview.cpp b/src/declarative/fx/qfxlistview.cpp
index 147c977..34fe827 100644
--- a/src/declarative/fx/qfxlistview.cpp
+++ b/src/declarative/fx/qfxlistview.cpp
@@ -1344,7 +1344,7 @@ qreal QFxListView::maxXExtent() const
void QFxListView::keyPressEvent(QKeyEvent *event)
{
Q_D(QFxListView);
- if (d->model && d->model->count() && !d->locked) {
+ if (d->model && d->model->count() && d->interactive) {
if ((d->orient == Qt::Horizontal && event->key() == Qt::Key_Left)
|| (d->orient == Qt::Vertical && event->key() == Qt::Key_Up)) {
if (currentIndex() > 0 || d->wrap) {