From a3cfd5cd28c1450796f23a847afde0510171dd23 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Mon, 13 Jul 2009 15:35:17 +1000 Subject: Rename classes --- src/declarative/debugger/qmldebug.cpp | 14 +++--- src/declarative/debugger/qmldebug.h | 4 +- src/declarative/debugger/qmldebugclient.cpp | 66 ++++++++++++++--------------- src/declarative/debugger/qmldebugclient.h | 28 ++++++------ tools/qmldebugger/canvasframerate.cpp | 12 +++--- tools/qmldebugger/canvasframerate.h | 4 +- tools/qmldebugger/canvasscene.cpp | 10 ++--- tools/qmldebugger/canvasscene.h | 8 ++-- tools/qmldebugger/engine.cpp | 2 +- tools/qmldebugger/engine.h | 4 +- tools/qmldebugger/main.cpp | 2 +- 11 files changed, 77 insertions(+), 77 deletions(-) diff --git a/src/declarative/debugger/qmldebug.cpp b/src/declarative/debugger/qmldebug.cpp index 1808bba..8309ec6 100644 --- a/src/declarative/debugger/qmldebug.cpp +++ b/src/declarative/debugger/qmldebug.cpp @@ -3,10 +3,10 @@ #include #include -class QmlEngineDebugClient : public QmlDebugClientPlugin +class QmlEngineDebugClient : public QmlDebugClient { public: - QmlEngineDebugClient(QmlDebugClient *client, QmlEngineDebugPrivate *p); + QmlEngineDebugClient(QmlDebugConnection *client, QmlEngineDebugPrivate *p); protected: virtual void messageReceived(const QByteArray &); @@ -19,7 +19,7 @@ class QmlEngineDebugPrivate : public QObjectPrivate { Q_DECLARE_PUBLIC(QmlEngineDebug) public: - QmlEngineDebugPrivate(QmlDebugClient *); + QmlEngineDebugPrivate(QmlDebugConnection *); void message(const QByteArray &); @@ -38,9 +38,9 @@ public: QHash objectQuery; }; -QmlEngineDebugClient::QmlEngineDebugClient(QmlDebugClient *client, +QmlEngineDebugClient::QmlEngineDebugClient(QmlDebugConnection *client, QmlEngineDebugPrivate *p) -: QmlDebugClientPlugin(QLatin1String("QmlEngine"), client), priv(p) +: QmlDebugClient(QLatin1String("QmlEngine"), client), priv(p) { setEnabled(true); } @@ -50,7 +50,7 @@ void QmlEngineDebugClient::messageReceived(const QByteArray &data) priv->message(data); } -QmlEngineDebugPrivate::QmlEngineDebugPrivate(QmlDebugClient *c) +QmlEngineDebugPrivate::QmlEngineDebugPrivate(QmlDebugConnection *c) : client(c, this), nextId(0) { } @@ -206,7 +206,7 @@ void QmlEngineDebugPrivate::message(const QByteArray &data) } } -QmlEngineDebug::QmlEngineDebug(QmlDebugClient *client, QObject *parent) +QmlEngineDebug::QmlEngineDebug(QmlDebugConnection *client, QObject *parent) : QObject(*(new QmlEngineDebugPrivate(client)), parent) { } diff --git a/src/declarative/debugger/qmldebug.h b/src/declarative/debugger/qmldebug.h index 52a5400..11e6b3e 100644 --- a/src/declarative/debugger/qmldebug.h +++ b/src/declarative/debugger/qmldebug.h @@ -5,7 +5,7 @@ #include #include -class QmlDebugClient; +class QmlDebugConnection; class QmlDebugWatch; class QmlDebugEnginesQuery; class QmlDebugRootContextQuery; @@ -20,7 +20,7 @@ class Q_DECLARATIVE_EXPORT QmlEngineDebug : public QObject { Q_OBJECT public: - QmlEngineDebug(QmlDebugClient *, QObject * = 0); + QmlEngineDebug(QmlDebugConnection *, QObject * = 0); QmlDebugWatch *addWatch(const QmlDebugPropertyReference &, QObject *parent = 0); diff --git a/src/declarative/debugger/qmldebugclient.cpp b/src/declarative/debugger/qmldebugclient.cpp index 562d87d..7c5c37b 100644 --- a/src/declarative/debugger/qmldebugclient.cpp +++ b/src/declarative/debugger/qmldebugclient.cpp @@ -47,22 +47,22 @@ QT_BEGIN_NAMESPACE -class QmlDebugClientPrivate : public QObject +class QmlDebugConnectionPrivate : public QObject { Q_OBJECT public: - QmlDebugClientPrivate(QmlDebugClient *c); - QmlDebugClient *q; + QmlDebugConnectionPrivate(QmlDebugConnection *c); + QmlDebugConnection *q; QPacketProtocol *protocol; QStringList enabled; - QHash plugins; + QHash plugins; public slots: void connected(); void readyRead(); }; -QmlDebugClientPrivate::QmlDebugClientPrivate(QmlDebugClient *c) +QmlDebugConnectionPrivate::QmlDebugConnectionPrivate(QmlDebugConnection *c) : QObject(c), q(c), protocol(0) { protocol = new QPacketProtocol(q, this); @@ -70,59 +70,59 @@ QmlDebugClientPrivate::QmlDebugClientPrivate(QmlDebugClient *c) QObject::connect(protocol, SIGNAL(readyRead()), this, SLOT(readyRead())); } -void QmlDebugClientPrivate::connected() +void QmlDebugConnectionPrivate::connected() { QPacket pack; pack << QString(QLatin1String("QmlDebugServer")) << enabled; protocol->send(pack); } -void QmlDebugClientPrivate::readyRead() +void QmlDebugConnectionPrivate::readyRead() { QPacket pack = protocol->read(); QString name; QByteArray message; pack >> name >> message; - QHash::Iterator iter = + QHash::Iterator iter = plugins.find(name); if (iter == plugins.end()) { - qWarning() << "QmlDebugClient: Message received for missing plugin" << name; + qWarning() << "QmlDebugConnection: Message received for missing plugin" << name; } else { (*iter)->messageReceived(message); } } -QmlDebugClient::QmlDebugClient(QObject *parent) -: QTcpSocket(parent), d(new QmlDebugClientPrivate(this)) +QmlDebugConnection::QmlDebugConnection(QObject *parent) +: QTcpSocket(parent), d(new QmlDebugConnectionPrivate(this)) { } -bool QmlDebugClient::isConnected() const +bool QmlDebugConnection::isConnected() const { return state() == ConnectedState; } -class QmlDebugClientPluginPrivate : public QObjectPrivate +class QmlDebugClientPrivate : public QObjectPrivate { - Q_DECLARE_PUBLIC(QmlDebugClientPlugin); + Q_DECLARE_PUBLIC(QmlDebugClient); public: - QmlDebugClientPluginPrivate(); + QmlDebugClientPrivate(); QString name; - QmlDebugClient *client; + QmlDebugConnection *client; bool enabled; }; -QmlDebugClientPluginPrivate::QmlDebugClientPluginPrivate() +QmlDebugClientPrivate::QmlDebugClientPrivate() : client(0), enabled(false) { } -QmlDebugClientPlugin::QmlDebugClientPlugin(const QString &name, - QmlDebugClient *parent) -: QObject(*(new QmlDebugClientPluginPrivate), parent) +QmlDebugClient::QmlDebugClient(const QString &name, + QmlDebugConnection *parent) +: QObject(*(new QmlDebugClientPrivate), parent) { - Q_D(QmlDebugClientPlugin); + Q_D(QmlDebugClient); d->name = name; d->client = parent; @@ -130,28 +130,28 @@ QmlDebugClientPlugin::QmlDebugClientPlugin(const QString &name, return; if (d->client->d->plugins.contains(name)) { - qWarning() << "QmlDebugClientPlugin: Conflicting plugin name" << name; + qWarning() << "QmlDebugClient: Conflicting plugin name" << name; d->client = 0; } else { d->client->d->plugins.insert(name, this); } } -QString QmlDebugClientPlugin::name() const +QString QmlDebugClient::name() const { - Q_D(const QmlDebugClientPlugin); + Q_D(const QmlDebugClient); return d->name; } -bool QmlDebugClientPlugin::isEnabled() const +bool QmlDebugClient::isEnabled() const { - Q_D(const QmlDebugClientPlugin); + Q_D(const QmlDebugClient); return d->enabled; } -void QmlDebugClientPlugin::setEnabled(bool e) +void QmlDebugClient::setEnabled(bool e) { - Q_D(QmlDebugClientPlugin); + Q_D(QmlDebugClient); if (e == d->enabled) return; @@ -174,16 +174,16 @@ void QmlDebugClientPlugin::setEnabled(bool e) } } -bool QmlDebugClientPlugin::isConnected() const +bool QmlDebugClient::isConnected() const { - Q_D(const QmlDebugClientPlugin); + Q_D(const QmlDebugClient); return d->client->isConnected(); } -void QmlDebugClientPlugin::sendMessage(const QByteArray &message) +void QmlDebugClient::sendMessage(const QByteArray &message) { - Q_D(QmlDebugClientPlugin); + Q_D(QmlDebugClient); if (!d->client || !d->client->isConnected()) return; @@ -193,7 +193,7 @@ void QmlDebugClientPlugin::sendMessage(const QByteArray &message) d->client->d->protocol->send(pack); } -void QmlDebugClientPlugin::messageReceived(const QByteArray &) +void QmlDebugClient::messageReceived(const QByteArray &) { } diff --git a/src/declarative/debugger/qmldebugclient.h b/src/declarative/debugger/qmldebugclient.h index 194e913..6397670 100644 --- a/src/declarative/debugger/qmldebugclient.h +++ b/src/declarative/debugger/qmldebugclient.h @@ -50,30 +50,30 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class QmlDebugClientPrivate; -class Q_DECLARATIVE_EXPORT QmlDebugClient : public QTcpSocket +class QmlDebugConnectionPrivate; +class Q_DECLARATIVE_EXPORT QmlDebugConnection : public QTcpSocket { Q_OBJECT - Q_DISABLE_COPY(QmlDebugClient) + Q_DISABLE_COPY(QmlDebugConnection) public: - QmlDebugClient(QObject * = 0); + QmlDebugConnection(QObject * = 0); bool isConnected() const; private: - QmlDebugClientPrivate *d; - friend class QmlDebugClientPlugin; - friend class QmlDebugClientPluginPrivate; + QmlDebugConnectionPrivate *d; + friend class QmlDebugClient; + friend class QmlDebugClientPrivate; }; -class QmlDebugClientPluginPrivate; -class Q_DECLARATIVE_EXPORT QmlDebugClientPlugin : public QObject +class QmlDebugClientPrivate; +class Q_DECLARATIVE_EXPORT QmlDebugClient : public QObject { Q_OBJECT - Q_DECLARE_PRIVATE(QmlDebugClientPlugin) - Q_DISABLE_COPY(QmlDebugClientPlugin) + Q_DECLARE_PRIVATE(QmlDebugClient) + Q_DISABLE_COPY(QmlDebugClient) public: - QmlDebugClientPlugin(const QString &, QmlDebugClient *parent); + QmlDebugClient(const QString &, QmlDebugConnection *parent); QString name() const; @@ -88,8 +88,8 @@ protected: virtual void messageReceived(const QByteArray &); private: - friend class QmlDebugClient; - friend class QmlDebugClientPrivate; + friend class QmlDebugConnection; + friend class QmlDebugConnectionPrivate; }; QT_END_NAMESPACE diff --git a/tools/qmldebugger/canvasframerate.cpp b/tools/qmldebugger/canvasframerate.cpp index f2a813d..d0be579 100644 --- a/tools/qmldebugger/canvasframerate.cpp +++ b/tools/qmldebugger/canvasframerate.cpp @@ -209,11 +209,11 @@ void QLineGraph::paintEvent(QPaintEvent *) drawTime(&p, r); } -class CanvasFrameRatePlugin : public QmlDebugClientPlugin +class CanvasFrameRatePlugin : public QmlDebugClient { Q_OBJECT public: - CanvasFrameRatePlugin(QmlDebugClient *client); + CanvasFrameRatePlugin(QmlDebugConnection *client); signals: void sample(int, int, int, int, bool); @@ -227,8 +227,8 @@ private: int ld; }; -CanvasFrameRatePlugin::CanvasFrameRatePlugin(QmlDebugClient *client) -: QmlDebugClientPlugin(QLatin1String("CanvasFrameRate"), client), la(-1) +CanvasFrameRatePlugin::CanvasFrameRatePlugin(QmlDebugConnection *client) +: QmlDebugClient(QLatin1String("CanvasFrameRate"), client), la(-1) { } @@ -248,7 +248,7 @@ void CanvasFrameRatePlugin::messageReceived(const QByteArray &data) ld = d; } -CanvasFrameRate::CanvasFrameRate(QmlDebugClient *client, QWidget *parent) +CanvasFrameRate::CanvasFrameRate(QmlDebugConnection *client, QWidget *parent) : QWidget(parent) { m_plugin = new CanvasFrameRatePlugin(client); @@ -300,7 +300,7 @@ void CanvasFrameRate::stateChanged(int s) { bool checked = s != 0; - static_cast(m_plugin)->setEnabled(checked); + static_cast(m_plugin)->setEnabled(checked); } QT_END_NAMESPACE diff --git a/tools/qmldebugger/canvasframerate.h b/tools/qmldebugger/canvasframerate.h index cc40d4c..912412b 100644 --- a/tools/qmldebugger/canvasframerate.h +++ b/tools/qmldebugger/canvasframerate.h @@ -5,13 +5,13 @@ QT_BEGIN_NAMESPACE -class QmlDebugClient; +class QmlDebugConnection; class QTabWidget; class CanvasFrameRate : public QWidget { Q_OBJECT public: - CanvasFrameRate(QmlDebugClient *, QWidget *parent = 0); + CanvasFrameRate(QmlDebugConnection *, QWidget *parent = 0); private slots: void newTab(); diff --git a/tools/qmldebugger/canvasscene.cpp b/tools/qmldebugger/canvasscene.cpp index 95f3098..65db9da 100644 --- a/tools/qmldebugger/canvasscene.cpp +++ b/tools/qmldebugger/canvasscene.cpp @@ -10,10 +10,10 @@ QT_BEGIN_NAMESPACE -class CanvasSceneClientPlugin : public QmlDebugClientPlugin +class CanvasSceneClientPlugin : public QmlDebugClient { public: - CanvasSceneClientPlugin(QmlDebugClient *, CanvasScene *s); + CanvasSceneClientPlugin(QmlDebugConnection *, CanvasScene *s); protected: void messageReceived(const QByteArray &); @@ -40,9 +40,9 @@ public: QFxImage *img; }; -CanvasSceneClientPlugin::CanvasSceneClientPlugin(QmlDebugClient *c, +CanvasSceneClientPlugin::CanvasSceneClientPlugin(QmlDebugConnection *c, CanvasScene *s) -: QmlDebugClientPlugin(QLatin1String("CanvasScene"), c), scene(s) +: QmlDebugClient(QLatin1String("CanvasScene"), c), scene(s) { } @@ -144,7 +144,7 @@ void CanvasSceneClientPlugin::dump(QDataStream &ds, int indent) dump(ds, indent + 1); } -CanvasScene::CanvasScene(QmlDebugClient *c, QWidget *parent) +CanvasScene::CanvasScene(QmlDebugConnection *c, QWidget *parent) : QWidget(parent) { client = new CanvasSceneClientPlugin(c, this); diff --git a/tools/qmldebugger/canvasscene.h b/tools/qmldebugger/canvasscene.h index 8b583e8..8c6b8d5 100644 --- a/tools/qmldebugger/canvasscene.h +++ b/tools/qmldebugger/canvasscene.h @@ -8,14 +8,14 @@ QT_BEGIN_NAMESPACE -class QmlDebugClient; +class QmlDebugConnection; class CanvasSceneClient; -class QmlDebugClientPlugin; +class QmlDebugClient; class CanvasScene : public QWidget { Q_OBJECT public: - CanvasScene(QmlDebugClient *, QWidget *parent = 0); + CanvasScene(QmlDebugConnection *, QWidget *parent = 0); void message(QDataStream &); private slots: @@ -29,7 +29,7 @@ private slots: private: void setOpacityRecur(QTreeWidgetItem *, qreal); void clone(QTreeWidgetItem *item, QSimpleCanvasItem *me, QDataStream &); - QmlDebugClientPlugin *client; + QmlDebugClient *client; QTreeWidget *m_tree; QSimpleCanvas *m_canvas; diff --git a/tools/qmldebugger/engine.cpp b/tools/qmldebugger/engine.cpp index 46d30c4..3b8c8b1 100644 --- a/tools/qmldebugger/engine.cpp +++ b/tools/qmldebugger/engine.cpp @@ -27,7 +27,7 @@ private: int m_engineId; }; -EnginePane::EnginePane(QmlDebugClient *client, QWidget *parent) +EnginePane::EnginePane(QmlDebugConnection *client, QWidget *parent) : QWidget(parent), m_client(client), m_engines(0), m_context(0), m_object(0) { QVBoxLayout *layout = new QVBoxLayout; diff --git a/tools/qmldebugger/engine.h b/tools/qmldebugger/engine.h index 191cd1d..a713f25 100644 --- a/tools/qmldebugger/engine.h +++ b/tools/qmldebugger/engine.h @@ -9,14 +9,14 @@ QT_BEGIN_NAMESPACE -class QmlDebugClient; +class QmlDebugConnection; class EngineClientPlugin; class QLineEdit; class EnginePane : public QWidget { Q_OBJECT public: - EnginePane(QmlDebugClient *, QWidget *parent = 0); + EnginePane(QmlDebugConnection *, QWidget *parent = 0); private slots: void queryEngines(); diff --git a/tools/qmldebugger/main.cpp b/tools/qmldebugger/main.cpp index 4bed41d..500836f 100644 --- a/tools/qmldebugger/main.cpp +++ b/tools/qmldebugger/main.cpp @@ -29,7 +29,7 @@ private slots: void connectionStateChanged(); private: - QmlDebugClient client; + QmlDebugConnection client; QLabel *m_connectionState; QLineEdit *m_host; -- cgit v0.12 From b95f28940857332983f176a8e0d356e3e67e5acc Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Mon, 13 Jul 2009 17:41:47 +1000 Subject: Missing files --- tools/qmldebugger/engine.png | Bin 0 -> 6394 bytes tools/qmldebugger/engines.qml | 44 ++++++++++++++++++++++++++++++++++++++++++ tools/qmldebugger/refresh.png | Bin 0 -> 6169 bytes 3 files changed, 44 insertions(+) create mode 100644 tools/qmldebugger/engine.png create mode 100644 tools/qmldebugger/engines.qml create mode 100644 tools/qmldebugger/refresh.png diff --git a/tools/qmldebugger/engine.png b/tools/qmldebugger/engine.png new file mode 100644 index 0000000..a0a8a04 Binary files /dev/null and b/tools/qmldebugger/engine.png differ diff --git a/tools/qmldebugger/engines.qml b/tools/qmldebugger/engines.qml new file mode 100644 index 0000000..2435f10 --- /dev/null +++ b/tools/qmldebugger/engines.qml @@ -0,0 +1,44 @@ +Item { + height: 100 + id: Root + signal engineClicked(int id) + signal refreshEngines() + + HorizontalLayout { + anchors.fill: parent + Repeater { + dataSource: engines + Item { + width: 100; height: 100; + Image { + id: Image; + source: "engine.png" + anchors.horizontalCenter: parent.horizontalCenter + } + Text { + anchors.top: Image.bottom; + text: modelData.name + "(" + modelData.engineId + ")" + anchors.horizontalCenter: parent.horizontalCenter + } + MouseRegion { + anchors.fill: parent + onClicked: Root.engineClicked(modelData.engineId); + } + } + } + } + + + Image { + y: 15 + source: "refresh.png"; + width: 75; + height: 63; + smooth: true + anchors.right: parent.right + MouseRegion { + anchors.fill: parent + onClicked: Root.refreshEngines() + } + } +} diff --git a/tools/qmldebugger/refresh.png b/tools/qmldebugger/refresh.png new file mode 100644 index 0000000..8befc80 Binary files /dev/null and b/tools/qmldebugger/refresh.png differ -- cgit v0.12 From 9eca9e028884fb82d97e284826faa7965af356bd Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Mon, 13 Jul 2009 17:44:29 +1000 Subject: Rename QmlDebugServerPlugin -> QmlDebugService --- src/declarative/canvas/qsimplecanvas.cpp | 2 +- .../canvas/qsimplecanvasdebugplugin.cpp | 6 +- .../canvas/qsimplecanvasdebugplugin_p.h | 6 +- src/declarative/debugger/debugger.pri | 4 +- src/declarative/debugger/qmldebugserver.cpp | 380 --------------------- src/declarative/debugger/qmldebugserver.h | 86 ----- src/declarative/debugger/qmldebugservice.cpp | 380 +++++++++++++++++++++ src/declarative/debugger/qmldebugservice.h | 86 +++++ src/declarative/qml/qmlenginedebug.cpp | 12 +- src/declarative/qml/qmlenginedebug_p.h | 4 +- 10 files changed, 483 insertions(+), 483 deletions(-) delete mode 100644 src/declarative/debugger/qmldebugserver.cpp delete mode 100644 src/declarative/debugger/qmldebugserver.h create mode 100644 src/declarative/debugger/qmldebugservice.cpp create mode 100644 src/declarative/debugger/qmldebugservice.h diff --git a/src/declarative/canvas/qsimplecanvas.cpp b/src/declarative/canvas/qsimplecanvas.cpp index a4998dc..3e586f7 100644 --- a/src/declarative/canvas/qsimplecanvas.cpp +++ b/src/declarative/canvas/qsimplecanvas.cpp @@ -573,7 +573,7 @@ void QSimpleCanvasPrivate::init(QSimpleCanvas::CanvasMode mode) if (continuousUpdate()) qWarning("QSimpleCanvas: Continuous update enabled"); - if (QmlDebugServerPlugin::isDebuggingEnabled()) { + if (QmlDebugService::isDebuggingEnabled()) { debugPlugin = new QSimpleCanvasDebugPlugin(q); new QSimpleCanvasSceneDebugPlugin(q); } diff --git a/src/declarative/canvas/qsimplecanvasdebugplugin.cpp b/src/declarative/canvas/qsimplecanvasdebugplugin.cpp index 12088c1..ffb3517 100644 --- a/src/declarative/canvas/qsimplecanvasdebugplugin.cpp +++ b/src/declarative/canvas/qsimplecanvasdebugplugin.cpp @@ -67,7 +67,7 @@ private: }; QSimpleCanvasDebugPlugin::QSimpleCanvasDebugPlugin(QObject *parent) -: QmlDebugServerPlugin(QLatin1String("CanvasFrameRate"), parent), _breaks(0) +: QmlDebugService(QLatin1String("CanvasFrameRate"), parent), _breaks(0) { _time.start(); new FrameBreakAnimation(this); @@ -96,7 +96,7 @@ void QSimpleCanvasDebugPlugin::frameBreak() } QSimpleCanvasSceneDebugPlugin::QSimpleCanvasSceneDebugPlugin(QSimpleCanvas *parent) -: QmlDebugServerPlugin(QLatin1String("CanvasScene"), parent), m_canvas(parent) +: QmlDebugService(QLatin1String("CanvasScene"), parent), m_canvas(parent) { } @@ -120,7 +120,7 @@ void QSimpleCanvasSceneDebugPlugin::refresh() void QSimpleCanvasSceneDebugPlugin::refresh(QDataStream &ds, QSimpleCanvasItem *item) { - ds << QmlDebugServerPlugin::objectToString(item) << item->x() << item->y() + ds << QmlDebugService::objectToString(item) << item->x() << item->y() << item->z() << item->width() << item->height() << (int)item->transformOrigin() << item->scale() << (int)item->flip() #ifdef QFX_RENDER_OPENGL diff --git a/src/declarative/canvas/qsimplecanvasdebugplugin_p.h b/src/declarative/canvas/qsimplecanvasdebugplugin_p.h index 270b78c..4c6af2c 100644 --- a/src/declarative/canvas/qsimplecanvasdebugplugin_p.h +++ b/src/declarative/canvas/qsimplecanvasdebugplugin_p.h @@ -46,10 +46,10 @@ #include "qtcpserver.h" #include "qtcpsocket.h" #include "qdatetime.h" -#include +#include QT_BEGIN_NAMESPACE -class QSimpleCanvasDebugPlugin : public QmlDebugServerPlugin +class QSimpleCanvasDebugPlugin : public QmlDebugService { public: QSimpleCanvasDebugPlugin(QObject *parent = 0); @@ -65,7 +65,7 @@ private: class QSimpleCanvas; class QSimpleCanvasItem; -class QSimpleCanvasSceneDebugPlugin : public QmlDebugServerPlugin +class QSimpleCanvasSceneDebugPlugin : public QmlDebugService { public: QSimpleCanvasSceneDebugPlugin(QSimpleCanvas *parent = 0); diff --git a/src/declarative/debugger/debugger.pri b/src/declarative/debugger/debugger.pri index 33076ea..82746fc 100644 --- a/src/declarative/debugger/debugger.pri +++ b/src/declarative/debugger/debugger.pri @@ -1,11 +1,11 @@ SOURCES += debugger/qmldebuggerstatus.cpp \ debugger/qpacketprotocol.cpp \ - debugger/qmldebugserver.cpp \ + debugger/qmldebugservice.cpp \ debugger/qmldebugclient.cpp \ debugger/qmldebug.cpp HEADERS += debugger/qmldebuggerstatus.h \ debugger/qpacketprotocol.h \ - debugger/qmldebugserver.h \ + debugger/qmldebugservice.h \ debugger/qmldebugclient.h \ debugger/qmldebug.h diff --git a/src/declarative/debugger/qmldebugserver.cpp b/src/declarative/debugger/qmldebugserver.cpp deleted file mode 100644 index ddfb88a..0000000 --- a/src/declarative/debugger/qmldebugserver.cpp +++ /dev/null @@ -1,380 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qmldebugserver.h" -#include -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class QmlDebugServerPrivate; -class QmlDebugServer : public QObject -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QmlDebugServer) - Q_DISABLE_COPY(QmlDebugServer) -public: - static QmlDebugServer *instance(); - -private slots: - void readyRead(); - -private: - friend class QmlDebugServerPlugin; - friend class QmlDebugServerPluginPrivate; - QmlDebugServer(int); -}; - -class QmlDebugServerPrivate : public QObjectPrivate -{ - Q_DECLARE_PUBLIC(QmlDebugServer) -public: - QmlDebugServerPrivate(); - void init(int port); - - QTcpSocket *connection; - QPacketProtocol *protocol; - QHash plugins; - QStringList enabledPlugins; -}; - -class QmlDebugServerPluginPrivate : public QObjectPrivate -{ - Q_DECLARE_PUBLIC(QmlDebugServerPlugin) -public: - QmlDebugServerPluginPrivate(); - - QString name; - QmlDebugServer *server; -}; - -QmlDebugServerPrivate::QmlDebugServerPrivate() -: connection(0), protocol(0) -{ -} - -void QmlDebugServerPrivate::init(int port) -{ - Q_Q(QmlDebugServer); - QTcpServer server; - - if (!server.listen(QHostAddress::Any, port)) { - qWarning("QmlDebugServer: Unable to listen on port %d", port); - return; - } - - qWarning("QmlDebugServer: Waiting for connection on port %d...", port); - - if (!server.waitForNewConnection(-1)) { - qWarning("QmlDebugServer: Connection error"); - return; - } - - connection = server.nextPendingConnection(); - connection->setParent(q); - protocol = new QPacketProtocol(connection, q); - - // ### Wait for hello - while (!protocol->packetsAvailable()) { - connection->waitForReadyRead(); - } - QPacket hello = protocol->read(); - QString name; - hello >> name >> enabledPlugins; - if (name != QLatin1String("QmlDebugServer")) { - qWarning("QmlDebugServer: Invalid hello message"); - delete protocol; delete connection; connection = 0; protocol = 0; - return; - } - - QObject::connect(protocol, SIGNAL(readyRead()), q, SLOT(readyRead())); - q->readyRead(); - - qWarning("QmlDebugServer: Connection established"); -} - -QmlDebugServer *QmlDebugServer::instance() -{ - static bool envTested = false; - static QmlDebugServer *server = 0; - - if (!envTested) { - envTested = true; - QByteArray env = qgetenv("QML_DEBUG_SERVER_PORT"); - - bool ok = false; - int port = env.toInt(&ok); - - if (ok && port > 1024) - server = new QmlDebugServer(port); - } - - if (server && server->d_func()->connection) - return server; - else - return 0; -} - -QmlDebugServer::QmlDebugServer(int port) -: QObject(*(new QmlDebugServerPrivate)) -{ - Q_D(QmlDebugServer); - d->init(port); -} - -void QmlDebugServer::readyRead() -{ - Q_D(QmlDebugServer); - - QString debugServer(QLatin1String("QmlDebugServer")); - - while (d->protocol->packetsAvailable()) { - QPacket pack = d->protocol->read(); - - QString name; - pack >> name; - - if (name == debugServer) { - int op = -1; QString plugin; - pack >> op >> plugin; - - if (op == 1) { - // Enable - if (!d->enabledPlugins.contains(plugin)) { - d->enabledPlugins.append(plugin); - QHash::Iterator iter = - d->plugins.find(plugin); - if (iter != d->plugins.end()) - (*iter)->enabledChanged(true); - } - - } else if (op == 2) { - // Disable - if (d->enabledPlugins.contains(plugin)) { - d->enabledPlugins.removeAll(plugin); - QHash::Iterator iter = - d->plugins.find(plugin); - if (iter != d->plugins.end()) - (*iter)->enabledChanged(false); - } - } else { - qWarning("QmlDebugServer: Invalid control message %d", op); - } - - } else { - QByteArray message; - pack >> message; - - QHash::Iterator iter = - d->plugins.find(name); - if (iter == d->plugins.end()) { - qWarning() << "QmlDebugServer: Message received for missing plugin" << name; - } else { - (*iter)->messageReceived(message); - } - } - } -} - -QmlDebugServerPluginPrivate::QmlDebugServerPluginPrivate() -: server(0) -{ -} - -QmlDebugServerPlugin::QmlDebugServerPlugin(const QString &name, QObject *parent) -: QObject(*(new QmlDebugServerPluginPrivate), parent) -{ - Q_D(QmlDebugServerPlugin); - d->name = name; - d->server = QmlDebugServer::instance(); - - if (!d->server) - return; - - if (d->server->d_func()->plugins.contains(name)) { - qWarning() << "QmlDebugServerPlugin: Conflicting plugin name" << name; - d->server = 0; - } else { - d->server->d_func()->plugins.insert(name, this); - } -} - -QString QmlDebugServerPlugin::name() const -{ - Q_D(const QmlDebugServerPlugin); - return d->name; -} - -bool QmlDebugServerPlugin::isEnabled() const -{ - Q_D(const QmlDebugServerPlugin); - return (d->server && d->server->d_func()->enabledPlugins.contains(d->name)); -} - -namespace { - - struct ObjectReference - { - QPointer object; - int id; - }; - - struct ObjectReferenceHash - { - ObjectReferenceHash() : nextId(0) {} - - QHash objects; - QHash ids; - - int nextId; - }; - -} -Q_GLOBAL_STATIC(ObjectReferenceHash, objectReferenceHash); - - -/*! - Returns a unique id for \a object. Calling this method multiple times - for the same object will return the same id. -*/ -int QmlDebugServerPlugin::idForObject(QObject *object) -{ - if (!object) - return -1; - - ObjectReferenceHash *hash = objectReferenceHash(); - QHash::Iterator iter = - hash->objects.find(object); - - if (iter == hash->objects.end()) { - int id = hash->nextId++; - - hash->ids.insert(id, object); - iter = hash->objects.insert(object, ObjectReference()); - iter->object = object; - iter->id = id; - } else if (iter->object != object) { - int id = hash->nextId++; - - hash->ids.remove(iter->id); - - hash->ids.insert(id, object); - iter->object = object; - iter->id = id; - } - return iter->id; -} - -/*! - Returns the object for unique \a id. If the object has not previously been - assigned an id, through idForObject(), then 0 is returned. If the object - has been destroyed, 0 is returned. -*/ -QObject *QmlDebugServerPlugin::objectForId(int id) -{ - ObjectReferenceHash *hash = objectReferenceHash(); - - QHash::Iterator iter = hash->ids.find(id); - if (iter == hash->ids.end()) - return 0; - - - QHash::Iterator objIter = - hash->objects.find(*iter); - Q_ASSERT(objIter != hash->objects.end()); - - if (objIter->object == 0) { - hash->ids.erase(iter); - hash->objects.erase(objIter); - return 0; - } else { - return *iter; - } -} - -bool QmlDebugServerPlugin::isDebuggingEnabled() -{ - return QmlDebugServer::instance() != 0; -} - -QString QmlDebugServerPlugin::objectToString(QObject *obj) -{ - if(!obj) - return QLatin1String("NULL"); - - QString objectName = obj->objectName(); - if(objectName.isEmpty()) - objectName = QLatin1String(""); - - QString rv = QLatin1String(obj->metaObject()->className()) + - QLatin1String(": ") + objectName; - - return rv; -} - -void QmlDebugServerPlugin::sendMessage(const QByteArray &message) -{ - Q_D(QmlDebugServerPlugin); - - if (!d->server || !d->server->d_func()->connection) - return; - - QPacket pack; - pack << d->name << message; - d->server->d_func()->protocol->send(pack); - d->server->d_func()->connection->flush(); -} - -void QmlDebugServerPlugin::enabledChanged(bool) -{ -} - -void QmlDebugServerPlugin::messageReceived(const QByteArray &) -{ -} - -QT_END_NAMESPACE - -#include "qmldebugserver.moc" diff --git a/src/declarative/debugger/qmldebugserver.h b/src/declarative/debugger/qmldebugserver.h deleted file mode 100644 index b15ee2e..0000000 --- a/src/declarative/debugger/qmldebugserver.h +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMLDEBUGSERVER_H -#define QMLDEBUGSERVER_H - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QmlDebugServerPluginPrivate; -class QmlDebugServerPlugin : public QObject -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QmlDebugServerPlugin) - Q_DISABLE_COPY(QmlDebugServerPlugin) -public: - QmlDebugServerPlugin(const QString &, QObject *parent = 0); - - QString name() const; - - bool isEnabled() const; - - void sendMessage(const QByteArray &); - - static int idForObject(QObject *); - static QObject *objectForId(int); - - - static bool isDebuggingEnabled(); - static QString objectToString(QObject *obj); - -protected: - virtual void enabledChanged(bool); - virtual void messageReceived(const QByteArray &); - -private: - friend class QmlDebugServer; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QMLDEBUGSERVER_H - diff --git a/src/declarative/debugger/qmldebugservice.cpp b/src/declarative/debugger/qmldebugservice.cpp new file mode 100644 index 0000000..9725494 --- /dev/null +++ b/src/declarative/debugger/qmldebugservice.cpp @@ -0,0 +1,380 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qmldebugservice.h" +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QmlDebugServerPrivate; +class QmlDebugServer : public QObject +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QmlDebugServer) + Q_DISABLE_COPY(QmlDebugServer) +public: + static QmlDebugServer *instance(); + +private slots: + void readyRead(); + +private: + friend class QmlDebugService; + friend class QmlDebugServicePrivate; + QmlDebugServer(int); +}; + +class QmlDebugServerPrivate : public QObjectPrivate +{ + Q_DECLARE_PUBLIC(QmlDebugServer) +public: + QmlDebugServerPrivate(); + void init(int port); + + QTcpSocket *connection; + QPacketProtocol *protocol; + QHash plugins; + QStringList enabledPlugins; +}; + +class QmlDebugServicePrivate : public QObjectPrivate +{ + Q_DECLARE_PUBLIC(QmlDebugService) +public: + QmlDebugServicePrivate(); + + QString name; + QmlDebugServer *server; +}; + +QmlDebugServerPrivate::QmlDebugServerPrivate() +: connection(0), protocol(0) +{ +} + +void QmlDebugServerPrivate::init(int port) +{ + Q_Q(QmlDebugServer); + QTcpServer server; + + if (!server.listen(QHostAddress::Any, port)) { + qWarning("QmlDebugServer: Unable to listen on port %d", port); + return; + } + + qWarning("QmlDebugServer: Waiting for connection on port %d...", port); + + if (!server.waitForNewConnection(-1)) { + qWarning("QmlDebugServer: Connection error"); + return; + } + + connection = server.nextPendingConnection(); + connection->setParent(q); + protocol = new QPacketProtocol(connection, q); + + // ### Wait for hello + while (!protocol->packetsAvailable()) { + connection->waitForReadyRead(); + } + QPacket hello = protocol->read(); + QString name; + hello >> name >> enabledPlugins; + if (name != QLatin1String("QmlDebugServer")) { + qWarning("QmlDebugServer: Invalid hello message"); + delete protocol; delete connection; connection = 0; protocol = 0; + return; + } + + QObject::connect(protocol, SIGNAL(readyRead()), q, SLOT(readyRead())); + q->readyRead(); + + qWarning("QmlDebugServer: Connection established"); +} + +QmlDebugServer *QmlDebugServer::instance() +{ + static bool envTested = false; + static QmlDebugServer *server = 0; + + if (!envTested) { + envTested = true; + QByteArray env = qgetenv("QML_DEBUG_SERVER_PORT"); + + bool ok = false; + int port = env.toInt(&ok); + + if (ok && port > 1024) + server = new QmlDebugServer(port); + } + + if (server && server->d_func()->connection) + return server; + else + return 0; +} + +QmlDebugServer::QmlDebugServer(int port) +: QObject(*(new QmlDebugServerPrivate)) +{ + Q_D(QmlDebugServer); + d->init(port); +} + +void QmlDebugServer::readyRead() +{ + Q_D(QmlDebugServer); + + QString debugServer(QLatin1String("QmlDebugServer")); + + while (d->protocol->packetsAvailable()) { + QPacket pack = d->protocol->read(); + + QString name; + pack >> name; + + if (name == debugServer) { + int op = -1; QString plugin; + pack >> op >> plugin; + + if (op == 1) { + // Enable + if (!d->enabledPlugins.contains(plugin)) { + d->enabledPlugins.append(plugin); + QHash::Iterator iter = + d->plugins.find(plugin); + if (iter != d->plugins.end()) + (*iter)->enabledChanged(true); + } + + } else if (op == 2) { + // Disable + if (d->enabledPlugins.contains(plugin)) { + d->enabledPlugins.removeAll(plugin); + QHash::Iterator iter = + d->plugins.find(plugin); + if (iter != d->plugins.end()) + (*iter)->enabledChanged(false); + } + } else { + qWarning("QmlDebugServer: Invalid control message %d", op); + } + + } else { + QByteArray message; + pack >> message; + + QHash::Iterator iter = + d->plugins.find(name); + if (iter == d->plugins.end()) { + qWarning() << "QmlDebugServer: Message received for missing plugin" << name; + } else { + (*iter)->messageReceived(message); + } + } + } +} + +QmlDebugServicePrivate::QmlDebugServicePrivate() +: server(0) +{ +} + +QmlDebugService::QmlDebugService(const QString &name, QObject *parent) +: QObject(*(new QmlDebugServicePrivate), parent) +{ + Q_D(QmlDebugService); + d->name = name; + d->server = QmlDebugServer::instance(); + + if (!d->server) + return; + + if (d->server->d_func()->plugins.contains(name)) { + qWarning() << "QmlDebugService: Conflicting plugin name" << name; + d->server = 0; + } else { + d->server->d_func()->plugins.insert(name, this); + } +} + +QString QmlDebugService::name() const +{ + Q_D(const QmlDebugService); + return d->name; +} + +bool QmlDebugService::isEnabled() const +{ + Q_D(const QmlDebugService); + return (d->server && d->server->d_func()->enabledPlugins.contains(d->name)); +} + +namespace { + + struct ObjectReference + { + QPointer object; + int id; + }; + + struct ObjectReferenceHash + { + ObjectReferenceHash() : nextId(0) {} + + QHash objects; + QHash ids; + + int nextId; + }; + +} +Q_GLOBAL_STATIC(ObjectReferenceHash, objectReferenceHash); + + +/*! + Returns a unique id for \a object. Calling this method multiple times + for the same object will return the same id. +*/ +int QmlDebugService::idForObject(QObject *object) +{ + if (!object) + return -1; + + ObjectReferenceHash *hash = objectReferenceHash(); + QHash::Iterator iter = + hash->objects.find(object); + + if (iter == hash->objects.end()) { + int id = hash->nextId++; + + hash->ids.insert(id, object); + iter = hash->objects.insert(object, ObjectReference()); + iter->object = object; + iter->id = id; + } else if (iter->object != object) { + int id = hash->nextId++; + + hash->ids.remove(iter->id); + + hash->ids.insert(id, object); + iter->object = object; + iter->id = id; + } + return iter->id; +} + +/*! + Returns the object for unique \a id. If the object has not previously been + assigned an id, through idForObject(), then 0 is returned. If the object + has been destroyed, 0 is returned. +*/ +QObject *QmlDebugService::objectForId(int id) +{ + ObjectReferenceHash *hash = objectReferenceHash(); + + QHash::Iterator iter = hash->ids.find(id); + if (iter == hash->ids.end()) + return 0; + + + QHash::Iterator objIter = + hash->objects.find(*iter); + Q_ASSERT(objIter != hash->objects.end()); + + if (objIter->object == 0) { + hash->ids.erase(iter); + hash->objects.erase(objIter); + return 0; + } else { + return *iter; + } +} + +bool QmlDebugService::isDebuggingEnabled() +{ + return QmlDebugServer::instance() != 0; +} + +QString QmlDebugService::objectToString(QObject *obj) +{ + if(!obj) + return QLatin1String("NULL"); + + QString objectName = obj->objectName(); + if(objectName.isEmpty()) + objectName = QLatin1String(""); + + QString rv = QLatin1String(obj->metaObject()->className()) + + QLatin1String(": ") + objectName; + + return rv; +} + +void QmlDebugService::sendMessage(const QByteArray &message) +{ + Q_D(QmlDebugService); + + if (!d->server || !d->server->d_func()->connection) + return; + + QPacket pack; + pack << d->name << message; + d->server->d_func()->protocol->send(pack); + d->server->d_func()->connection->flush(); +} + +void QmlDebugService::enabledChanged(bool) +{ +} + +void QmlDebugService::messageReceived(const QByteArray &) +{ +} + +QT_END_NAMESPACE + +#include "qmldebugservice.moc" diff --git a/src/declarative/debugger/qmldebugservice.h b/src/declarative/debugger/qmldebugservice.h new file mode 100644 index 0000000..b1344c4 --- /dev/null +++ b/src/declarative/debugger/qmldebugservice.h @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMLDEBUGSERVICE_H +#define QMLDEBUGSERVICE_H + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +class QmlDebugServicePrivate; +class QmlDebugService : public QObject +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QmlDebugService) + Q_DISABLE_COPY(QmlDebugService) +public: + QmlDebugService(const QString &, QObject *parent = 0); + + QString name() const; + + bool isEnabled() const; + + void sendMessage(const QByteArray &); + + static int idForObject(QObject *); + static QObject *objectForId(int); + + + static bool isDebuggingEnabled(); + static QString objectToString(QObject *obj); + +protected: + virtual void enabledChanged(bool); + virtual void messageReceived(const QByteArray &); + +private: + friend class QmlDebugServer; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QMLDEBUGSERVICE_H + diff --git a/src/declarative/qml/qmlenginedebug.cpp b/src/declarative/qml/qmlenginedebug.cpp index b5e44e7..2b8aac3 100644 --- a/src/declarative/qml/qmlenginedebug.cpp +++ b/src/declarative/qml/qmlenginedebug.cpp @@ -50,7 +50,7 @@ QT_BEGIN_NAMESPACE QList QmlEngineDebugServer::m_engines; QmlEngineDebugServer::QmlEngineDebugServer(QObject *parent) -: QmlDebugServerPlugin(QLatin1String("QmlEngine"), parent) +: QmlDebugService(QLatin1String("QmlEngine"), parent) { } @@ -135,7 +135,7 @@ void QmlEngineDebugServer::buildObjectList(QDataStream &message, QmlContextPrivate *p = (QmlContextPrivate *)QObjectPrivate::get(ctxt); QString ctxtName = ctxt->objectName(); - int ctxtId = QmlDebugServerPlugin::idForObject(ctxt); + int ctxtId = QmlDebugService::idForObject(ctxt); message << ctxtName << ctxtId; @@ -182,7 +182,7 @@ QmlEngineDebugServer::objectData(QObject *object) rv.objectName = object->objectName(); rv.objectType = object->metaObject()->className(); - rv.objectId = QmlDebugServerPlugin::idForObject(object); + rv.objectId = QmlDebugService::idForObject(object); return rv; } @@ -207,7 +207,7 @@ void QmlEngineDebugServer::messageReceived(const QByteArray &message) QmlEngine *engine = m_engines.at(ii); QString engineName = engine->objectName(); - int engineId = QmlDebugServerPlugin::idForObject(engine); + int engineId = QmlDebugService::idForObject(engine); rs << engineName << engineId; } @@ -219,7 +219,7 @@ void QmlEngineDebugServer::messageReceived(const QByteArray &message) ds >> queryId >> engineId; QmlEngine *engine = - qobject_cast(QmlDebugServerPlugin::objectForId(engineId)); + qobject_cast(QmlDebugService::objectForId(engineId)); QByteArray reply; QDataStream rs(&reply, QIODevice::WriteOnly); @@ -236,7 +236,7 @@ void QmlEngineDebugServer::messageReceived(const QByteArray &message) ds >> queryId >> objectId >> recurse; - QObject *object = QmlDebugServerPlugin::objectForId(objectId); + QObject *object = QmlDebugService::objectForId(objectId); QByteArray reply; QDataStream rs(&reply, QIODevice::WriteOnly); diff --git a/src/declarative/qml/qmlenginedebug_p.h b/src/declarative/qml/qmlenginedebug_p.h index 634f55f..e85ab6f 100644 --- a/src/declarative/qml/qmlenginedebug_p.h +++ b/src/declarative/qml/qmlenginedebug_p.h @@ -53,7 +53,7 @@ // We mean it. // -#include +#include #include #include @@ -62,7 +62,7 @@ QT_BEGIN_NAMESPACE class QmlEngine; class QmlContext; class QDataStream; -class QmlEngineDebugServer : public QmlDebugServerPlugin +class QmlEngineDebugServer : public QmlDebugService { public: QmlEngineDebugServer(QObject * = 0); -- cgit v0.12 From 7167e868ef96482604a006f957bf608ab6baca95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Mon, 13 Jul 2009 14:40:15 +0200 Subject: Compile. --- src/declarative/util/qfxview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/util/qfxview.cpp b/src/declarative/util/qfxview.cpp index 103442c..41f7db2 100644 --- a/src/declarative/util/qfxview.cpp +++ b/src/declarative/util/qfxview.cpp @@ -60,7 +60,7 @@ #include "qfxview.h" #include #include -#include +#include QT_BEGIN_NAMESPACE -- cgit v0.12 From 961f765440aee37ee129172a97e681808b2c7928 Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Tue, 14 Jul 2009 10:06:15 +1000 Subject: Add access to Qt palettes from QML. --- src/declarative/util/qmlpalette.cpp | 163 ++++++++++++++++++++++++++++++++++++ src/declarative/util/qmlpalette.h | 111 ++++++++++++++++++++++++ src/declarative/util/util.pri | 2 + tools/qmlviewer/qmlviewer.cpp | 25 ++++++ tools/qmlviewer/qmlviewer.h | 5 ++ 5 files changed, 306 insertions(+) create mode 100644 src/declarative/util/qmlpalette.cpp create mode 100644 src/declarative/util/qmlpalette.h diff --git a/src/declarative/util/qmlpalette.cpp b/src/declarative/util/qmlpalette.cpp new file mode 100644 index 0000000..670966d --- /dev/null +++ b/src/declarative/util/qmlpalette.cpp @@ -0,0 +1,163 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "private/qobject_p.h" +#include "qmlpalette.h" + +QT_BEGIN_NAMESPACE + +class QmlPalettePrivate : public QObjectPrivate +{ +public: + QPalette palette; + QPalette::ColorGroup group; +}; + +QML_DEFINE_TYPE(QmlPalette,Palette) + +/*! + \internal + \class QmlPalette + \ingroup group_utility + \brief The QmlPalette class gives access to the Qt palettes. +*/ +QmlPalette::QmlPalette(QObject *parent) + : QObject(*(new QmlPalettePrivate), parent) +{ + Q_D(QmlPalette); + d->group = QPalette::Active; +} + +QmlPalette::~QmlPalette() +{ +} + +QColor QmlPalette::window() const +{ + Q_D(const QmlPalette); + return d->palette.color(d->group, QPalette::Window); +} + +QColor QmlPalette::windowText() const +{ + Q_D(const QmlPalette); + return d->palette.color(d->group, QPalette::WindowText); +} + +QColor QmlPalette::base() const +{ + Q_D(const QmlPalette); + return d->palette.color(d->group, QPalette::Base); +} + +QColor QmlPalette::alternateBase() const +{ + Q_D(const QmlPalette); + return d->palette.color(d->group, QPalette::AlternateBase); +} + +QColor QmlPalette::button() const +{ + Q_D(const QmlPalette); + return d->palette.color(d->group, QPalette::Button); +} + +QColor QmlPalette::buttonText() const +{ + Q_D(const QmlPalette); + return d->palette.color(d->group, QPalette::ButtonText); +} + +QColor QmlPalette::light() const +{ + Q_D(const QmlPalette); + return d->palette.color(d->group, QPalette::Light); +} + +QColor QmlPalette::midlight() const +{ + Q_D(const QmlPalette); + return d->palette.color(d->group, QPalette::Midlight); +} + +QColor QmlPalette::dark() const +{ + Q_D(const QmlPalette); + return d->palette.color(d->group, QPalette::Dark); +} + +QColor QmlPalette::mid() const +{ + Q_D(const QmlPalette); + return d->palette.color(d->group, QPalette::Mid); +} + +QColor QmlPalette::shadow() const +{ + Q_D(const QmlPalette); + return d->palette.color(d->group, QPalette::Shadow); +} + +QColor QmlPalette::highlight() const +{ + Q_D(const QmlPalette); + return d->palette.color(d->group, QPalette::Highlight); +} + +QColor QmlPalette::highlightedText() const +{ + Q_D(const QmlPalette); + return d->palette.color(d->group, QPalette::HighlightedText); +} + +void QmlPalette::setColorGroup(QPalette::ColorGroup colorGroup) +{ + Q_D(QmlPalette); + d->group = colorGroup; +} + +QPalette QmlPalette::palette() const +{ + Q_D(const QmlPalette); + return d->palette; +} + +QT_END_NAMESPACE diff --git a/src/declarative/util/qmlpalette.h b/src/declarative/util/qmlpalette.h new file mode 100644 index 0000000..f176764 --- /dev/null +++ b/src/declarative/util/qmlpalette.h @@ -0,0 +1,111 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMLPALETTE_H +#define QMLPALETTE_H + +#include +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) + +class QmlPalettePrivate; +class Q_DECLARATIVE_EXPORT QmlPalette : public QObject +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QmlPalette) + +public: + QmlPalette(QObject *parent=0); + ~QmlPalette(); + + Q_PROPERTY(QColor window READ window CONSTANT) + Q_PROPERTY(QColor windowText READ windowText CONSTANT) + Q_PROPERTY(QColor base READ base CONSTANT) + Q_PROPERTY(QColor alternateBase READ alternateBase CONSTANT) + Q_PROPERTY(QColor button READ button CONSTANT) + Q_PROPERTY(QColor buttonText READ buttonText CONSTANT) + Q_PROPERTY(QColor light READ light CONSTANT) + Q_PROPERTY(QColor midlight READ midlight CONSTANT) + Q_PROPERTY(QColor dark READ dark CONSTANT) + Q_PROPERTY(QColor mid READ mid CONSTANT) + Q_PROPERTY(QColor shadow READ shadow CONSTANT) + Q_PROPERTY(QColor highlight READ highlight CONSTANT) + Q_PROPERTY(QColor highlightedText READ highlightedText CONSTANT) + + QColor window() const; + QColor windowText() const; + + QColor base() const; + QColor alternateBase() const; + + QColor button() const; + QColor buttonText() const; + + QColor light() const; + QColor midlight() const; + QColor dark() const; + QColor mid() const; + QColor shadow() const; + + QColor highlight() const; + QColor highlightedText() const; + + QPalette palette() const; + + void setColorGroup(QPalette::ColorGroup); + +Q_SIGNALS: + void updated(); +}; + +QT_END_NAMESPACE + +QML_DECLARE_TYPE(QmlPalette) + +QT_END_HEADER + +#endif // QMLPALETTE_H diff --git a/src/declarative/util/util.pri b/src/declarative/util/util.pri index aae10af..dcab10a 100644 --- a/src/declarative/util/util.pri +++ b/src/declarative/util/util.pri @@ -7,6 +7,7 @@ SOURCES += \ util/qmlscript.cpp \ util/qmlanimation.cpp \ util/qmlfont.cpp \ + util/qmlpalette.cpp \ util/qmlfollow.cpp \ util/qmlstate.cpp\ util/qmltransitionmanager.cpp \ @@ -31,6 +32,7 @@ HEADERS += \ util/qmlanimation.h \ util/qmlanimation_p.h \ util/qmlfont.h \ + util/qmlpalette.h \ util/qmlfollow.h \ util/qmlstate.h\ util/qmlstateoperations.h \ diff --git a/tools/qmlviewer/qmlviewer.cpp b/tools/qmlviewer/qmlviewer.cpp index db0dc18..b6ce619 100644 --- a/tools/qmlviewer/qmlviewer.cpp +++ b/tools/qmlviewer/qmlviewer.cpp @@ -17,6 +17,7 @@ #include "qmlviewer.h" #include #include +#include "qmlpalette.h" #include "qml.h" #include #include "qfxtestengine.h" @@ -133,6 +134,8 @@ QmlViewer::QmlViewer(QFxTestEngine::TestMode testMode, const QString &testDir, Q devicemode = false; skin = 0; canvas = 0; + palette = 0; + disabledPalette = 0; record_autotime = 0; record_period = 20; @@ -383,6 +386,7 @@ void QmlViewer::openQml(const QString& fileName) } } + setupPalettes(); canvas->setUrl(url); QTime t; @@ -407,6 +411,18 @@ void QmlViewer::openQml(const QString& fileName) #endif } +void QmlViewer:: setupPalettes() +{ + delete palette; + palette = new QmlPalette; + QmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("activePalette", palette); + + delete disabledPalette; + disabledPalette = new QmlPalette; + disabledPalette->setColorGroup(QPalette::Disabled); + ctxt->setContextProperty("disabledPalette", disabledPalette); +} void QmlViewer::setSkin(const QString& skinDirectory) { @@ -486,6 +502,15 @@ void QmlViewer::setRecordFile(const QString& f) record_file = f; } +bool QmlViewer::event(QEvent *event) +{ + if (event->type() == QEvent::PaletteChange) { + setupPalette(); + return true; + } + return QWidget::event(event); +} + void QmlViewer::setRecordPeriod(int ms) { record_period = ms; diff --git a/tools/qmlviewer/qmlviewer.h b/tools/qmlviewer/qmlviewer.h index c533fe0..765d42f 100644 --- a/tools/qmlviewer/qmlviewer.h +++ b/tools/qmlviewer/qmlviewer.h @@ -25,6 +25,7 @@ QT_BEGIN_NAMESPACE class QFxView; class PreviewDeviceSkin; class QFxTestEngine; +class QmlPalette; class QProcess; class QmlViewer : public QWidget @@ -61,6 +62,7 @@ public slots: protected: virtual void keyPressEvent(QKeyEvent *); virtual void timerEvent(QTimerEvent *); + virtual bool event(QEvent *event); void createMenu(QMenuBar *menu, QMenu *flatmenu); @@ -70,11 +72,14 @@ private slots: private: void setupProxy(); + void setupPalettes(); QString currentFileName; PreviewDeviceSkin *skin; QSize skinscreensize; QFxView *canvas; + QmlPalette *palette; + QmlPalette *disabledPalette; void init(QFxTestEngine::TestMode, const QString &, const QString& fileName); QBasicTimer recordTimer; QList frames; -- cgit v0.12 From 2ad297df799c74453607263a4d80724ae748eb4c Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Tue, 14 Jul 2009 10:30:27 +1000 Subject: typo --- tools/qmlviewer/qmlviewer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/qmlviewer/qmlviewer.cpp b/tools/qmlviewer/qmlviewer.cpp index b6ce619..6de1b97 100644 --- a/tools/qmlviewer/qmlviewer.cpp +++ b/tools/qmlviewer/qmlviewer.cpp @@ -505,7 +505,7 @@ void QmlViewer::setRecordFile(const QString& f) bool QmlViewer::event(QEvent *event) { if (event->type() == QEvent::PaletteChange) { - setupPalette(); + setupPalettes(); return true; } return QWidget::event(event); -- cgit v0.12