summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2009-04-22 23:23:33 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2009-04-22 23:23:33 (GMT)
commitc41be719a15cd8d702dd1064fee2b224f657c067 (patch)
tree6cb88f763194a66e4c5c7bf5797614f47b3d4671
parenta1458a0426caa71bab4527ca079c3004bb2b5abd (diff)
parentebda84cd06faaf440a096bda7966fa795ca86318 (diff)
downloadQt-c41be719a15cd8d702dd1064fee2b224f657c067.zip
Qt-c41be719a15cd8d702dd1064fee2b224f657c067.tar.gz
Qt-c41be719a15cd8d702dd1064fee2b224f657c067.tar.bz2
Merge branch 'kinetic-animations' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Conflicts: src/gui/animation/qguivariantanimation.cpp
-rw-r--r--bin/snapshot122
-rw-r--r--examples/animation/animatedtiles/main.cpp1
-rw-r--r--examples/animation/sub-attaq/boat.cpp1
-rw-r--r--examples/animation/sub-attaq/boat.h2
-rw-r--r--examples/animation/sub-attaq/qanimationstate.cpp3
-rw-r--r--examples/animation/sub-attaq/submarine.cpp9
-rw-r--r--src/corelib/animation/qpropertyanimation.cpp22
-rw-r--r--src/corelib/animation/qvariantanimation_p.h14
-rw-r--r--src/gui/animation/qguivariantanimation.cpp7
-rw-r--r--tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp22
10 files changed, 128 insertions, 75 deletions
diff --git a/bin/snapshot b/bin/snapshot
index 783d15c..b9a64e1 100644
--- a/bin/snapshot
+++ b/bin/snapshot
@@ -14,6 +14,40 @@ use strict;
my $targetPath = "";
my $qtdir = $ENV{"QTDIR"};
+my @class_renames = (
+ "QAbstractAnimation",
+ "QAnimationGroup",
+ "QParallelAnimationGroup",
+ "QSequentialAnimationGroup",
+ "QEasingCurve",
+ "QVariantAnimation",
+ "QPropertyAnimation",
+ "QItemAnimation",
+ "QPauseAnimation",
+ "QAbstractState",
+ "QAbstractStateGroup",
+ "QAbstractTransition",
+ "QActionState",
+ "QEventTransition",
+ "QFinalState",
+ "QHistoryState",
+ "QParallelStateGroup",
+ "QSignalEvent",
+ "QSignalTransition",
+ "QState",
+ "QStateAction",
+ "QStateInvokeMethodAction",
+ "QStateFinishedEvent",
+ "QStateFinishedTransition",
+ "QStateMachine",
+ "QTransition",
+ "QMouseEventTransition",
+ "QBasicMouseEventTransition",
+ "QKeyEventTransition",
+ "QBasicKeyEventTransition",
+ "QGraphicsWidget",
+ "QBoundEvent");
+
my @files = (
"3rdparty/easing/easing.cpp",
"corelib/tools/qeasingcurve.h",
@@ -40,6 +74,8 @@ my @files = (
"corelib/animation/qsequentialanimationgroup.h",
"corelib/animation/qsequentialanimationgroup_p.h",
"gui/animation/qguivariantanimation.cpp",
+ "gui/animation/animation.pri",
+
"corelib/statemachine/statemachine.pri",
"corelib/statemachine/qabstractstate.cpp",
"corelib/statemachine/qabstractstate.h",
@@ -110,13 +146,13 @@ open(OXML, "> " . $projectXML) || die "Could not open $projectXML for writing (n
print "COPYING SOURCES...\n";
foreach my $files(@files) {
- copyFile("$qtdir/src/$files","$targetPath/src");
+ copyFile("$qtdir/src/$files","$targetPath/src", 1);
}
-copyFile("$qtdir/doc/src/animation.qdoc","$targetPath/doc");
-copyFile("$qtdir/doc/src/statemachine.qdoc","$targetPath/doc");
-copyFile("$qtdir/src/3rdparty/easing/legal.qdoc","$targetPath/doc");
+copyFile("$qtdir/doc/src/animation.qdoc","$targetPath/doc", 0);
+copyFile("$qtdir/doc/src/statemachine.qdoc","$targetPath/doc", 0);
+copyFile("$qtdir/src/3rdparty/easing/legal.qdoc","$targetPath/doc", 0);
-copyFile("$qtdir/doc/src/snippets/code/src_corelib_tools_qeasingcurve.cpp","$targetPath/doc/src/snippets/code");
+copyFile("$qtdir/doc/src/snippets/code/src_corelib_tools_qeasingcurve.cpp","$targetPath/doc/src/snippets/code", 0);
my %animation_examples = (
@@ -150,7 +186,9 @@ my %animation_examples = (
"mainwindow.cpp",
"mainwindow.h",
"pics/scalable/*",
- "pics/big/*",
+ "pics/big/*.png",
+ "pics/big/explosion/boat/*",
+ "pics/big/explosion/submarine/*",
"pics/small/*",
"pics/welcome/*",
"pixmapitem.cpp",
@@ -161,8 +199,11 @@ my %animation_examples = (
"submarine_p.h",
"states.cpp",
"states.h",
+ "qanimationstate.cpp",
+ "qanimationstate.h",
"torpedo.cpp",
- "torpedo.h"],
+ "torpedo.h",
+ "data.xml"],
"stickman" => ["stickman.pro",
"main.cpp",
"animation.cpp",
@@ -175,6 +216,7 @@ my %animation_examples = (
"node.h",
"stickman.cpp",
"stickman.h",
+ "editor/*",
"animations/chilling",
"animations/dancing",
"animations/dead",
@@ -193,7 +235,7 @@ for $exDir ( keys %animation_examples ) {
my $glob = 0;
if (index($ex_file,"/") > 0) {
my($basefile, $fullPath) = fileparse("$targetPath/examples/$exDir/$ex_file");
- if ($basefile eq "*") {
+ if (index($basefile, "*") >= 0) {
$glob = 1;
}
mkpath "$fullPath", 0777 unless(-e "$fullPath");
@@ -209,20 +251,25 @@ for $exDir ( keys %animation_examples ) {
if ($glob eq 1) {
my @globFiles = < $qtdir/examples/animation/$exDir/$ex_file >;
foreach my $globFile(@globFiles) {
- copyFile("$globFile", "$copyTargetPath");
+ copyFile("$globFile", "$copyTargetPath", 0);
}
} else {
- copyFile("$qtdir/examples/animation/$exDir/$ex_file", "$copyTargetPath");
+ copyFile("$qtdir/examples/animation/$exDir/$ex_file", "$copyTargetPath", 0);
}
}
}
close OXML;
print("Finished!");
+
+
######################################################################
# Syntax: copyFile(gitfile, destinationPath)
# Params: gitfile, string, filename to create duplicate for
# destinationPath, string, destination name of duplicate
+# autoRename, int, 0: Don't rename
+# 1: The file should be renamed to have the "qt" prefix
+#
#
# Purpose: Copies to the solutions area.
# Returns: --
@@ -230,7 +277,7 @@ print("Finished!");
######################################################################
sub copyFile
{
- my ($gitfile, $destinationPath) = @_;
+ my ($gitfile, $destinationPath, $autoRename) = @_;
# Bi-directional synchronization
open( I, "< " . $gitfile ) || die "Could not open $gitfile for reading";
local $/;
@@ -239,44 +286,20 @@ sub copyFile
my ($baseFileName, $path, $ext) = fileparse($gitfile, qr/\.[^.]*/);
if ($ext eq ".h" or $ext eq ".cpp" or $ext eq ".qdoc") {
# both public and private classes
- $filecontents =~s/QAbstractAnimation/QtAbstractAnimation/g;
- $filecontents =~s/QAnimationGroup/QtAnimationGroup/g;
- $filecontents =~s/QParallelAnimationGroup/QtParallelAnimationGroup/g;
- $filecontents =~s/QSequentialAnimationGroup/QtSequentialAnimationGroup/g;
- $filecontents =~s/QEasingCurve/QtEasingCurve/g;
- $filecontents =~s/QVariantAnimation/QtVariantAnimation/g;
- $filecontents =~s/QPropertyAnimation/QtPropertyAnimation/g;
- $filecontents =~s/QItemAnimation/QtItemAnimation/g;
- $filecontents =~s/QPauseAnimation/QtPauseAnimation/g;
- $filecontents =~s/QAbstractState/QtAbstractState/g;
- $filecontents =~s/QAbstractStateGroup/QtAbstractStateGroup/g;
- $filecontents =~s/QAbstractTransition/QtAbstractTransition/g;
- $filecontents =~s/QActionState/QtActionState/g;
- $filecontents =~s/QEventTransition/QtEventTransition/g;
- $filecontents =~s/QFinalState/QtFinalState/g;
- $filecontents =~s/QHistoryState/QtHistoryState/g;
- $filecontents =~s/QParallelStateGroup/QtParallelStateGroup/g;
- $filecontents =~s/QSignalEvent/QtSignalEvent/g;
- $filecontents =~s/QSignalTransition/QtSignalTransition/g;
- $filecontents =~s/QState/QtState/g;
- $filecontents =~s/QStateAction/QtStateAction/g;
- $filecontents =~s/QStateInvokeMethodAction/QtStateInvokeMethodAction/g;
- $filecontents =~s/QStateFinishedEvent/QtStateFinishedEvent/g;
- $filecontents =~s/QStateFinishedTransition/QtStateFinishedTransition/g;
- $filecontents =~s/QStateMachine/QtStateMachine/g;
- $filecontents =~s/QActionTransition/QtActionTransition/g;
- $filecontents =~s/QMouseEventTransition/QtMouseEventTransition/g;
- $filecontents =~s/QKeyEventTransition/QtKeyEventTransition/g;
- $filecontents =~s/QGraphicsWidget/QtGraphicsWidget/g;
+ foreach my $qtClass(@class_renames) {
+ my $solutionClass = $qtClass;
+ $solutionClass =~s/^Q/Qt/g;
+ $filecontents =~s/$qtClass/$solutionClass/g;
+ my $qtFilename = lc($qtClass);
+ my $solutionFilename = lc($solutionClass);
+ $filecontents =~s/(#\s*include\s+["])$qtFilename/${1}$solutionFilename/g;
+ }
+
$filecontents =~s/Q_CORE_EXPORT/Q_ANIMATION_EXPORT/g;
$filecontents =~s/Q_GUI_EXPORT/Q_ANIMATION_EXPORT/g;
- $filecontents =~s/QBoundEvent/QtBoundEvent/g;
-
$filecontents =~s/class Q_GUI_EXPORT/class/g;
$filecontents =~s/class Q_AUTOTEST_EXPORT/class/g;
- $filecontents =~s/(#\s*include\s+["])q/${1}qt/g;
-
# moc stuff
$filecontents =~s/(#\s*include\s+["])moc_q/${1}moc_qt/g;
@@ -300,7 +323,14 @@ sub copyFile
if (index($gitfile, "gui/statemachine") >= 0) {
$baseFileName = "gui_statemachine";
}
-
+ }
+ if ($baseFileName eq "animation") {
+ if (index($gitfile, "corelib/animation") >= 0) {
+ $baseFileName = "corelib_animation";
+ }
+ if (index($gitfile, "gui/animation") >= 0) {
+ $baseFileName = "gui_animation";
+ }
}
}
@@ -312,7 +342,7 @@ sub copyFile
mkpath $destinationPath, 0777 unless(-e "$destinationPath");
- if ($ext eq ".h" or $ext eq ".cpp" or $ext eq ".qdoc") {
+ if ($autoRename eq 1 and ($ext eq ".h" or $ext eq ".cpp" or $ext eq ".qdoc")) {
$baseFileName =~s/^q/qt/g;
}
my $targetFile = "$destinationPath/$baseFileName$ext";
diff --git a/examples/animation/animatedtiles/main.cpp b/examples/animation/animatedtiles/main.cpp
index cfaa4ce..9b0b0a5 100644
--- a/examples/animation/animatedtiles/main.cpp
+++ b/examples/animation/animatedtiles/main.cpp
@@ -7,6 +7,7 @@
# include "qgraphicswidget.h"
# include "qparallelanimationgroup.h"
# include "qpropertyanimation.h"
+# include "qsignaltransition.h"
#else
#include <QtCore/qstate.h>
#endif
diff --git a/examples/animation/sub-attaq/boat.cpp b/examples/animation/sub-attaq/boat.cpp
index 633e1b1..5721485 100644
--- a/examples/animation/sub-attaq/boat.cpp
+++ b/examples/animation/sub-attaq/boat.cpp
@@ -56,6 +56,7 @@
# include "qhistorystate.h"
# include "qfinalstate.h"
# include "qstate.h"
+# include "qpauseanimation.h"
#include "qsequentialanimationgroup.h"
#else
#include <QPropertyAnimation>
diff --git a/examples/animation/sub-attaq/boat.h b/examples/animation/sub-attaq/boat.h
index 4c4a737..b8d5772 100644
--- a/examples/animation/sub-attaq/boat.h
+++ b/examples/animation/sub-attaq/boat.h
@@ -49,7 +49,7 @@
#include <QDebug>
#if defined(QT_EXPERIMENTAL_SOLUTION)
-# include "qgraphicswidget.h"
+# include "qtgraphicswidget.h"
#else
# include <QtGui/QGraphicsWidget>
#endif
diff --git a/examples/animation/sub-attaq/qanimationstate.cpp b/examples/animation/sub-attaq/qanimationstate.cpp
index 70285a8..3659657 100644
--- a/examples/animation/sub-attaq/qanimationstate.cpp
+++ b/examples/animation/sub-attaq/qanimationstate.cpp
@@ -43,11 +43,12 @@
#if defined(QT_EXPERIMENTAL_SOLUTION)
# include "qstate.h"
+# include "qstate_p.h"
#else
# include <QtCore/qstate.h>
+# include <private/qstate_p.h>
#endif
-#include <private/qstate_p.h>
QT_BEGIN_NAMESPACE
diff --git a/examples/animation/sub-attaq/submarine.cpp b/examples/animation/sub-attaq/submarine.cpp
index e64ffdd..555617c 100644
--- a/examples/animation/sub-attaq/submarine.cpp
+++ b/examples/animation/sub-attaq/submarine.cpp
@@ -50,10 +50,11 @@
#include "qanimationstate.h"
#if defined(QT_EXPERIMENTAL_SOLUTION)
-#include "qpropertyanimation.h"
-#include "qstatemachine.h"
-#include "qfinalstate.h"
-#include "qsequentialanimationgroup.h"
+# include "qpropertyanimation.h"
+# include "qstatemachine.h"
+# include "qfinalstate.h"
+# include "qsequentialanimationgroup.h"
+# include "qpauseanimation.h"
#else
#include <QPropertyAnimation>
#include <QStateMachine>
diff --git a/src/corelib/animation/qpropertyanimation.cpp b/src/corelib/animation/qpropertyanimation.cpp
index edcabaa..9a0c5bc 100644
--- a/src/corelib/animation/qpropertyanimation.cpp
+++ b/src/corelib/animation/qpropertyanimation.cpp
@@ -49,7 +49,7 @@
by itself as a simple animation class, or as part of more complex
animations through QAnimationGroup.
- The most common way to use QPropertyAnimation is to construct an instance
+ The most common way to use QPropertyAnimation is to construct an instance
of it by passing a pointer to a QObject or a QWidget, and the name of the
property you would like to animate to QPropertyAnimation's constructor.
@@ -220,11 +220,20 @@ void QPropertyAnimation::updateCurrentValue(const QVariant &value)
/*!
\reimp
+
+ If the startValue is not defined when the state of the animation changes from Stopped to Running,
+ the current property value is used as the initial value for the animation.
*/
void QPropertyAnimation::updateState(QAbstractAnimation::State oldState,
QAbstractAnimation::State newState)
{
Q_D(QPropertyAnimation);
+
+ if (!d->target) {
+ qWarning("QPropertyAnimation::updateState: Changing state of an animation without target");
+ return;
+ }
+
QVariantAnimation::updateState(oldState, newState);
QMutexLocker locker(guardHashLock());
QPropertyAnimationHash * hash = _q_runningAnimations();
@@ -235,20 +244,19 @@ void QPropertyAnimation::updateState(QAbstractAnimation::State oldState,
if (oldAnim) {
// try to stop the top level group
QAbstractAnimation *current = oldAnim;
- while(current->group() && current->state() != Stopped) current = current->group();
+ while (current->group() && current->state() != Stopped)
+ current = current->group();
current->stop();
}
hash->insert(key, this);
- // Initialize start value
- // ### review this line below, d->atEnd() ?
- // ### avoid entering a state where start value is not set
- if (d->target && (d->atBeginning() || d->atEnd())) {
+
+ // update the default start value
+ if (oldState == Stopped) {
d->setDefaultStartValue(d->target->property(d->propertyName.constData()));
}
} else if (hash->value(key) == this) {
hash->remove(key);
}
-
}
#include "moc_qpropertyanimation.cpp"
diff --git a/src/corelib/animation/qvariantanimation_p.h b/src/corelib/animation/qvariantanimation_p.h
index 66910c1..14a3ef6 100644
--- a/src/corelib/animation/qvariantanimation_p.h
+++ b/src/corelib/animation/qvariantanimation_p.h
@@ -88,18 +88,6 @@ public:
return q->d_func();
}
-
- //some helper functions
- bool atBeginning() const
- {
- return currentTime == 0;
- }
-
- bool atEnd() const
- {
- return currentTime == duration && currentLoop == (loopCount - 1);
- }
-
void setDefaultStartValue(const QVariant &value);
int duration;
@@ -109,7 +97,7 @@ public:
QVariant currentValue;
QVariant defaultStartValue;
bool hasStartValue;
-
+
//this is used to keep track of the KeyValue interval in which we currently are
struct
{
diff --git a/src/gui/animation/qguivariantanimation.cpp b/src/gui/animation/qguivariantanimation.cpp
index fab377a..ed18caa 100644
--- a/src/gui/animation/qguivariantanimation.cpp
+++ b/src/gui/animation/qguivariantanimation.cpp
@@ -41,8 +41,6 @@
#ifndef QT_NO_ANIMATION
-/*QT_BEGIN_NAMESPACE
-
#ifdef QT_EXPERIMENTAL_SOLUTION
# include "qvariantanimation.h"
# include "qvariantanimation_p.h"
@@ -51,6 +49,9 @@
#include <private/qvariantanimation_p.h>
#endif
+#include <QtGui/qcolor.h>
+
+QT_BEGIN_NAMESPACE
template<> Q_INLINE_TEMPLATE QColor _q_interpolate(const QColor &f,const QColor &t, qreal progress)
{
@@ -74,6 +75,6 @@ static int qUnregisterGuiGetInterpolator()
}
Q_DESTRUCTOR_FUNCTION(qUnregisterGuiGetInterpolator)
-QT_END_NAMESPACE*/
+QT_END_NAMESPACE
#endif //QT_NO_ANIMATION
diff --git a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp
index 437c862..f0deab5 100644
--- a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp
+++ b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp
@@ -84,6 +84,7 @@ private slots:
void deletion3();
void duration0();
void noStartValue();
+ void noStartValueWithLoop();
void startWhenAnotherIsRunning();
void easingcurve_data();
void easingcurve();
@@ -416,6 +417,27 @@ void tst_QPropertyAnimation::noStartValue()
QCOMPARE(o.values.last(), 420);
}
+void tst_QPropertyAnimation::noStartValueWithLoop()
+{
+ StartValueTester o;
+ o.setProperty("ole", 42);
+ o.values.clear();
+
+ QPropertyAnimation a(&o, "ole");
+ a.setEndValue(420);
+ a.setDuration(250);
+ a.setLoopCount(2);
+ a.start();
+
+ a.setCurrentTime(250);
+ QCOMPARE(o.values.first(), 42);
+ QCOMPARE(a.currentValue().toInt(), 42);
+ QCOMPARE(o.values.last(), 42);
+
+ a.setCurrentTime(500);
+ QCOMPARE(a.currentValue().toInt(), 420);
+}
+
void tst_QPropertyAnimation::startWhenAnotherIsRunning()
{
StartValueTester o;