added mode buttons to custom qml viewer and qmljsinspector toolbar

This commit is contained in:
Lasse Holmstedt
2010-07-12 12:02:35 +02:00
committed by Olivier Goffart
parent c53a0337b6
commit 2f8dc2833b
17 changed files with 143 additions and 18 deletions

View File

@@ -24,6 +24,7 @@ static QToolButton *createToolButton(QAction *action)
QmlInspectorToolbar::QmlInspectorToolbar(QObject *parent) : QmlInspectorToolbar::QmlInspectorToolbar(QObject *parent) :
QObject(parent), QObject(parent),
m_designmodeAction(0),
m_reloadAction(0), m_reloadAction(0),
m_playAction(0), m_playAction(0),
m_pauseAction(0), m_pauseAction(0),
@@ -42,6 +43,7 @@ QmlInspectorToolbar::QmlInspectorToolbar(QObject *parent) :
void QmlInspectorToolbar::setEnabled(bool value) void QmlInspectorToolbar::setEnabled(bool value)
{ {
m_designmodeAction->setEnabled(value);
m_reloadAction->setEnabled(value); m_reloadAction->setEnabled(value);
m_playAction->setEnabled(value); m_playAction->setEnabled(value);
m_pauseAction->setEnabled(value); m_pauseAction->setEnabled(value);
@@ -56,6 +58,9 @@ void QmlInspectorToolbar::setEnabled(bool value)
void QmlInspectorToolbar::enable() void QmlInspectorToolbar::enable()
{ {
setEnabled(true); setEnabled(true);
m_emitSignals = false;
activateDesignModeOnClick();
m_emitSignals = true;
} }
void QmlInspectorToolbar::disable() void QmlInspectorToolbar::disable()
@@ -104,6 +109,14 @@ void QmlInspectorToolbar::changeAnimationSpeed(qreal slowdownFactor)
m_emitSignals = true; m_emitSignals = true;
} }
void QmlInspectorToolbar::setDesignModeBehavior(bool inDesignMode)
{
m_emitSignals = false;
m_designmodeAction->setChecked(inDesignMode);
activateDesignModeOnClick();
m_emitSignals = true;
}
void QmlInspectorToolbar::createActions(const Core::Context &context) void QmlInspectorToolbar::createActions(const Core::Context &context)
{ {
Core::ICore *core = Core::ICore::instance(); Core::ICore *core = Core::ICore::instance();
@@ -111,9 +124,8 @@ void QmlInspectorToolbar::createActions(const Core::Context &context)
ExtensionSystem::PluginManager *pluginManager = ExtensionSystem::PluginManager::instance(); ExtensionSystem::PluginManager *pluginManager = ExtensionSystem::PluginManager::instance();
Debugger::DebuggerUISwitcher *uiSwitcher = pluginManager->getObject<Debugger::DebuggerUISwitcher>(); Debugger::DebuggerUISwitcher *uiSwitcher = pluginManager->getObject<Debugger::DebuggerUISwitcher>();
m_designmodeAction = new QAction(QIcon(":/qml/images/designmode.png"), "Design Mode", this);
m_reloadAction = new QAction(QIcon(":/qml/images/reload.png"), "Reload", this); m_reloadAction = new QAction(QIcon(":/qml/images/reload.png"), "Reload", this);
m_reloadAction->setDisabled(true);
m_playAction = new QAction(QIcon(":/qml/images/play-small.png"), tr("Play animations"), this); m_playAction = new QAction(QIcon(":/qml/images/play-small.png"), tr("Play animations"), this);
m_pauseAction = new QAction(QIcon(":/qml/images/pause-small.png"), tr("Pause animations"), this); m_pauseAction = new QAction(QIcon(":/qml/images/pause-small.png"), tr("Pause animations"), this);
m_selectAction = new QAction(QIcon(":/qml/images/select-small.png"), tr("Select"), this); m_selectAction = new QAction(QIcon(":/qml/images/select-small.png"), tr("Select"), this);
@@ -122,6 +134,8 @@ void QmlInspectorToolbar::createActions(const Core::Context &context)
m_colorPickerAction = new QAction(QIcon(":/qml/images/color-picker-small.png"), tr("Color Picker"), this); m_colorPickerAction = new QAction(QIcon(":/qml/images/color-picker-small.png"), tr("Color Picker"), this);
m_toQmlAction = new QAction(QIcon(":/qml/images/to-qml-small.png"), tr("Apply Changes to QML Viewer"), this); m_toQmlAction = new QAction(QIcon(":/qml/images/to-qml-small.png"), tr("Apply Changes to QML Viewer"), this);
m_fromQmlAction = new QAction(QIcon(":/qml/images/from-qml-small.png"), tr("Apply Changes to Document"), this); m_fromQmlAction = new QAction(QIcon(":/qml/images/from-qml-small.png"), tr("Apply Changes to Document"), this);
m_designmodeAction->setCheckable(true);
m_designmodeAction->setChecked(false);
m_playAction->setCheckable(true); m_playAction->setCheckable(true);
m_playAction->setChecked(true); m_playAction->setChecked(true);
m_pauseAction->setCheckable(true); m_pauseAction->setCheckable(true);
@@ -130,6 +144,7 @@ void QmlInspectorToolbar::createActions(const Core::Context &context)
m_zoomAction->setCheckable(true); m_zoomAction->setCheckable(true);
m_colorPickerAction->setCheckable(true); m_colorPickerAction->setCheckable(true);
am->registerAction(m_designmodeAction, QmlJSInspector::Constants::DESIGNMODE_ACTION, context);
am->registerAction(m_reloadAction, QmlJSInspector::Constants::RELOAD_ACTION, context); am->registerAction(m_reloadAction, QmlJSInspector::Constants::RELOAD_ACTION, context);
am->registerAction(m_playAction, QmlJSInspector::Constants::PLAY_ACTION, context); am->registerAction(m_playAction, QmlJSInspector::Constants::PLAY_ACTION, context);
am->registerAction(m_pauseAction, QmlJSInspector::Constants::PAUSE_ACTION, context); am->registerAction(m_pauseAction, QmlJSInspector::Constants::PAUSE_ACTION, context);
@@ -149,6 +164,7 @@ void QmlInspectorToolbar::createActions(const Core::Context &context)
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::RELOAD_ACTION)->action())); configBarLayout->addWidget(createToolButton(am->command(QmlJSInspector::Constants::RELOAD_ACTION)->action()));
configBarLayout->addWidget(createToolButton(am->command(QmlJSInspector::Constants::PLAY_ACTION)->action())); configBarLayout->addWidget(createToolButton(am->command(QmlJSInspector::Constants::PLAY_ACTION)->action()));
configBarLayout->addWidget(createToolButton(am->command(QmlJSInspector::Constants::PAUSE_ACTION)->action())); configBarLayout->addWidget(createToolButton(am->command(QmlJSInspector::Constants::PAUSE_ACTION)->action()));
@@ -167,6 +183,7 @@ void QmlInspectorToolbar::createActions(const Core::Context &context)
uiSwitcher->setToolbar(QmlJSInspector::Constants::LANG_QML, configBar); uiSwitcher->setToolbar(QmlJSInspector::Constants::LANG_QML, configBar);
setEnabled(false); setEnabled(false);
connect(m_designmodeAction, SIGNAL(triggered()), SLOT(activateDesignModeOnClick()));
connect(m_reloadAction, SIGNAL(triggered()), SIGNAL(reloadSelected())); connect(m_reloadAction, SIGNAL(triggered()), SIGNAL(reloadSelected()));
connect(m_colorPickerAction, SIGNAL(triggered()), SLOT(activateColorPickerOnClick())); connect(m_colorPickerAction, SIGNAL(triggered()), SLOT(activateColorPickerOnClick()));
@@ -183,6 +200,24 @@ void QmlInspectorToolbar::createActions(const Core::Context &context)
connect(m_fromQmlAction, SIGNAL(triggered()), SLOT(activateFromQml())); connect(m_fromQmlAction, SIGNAL(triggered()), SLOT(activateFromQml()));
} }
void QmlInspectorToolbar::activateDesignModeOnClick()
{
bool checked = m_designmodeAction->isChecked();
m_reloadAction->setEnabled(checked);
m_playAction->setEnabled(checked);
m_pauseAction->setEnabled(checked);
m_selectAction->setEnabled(checked);
m_selectMarqueeAction->setEnabled(checked);
m_zoomAction->setEnabled(checked);
m_colorPickerAction->setEnabled(checked);
m_toQmlAction->setEnabled(checked);
m_fromQmlAction->setEnabled(checked);
if (m_emitSignals)
emit designModeSelected(checked);
}
void QmlInspectorToolbar::activatePlayOnClick() void QmlInspectorToolbar::activatePlayOnClick()
{ {
m_pauseAction->setChecked(false); m_pauseAction->setChecked(false);

View File

@@ -39,10 +39,12 @@ public slots:
void activateMarqueeSelectTool(); void activateMarqueeSelectTool();
void activateZoomTool(); void activateZoomTool();
void changeAnimationSpeed(qreal slowdownFactor); void changeAnimationSpeed(qreal slowdownFactor);
void setDesignModeBehavior(bool inDesignMode);
signals: signals:
void animationSpeedChanged(qreal slowdownFactor = 1.0f); void animationSpeedChanged(qreal slowdownFactor = 1.0f);
void designModeSelected(bool checked);
void reloadSelected(); void reloadSelected();
void colorPickerSelected(); void colorPickerSelected();
void selectToolSelected(); void selectToolSelected();
@@ -53,6 +55,7 @@ signals:
void applyChangesFromQmlFileSelected(); void applyChangesFromQmlFileSelected();
private slots: private slots:
void activateDesignModeOnClick();
void activatePlayOnClick(); void activatePlayOnClick();
void activatePauseOnClick(); void activatePauseOnClick();
void activateColorPickerOnClick(); void activateColorPickerOnClick();
@@ -64,6 +67,7 @@ private slots:
void activateToQml(); void activateToQml();
private: private:
QAction *m_designmodeAction;
QAction *m_reloadAction; QAction *m_reloadAction;
QAction *m_playAction; QAction *m_playAction;
QAction *m_pauseAction; QAction *m_pauseAction;

View File

@@ -77,8 +77,9 @@ bool ClientProxy::connectToViewer(const QString &host, quint16 port)
disconnect(m_designClient, disconnect(m_designClient,
SIGNAL(selectMarqueeToolActivated()), this, SIGNAL(selectMarqueeToolActivated())); SIGNAL(selectMarqueeToolActivated()), this, SIGNAL(selectMarqueeToolActivated()));
disconnect(m_designClient, disconnect(m_designClient,
SIGNAL(animationSpeedChanged(qreal)), this, SIGNAL(animationSpeedChanged(qreal))); SIGNAL(animationSpeedChanged(qreal)), this, SIGNAL(animationSpeedChanged(qreal)));
disconnect(m_designClient,
SIGNAL(designModeBehaviorChanged(bool)), this, SIGNAL(designModeBehaviorChanged(bool)));
emit aboutToDisconnect(); emit aboutToDisconnect();
@@ -173,7 +174,8 @@ void ClientProxy::connectionStateChanged()
SIGNAL(selectMarqueeToolActivated()), SIGNAL(selectMarqueeToolActivated())); SIGNAL(selectMarqueeToolActivated()), SIGNAL(selectMarqueeToolActivated()));
connect(m_designClient, connect(m_designClient,
SIGNAL(animationSpeedChanged(qreal)), SIGNAL(animationSpeedChanged(qreal))); SIGNAL(animationSpeedChanged(qreal)), SIGNAL(animationSpeedChanged(qreal)));
connect(m_designClient,
SIGNAL(designModeBehaviorChanged(bool)), SIGNAL(designModeBehaviorChanged(bool)));
} }
(void) new DebuggerClient(m_conn); (void) new DebuggerClient(m_conn);
@@ -333,6 +335,12 @@ void ClientProxy::reloadQmlViewer()
m_designClient->reloadViewer(); m_designClient->reloadViewer();
} }
void ClientProxy::setDesignModeBehavior(bool inDesignMode)
{
if (m_designClient && m_conn->isConnected())
m_designClient->setDesignModeBehavior(inDesignMode);
}
void ClientProxy::setAnimationSpeed(qreal slowdownFactor) void ClientProxy::setAnimationSpeed(qreal slowdownFactor)
{ {
if (m_designClient && m_conn->isConnected()) if (m_designClient && m_conn->isConnected())

View File

@@ -94,11 +94,13 @@ signals:
void selectMarqueeToolActivated(); void selectMarqueeToolActivated();
void zoomToolActivated(); void zoomToolActivated();
void animationSpeedChanged(qreal slowdownFactor); void animationSpeedChanged(qreal slowdownFactor);
void designModeBehaviorChanged(bool inDesignMode);
public slots: public slots:
void queryEngineContext(int id); void queryEngineContext(int id);
void reloadQmlViewer(); void reloadQmlViewer();
void setDesignModeBehavior(bool inDesignMode);
void setAnimationSpeed(qreal slowdownFactor = 1.0f); void setAnimationSpeed(qreal slowdownFactor = 1.0f);
void changeToColorPickerTool(); void changeToColorPickerTool();
void changeToZoomTool(); void changeToZoomTool();

View File

@@ -93,6 +93,10 @@ void QmlJSDesignDebugClient::messageReceived(const QByteArray &message)
qreal slowdownFactor; qreal slowdownFactor;
ds >> slowdownFactor; ds >> slowdownFactor;
emit animationSpeedChanged(slowdownFactor); emit animationSpeedChanged(slowdownFactor);
} else if (type == "SET_DESIGN_MODE") {
bool inDesignMode;
ds >> inDesignMode;
emit designModeBehaviorChanged(inDesignMode);
} }
} }
@@ -126,6 +130,20 @@ void QmlJSDesignDebugClient::reloadViewer()
sendMessage(message); sendMessage(message);
} }
void QmlJSDesignDebugClient::setDesignModeBehavior(bool inDesignMode)
{
if (!m_connection || !m_connection->isConnected())
return;
QByteArray message;
QDataStream ds(&message, QIODevice::WriteOnly);
ds << QByteArray("SET_DESIGN_MODE")
<< inDesignMode;
sendMessage(message);
}
void QmlJSDesignDebugClient::setAnimationSpeed(qreal slowdownFactor) void QmlJSDesignDebugClient::setAnimationSpeed(qreal slowdownFactor)
{ {
if (!m_connection || !m_connection->isConnected()) if (!m_connection || !m_connection->isConnected())

View File

@@ -57,6 +57,7 @@ public:
void setSelectedItemsByObjectId(const QList<QDeclarativeDebugObjectReference> &objects); void setSelectedItemsByObjectId(const QList<QDeclarativeDebugObjectReference> &objects);
void reloadViewer(); void reloadViewer();
void setDesignModeBehavior(bool inDesignMode);
void setAnimationSpeed(qreal slowdownFactor); void setAnimationSpeed(qreal slowdownFactor);
void changeToColorPickerTool(); void changeToColorPickerTool();
void changeToSelectTool(); void changeToSelectTool();
@@ -73,6 +74,7 @@ signals:
void selectMarqueeToolActivated(); void selectMarqueeToolActivated();
void zoomToolActivated(); void zoomToolActivated();
void animationSpeedChanged(qreal slowdownFactor); void animationSpeedChanged(qreal slowdownFactor);
void designModeBehaviorChanged(bool inDesignMode);
protected: protected:
virtual void messageReceived(const QByteArray &); virtual void messageReceived(const QByteArray &);

View File

@@ -17,5 +17,6 @@
<file>images/from-qml-small.png</file> <file>images/from-qml-small.png</file>
<file>images/zoom-small.png</file> <file>images/zoom-small.png</file>
<file>images/select-marquee-small.png</file> <file>images/select-marquee-small.png</file>
<file>images/designmode.png</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@@ -42,6 +42,7 @@ const char * const M_DEBUG_SIMULTANEOUSLY = "QmlInspector.Menu.SimultaneousDebug
const char * const LANG_QML = "QML"; const char * const LANG_QML = "QML";
const char * const DESIGNMODE_ACTION = "QmlInspector.DesignMode";
const char * const RELOAD_ACTION = "QmlInspector.Reload"; const char * const RELOAD_ACTION = "QmlInspector.Reload";
const char * const PLAY_ACTION = "QmlInspector.Play"; const char * const PLAY_ACTION = "QmlInspector.Play";
const char * const PAUSE_ACTION = "QmlInspector.Pause"; const char * const PAUSE_ACTION = "QmlInspector.Pause";

View File

@@ -158,6 +158,7 @@ void InspectorPlugin::extensionsInitialized()
connect(_clientProxy, SIGNAL(connected(QDeclarativeEngineDebug*)), m_toolbar, SLOT(enable())); connect(_clientProxy, SIGNAL(connected(QDeclarativeEngineDebug*)), m_toolbar, SLOT(enable()));
connect(_clientProxy, SIGNAL(disconnected()), m_toolbar, SLOT(disable())); connect(_clientProxy, SIGNAL(disconnected()), m_toolbar, SLOT(disable()));
connect(m_toolbar, SIGNAL(designModeSelected(bool)), _clientProxy, SLOT(setDesignModeBehavior(bool)));
connect(m_toolbar, SIGNAL(reloadSelected()), _clientProxy, SLOT(reloadQmlViewer())); connect(m_toolbar, SIGNAL(reloadSelected()), _clientProxy, SLOT(reloadQmlViewer()));
connect(m_toolbar, SIGNAL(animationSpeedChanged(qreal)), _clientProxy, SLOT(setAnimationSpeed(qreal))); connect(m_toolbar, SIGNAL(animationSpeedChanged(qreal)), _clientProxy, SLOT(setAnimationSpeed(qreal)));
connect(m_toolbar, SIGNAL(colorPickerSelected()), _clientProxy, SLOT(changeToColorPickerTool())); connect(m_toolbar, SIGNAL(colorPickerSelected()), _clientProxy, SLOT(changeToColorPickerTool()));
@@ -169,6 +170,7 @@ void InspectorPlugin::extensionsInitialized()
connect(_clientProxy, SIGNAL(selectToolActivated()), m_toolbar, SLOT(activateSelectTool())); connect(_clientProxy, SIGNAL(selectToolActivated()), m_toolbar, SLOT(activateSelectTool()));
connect(_clientProxy, SIGNAL(selectMarqueeToolActivated()), m_toolbar, SLOT(activateMarqueeSelectTool())); connect(_clientProxy, SIGNAL(selectMarqueeToolActivated()), m_toolbar, SLOT(activateMarqueeSelectTool()));
connect(_clientProxy, SIGNAL(zoomToolActivated()), m_toolbar, SLOT(activateZoomTool())); connect(_clientProxy, SIGNAL(zoomToolActivated()), m_toolbar, SLOT(activateZoomTool()));
connect(_clientProxy, SIGNAL(designModeBehaviorChanged(bool)), m_toolbar, SLOT(setDesignModeBehavior(bool)));
connect(_clientProxy, SIGNAL(animationSpeedChanged(qreal)), m_toolbar, SLOT(changeAnimationSpeed(qreal))); connect(_clientProxy, SIGNAL(animationSpeedChanged(qreal)), m_toolbar, SLOT(changeAnimationSpeed(qreal)));
} }

View File

@@ -81,12 +81,6 @@ QmlRunControl::~QmlRunControl()
void QmlRunControl::start() void QmlRunControl::start()
{ {
if (runMode() == ProjectExplorer::Constants::DEBUGMODE) {
if (!m_commandLineArguments.contains(QmlJSInspector::Constants::ARG_DESIGNMODE)) {
m_commandLineArguments.append(QmlJSInspector::Constants::ARG_DESIGNMODE);
}
}
m_applicationLauncher.start(ProjectExplorer::ApplicationLauncher::Gui, m_executable, m_applicationLauncher.start(ProjectExplorer::ApplicationLauncher::Gui, m_executable,
m_commandLineArguments); m_commandLineArguments);

View File

@@ -9,5 +9,6 @@
<file>images/from-qml.png</file> <file>images/from-qml.png</file>
<file>images/zoom.png</file> <file>images/zoom.png</file>
<file>images/to-qml.png</file> <file>images/to-qml.png</file>
<file>images/designmode.png</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@@ -14,6 +14,7 @@ QmlToolbar::QmlToolbar(QWidget *parent) :
m_emitSignals(true), m_emitSignals(true),
ui(new Ui) ui(new Ui)
{ {
ui->designmode = new QAction(QIcon(":/qml/images/designmode.png"), tr("Design Mode"), this);
ui->play = new QAction(QIcon(":/qml/images/play.png"), tr("Play"), this); ui->play = new QAction(QIcon(":/qml/images/play.png"), tr("Play"), this);
ui->pause = new QAction(QIcon(":/qml/images/pause.png"), tr("Pause"), this); ui->pause = new QAction(QIcon(":/qml/images/pause.png"), tr("Pause"), this);
ui->select = new QAction(QIcon(":/qml/images/select.png"), tr("Select"), this); ui->select = new QAction(QIcon(":/qml/images/select.png"), tr("Select"), this);
@@ -22,6 +23,9 @@ QmlToolbar::QmlToolbar(QWidget *parent) :
ui->colorPicker = new QAction(QIcon(":/qml/images/color-picker.png"), tr("Color Picker"), this); ui->colorPicker = new QAction(QIcon(":/qml/images/color-picker.png"), tr("Color Picker"), this);
ui->toQml = new QAction(QIcon(":/qml/images/to-qml.png"), tr("Apply Changes to QML Viewer"), this); ui->toQml = new QAction(QIcon(":/qml/images/to-qml.png"), tr("Apply Changes to QML Viewer"), this);
ui->fromQml = new QAction(QIcon(":/qml/images/from-qml.png"), tr("Apply Changes to Document"), this); ui->fromQml = new QAction(QIcon(":/qml/images/from-qml.png"), tr("Apply Changes to Document"), this);
ui->designmode->setCheckable(true);
ui->designmode->setChecked(false);
ui->play->setCheckable(true); ui->play->setCheckable(true);
ui->play->setChecked(true); ui->play->setChecked(true);
ui->pause->setCheckable(true); ui->pause->setCheckable(true);
@@ -32,6 +36,7 @@ QmlToolbar::QmlToolbar(QWidget *parent) :
setWindowTitle(tr("Tools")); setWindowTitle(tr("Tools"));
addAction(ui->designmode);
addAction(ui->play); addAction(ui->play);
addAction(ui->pause); addAction(ui->pause);
addSeparator(); addSeparator();
@@ -51,6 +56,8 @@ QmlToolbar::QmlToolbar(QWidget *parent) :
setWindowFlags(Qt::Tool); setWindowFlags(Qt::Tool);
connect(ui->designmode, SIGNAL(toggled(bool)), SLOT(setDesignModeBehaviorOnClick(bool)));
connect(ui->colorPicker, SIGNAL(triggered()), SLOT(activateColorPickerOnClick())); connect(ui->colorPicker, SIGNAL(triggered()), SLOT(activateColorPickerOnClick()));
connect(ui->play, SIGNAL(triggered()), SLOT(activatePlayOnClick())); connect(ui->play, SIGNAL(triggered()), SLOT(activatePlayOnClick()));
@@ -112,6 +119,29 @@ void QmlToolbar::activateZoom()
m_emitSignals = true; m_emitSignals = true;
} }
void QmlToolbar::setDesignModeBehavior(bool inDesignMode)
{
m_emitSignals = false;
ui->designmode->setChecked(inDesignMode);
setDesignModeBehaviorOnClick(inDesignMode);
m_emitSignals = true;
}
void QmlToolbar::setDesignModeBehaviorOnClick(bool checked)
{
ui->play->setEnabled(checked);
ui->pause->setEnabled(checked);
ui->select->setEnabled(checked);
ui->selectMarquee->setEnabled(checked);
ui->zoom->setEnabled(checked);
ui->colorPicker->setEnabled(checked);
ui->toQml->setEnabled(checked);
ui->fromQml->setEnabled(checked);
if (m_emitSignals)
emit designModeBehaviorChanged(checked);
}
void QmlToolbar::setColorBoxColor(const QColor &color) void QmlToolbar::setColorBoxColor(const QColor &color)
{ {
ui->colorBox->setColor(color); ui->colorBox->setColor(color);
@@ -120,8 +150,8 @@ void QmlToolbar::setColorBoxColor(const QColor &color)
void QmlToolbar::activatePlayOnClick() void QmlToolbar::activatePlayOnClick()
{ {
ui->pause->setChecked(false); ui->pause->setChecked(false);
ui->play->setChecked(true);
if (!m_isRunning) { if (!m_isRunning) {
ui->play->setChecked(true);
m_isRunning = true; m_isRunning = true;
if (m_emitSignals) if (m_emitSignals)
emit executionStarted(); emit executionStarted();
@@ -131,9 +161,9 @@ void QmlToolbar::activatePlayOnClick()
void QmlToolbar::activatePauseOnClick() void QmlToolbar::activatePauseOnClick()
{ {
ui->play->setChecked(false); ui->play->setChecked(false);
ui->pause->setChecked(true);
if (m_isRunning) { if (m_isRunning) {
m_isRunning = false; m_isRunning = false;
ui->pause->setChecked(true);
if (m_emitSignals) if (m_emitSignals)
emit executionPaused(); emit executionPaused();
} }

View File

@@ -17,6 +17,7 @@ public:
~QmlToolbar(); ~QmlToolbar();
public slots: public slots:
void setDesignModeBehavior(bool inDesignMode);
void setColorBoxColor(const QColor &color); void setColorBoxColor(const QColor &color);
void startExecution(); void startExecution();
void pauseExecution(); void pauseExecution();
@@ -29,6 +30,7 @@ signals:
void executionStarted(); void executionStarted();
void executionPaused(); void executionPaused();
void designModeBehaviorChanged(bool inDesignMode);
void colorPickerSelected(); void colorPickerSelected();
void selectToolSelected(); void selectToolSelected();
void marqueeSelectToolSelected(); void marqueeSelectToolSelected();
@@ -38,6 +40,7 @@ signals:
void applyChangesFromQmlFileSelected(); void applyChangesFromQmlFileSelected();
private slots: private slots:
void setDesignModeBehaviorOnClick(bool inDesignMode);
void activatePlayOnClick(); void activatePlayOnClick();
void activatePauseOnClick(); void activatePauseOnClick();
void activateColorPickerOnClick(); void activateColorPickerOnClick();
@@ -51,6 +54,7 @@ private slots:
private: private:
class Ui { class Ui {
public: public:
QAction *designmode;
QAction *play; QAction *play;
QAction *pause; QAction *pause;
QAction *select; QAction *select;

View File

@@ -40,17 +40,31 @@ void QDeclarativeDesignDebugServer::messageReceived(const QByteArray &message)
QByteArray toolName; QByteArray toolName;
ds >> toolName; ds >> toolName;
if (toolName == "COLOR_PICKER") { if (toolName == "COLOR_PICKER") {
colorPickerToolRequested(); emit colorPickerToolRequested();
} else if (toolName == "SELECT") { } else if (toolName == "SELECT") {
selectToolRequested(); emit selectToolRequested();
} else if (toolName == "SELECT_MARQUEE") { } else if (toolName == "SELECT_MARQUEE") {
selectMarqueeToolRequested(); emit selectMarqueeToolRequested();
} else if (toolName == "ZOOM") { } else if (toolName == "ZOOM") {
zoomToolRequested(); emit zoomToolRequested();
} }
} else if (type == "SET_DESIGN_MODE") {
bool inDesignMode;
ds >> inDesignMode;
emit designModeBehaviorChanged(inDesignMode);
} }
} }
void QDeclarativeDesignDebugServer::setDesignModeBehavior(bool inDesignMode)
{
QByteArray message;
QDataStream ds(&message, QIODevice::WriteOnly);
ds << QByteArray("SET_DESIGN_MODE")
<< inDesignMode;
sendMessage(message);
}
void QDeclarativeDesignDebugServer::setCurrentObjects(QList<QObject*> objects) void QDeclarativeDesignDebugServer::setCurrentObjects(QList<QObject*> objects)
{ {

View File

@@ -58,12 +58,14 @@ class QDeclarativeDesignDebugServer : public QDeclarativeDebugService
public: public:
QDeclarativeDesignDebugServer(QObject *parent = 0); QDeclarativeDesignDebugServer(QObject *parent = 0);
void setDesignModeBehavior(bool inDesignMode);
void setCurrentObjects(QList<QObject*> items); void setCurrentObjects(QList<QObject*> items);
void setAnimationSpeed(qreal slowdownFactor); void setAnimationSpeed(qreal slowdownFactor);
void setCurrentTool(QmlViewer::Constants::DesignTool toolId); void setCurrentTool(QmlViewer::Constants::DesignTool toolId);
Q_SIGNALS: Q_SIGNALS:
void currentObjectsChanged(const QList<QObject*> &objects); void currentObjectsChanged(const QList<QObject*> &objects);
void designModeBehaviorChanged(bool inDesignMode);
void reloadRequested(); void reloadRequested();
void selectToolRequested(); void selectToolRequested();
void selectMarqueeToolRequested(); void selectMarqueeToolRequested();

View File

@@ -38,6 +38,7 @@ QDeclarativeDesignView::QDeclarativeDesignView(QWidget *parent) :
setMouseTracking(true); setMouseTracking(true);
connect(qmlDesignDebugServer(), SIGNAL(designModeBehaviorChanged(bool)), SLOT(setDesignModeBehavior(bool)));
connect(qmlDesignDebugServer(), SIGNAL(reloadRequested()), SLOT(reloadView())); connect(qmlDesignDebugServer(), SIGNAL(reloadRequested()), SLOT(reloadView()));
connect(qmlDesignDebugServer(), connect(qmlDesignDebugServer(),
SIGNAL(currentObjectsChanged(QList<QObject*>)), SIGNAL(currentObjectsChanged(QList<QObject*>)),
@@ -48,7 +49,6 @@ QDeclarativeDesignView::QDeclarativeDesignView(QWidget *parent) :
connect(qmlDesignDebugServer(), SIGNAL(selectToolRequested()), SLOT(changeToSingleSelectTool())); connect(qmlDesignDebugServer(), SIGNAL(selectToolRequested()), SLOT(changeToSingleSelectTool()));
connect(qmlDesignDebugServer(), SIGNAL(zoomToolRequested()), SLOT(changeToZoomTool())); connect(qmlDesignDebugServer(), SIGNAL(zoomToolRequested()), SLOT(changeToZoomTool()));
connect(this, SIGNAL(designModeBehaviorChanged(bool)), SLOT(setDesignModeBehavior(bool)));
connect(this, SIGNAL(statusChanged(QDeclarativeView::Status)), SLOT(onStatusChanged(QDeclarativeView::Status))); connect(this, SIGNAL(statusChanged(QDeclarativeView::Status)), SLOT(onStatusChanged(QDeclarativeView::Status)));
connect(m_colorPickerTool, SIGNAL(selectedColorChanged(QColor)), SIGNAL(selectedColorChanged(QColor))); connect(m_colorPickerTool, SIGNAL(selectedColorChanged(QColor)), SIGNAL(selectedColorChanged(QColor)));
@@ -219,6 +219,10 @@ void QDeclarativeDesignView::wheelEvent(QWheelEvent *event)
void QDeclarativeDesignView::setDesignModeBehavior(bool value) void QDeclarativeDesignView::setDesignModeBehavior(bool value)
{ {
emit designModeBehaviorChanged(value);
m_toolbar->setDesignModeBehavior(value);
m_designModeBehavior = value; m_designModeBehavior = value;
if (m_subcomponentEditorTool) { if (m_subcomponentEditorTool) {
m_subcomponentEditorTool->clear(); m_subcomponentEditorTool->clear();
@@ -488,6 +492,9 @@ void QDeclarativeDesignView::createToolbar()
m_toolbar = new QmlToolbar(this); m_toolbar = new QmlToolbar(this);
connect(this, SIGNAL(selectedColorChanged(QColor)), m_toolbar, SLOT(setColorBoxColor(QColor))); connect(this, SIGNAL(selectedColorChanged(QColor)), m_toolbar, SLOT(setColorBoxColor(QColor)));
connect(this, SIGNAL(designModeBehaviorChanged(bool)), m_toolbar, SLOT(setDesignModeBehavior(bool)));
connect(m_toolbar, SIGNAL(designModeBehaviorChanged(bool)), this, SLOT(setDesignModeBehavior(bool)));
connect(m_toolbar, SIGNAL(executionStarted()), this, SLOT(continueExecution())); connect(m_toolbar, SIGNAL(executionStarted()), this, SLOT(continueExecution()));
connect(m_toolbar, SIGNAL(executionPaused()), this, SLOT(pauseExecution())); connect(m_toolbar, SIGNAL(executionPaused()), this, SLOT(pauseExecution()));
connect(m_toolbar, SIGNAL(colorPickerSelected()), this, SLOT(changeToColorPickerTool())); connect(m_toolbar, SIGNAL(colorPickerSelected()), this, SLOT(changeToColorPickerTool()));

View File

@@ -633,7 +633,6 @@ void QDeclarativeViewer::setDesignModeBehavior(bool value)
{ {
designModeBehaviorAction->setChecked(value); designModeBehaviorAction->setChecked(value);
canvas->setDesignModeBehavior(value); canvas->setDesignModeBehavior(value);
canvas->toolbar()->setEnabled(value);
} }
void QDeclarativeViewer::setDebugMode(bool on) void QDeclarativeViewer::setDebugMode(bool on)
@@ -701,6 +700,7 @@ void QDeclarativeViewer::createMenu()
designModeBehaviorAction->setCheckable(true); designModeBehaviorAction->setCheckable(true);
designModeBehaviorAction->setChecked(canvas->designModeBehavior()); designModeBehaviorAction->setChecked(canvas->designModeBehavior());
connect(designModeBehaviorAction, SIGNAL(triggered(bool)), this, SLOT(setDesignModeBehavior(bool))); connect(designModeBehaviorAction, SIGNAL(triggered(bool)), this, SLOT(setDesignModeBehavior(bool)));
connect(canvas, SIGNAL(designModeBehaviorChanged(bool)), designModeBehaviorAction, SLOT(setChecked(bool)));
QAction *proxyAction = new QAction(tr("HTTP &Proxy..."), this); QAction *proxyAction = new QAction(tr("HTTP &Proxy..."), this);
connect(proxyAction, SIGNAL(triggered()), this, SLOT(showProxySettings())); connect(proxyAction, SIGNAL(triggered()), this, SLOT(showProxySettings()));