summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/qmlviewer/qfxtester.cpp2
-rw-r--r--tools/qmlviewer/qmlviewer.cpp37
-rw-r--r--tools/qmlviewer/qmlviewer.h3
3 files changed, 21 insertions, 21 deletions
diff --git a/tools/qmlviewer/qfxtester.cpp b/tools/qmlviewer/qfxtester.cpp
index bd96545..8eceb4c 100644
--- a/tools/qmlviewer/qfxtester.cpp
+++ b/tools/qmlviewer/qfxtester.cpp
@@ -147,7 +147,7 @@ void QmlGraphicsTester::imagefailure()
void QmlGraphicsTester::complete()
{
if ((options & QmlViewer::TestErrorProperty) && !hasFailed) {
- QString e = m_view->root()->property("error").toString();
+ QString e = m_view->rootObject()->property("error").toString();
if (!e.isEmpty()) {
qWarning() << "Test failed:" << e;
hasFailed = true;
diff --git a/tools/qmlviewer/qmlviewer.cpp b/tools/qmlviewer/qmlviewer.cpp
index 7c620ef..3cfbee2 100644
--- a/tools/qmlviewer/qmlviewer.cpp
+++ b/tools/qmlviewer/qmlviewer.cpp
@@ -80,6 +80,7 @@
#include <QAction>
#include <QFileDialog>
#include <QTimer>
+#include <QGraphicsObject>
#include <QNetworkProxyFactory>
#include <QKeyEvent>
#include <QMutex>
@@ -473,13 +474,12 @@ QmlViewer::QmlViewer(QWidget *parent, Qt::WindowFlags flags)
canvas = new QmlView(this);
canvas->setAttribute(Qt::WA_OpaquePaintEvent);
canvas->setAttribute(Qt::WA_NoSystemBackground);
- canvas->setContentResizable(!skin || !scaleSkin);
+ canvas->setResizeMode((!skin || !scaleSkin) ? QmlView::SizeRootObjectToView : QmlView::SizeViewToRootObject);
canvas->setFocus();
QObject::connect(canvas, SIGNAL(sceneResized(QSize)), this, SLOT(sceneResized(QSize)));
- QObject::connect(canvas, SIGNAL(initialSize(QSize)), this, SLOT(adjustSizeSlot()));
- QObject::connect(canvas, SIGNAL(errors(QList<QmlError>)), this, SLOT(executeErrors()));
- QObject::connect(canvas, SIGNAL(quit()), QCoreApplication::instance (), SLOT(quit()));
+ QObject::connect(canvas, SIGNAL(statusChanged(QmlView::Status)), this, SLOT(statusChanged()));
+ QObject::connect(canvas->engine(), SIGNAL(quit()), QCoreApplication::instance (), SLOT(quit()));
if (!(flags & Qt::FramelessWindowHint)) {
createMenu(menuBar(),0);
@@ -516,11 +516,6 @@ QmlViewer::~QmlViewer()
delete namFactory;
}
-void QmlViewer::adjustSizeSlot()
-{
- resize(sizeHint());
-}
-
QMenuBar *QmlViewer::menuBar() const
{
#if !defined(Q_OS_SYMBIAN)
@@ -731,7 +726,7 @@ void QmlViewer::setScaleSkin()
if (scaleSkin)
return;
scaleSkin = true;
- canvas->setContentResizable(!skin || !scaleSkin);
+ canvas->setResizeMode((!skin || !scaleSkin) ? QmlView::SizeRootObjectToView : QmlView::SizeViewToRootObject);
if (skin) {
canvas->setFixedSize(canvas->sizeHint());
skin->setScreenSize(canvas->sizeHint());
@@ -744,7 +739,7 @@ void QmlViewer::setScaleView()
return;
scaleSkin = false;
if (skin) {
- canvas->setContentResizable(!skin || !scaleSkin);
+ canvas->setResizeMode((!skin || !scaleSkin) ? QmlView::SizeRootObjectToView : QmlView::SizeViewToRootObject);
canvas->setMinimumSize(QSize(0,0));
canvas->setMaximumSize(QSize(16777215,16777215));
canvas->resize(skin->standardScreenSize());
@@ -889,7 +884,8 @@ void QmlViewer::openWgt(const QString& doc)
QUrl url(doc);
if (url.isRelative())
url = QUrl::fromLocalFile(doc);
- canvas->reset();
+ delete canvas->rootObject();
+ canvas->engine()->clearComponentCache();
QNetworkAccessManager * nam = canvas->engine()->networkAccessManager();
wgtreply = nam->get(QNetworkRequest(url));
connect(wgtreply,SIGNAL(finished()),this,SLOT(unpackWgt()));
@@ -971,7 +967,7 @@ void QmlViewer::unpackWgt()
void QmlViewer::openFile()
{
- QString cur = canvas->url().toLocalFile();
+ QString cur = canvas->source().toLocalFile();
if (useQmlFileBrowser) {
openQml("qrc:/content/Browser.qml");
} else {
@@ -983,9 +979,13 @@ void QmlViewer::openFile()
}
}
-void QmlViewer::executeErrors()
+void QmlViewer::statusChanged()
{
- if (tester) tester->executefailure();
+ if (canvas->status() == QmlView::Error && tester)
+ tester->executefailure();
+
+ if (canvas->status() == QmlView::Ready)
+ resize(sizeHint());
}
void QmlViewer::launch(const QString& file_or_url)
@@ -1008,7 +1008,8 @@ void QmlViewer::openQml(const QString& file_or_url)
if (!m_script.isEmpty())
tester = new QmlGraphicsTester(m_script, m_scriptOptions, canvas);
- canvas->reset();
+ delete canvas->rootObject();
+ canvas->engine()->clearComponentCache();
QmlContext *ctxt = canvas->rootContext();
ctxt->setContextProperty("qmlViewer", this);
#ifdef Q_OS_SYMBIAN
@@ -1058,7 +1059,7 @@ void QmlViewer::openQml(const QString& file_or_url)
}
}
- canvas->setUrl(url);
+ canvas->setSource(url);
QTime t;
t.start();
@@ -1125,7 +1126,7 @@ void QmlViewer::setSkin(const QString& skinDirOrName)
skin->deleteLater();
}
- canvas->setContentResizable(!skin || !scaleSkin);
+ canvas->setResizeMode((!skin || !scaleSkin) ? QmlView::SizeRootObjectToView : QmlView::SizeViewToRootObject);
DeviceSkinParameters parameters;
if (!skinDirectory.isEmpty() && parameters.read(skinDirectory,DeviceSkinParameters::ReadAll,&err)) {
diff --git a/tools/qmlviewer/qmlviewer.h b/tools/qmlviewer/qmlviewer.h
index 6b05584..fbb5aa5 100644
--- a/tools/qmlviewer/qmlviewer.h
+++ b/tools/qmlviewer/qmlviewer.h
@@ -116,7 +116,7 @@ public slots:
void showProxySettings ();
void proxySettingsChanged ();
void setScaleView();
- void executeErrors();
+ void statusChanged();
void setSlowMode(bool);
void launch(const QString &);
@@ -132,7 +132,6 @@ private slots:
void chooseRecordingOptions();
void pickRecordingFile();
void setScaleSkin();
- void adjustSizeSlot();
void setPortrait();
void setLandscape();
void toggleOrientation();