QmlObserver: Add 'show app on top' switch to creator + qmlobserver

This is convenient especially in the observer mode.

Reviewed-by: Christiaan Janssen
This commit is contained in:
Kai Koehne
2010-11-23 10:07:09 +01:00
parent e0811beef3
commit d2ed221b1b
18 changed files with 144 additions and 4 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

@@ -65,6 +65,7 @@ QmlInspectorToolbar::QmlInspectorToolbar(QObject *parent) :
m_selectAction(0),
m_zoomAction(0),
m_colorPickerAction(0),
m_showAppOnTopAction(0),
m_defaultAnimSpeedAction(0),
m_halfAnimSpeedAction(0),
m_fourthAnimSpeedAction(0),
@@ -86,6 +87,7 @@ QmlInspectorToolbar::QmlInspectorToolbar(QObject *parent) :
void QmlInspectorToolbar::setEnabled(bool value)
{
m_fromQmlAction->setEnabled(value);
m_showAppOnTopAction->setEnabled(value);
m_observerModeAction->setEnabled(value);
m_playAction->setEnabled(value);
m_selectAction->setEnabled(value);
@@ -166,6 +168,13 @@ void QmlInspectorToolbar::setDesignModeBehavior(bool inDesignMode)
m_emitSignals = true;
}
void QmlInspectorToolbar::setShowAppOnTop(bool showAppOnTop)
{
m_emitSignals = false;
m_showAppOnTopAction->setChecked(showAppOnTop);
m_emitSignals = true;
}
void QmlInspectorToolbar::createActions(const Core::Context &context)
{
Core::ICore *core = Core::ICore::instance();
@@ -174,6 +183,9 @@ void QmlInspectorToolbar::createActions(const Core::Context &context)
m_fromQmlAction =
new QAction(QIcon(QLatin1String(":/qml/images/from-qml-small.png")),
tr("Apply Changes on Save"), this);
m_showAppOnTopAction =
new QAction(QIcon(QLatin1String(":/qml/images/app-on-top.png")),
tr("Show application on top"), this);
m_observerModeAction =
new QAction(QIcon(QLatin1String(":/qml/images/observermode.png")),
tr("Observer Mode"), this);
@@ -191,6 +203,8 @@ void QmlInspectorToolbar::createActions(const Core::Context &context)
m_fromQmlAction->setCheckable(true);
m_fromQmlAction->setChecked(true);
m_showAppOnTopAction->setCheckable(true);
m_showAppOnTopAction->setChecked(false);
m_observerModeAction->setCheckable(true);
m_observerModeAction->setChecked(false);
m_selectAction->setCheckable(true);
@@ -203,6 +217,8 @@ void QmlInspectorToolbar::createActions(const Core::Context &context)
am->registerAction(m_zoomAction, QmlJSInspector::Constants::ZOOM_ACTION, context);
am->registerAction(m_colorPickerAction, QmlJSInspector::Constants::COLOR_PICKER_ACTION, context);
am->registerAction(m_fromQmlAction, QmlJSInspector::Constants::FROM_QML_ACTION, context);
am->registerAction(m_showAppOnTopAction,
QmlJSInspector::Constants::SHOW_APP_ON_TOP_ACTION, context);
m_barWidget = new Utils::StyledBar;
m_barWidget->setSingleRow(true);
@@ -250,6 +266,9 @@ void QmlInspectorToolbar::createActions(const Core::Context &context)
configBarLayout->addWidget(
createToolButton(am->command(QmlJSInspector::Constants::FROM_QML_ACTION)->action()));
configBarLayout->addWidget(
createToolButton(
am->command(QmlJSInspector::Constants::SHOW_APP_ON_TOP_ACTION)->action()));
configBarLayout->addSpacing(10);
configBarLayout->addWidget(
@@ -277,6 +296,7 @@ void QmlInspectorToolbar::createActions(const Core::Context &context)
setEnabled(false);
connect(m_fromQmlAction, SIGNAL(triggered()), SLOT(activateFromQml()));
connect(m_showAppOnTopAction, SIGNAL(triggered()), SLOT(showAppOnTopClick()));
connect(m_observerModeAction, SIGNAL(triggered()), SLOT(activateDesignModeOnClick()));
connect(m_playAction, SIGNAL(triggered()), SLOT(activatePlayOnClick()));
connect(m_colorPickerAction, SIGNAL(triggered()), SLOT(activateColorPickerOnClick()));
@@ -404,6 +424,12 @@ void QmlInspectorToolbar::activateZoomOnClick()
}
}
void QmlInspectorToolbar::showAppOnTopClick()
{
if (m_emitSignals)
emit showAppOnTopSelected(m_showAppOnTopAction->isChecked());
}
void QmlInspectorToolbar::setSelectedColor(const QColor &color)
{
m_colorBox->setColor(color);

View File

@@ -80,6 +80,7 @@ public slots:
void activateZoomTool();
void setAnimationSpeed(qreal slowdownFactor);
void setDesignModeBehavior(bool inDesignMode);
void setShowAppOnTop(bool showAppOnTop);
void setSelectedColor(const QColor &color);
signals:
@@ -91,6 +92,7 @@ signals:
void selectToolSelected();
void zoomToolSelected();
void showAppOnTopSelected(bool isChecked);
void animationSpeedChanged(qreal slowdownFactor = 1.0f);
private slots:
@@ -100,6 +102,8 @@ private slots:
void activateSelectToolOnClick();
void activateZoomOnClick();
void showAppOnTopClick();
void changeToDefaultAnimSpeed();
void changeToHalfAnimSpeed();
void changeToFourthAnimSpeed();
@@ -119,6 +123,8 @@ private:
QAction *m_zoomAction;
QAction *m_colorPickerAction;
QAction *m_showAppOnTopAction;
QAction *m_defaultAnimSpeedAction;
QAction *m_halfAnimSpeedAction;
QAction *m_fourthAnimSpeedAction;

View File

@@ -89,6 +89,8 @@ void ClientProxy::connectToServer()
SIGNAL(animationSpeedChanged(qreal)));
connect(m_observerClient, SIGNAL(designModeBehaviorChanged(bool)),
SIGNAL(designModeBehaviorChanged(bool)));
connect(m_observerClient, SIGNAL(showAppOnTopChanged(bool)),
SIGNAL(showAppOnTopChanged(bool)));
connect(m_observerClient, SIGNAL(reloaded()), this,
SIGNAL(serverReloaded()));
connect(m_observerClient, SIGNAL(selectedColorChanged(QColor)),
@@ -484,6 +486,12 @@ void ClientProxy::changeToSelectMarqueeTool()
m_observerClient->changeToSelectMarqueeTool();
}
void ClientProxy::showAppOnTop(bool showOnTop)
{
if (isConnected())
m_observerClient->showAppOnTop(showOnTop);
}
void ClientProxy::createQmlObject(const QString &qmlText, int parentDebugId,
const QStringList &imports, const QString &filename)
{

View File

@@ -100,6 +100,7 @@ signals:
void zoomToolActivated();
void animationSpeedChanged(qreal slowdownFactor);
void designModeBehaviorChanged(bool inDesignMode);
void showAppOnTopChanged(bool showAppOnTop);
void serverReloaded();
void selectedColorChanged(const QColor &color);
void contextPathUpdated(const QStringList &contextPath);
@@ -115,6 +116,7 @@ public slots:
void changeToZoomTool();
void changeToSelectTool();
void changeToSelectMarqueeTool();
void showAppOnTop(bool showOnTop);
void createQmlObject(const QString &qmlText, int parentDebugId,
const QStringList &imports, const QString &filename = QString());
void destroyQmlObject(int debugId);

View File

@@ -768,9 +768,9 @@ void InspectorUi::setupToolbar(bool doConnect)
m_clientProxy, SLOT(changeToSelectTool()));
connect(m_toolbar, SIGNAL(applyChangesFromQmlFileTriggered(bool)),
this, SLOT(setApplyChangesToQmlObserver(bool)));
connect(m_toolbar, SIGNAL(showAppOnTopSelected(bool)),
m_clientProxy, SLOT(showAppOnTop(bool)));
connect(this, SIGNAL(livePreviewActivated(bool)),
m_toolbar, SLOT(setLivePreviewChecked(bool)));
connect(m_clientProxy, SIGNAL(colorPickerActivated()),
m_toolbar, SLOT(activateColorPicker()));
connect(m_clientProxy, SIGNAL(selectToolActivated()),
@@ -779,6 +779,8 @@ void InspectorUi::setupToolbar(bool doConnect)
m_toolbar, SLOT(activateZoomTool()));
connect(m_clientProxy, SIGNAL(designModeBehaviorChanged(bool)),
m_toolbar, SLOT(setDesignModeBehavior(bool)));
connect(m_clientProxy, SIGNAL(showAppOnTopChanged(bool)),
m_toolbar, SLOT(setShowAppOnTop(bool)));
connect(m_clientProxy, SIGNAL(selectedColorChanged(QColor)),
m_toolbar, SLOT(setSelectedColor(QColor)));
@@ -804,9 +806,9 @@ void InspectorUi::setupToolbar(bool doConnect)
m_clientProxy, SLOT(changeToSelectTool()));
disconnect(m_toolbar, SIGNAL(applyChangesFromQmlFileTriggered(bool)),
this, SLOT(setApplyChangesToQmlObserver(bool)));
disconnect(m_toolbar, SIGNAL(showAppOnTopSelected(bool)),
m_clientProxy, SLOT(showAppOnTop(bool)));
disconnect(this, SIGNAL(livePreviewActivated(bool)),
m_toolbar, SLOT(setLivePreviewChecked(bool)));
disconnect(m_clientProxy, SIGNAL(colorPickerActivated()),
m_toolbar, SLOT(activateColorPicker()));
disconnect(m_clientProxy, SIGNAL(selectToolActivated()),
@@ -815,6 +817,8 @@ void InspectorUi::setupToolbar(bool doConnect)
m_toolbar, SLOT(activateZoomTool()));
disconnect(m_clientProxy, SIGNAL(designModeBehaviorChanged(bool)),
m_toolbar, SLOT(setDesignModeBehavior(bool)));
disconnect(m_clientProxy, SIGNAL(showAppOnTopChanged(bool)),
m_toolbar, SLOT(setShowAppOnTop(bool)));
disconnect(m_clientProxy, SIGNAL(selectedColorChanged(QColor)),
m_toolbar, SLOT(setSelectedColor(QColor)));

