added animation slowdown dropdown menu to toolbar

This commit is contained in:
Lasse Holmstedt
2010-07-12 14:32:54 +02:00
committed by Olivier Goffart
parent 66a008e9de
commit 46b57ff723
5 changed files with 107 additions and 7 deletions

View File

@@ -11,6 +11,8 @@
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QAction> #include <QAction>
#include <QToolButton> #include <QToolButton>
#include <QMenu>
#include <QActionGroup>
namespace QmlJSInspector { namespace QmlJSInspector {
namespace Internal { namespace Internal {
@@ -34,8 +36,15 @@ QmlInspectorToolbar::QmlInspectorToolbar(QObject *parent) :
m_colorPickerAction(0), m_colorPickerAction(0),
m_toQmlAction(0), m_toQmlAction(0),
m_fromQmlAction(0), m_fromQmlAction(0),
m_defaultAnimSpeedAction(0),
m_halfAnimSpeedAction(0),
m_fourthAnimSpeedAction(0),
m_eighthAnimSpeedAction(0),
m_tenthAnimSpeedAction(0),
m_emitSignals(true), m_emitSignals(true),
m_isRunning(false), m_isRunning(false),
m_animationSpeed(1.0f),
m_previousAnimationSpeed(0.0f),
m_activeTool(NoTool) m_activeTool(NoTool)
{ {
@@ -59,6 +68,7 @@ void QmlInspectorToolbar::enable()
{ {
setEnabled(true); setEnabled(true);
m_emitSignals = false; m_emitSignals = false;
changeAnimationSpeed(1.0f);
activateDesignModeOnClick(); activateDesignModeOnClick();
m_emitSignals = true; m_emitSignals = true;
} }
@@ -104,6 +114,20 @@ void QmlInspectorToolbar::changeAnimationSpeed(qreal slowdownFactor)
if (slowdownFactor == 0) { if (slowdownFactor == 0) {
activatePauseOnClick(); activatePauseOnClick();
} else { } 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(); activatePlayOnClick();
} }
m_emitSignals = true; m_emitSignals = true;
@@ -162,11 +186,39 @@ void QmlInspectorToolbar::createActions(const Core::Context &context)
configBarLayout->setMargin(0); configBarLayout->setMargin(0);
configBarLayout->setSpacing(5); 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::DEBUG)->action()));
configBarLayout->addWidget(createToolButton(am->command(ProjectExplorer::Constants::STOP)->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::DESIGNMODE_ACTION)->action()));
configBarLayout->addWidget(createToolButton(am->command(QmlJSInspector::Constants::RELOAD_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::PAUSE_ACTION)->action()));
configBarLayout->addWidget(createToolButton(am->command(QmlJSInspector::Constants::SELECT_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())); 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() void QmlInspectorToolbar::activateDesignModeOnClick()
{ {
bool checked = m_designmodeAction->isChecked(); bool checked = m_designmodeAction->isChecked();
@@ -221,11 +303,12 @@ void QmlInspectorToolbar::activateDesignModeOnClick()
void QmlInspectorToolbar::activatePlayOnClick() void QmlInspectorToolbar::activatePlayOnClick()
{ {
m_pauseAction->setChecked(false); m_pauseAction->setChecked(false);
if (!m_isRunning) { if (!m_isRunning || m_animationSpeed != m_previousAnimationSpeed) {
m_playAction->setChecked(true); m_playAction->setChecked(true);
m_isRunning = true; m_isRunning = true;
m_previousAnimationSpeed = m_animationSpeed;
if (m_emitSignals) if (m_emitSignals)
emit animationSpeedChanged(1.0f); emit animationSpeedChanged(m_animationSpeed);
} }
} }

View File

@@ -63,6 +63,12 @@ private slots:
void activateMarqueeSelectToolOnClick(); void activateMarqueeSelectToolOnClick();
void activateZoomOnClick(); void activateZoomOnClick();
void changeToDefaultAnimSpeed();
void changeToHalfAnimSpeed();
void changeToFourthAnimSpeed();
void changeToEighthAnimSpeed();
void changeToTenthAnimSpeed();
void activateFromQml(); void activateFromQml();
void activateToQml(); void activateToQml();
@@ -78,8 +84,17 @@ private:
QAction *m_toQmlAction; QAction *m_toQmlAction;
QAction *m_fromQmlAction; QAction *m_fromQmlAction;
QAction *m_defaultAnimSpeedAction;
QAction *m_halfAnimSpeedAction;
QAction *m_fourthAnimSpeedAction;
QAction *m_eighthAnimSpeedAction;
QAction *m_tenthAnimSpeedAction;
bool m_emitSignals; bool m_emitSignals;
bool m_isRunning; bool m_isRunning;
qreal m_animationSpeed;
qreal m_previousAnimationSpeed;
DesignTool m_activeTool; DesignTool m_activeTool;
}; };

View File

@@ -154,7 +154,6 @@ void QmlJSDesignDebugClient::setAnimationSpeed(qreal slowdownFactor)
ds << QByteArray("SET_ANIMATION_SPEED") ds << QByteArray("SET_ANIMATION_SPEED")
<< slowdownFactor; << slowdownFactor;
sendMessage(message); sendMessage(message);
} }

