Commit 46b57ff7 authored by Lasse Holmstedt's avatar Lasse Holmstedt Committed by Olivier Goffart
Browse files

added animation slowdown dropdown menu to toolbar

parent 66a008e9
......@@ -11,6 +11,8 @@
#include <QHBoxLayout>
#include <QAction>
#include <QToolButton>
#include <QMenu>
#include <QActionGroup>
namespace QmlJSInspector {
namespace Internal {
......@@ -34,8 +36,15 @@ QmlInspectorToolbar::QmlInspectorToolbar(QObject *parent) :
m_colorPickerAction(0),
m_toQmlAction(0),
m_fromQmlAction(0),
m_defaultAnimSpeedAction(0),
m_halfAnimSpeedAction(0),
m_fourthAnimSpeedAction(0),
m_eighthAnimSpeedAction(0),
m_tenthAnimSpeedAction(0),
m_emitSignals(true),
m_isRunning(false),
m_animationSpeed(1.0f),
m_previousAnimationSpeed(0.0f),
m_activeTool(NoTool)
{
......@@ -59,6 +68,7 @@ void QmlInspectorToolbar::enable()
{
setEnabled(true);
m_emitSignals = false;
changeAnimationSpeed(1.0f);
activateDesignModeOnClick();
m_emitSignals = true;
}
......@@ -104,6 +114,20 @@ void QmlInspectorToolbar::changeAnimationSpeed(qreal slowdownFactor)
if (slowdownFactor == 0) {
activatePauseOnClick();
} else {
m_animationSpeed = slowdownFactor;
if (slowdownFactor == 1.0f) {
m_defaultAnimSpeedAction->setChecked(true);
} else if (slowdownFactor == 2.0f) {
m_halfAnimSpeedAction->setChecked(true);
} else if (slowdownFactor == 4.0f) {
m_fourthAnimSpeedAction->setChecked(true);
} else if (slowdownFactor == 8.0f) {
m_eighthAnimSpeedAction->setChecked(true);
} else if (slowdownFactor == 10.0f) {
m_tenthAnimSpeedAction->setChecked(true);
}
activatePlayOnClick();
}
m_emitSignals = true;
......@@ -162,11 +186,39 @@ void QmlInspectorToolbar::createActions(const Core::Context &context)
configBarLayout->setMargin(0);
configBarLayout->setSpacing(5);
QMenu *playSpeedMenu = new QMenu(configBar);
QActionGroup *playSpeedMenuActions = new QActionGroup(this);
playSpeedMenuActions->setExclusive(true);
m_defaultAnimSpeedAction = playSpeedMenu->addAction(tr("1x"), this, SLOT(changeToDefaultAnimSpeed()));
m_defaultAnimSpeedAction->setCheckable(true);
m_defaultAnimSpeedAction->setChecked(true);
playSpeedMenuActions->addAction(m_defaultAnimSpeedAction);
m_halfAnimSpeedAction = playSpeedMenu->addAction(tr("0.5x"), this, SLOT(changeToHalfAnimSpeed()));
m_halfAnimSpeedAction->setCheckable(true);
playSpeedMenuActions->addAction(m_halfAnimSpeedAction);
m_fourthAnimSpeedAction = playSpeedMenu->addAction(tr("0.25x"), this, SLOT(changeToFourthAnimSpeed()));
m_fourthAnimSpeedAction->setCheckable(true);
playSpeedMenuActions->addAction(m_fourthAnimSpeedAction);
m_eighthAnimSpeedAction = playSpeedMenu->addAction(tr("0.125x"), this, SLOT(changeToEighthAnimSpeed()));
m_eighthAnimSpeedAction->setCheckable(true);
playSpeedMenuActions->addAction(m_eighthAnimSpeedAction);
m_tenthAnimSpeedAction = playSpeedMenu->addAction(tr("0.1x"), this, SLOT(changeToTenthAnimSpeed()));
m_tenthAnimSpeedAction->setCheckable(true);
playSpeedMenuActions->addAction(m_tenthAnimSpeedAction);
configBarLayout->addWidget(createToolButton(am->command(ProjectExplorer::Constants::DEBUG)->action()));
configBarLayout->addWidget(createToolButton(am->command(ProjectExplorer::Constants::STOP)->action()));
configBarLayout->addWidget(createToolButton(am->command(QmlJSInspector::Constants::DESIGNMODE_ACTION)->action()));
configBarLayout->addWidget(createToolButton(am->command(QmlJSInspector::Constants::RELOAD_ACTION)->action()));
configBarLayout->addWidget(createToolButton(am->command(QmlJSInspector::Constants::PLAY_ACTION)->action()));
QToolButton *playButton = createToolButton(am->command(QmlJSInspector::Constants::PLAY_ACTION)->action());
playButton->setMenu(playSpeedMenu);
configBarLayout->addWidget(playButton);
configBarLayout->addWidget(createToolButton(am->command(QmlJSInspector::Constants::PAUSE_ACTION)->action()));
configBarLayout->addWidget(createToolButton(am->command(QmlJSInspector::Constants::SELECT_ACTION)->action()));
......@@ -200,6 +252,36 @@ void QmlInspectorToolbar::createActions(const Core::Context &context)
connect(m_fromQmlAction, SIGNAL(triggered()), SLOT(activateFromQml()));
}
void QmlInspectorToolbar::changeToDefaultAnimSpeed()
{
m_animationSpeed = 1.0f;
activatePlayOnClick();
}
void QmlInspectorToolbar::changeToHalfAnimSpeed()
{
m_animationSpeed = 2.0f;
activatePlayOnClick();
}
void QmlInspectorToolbar::changeToFourthAnimSpeed()
{
m_animationSpeed = 4.0f;
activatePlayOnClick();
}
void QmlInspectorToolbar::changeToEighthAnimSpeed()
{
m_animationSpeed = 8.0f;
activatePlayOnClick();
}
void QmlInspectorToolbar::changeToTenthAnimSpeed()
{
m_animationSpeed = 10.0f;
activatePlayOnClick();
}
void QmlInspectorToolbar::activateDesignModeOnClick()
{
bool checked = m_designmodeAction->isChecked();
......@@ -221,11 +303,12 @@ void QmlInspectorToolbar::activateDesignModeOnClick()
void QmlInspectorToolbar::activatePlayOnClick()
{
m_pauseAction->setChecked(false);
if (!m_isRunning) {
if (!m_isRunning || m_animationSpeed != m_previousAnimationSpeed) {
m_playAction->setChecked(true);
m_isRunning = true;
m_previousAnimationSpeed = m_animationSpeed;
if (m_emitSignals)
emit animationSpeedChanged(1.0f);
emit animationSpeedChanged(m_animationSpeed);
}
}
......
......@@ -63,6 +63,12 @@ private slots:
void activateMarqueeSelectToolOnClick();
void activateZoomOnClick();
void changeToDefaultAnimSpeed();
void changeToHalfAnimSpeed();
void changeToFourthAnimSpeed();
void changeToEighthAnimSpeed();
void changeToTenthAnimSpeed();
void activateFromQml();
void activateToQml();
......@@ -78,8 +84,17 @@ private:
QAction *m_toQmlAction;
QAction *m_fromQmlAction;
QAction *m_defaultAnimSpeedAction;
QAction *m_halfAnimSpeedAction;
QAction *m_fourthAnimSpeedAction;
QAction *m_eighthAnimSpeedAction;
QAction *m_tenthAnimSpeedAction;
bool m_emitSignals;
bool m_isRunning;
qreal m_animationSpeed;
qreal m_previousAnimationSpeed;
DesignTool m_activeTool;
};
......
......@@ -154,7 +154,6 @@ void QmlJSDesignDebugClient::setAnimationSpeed(qreal slowdownFactor)
ds << QByteArray("SET_ANIMATION_SPEED")
<< slowdownFactor;
sendMessage(message);
}
......
......@@ -91,6 +91,7 @@ void RubberBandSelectionManipulator::select(SelectionType selectionType)
foreach (QGraphicsItem* item, itemList) {
if (item
&& item->parentItem()
&& !newSelectionList.contains(item)
//&& m_beginFormEditorItem->childItems().contains(item) // TODO activate this test
)
{
......
......@@ -228,6 +228,8 @@ void QDeclarativeDesignView::setDesignModeBehavior(bool value)
if (m_subcomponentEditorTool) {
m_subcomponentEditorTool->clear();
clearHighlightBoundingRect();
setSelectedItems(QList<QGraphicsItem*>());
if (rootObject())
m_subcomponentEditorTool->pushContext(rootObject());
}
......@@ -335,7 +337,6 @@ void QDeclarativeDesignView::changeToSelectTool()
void QDeclarativeDesignView::changeToMarqueeSelectTool()
{
qDebug() << "changed to marquee select tool";
changeToSelectTool();
m_currentToolMode = Constants::MarqueeSelectionToolMode;
m_selectionTool->setRubberbandSelectionMode(true);
......@@ -347,7 +348,6 @@ void QDeclarativeDesignView::changeToMarqueeSelectTool()
void QDeclarativeDesignView::changeToZoomTool()
{
m_currentToolMode = Constants::ZoomMode;
qDebug() << "changed to zoom tool";
m_currentTool->clear();
m_currentTool = m_zoomTool;
m_currentTool->clear();
......@@ -386,10 +386,12 @@ void QDeclarativeDesignView::continueExecution(qreal slowdownFactor)
Q_ASSERT(slowdownFactor > 0);
m_slowdownFactor = slowdownFactor;
static const qreal animSpeedSnapDelta = 0.01f;
bool useStandardSpeed = (qAbs(1.0f - m_slowdownFactor) < animSpeedSnapDelta);
QUnifiedTimer *timer = QUnifiedTimer::instance();
timer->setSlowdownFactor(m_slowdownFactor);
timer->setSlowModeEnabled(false);
timer->setSlowModeEnabled(!useStandardSpeed);
m_executionPaused = false;
emit executionStarted(m_slowdownFactor);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment