Commit 7c90a351 authored by Kai Koehne's avatar Kai Koehne
Browse files

QmlInspector: Get rid of explicit 'Design mode' button

Instead let the user just select & deselect between the Zoom Tool,
the Selection Tool and the Color Picker.

Change-Id: Ieac0bc0381760237004599e59cafa43544fb03d4
Reviewed-on: http://codereview.qt.nokia.com/753

Reviewed-by: default avatarQt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: default avatarChristiaan Janssen <christiaan.janssen@nokia.com>
parent 5846005b
......@@ -66,7 +66,6 @@ static QToolButton *toolButton(QAction *action)
QmlInspectorToolBar::QmlInspectorToolBar(QObject *parent) :
QObject(parent),
m_fromQmlAction(0),
m_inspectorModeAction(0),
m_playAction(0),
m_selectAction(0),
m_zoomAction(0),
......@@ -79,6 +78,7 @@ QmlInspectorToolBar::QmlInspectorToolBar(QObject *parent) :
m_emitSignals(true),
m_paused(false),
m_animationSpeed(1.0f),
m_designModeActive(false),
m_activeTool(NoTool),
m_barWidget(0)
{
......@@ -88,7 +88,6 @@ void QmlInspectorToolBar::setEnabled(bool value)
{
m_fromQmlAction->setEnabled(value);
m_showAppOnTopAction->setEnabled(value);
m_inspectorModeAction->setEnabled(value);
m_playAction->setEnabled(value);
m_selectAction->setEnabled(value);
m_zoomAction->setEnabled(value);
......@@ -101,38 +100,33 @@ void QmlInspectorToolBar::enable()
setEnabled(true);
m_emitSignals = false;
m_showAppOnTopAction->setChecked(false);
m_inspectorModeAction->setChecked(false);
setAnimationSpeed(1.0f);
activateDesignModeOnClick();
m_designModeActive = false;
updateDesignModeActions(NoTool);
m_emitSignals = true;
}
void QmlInspectorToolBar::disable()
{
setAnimationSpeed(1.0f);
activateSelectTool();
m_designModeActive = false;
updateDesignModeActions(NoTool);
setEnabled(false);
}
void QmlInspectorToolBar::activateColorPicker()
{
m_emitSignals = false;
activateColorPickerOnClick();
m_emitSignals = true;
updateDesignModeActions(ColorPickerMode);
}
void QmlInspectorToolBar::activateSelectTool()
{
m_emitSignals = false;
activateSelectToolOnClick();
m_emitSignals = true;
updateDesignModeActions(SelectionToolMode);
}
void QmlInspectorToolBar::activateZoomTool()
{
m_emitSignals = false;
activateZoomOnClick();
m_emitSignals = true;
updateDesignModeActions(ZoomMode);
}
void QmlInspectorToolBar::setAnimationSpeed(qreal slowDownFactor)
......@@ -165,8 +159,8 @@ void QmlInspectorToolBar::setAnimationPaused(bool paused)
void QmlInspectorToolBar::setDesignModeBehavior(bool inDesignMode)
{
m_emitSignals = false;
m_inspectorModeAction->setChecked(inDesignMode);
activateDesignModeOnClick();
m_designModeActive = inDesignMode;
updateDesignModeActions(m_activeTool);
m_emitSignals = true;
}
......@@ -189,9 +183,6 @@ void QmlInspectorToolBar::createActions()
m_showAppOnTopAction =
new QAction(QIcon(QLatin1String(":/qml/images/app-on-top.png")),
tr("Show application on top"), this);
m_inspectorModeAction =
new QAction(QIcon(QLatin1String(":/qml/images/inspectormode.png")),
tr("Inspector Mode"), this);
m_playAction =
new QAction(m_pauseIcon, tr("Play/Pause Animations"), this);
m_selectAction =
......@@ -208,13 +199,10 @@ void QmlInspectorToolBar::createActions()
m_fromQmlAction->setChecked(true);
m_showAppOnTopAction->setCheckable(true);
m_showAppOnTopAction->setChecked(false);
m_inspectorModeAction->setCheckable(true);
m_inspectorModeAction->setChecked(false);
m_selectAction->setCheckable(true);
m_zoomAction->setCheckable(true);
m_colorPickerAction->setCheckable(true);
am->registerAction(m_inspectorModeAction, Constants::INSPECTORMODE_ACTION, context);
Core::Command *command = am->registerAction(m_playAction, Constants::PLAY_ACTION, context);
command->setAttribute(Core::Command::CA_UpdateIcon);
am->registerAction(m_selectAction, Constants::SELECT_ACTION, context);
......@@ -281,7 +269,6 @@ void QmlInspectorToolBar::createActions()
// Inspector
toolBarLayout->addWidget(new Utils::StyledSeparator);
toolBarLayout->addWidget(toolButton(am->command(Constants::INSPECTORMODE_ACTION)->action()));
toolBarLayout->addWidget(toolButton(am->command(Constants::SELECT_ACTION)->action()));
toolBarLayout->addWidget(toolButton(am->command(Constants::ZOOM_ACTION)->action()));
toolBarLayout->addWidget(toolButton(am->command(Constants::COLOR_PICKER_ACTION)->action()));
......@@ -295,12 +282,10 @@ void QmlInspectorToolBar::createActions()
connect(m_fromQmlAction, SIGNAL(triggered()), SLOT(activateFromQml()));
connect(m_showAppOnTopAction, SIGNAL(triggered()), SLOT(showAppOnTopClick()));
connect(m_inspectorModeAction, SIGNAL(triggered()), SLOT(activateDesignModeOnClick()));
connect(m_playAction, SIGNAL(triggered()), SLOT(activatePlayOnClick()));
connect(m_colorPickerAction, SIGNAL(triggered()), SLOT(activateColorPickerOnClick()));
connect(m_selectAction, SIGNAL(triggered()), SLOT(activateSelectToolOnClick()));
connect(m_zoomAction, SIGNAL(triggered()), SLOT(activateZoomOnClick()));
connect(m_colorPickerAction, SIGNAL(triggered()), SLOT(activateColorPickerOnClick()));
connect(m_colorPickerAction, SIGNAL(triggered(bool)), SLOT(colorPickerTriggered(bool)));
connect(m_selectAction, SIGNAL(triggered(bool)), SLOT(selectToolTriggered(bool)));
connect(m_zoomAction, SIGNAL(triggered(bool)), SLOT(zoomToolTriggered(bool)));
Debugger::DebuggerMainWindow *mw = Debugger::DebuggerPlugin::mainWindow();
activeDebugLanguagesChanged(mw->activeDebugLanguages());
......@@ -323,18 +308,6 @@ void QmlInspectorToolBar::changeAnimationSpeed()
updatePlayAction();
}
void QmlInspectorToolBar::activateDesignModeOnClick()
{
bool checked = m_inspectorModeAction->isChecked();
m_selectAction->setEnabled(checked);
m_zoomAction->setEnabled(checked);
m_colorPickerAction->setEnabled(checked);
if (m_emitSignals)
emit designModeSelected(checked);
}
void QmlInspectorToolBar::activatePlayOnClick()
{
m_paused = !m_paused;
......@@ -347,43 +320,43 @@ void QmlInspectorToolBar::updatePlayAction()
m_playAction->setIcon(m_paused ? m_playIcon : m_pauseIcon);
}
void QmlInspectorToolBar::activateColorPickerOnClick()
void QmlInspectorToolBar::colorPickerTriggered(bool checked)
{
m_zoomAction->setChecked(false);
m_selectAction->setChecked(false);
m_colorPickerAction->setChecked(true);
if (m_activeTool != ColorPickerMode) {
m_activeTool = ColorPickerMode;
if (m_emitSignals)
emit colorPickerSelected();
updateDesignModeActions(ColorPickerMode);
if (m_designModeActive != checked) {
m_designModeActive = checked;
emit designModeSelected(checked);
}
if (checked)
emit colorPickerSelected();
}
void QmlInspectorToolBar::activateSelectToolOnClick()
void QmlInspectorToolBar::selectToolTriggered(bool checked)
{
m_zoomAction->setChecked(false);
m_colorPickerAction->setChecked(false);
m_selectAction->setChecked(true);
if (m_activeTool != SelectionToolMode) {
m_activeTool = SelectionToolMode;
if (m_emitSignals)
emit selectToolSelected();
updateDesignModeActions(SelectionToolMode);
if (m_designModeActive != checked) {
m_designModeActive = checked;
emit designModeSelected(checked);
}
if (checked)
emit selectToolSelected();
}
void QmlInspectorToolBar::activateZoomOnClick()
void QmlInspectorToolBar::zoomToolTriggered(bool checked)
{
m_selectAction->setChecked(false);
m_colorPickerAction->setChecked(false);
m_zoomAction->setChecked(true);
if (m_activeTool != ZoomMode) {
m_activeTool = ZoomMode;
if (m_emitSignals)
emit zoomToolSelected();
updateDesignModeActions(ZoomMode);
if (m_designModeActive != checked) {
m_designModeActive = checked;
emit designModeSelected(checked);
}
if (checked)
emit zoomToolSelected();
}
void QmlInspectorToolBar::showAppOnTopClick()
......@@ -408,5 +381,13 @@ void QmlInspectorToolBar::activeDebugLanguagesChanged(Debugger::DebuggerLanguage
m_operateByInstructionButton->setVisible(languages & Debugger::CppLanguage);
}
void QmlInspectorToolBar::updateDesignModeActions(DesignTool activeTool)
{
m_activeTool = activeTool;
m_selectAction->setChecked(m_designModeActive && (m_activeTool == SelectionToolMode));
m_zoomAction->setChecked(m_designModeActive && (m_activeTool == ZoomMode));
m_colorPickerAction->setChecked(m_designModeActive && (m_activeTool == ColorPickerMode));
}
} // namespace Internal
} // namespace QmlJSInspector
......@@ -93,7 +93,7 @@ public slots:
signals:
void applyChangesFromQmlFileTriggered(bool isChecked);
void designModeSelected(bool checked);
void designModeSelected(bool);
void reloadSelected();
void colorPickerSelected();
void selectToolSelected();
......@@ -105,11 +105,10 @@ signals:
void animationPausedChanged(bool paused);
private slots:
void activateDesignModeOnClick();
void activatePlayOnClick();
void activateColorPickerOnClick();
void activateSelectToolOnClick();
void activateZoomOnClick();
void colorPickerTriggered(bool checked);
void selectToolTriggered(bool checked);
void zoomToolTriggered(bool checked);
void showAppOnTopClick();
......@@ -122,10 +121,11 @@ private slots:
void activeDebugLanguagesChanged(Debugger::DebuggerLanguages languages);
private:
void updateDesignModeActions(DesignTool activeTool);
QToolButton *m_operateByInstructionButton;
QAction *m_fromQmlAction;
QAction *m_inspectorModeAction;
QAction *m_playAction;
QAction *m_selectAction;
QAction *m_zoomAction;
......@@ -145,6 +145,7 @@ private:
bool m_paused;
qreal m_animationSpeed;
bool m_designModeActive;
DesignTool m_activeTool;
Utils::StyledBar *m_barWidget;
......
......@@ -18,7 +18,6 @@
<file>images/zoom-small.png</file>
<file>images/select-marquee-small.png</file>
<file>images/color-picker-small-hicontrast.png</file>
<file>images/inspectormode.png</file>
<file>images/app-on-top.png</file>
</qresource>
</RCC>
......@@ -38,7 +38,6 @@ namespace Constants {
const char * const INFO_EXPERIMENTAL = "QmlInspector.Experimental";
const char * const INFO_OUT_OF_SYNC = "QmlInspector.OutOfSyncWarning";
const char * const INSPECTORMODE_ACTION = "QmlInspector.DesignMode";
const char * const PLAY_ACTION = "QmlInspector.Play";
const char * const SELECT_ACTION = "QmlInspector.Select";
const char * const ZOOM_ACTION = "QmlInspector.Zoom";
......
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