View File

@@ -91,6 +91,7 @@ void RubberBandSelectionManipulator::select(SelectionType selectionType)
foreach (QGraphicsItem* item, itemList) { foreach (QGraphicsItem* item, itemList) {
if (item if (item
&& item->parentItem() && item->parentItem()
&& !newSelectionList.contains(item)
//&& m_beginFormEditorItem->childItems().contains(item) // TODO activate this test //&& m_beginFormEditorItem->childItems().contains(item) // TODO activate this test
) )
{ {

View File

@@ -228,6 +228,8 @@ void QDeclarativeDesignView::setDesignModeBehavior(bool value)
if (m_subcomponentEditorTool) { if (m_subcomponentEditorTool) {
m_subcomponentEditorTool->clear(); m_subcomponentEditorTool->clear();
clearHighlightBoundingRect(); clearHighlightBoundingRect();
setSelectedItems(QList<QGraphicsItem*>());
if (rootObject()) if (rootObject())
m_subcomponentEditorTool->pushContext(rootObject()); m_subcomponentEditorTool->pushContext(rootObject());
} }
@@ -335,7 +337,6 @@ void QDeclarativeDesignView::changeToSelectTool()
void QDeclarativeDesignView::changeToMarqueeSelectTool() void QDeclarativeDesignView::changeToMarqueeSelectTool()
{ {
qDebug() << "changed to marquee select tool";
changeToSelectTool(); changeToSelectTool();
m_currentToolMode = Constants::MarqueeSelectionToolMode; m_currentToolMode = Constants::MarqueeSelectionToolMode;
m_selectionTool->setRubberbandSelectionMode(true); m_selectionTool->setRubberbandSelectionMode(true);
@@ -347,7 +348,6 @@ void QDeclarativeDesignView::changeToMarqueeSelectTool()
void QDeclarativeDesignView::changeToZoomTool() void QDeclarativeDesignView::changeToZoomTool()
{ {
m_currentToolMode = Constants::ZoomMode; m_currentToolMode = Constants::ZoomMode;
qDebug() << "changed to zoom tool";
m_currentTool->clear(); m_currentTool->clear();
m_currentTool = m_zoomTool; m_currentTool = m_zoomTool;
m_currentTool->clear(); m_currentTool->clear();
@@ -386,10 +386,12 @@ void QDeclarativeDesignView::continueExecution(qreal slowdownFactor)
Q_ASSERT(slowdownFactor > 0); Q_ASSERT(slowdownFactor > 0);
m_slowdownFactor = slowdownFactor; m_slowdownFactor = slowdownFactor;
static const qreal animSpeedSnapDelta = 0.01f;
bool useStandardSpeed = (qAbs(1.0f - m_slowdownFactor) < animSpeedSnapDelta);
QUnifiedTimer *timer = QUnifiedTimer::instance(); QUnifiedTimer *timer = QUnifiedTimer::instance();
timer->setSlowdownFactor(m_slowdownFactor); timer->setSlowdownFactor(m_slowdownFactor);
timer->setSlowModeEnabled(false); timer->setSlowModeEnabled(!useStandardSpeed);
m_executionPaused = false; m_executionPaused = false;
emit executionStarted(m_slowdownFactor); emit executionStarted(m_slowdownFactor);