View File

@@ -19,5 +19,6 @@
<file>images/select-marquee-small.png</file>
<file>images/color-picker-small-hicontrast.png</file>
<file>images/observermode.png</file>
<file>images/app-on-top.png</file>
</qresource>
</RCC>

View File

@@ -50,6 +50,7 @@ const char * const ZOOM_ACTION = "QmlInspector.Zoom";
const char * const COLOR_PICKER_ACTION = "QmlInspector.ColorPicker";
const char * const TO_QML_ACTION = "QmlInspector.ToQml";
const char * const FROM_QML_ACTION = "QmlInspector.FromQml";
const char * const SHOW_APP_ON_TOP_ACTION = "QmlInspector.ShowAppOnTop";
// settings
const char * const S_QML_INSPECTOR = "QML.Inspector";

View File

@@ -107,6 +107,10 @@ void QmlJSObserverClient::messageReceived(const QByteArray &message)
bool inDesignMode;
ds >> inDesignMode;
emit designModeBehaviorChanged(inDesignMode);
} else if (type == "SHOW_APP_ON_TOP") {
bool showAppOnTop;
ds >> showAppOnTop;
emit showAppOnTopChanged(showAppOnTop);
} else if (type == "RELOADED") {
emit reloaded();
} else if (type == "COLOR_CHANGED") {
@@ -337,6 +341,23 @@ void QmlJSObserverClient::changeToZoomTool()
sendMessage(message);
}
void QmlJSObserverClient::showAppOnTop(bool showOnTop)
{
if (!m_connection || !m_connection->isConnected())
return;
QByteArray message;
QDataStream ds(&message, QIODevice::WriteOnly);
ds << QByteArray("SHOW_APP_ON_TOP")
<< showOnTop;
if (debug)
qDebug() << "QmlJSObserverClient: Sending" <<"SHOWONTOP" << showOnTop;
sendMessage(message);
}
void QmlJSObserverClient::createQmlObject(const QString &qmlText, int parentDebugId,
const QStringList &imports, const QString &filename)
{

View File

@@ -62,6 +62,7 @@ public:
void changeToSelectTool();
void changeToSelectMarqueeTool();
void changeToZoomTool();
void showAppOnTop(bool showOnTop);
void createQmlObject(const QString &qmlText, int parentDebugId,
const QStringList &imports, const QString &filename);
@@ -90,6 +91,7 @@ signals:
void zoomToolActivated();
void animationSpeedChanged(qreal slowdownFactor);
void designModeBehaviorChanged(bool inDesignMode);
void showAppOnTopChanged(bool showAppOnTop);
void reloaded(); // the server has reloaded the document
void contextPathUpdated(const QStringList &path);