aboutsummaryrefslogtreecommitdiffstats
path: root/src/tools/qml
diff options
context:
space:
mode:
authorChristiaan Janssen <[email protected]>2010-09-07 17:23:12 +0200
committerChristiaan Janssen <[email protected]>2010-09-07 17:25:07 +0200
commita9a99225b876acf0c5664d2a7d021c3f05c1b48e (patch)
treeccfaf481f8a5c59ae904fb646b18c5f1ea0e6ed8 /src/tools/qml
parentebc305b0d8440c7171e5e7b548c167f302b3467d (diff)
QmlInspector: Added pause and step animations option
Reviewed-by: Lasse Holmstedt
Diffstat (limited to 'src/tools/qml')
-rw-r--r--src/tools/qml/qmlobserver/qmlruntime.cpp30
-rw-r--r--src/tools/qml/qmlobserver/qmlruntime.h8
2 files changed, 35 insertions, 3 deletions
diff --git a/src/tools/qml/qmlobserver/qmlruntime.cpp b/src/tools/qml/qmlobserver/qmlruntime.cpp
index 58328110b6c..6e5bdcf335c 100644
--- a/src/tools/qml/qmlobserver/qmlruntime.cpp
+++ b/src/tools/qml/qmlobserver/qmlruntime.cpp
@@ -98,6 +98,7 @@
#include <QMutexLocker>
#include "proxysettings.h"
#include "deviceorientation.h"
+#include <QInputDialog>
#ifdef GL_SUPPORTED
#include <QGLWidget>
@@ -770,10 +771,16 @@ void QDeclarativeViewer::createMenu()
speedAction->setData(10.0f);
playSpeedMenuActions->addAction(speedAction);
- pauseAnimationsAction = playSpeedMenu->addAction(tr("Pause"), this, SLOT(pauseAnimations(bool)));
+ pauseAnimationsAction = playSpeedMenu->addAction(tr("Pause"), this, SLOT(setAnimationsPaused(bool)));
pauseAnimationsAction->setCheckable(true);
pauseAnimationsAction->setShortcut(QKeySequence("Ctrl+."));
+ animationStepAction = playSpeedMenu->addAction(tr("Pause and step"), this, SLOT(stepAnimations()));
+ animationStepAction->setShortcut(QKeySequence("Ctrl+,"));
+
+ animationSetStepAction = playSpeedMenu->addAction(tr("Set step"), this, SLOT(setAnimationStep()));
+ m_stepSize = 40;
+
QAction *playSpeedAction = new QAction(tr("Animations"), this);
playSpeedAction->setMenu(playSpeedMenu);
@@ -1002,7 +1009,7 @@ void QDeclarativeViewer::toggleRecording()
setRecording(recording);
}
-void QDeclarativeViewer::pauseAnimations(bool enable)
+void QDeclarativeViewer::setAnimationsPaused(bool enable)
{
if (enable) {
setAnimationSpeed(0.0);
@@ -1011,6 +1018,25 @@ void QDeclarativeViewer::pauseAnimations(bool enable)
}
}
+void QDeclarativeViewer::pauseAnimations() {
+ pauseAnimationsAction->setChecked(true);
+ setAnimationsPaused(true);
+}
+
+void QDeclarativeViewer::stepAnimations()
+{
+ setAnimationSpeed(1.0);
+ QTimer::singleShot(m_stepSize, this, SLOT(pauseAnimations()));
+}
+
+void QDeclarativeViewer::setAnimationStep()
+{
+ bool ok;
+ int stepSize = QInputDialog::getInt(this, tr("Set animation step duration"),
+ tr("Step duration (ms):"), m_stepSize, 20, 10000, 1, &ok);
+ if (ok) m_stepSize = stepSize;
+}
+
void QDeclarativeViewer::changeAnimationSpeed()
{
QAction *action = qobject_cast<QAction*>(sender());
diff --git a/src/tools/qml/qmlobserver/qmlruntime.h b/src/tools/qml/qmlobserver/qmlruntime.h
index c4653201c79..2c6c5eefbd4 100644
--- a/src/tools/qml/qmlobserver/qmlruntime.h
+++ b/src/tools/qml/qmlobserver/qmlruntime.h
@@ -131,7 +131,10 @@ public slots:
void proxySettingsChanged ();
void rotateOrientation();
void statusChanged();
- void pauseAnimations(bool);
+ void setAnimationsPaused(bool);
+ void pauseAnimations();
+ void stepAnimations();
+ void setAnimationStep();
void changeAnimationSpeed();
void launch(const QString &);
@@ -193,7 +196,10 @@ private:
bool convertAvailable;
float animationSpeed;
+ int m_stepSize;
QAction *pauseAnimationsAction;
+ QAction *animationStepAction;
+ QAction *animationSetStepAction;
QActionGroup *orientation;
QAction *showWarningsWindow;