aboutsummaryrefslogtreecommitdiffstats
path: root/src/tools/qml
diff options
context:
space:
mode:
authorKai Koehne <[email protected]>2010-09-14 13:39:32 +0200
committerKai Koehne <[email protected]>2010-09-15 14:18:39 +0200
commit63cae2981b45b8d6c9334d28e0929d8a29f0c1eb (patch)
tree977a54e33cbae7d53bad04a1e952c7f5b342d3b0 /src/tools/qml
parent0fa0d00fcdbb07568cce6bf911c7634893f0c8b6 (diff)
QmlJsDebugger: Replace QDDesignView by QDViewObserver
Don't force users to inherit from QDeclarativeDesignView. Instead we're using now event filters to let a user attach a QDeclarativeViewObserver object to a QDeclarativeDesignView.
Diffstat (limited to 'src/tools/qml')
-rw-r--r--src/tools/qml/qmlobserver/qmlruntime.cpp29
-rw-r--r--src/tools/qml/qmlobserver/qmlruntime.h5
2 files changed, 18 insertions, 16 deletions
diff --git a/src/tools/qml/qmlobserver/qmlruntime.cpp b/src/tools/qml/qmlobserver/qmlruntime.cpp
index 6e5bdcf335c..fbbeda6efeb 100644
--- a/src/tools/qml/qmlobserver/qmlruntime.cpp
+++ b/src/tools/qml/qmlobserver/qmlruntime.cpp
@@ -54,7 +54,7 @@
# include "ui_recopts.h"
#endif
-#include <qdeclarativedesignview.h>
+#include <qdeclarativeviewobserver.h>
#include <qdeclarativedesigndebugserver.h>
#include <utils/crumblepath.h>
@@ -613,13 +613,14 @@ QDeclarativeViewer::QDeclarativeViewer(QWidget *parent, Qt::WindowFlags flags)
recdlg->warning->hide();
}
- canvas = new QmlViewer::QDeclarativeDesignView(this);
+ canvas = new QDeclarativeView(this);
+ observer = new QmlViewer::QDeclarativeViewObserver(canvas, this);
if (!(flags & Qt::FramelessWindowHint)) {
m_crumblePathWidget = new Utils::CrumblePath(canvas);
#ifndef Q_WS_MAC
m_crumblePathWidget->setStyleSheet("QWidget { border-bottom: 1px solid black; }");
#endif
- m_crumblePathWidget->setVisible(canvas->designModeBehavior());
+ m_crumblePathWidget->setVisible(observer->designModeBehavior());
// CrumblePath is not in a layout, so that it overlays the central widget
// The event filter ensures that its width stays in sync nevertheless
@@ -641,15 +642,15 @@ QDeclarativeViewer::QDeclarativeViewer(QWidget *parent, Qt::WindowFlags flags)
canvas->setFocus();
- QObject::connect(canvas, SIGNAL(reloadRequested()), this, SLOT(reload()));
+ QObject::connect(observer, SIGNAL(reloadRequested()), this, SLOT(reload()));
QObject::connect(canvas, SIGNAL(sceneResized(QSize)), this, SLOT(sceneResized(QSize)));
QObject::connect(canvas, SIGNAL(statusChanged(QDeclarativeView::Status)), this, SLOT(statusChanged()));
if (m_crumblePathWidget) {
- QObject::connect(canvas, SIGNAL(inspectorContextCleared()), m_crumblePathWidget, SLOT(clear()));
- QObject::connect(canvas, SIGNAL(inspectorContextPushed(QString)), m_crumblePathWidget, SLOT(pushElement(QString)));
- QObject::connect(canvas, SIGNAL(inspectorContextPopped()), m_crumblePathWidget, SLOT(popElement()));
- QObject::connect(m_crumblePathWidget, SIGNAL(elementClicked(int)), canvas, SLOT(setInspectorContext(int)));
- QObject::connect(canvas, SIGNAL(designModeBehaviorChanged(bool)), m_crumblePathWidget, SLOT(setVisible(bool)));
+ QObject::connect(observer, SIGNAL(inspectorContextCleared()), m_crumblePathWidget, SLOT(clear()));
+ QObject::connect(observer, SIGNAL(inspectorContextPushed(QString)), m_crumblePathWidget, SLOT(pushElement(QString)));
+ QObject::connect(observer, SIGNAL(inspectorContextPopped()), m_crumblePathWidget, SLOT(popElement()));
+ QObject::connect(m_crumblePathWidget, SIGNAL(elementClicked(int)), observer, SLOT(setInspectorContext(int)));
+ QObject::connect(observer, SIGNAL(designModeBehaviorChanged(bool)), m_crumblePathWidget, SLOT(setVisible(bool)));
}
QObject::connect(canvas->engine(), SIGNAL(quit()), QCoreApplication::instance (), SLOT(quit()));
@@ -691,12 +692,12 @@ void QDeclarativeViewer::setDesignModeBehavior(bool value)
{
if (designModeBehaviorAction)
designModeBehaviorAction->setChecked(value);
- canvas->setDesignModeBehavior(value);
+ observer->setDesignModeBehavior(value);
}
void QDeclarativeViewer::setDebugMode(bool on)
{
- canvas->setDebugMode(on);
+ observer->setDebugMode(on);
}
void QDeclarativeViewer::enableExperimentalGestures()
@@ -792,10 +793,10 @@ void QDeclarativeViewer::createMenu()
designModeBehaviorAction = new QAction(tr("&Observer Mode"), this);
designModeBehaviorAction->setShortcut(QKeySequence("Ctrl+D"));
designModeBehaviorAction->setCheckable(true);
- designModeBehaviorAction->setChecked(canvas->designModeBehavior());
+ designModeBehaviorAction->setChecked(observer->designModeBehavior());
designModeBehaviorAction->setEnabled(QDeclarativeDesignDebugServer::hasDebuggingClient());
connect(designModeBehaviorAction, SIGNAL(triggered(bool)), this, SLOT(setDesignModeBehavior(bool)));
- connect(canvas, SIGNAL(designModeBehaviorChanged(bool)), designModeBehaviorAction, SLOT(setChecked(bool)));
+ connect(observer, SIGNAL(designModeBehaviorChanged(bool)), designModeBehaviorAction, SLOT(setChecked(bool)));
connect(QDeclarativeDesignDebugServer::instance(), SIGNAL(debuggingClientChanged(bool)), designModeBehaviorAction, SLOT(setEnabled(bool)));
QAction *proxyAction = new QAction(tr("HTTP &Proxy..."), this);
@@ -1060,7 +1061,7 @@ void QDeclarativeViewer::addPluginPath(const QString& plugin)
void QDeclarativeViewer::reload()
{
- canvas->setDesignModeBehavior(false);
+ observer->setDesignModeBehavior(false);
open(currentFileOrUrl);
}
diff --git a/src/tools/qml/qmlobserver/qmlruntime.h b/src/tools/qml/qmlobserver/qmlruntime.h
index 2c6c5eefbd4..1160d91eb52 100644
--- a/src/tools/qml/qmlobserver/qmlruntime.h
+++ b/src/tools/qml/qmlobserver/qmlruntime.h
@@ -50,7 +50,7 @@
#include "loggerwidget.h"
namespace QmlViewer {
- class QDeclarativeDesignView;
+ class QDeclarativeViewObserver;
}
namespace Utils {
class CrumblePath;
@@ -167,7 +167,8 @@ private:
LoggerWidget *loggerWindow;
- QmlViewer::QDeclarativeDesignView *canvas;
+ QDeclarativeView *canvas;
+ QmlViewer::QDeclarativeViewObserver *observer;
QSize initialSize;
QString currentFileOrUrl;
QTimer recordTimer;