summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2009-05-07 04:24:12 (GMT)
committerMartin Jones <martin.jones@nokia.com>2009-05-07 04:24:12 (GMT)
commit606e899f018fbe1eb8f0621e3c47c44672e80624 (patch)
tree76e4863c3fec7aa836231823f7a6e464e55c089c
parent572f00d8c2684f6e396d17638ae08bfac57b410e (diff)
parent9e9ee6ac63038c050ef02b102c23ebb899c45374 (diff)
downloadQt-606e899f018fbe1eb8f0621e3c47c44672e80624.zip
Qt-606e899f018fbe1eb8f0621e3c47c44672e80624.tar.gz
Qt-606e899f018fbe1eb8f0621e3c47c44672e80624.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
-rw-r--r--doc/src/declarative/animation.qdoc17
-rw-r--r--src/declarative/util/qmlanimation.cpp3
-rw-r--r--src/declarative/util/qmlanimation_p.h14
-rw-r--r--tools/qmlviewer/main.cpp1
-rw-r--r--tools/qmlviewer/qmlviewer.cpp42
-rw-r--r--tools/qmlviewer/qmlviewer.h3
6 files changed, 60 insertions, 20 deletions
diff --git a/doc/src/declarative/animation.qdoc b/doc/src/declarative/animation.qdoc
index f7e03ee..f17f5c9 100644
--- a/doc/src/declarative/animation.qdoc
+++ b/doc/src/declarative/animation.qdoc
@@ -25,7 +25,7 @@ Other Features:
\o Animation synchronization
\endlist
-The simplest form of animation is using \c NumericAnimation
+The simplest form of animation is using \l NumericAnimation
The following example creates a bouncing effect:
\code
@@ -34,20 +34,15 @@ Rect {
width: 120; height: 200; color: "white"
Image {
id: img
- source: "pics/qtlogo.png"
+ source: "qt-logo.png"
x: 60-img.width/2
- y: 200-img.height
+ y: 0
y: SequentialAnimation {
running: true
repeat: true
- NumericAnimation {
- to: 200-img.height
- easing: "easeOutBounce(amplitude:100)"
- duration: 2000
- }
- PauseAnimation {
- duration: 1000
- }
+ NumericAnimation { to: 200-img.height; easing: "easeOutBounce"; duration: 2000 }
+ PauseAnimation { duration: 1000 }
+ NumericAnimation { to: 0; easing: "easeOutQuad"; duration: 1000 }
}
}
}
diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp
index 08a7a28..dd4e1eb 100644
--- a/src/declarative/util/qmlanimation.cpp
+++ b/src/declarative/util/qmlanimation.cpp
@@ -791,6 +791,7 @@ void QmlColorAnimation::prepare(QmlMetaProperty &p)
d->fromSourced = false;
d->value.QmlTimeLineValue::setValue(0.);
d->ca->setAnimValue(&d->value, QAbstractAnimation::KeepWhenStopped);
+ d->ca->setFromSourcedValue(&d->fromSourced);
}
QAbstractAnimation *QmlColorAnimation::qtAnimation()
@@ -1595,6 +1596,7 @@ void QmlNumericAnimation::prepare(QmlMetaProperty &p)
d->fromSourced = false;
d->value.QmlTimeLineValue::setValue(0.);
d->na->setAnimValue(&d->value, QAbstractAnimation::KeepWhenStopped);
+ d->na->setFromSourcedValue(&d->fromSourced);
}
QAbstractAnimation *QmlNumericAnimation::qtAnimation()
@@ -2152,6 +2154,7 @@ void QmlVariantAnimation::prepare(QmlMetaProperty &p)
d->fromSourced = false;
d->value.QmlTimeLineValue::setValue(0.);
d->va->setAnimValue(&d->value, QAbstractAnimation::KeepWhenStopped);
+ d->va->setFromSourcedValue(&d->fromSourced);
}
void QmlVariantAnimation::transition(QmlStateActions &actions,
diff --git a/src/declarative/util/qmlanimation_p.h b/src/declarative/util/qmlanimation_p.h
index 06b7c08..00937a6 100644
--- a/src/declarative/util/qmlanimation_p.h
+++ b/src/declarative/util/qmlanimation_p.h
@@ -116,8 +116,7 @@ private:
class QmlTimeLineValueAnimator : public QVariantAnimation
{
public:
- QmlTimeLineValueAnimator(QObject *parent = 0) : QVariantAnimation(parent), animValue(0), policy(KeepWhenStopped) {}
- QmlTimeLineValueAnimator(QmlTimeLineValue *value, QObject *parent = 0) : QVariantAnimation(parent), animValue(value), policy(KeepWhenStopped) {}
+ QmlTimeLineValueAnimator(QObject *parent = 0) : QVariantAnimation(parent), animValue(0), fromSourced(0), policy(KeepWhenStopped) {}
void setAnimValue(QmlTimeLineValue *value, DeletionPolicy p)
{
if (state() == Running)
@@ -125,6 +124,10 @@ public:
animValue = value;
policy = p;
}
+ void setFromSourcedValue(bool *value)
+ {
+ fromSourced = value;
+ }
protected:
virtual void updateCurrentValue(const QVariant &value)
{
@@ -134,7 +137,11 @@ protected:
virtual void updateState(State oldState, State newState)
{
QVariantAnimation::updateState(oldState, newState);
- if (newState == Stopped && policy == DeleteWhenStopped) {
+ if (newState == Running) {
+ //check for new from every loop
+ if (fromSourced)
+ *fromSourced = false;
+ } else if (newState == Stopped && policy == DeleteWhenStopped) {
delete animValue;
animValue = 0;
}
@@ -142,6 +149,7 @@ protected:
private:
QmlTimeLineValue *animValue;
+ bool *fromSourced;
DeletionPolicy policy;
};
diff --git a/tools/qmlviewer/main.cpp b/tools/qmlviewer/main.cpp
index b588111..3f74ef6 100644
--- a/tools/qmlviewer/main.cpp
+++ b/tools/qmlviewer/main.cpp
@@ -60,7 +60,6 @@ int main(int argc, char ** argv)
char raster[] = "raster";
newargv[argc+1] = raster;
-
QApplication app(newargc, newargv);
app.setApplicationName("viewer");
diff --git a/tools/qmlviewer/qmlviewer.cpp b/tools/qmlviewer/qmlviewer.cpp
index dbbe233..04054ec 100644
--- a/tools/qmlviewer/qmlviewer.cpp
+++ b/tools/qmlviewer/qmlviewer.cpp
@@ -53,7 +53,8 @@ QmlViewer::QmlViewer(QFxTestEngine::TestMode testMode, const QString &testDir, Q
setAttribute(Qt::WA_OpaquePaintEvent);
setAttribute(Qt::WA_NoSystemBackground);
- createMenuBar();
+ if (!(flags & Qt::FramelessWindowHint))
+ createMenuBar();
canvas = new QFxView(this);
if(testMode != QFxTestEngine::NoTest)
@@ -79,12 +80,44 @@ void QmlViewer::createMenuBar()
connect(reloadAction, SIGNAL(triggered()), this, SLOT(reload()));
fileMenu->addAction(reloadAction);
+ QAction *quitAction = new QAction(tr("&Quit"), this);
+ quitAction->setShortcut(QKeySequence("Ctrl+Q"));
+ connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
+ fileMenu->addSeparator();
+ fileMenu->addAction(quitAction);
+
+ /*QMenu *recordMenu = menuBar()->addMenu(tr("&Recording"));
+
+ QAction *snapshotAction = new QAction(tr("&Take Snapsot"), this);
+ connect(snapshotAction, SIGNAL(triggered()), this, SLOT(takeSnapShot()));
+ recordMenu->addAction(snapshotAction);
+
+ recordAction = new QAction(tr("&Start Recording Video"), this);
+ connect(recordAction, SIGNAL(triggered()), this, SLOT(toggleRecording()));
+ recordMenu->addAction(recordAction);*/
+
QMenu *helpMenu = menuBar()->addMenu(tr("&Help"));
QAction *aboutAction = new QAction(tr("&About Qt..."), this);
connect(aboutAction, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
helpMenu->addAction(aboutAction);
}
+void QmlViewer::takeSnapShot()
+{
+ static int snapshotcount = 1;
+ QString snapFileName = QString(QLatin1String("snapshot%1.png")).arg(snapshotcount);
+ canvas->asImage().save(snapFileName);
+ qDebug() << "Wrote" << snapFileName;
+ ++snapshotcount;
+}
+
+void QmlViewer::toggleRecording()
+{
+ bool recording = recordTimer.isActive();
+ //recordAction->setText(recording ? tr("&Start Recording Video") : tr("&End Recording Video"));
+ setRecording(!recording);
+}
+
void QmlViewer::reload()
{
openQml(currentFileName);
@@ -297,10 +330,9 @@ void QmlViewer::keyPressEvent(QKeyEvent *event)
<< "device keys: 0=quit, 1..8=F1..F8"
;
} else if (event->key() == Qt::Key_F2 || (event->key() == Qt::Key_2 && devicemode)) {
- setRecording(!recordTimer.isActive());
+ toggleRecording();
} else if (event->key() == Qt::Key_F3 || (event->key() == Qt::Key_3 && devicemode)) {
- canvas->asImage().save("snapshot.png");
- qDebug() << "Wrote snapshot.png";
+ takeSnapShot();
} else if (event->key() == Qt::Key_F4 || (event->key() == Qt::Key_4 && devicemode)) {
canvas->dumpItems();
canvas->checkState();
@@ -398,7 +430,7 @@ void QmlViewer::setRecording(bool on)
args << "-delay" << QString::number(record_period/10);
args << inputs;
args << record_file;
- qDebug() << "Converting..." << record_file;
+ qDebug() << "Converting..." << record_file << "(this may take a while)";
if (0!=QProcess::execute("convert", args)) {
qWarning() << "Cannot run ImageMagick 'convert' - recorded frames not converted";
inputs.clear(); // don't remove them
diff --git a/tools/qmlviewer/qmlviewer.h b/tools/qmlviewer/qmlviewer.h
index b4117a2..405e8d9 100644
--- a/tools/qmlviewer/qmlviewer.h
+++ b/tools/qmlviewer/qmlviewer.h
@@ -48,6 +48,8 @@ public slots:
void openQml(const QString& fileName);
void open();
void reload();
+ void takeSnapShot();
+ void toggleRecording();
protected:
virtual void keyPressEvent(QKeyEvent *);
@@ -70,6 +72,7 @@ private:
int record_period;
int record_autotime;
bool devicemode;
+ QAction *recordAction;
QFxTestEngine *testEngine;
};