diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/qml/qdeclarativetester.cpp | 18 | ||||
-rw-r--r-- | tools/qml/qml.pri | 29 | ||||
-rw-r--r-- | tools/qml/qml.pro | 35 | ||||
-rw-r--r-- | tools/qml/qmlruntime.cpp | 140 | ||||
-rw-r--r-- | tools/qml/qmlruntime.h | 7 |
5 files changed, 77 insertions, 152 deletions
diff --git a/tools/qml/qdeclarativetester.cpp b/tools/qml/qdeclarativetester.cpp index cf537ee..11fa22f 100644 --- a/tools/qml/qdeclarativetester.cpp +++ b/tools/qml/qdeclarativetester.cpp @@ -332,6 +332,24 @@ void QDeclarativeTester::updateCurrentTime(int msec) qWarning() << "QDeclarativeTester: Image mismatch. Reject saved to:" << reject; img.save(reject); + bool doDiff = (goodImage.size() == img.size()); + if (doDiff) { + QImage diffimg(m_view->width(), m_view->height(), QImage::Format_RGB32); + diffimg.fill(qRgb(255,255,255)); + QPainter p(&diffimg); + int diffCount = 0; + for (int x = 0; x < img.width(); ++x) { + for (int y = 0; y < img.height(); ++y) { + if (goodImage.pixel(x,y) != img.pixel(x,y)) { + ++diffCount; + p.drawPoint(x,y); + } + } + } + QString diff(frame->image().toLocalFile() + ".diff.png"); + diffimg.save(diff); + qWarning().nospace() << " Diff (" << diffCount << " pixels differed) saved to: " << diff; + } imagefailure(); } } diff --git a/tools/qml/qml.pri b/tools/qml/qml.pri new file mode 100644 index 0000000..c48e919 --- /dev/null +++ b/tools/qml/qml.pri @@ -0,0 +1,29 @@ +QT += declarative script network sql +contains(QT_CONFIG, opengl) { + QT += opengl + DEFINES += GL_SUPPORTED +} + +INCLUDEPATH += $$PWD + +HEADERS += $$PWD/qmlruntime.h \ + $$PWD/proxysettings.h \ + $$PWD/qdeclarativetester.h \ + $$PWD/deviceorientation.h \ + $$PWD/qdeclarativefolderlistmodel.h +SOURCES += $$PWD/qmlruntime.cpp \ + $$PWD/proxysettings.cpp \ + $$PWD/qdeclarativetester.cpp \ + $$PWD/qdeclarativefolderlistmodel.cpp + +RESOURCES = $$PWD/qmlruntime.qrc +maemo5 { + SOURCES += $$PWD/deviceorientation_maemo.cpp +} else { + SOURCES += $$PWD/deviceorientation.cpp +} +FORMS = $$PWD/recopts.ui \ + $$PWD/proxysettings.ui + +include(../shared/deviceskin/deviceskin.pri) + diff --git a/tools/qml/qml.pro b/tools/qml/qml.pro index 1ed8b2c..869907f 100644 --- a/tools/qml/qml.pro +++ b/tools/qml/qml.pro @@ -1,40 +1,15 @@ TEMPLATE = app -CONFIG += qt \ - uic +CONFIG += qt uic DESTDIR = ../../bin -QT += declarative \ - script \ - network \ - sql -contains(QT_CONFIG, opengl) { - QT += opengl - DEFINES += GL_SUPPORTED -} +include(qml.pri) + +SOURCES += main.cpp -# Input -HEADERS += qmlruntime.h \ - proxysettings.h \ - qdeclarativetester.h \ - deviceorientation.h \ - qdeclarativefolderlistmodel.h -SOURCES += main.cpp \ - qmlruntime.cpp \ - proxysettings.cpp \ - qdeclarativetester.cpp \ - qdeclarativefolderlistmodel.cpp -RESOURCES = qmlruntime.qrc -maemo5 { - SOURCES += deviceorientation_maemo.cpp -} else { - SOURCES += deviceorientation.cpp -} -FORMS = recopts.ui \ - proxysettings.ui INCLUDEPATH += ../../include/QtDeclarative INCLUDEPATH += ../../src/declarative/util INCLUDEPATH += ../../src/declarative/graphicsitems -include(../shared/deviceskin/deviceskin.pri) + target.path = $$[QT_INSTALL_BINS] INSTALLS += target diff --git a/tools/qml/qmlruntime.cpp b/tools/qml/qmlruntime.cpp index df29294..53409c1 100644 --- a/tools/qml/qmlruntime.cpp +++ b/tools/qml/qmlruntime.cpp @@ -55,11 +55,6 @@ #include <QAbstractAnimation> #include "deviceskin.h" -#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 3)) -#include <private/qzipreader_p.h> -#define QDECLARATIVEVIEWER_ZIP_SUPPORT -#endif - #include <QSettings> #include <QXmlStreamReader> #include <QBuffer> @@ -470,6 +465,8 @@ QDeclarativeViewer::QDeclarativeViewer(QWidget *parent, Qt::WindowFlags flags) , portraitOrientation(0), landscapeOrientation(0) , m_scriptOptions(0), tester(0), useQmlFileBrowser(true) { + QDeclarativeViewer::registerTypes(); + devicemode = false; skin = 0; canvas = 0; @@ -553,6 +550,11 @@ QMenuBar *QDeclarativeViewer::menuBar() const return mb; } +QDeclarativeView *QDeclarativeViewer::view() const +{ + return canvas; +} + void QDeclarativeViewer::createMenu(QMenuBar *menu, QMenu *flatmenu) { QObject *parent = flatmenu ? (QObject*)flatmenu : (QObject*)menu; @@ -891,120 +893,19 @@ void QDeclarativeViewer::addPluginPath(const QString& plugin) void QDeclarativeViewer::reload() { - openQml(currentFileOrUrl); -} - -void QDeclarativeViewer::open(const QString& doc) -{ -#ifdef QDECLARATIVEVIEWER_ZIP_SUPPORT - if (doc.endsWith(".wgt",Qt::CaseInsensitive) - || doc.endsWith(".wgz",Qt::CaseInsensitive) - || doc.endsWith(".zip",Qt::CaseInsensitive)) - openWgt(doc); - else -#endif - openQml(doc); -} - -void QDeclarativeViewer::openWgt(const QString& doc) -{ -#ifdef QDECLARATIVEVIEWER_ZIP_SUPPORT - // XXX This functionality could be migrated to QDeclarativeView once refined - - QUrl url(doc); - if (url.isRelative()) - url = QUrl::fromLocalFile(doc); - delete canvas->rootObject(); - canvas->engine()->clearComponentCache(); - QNetworkAccessManager * nam = canvas->engine()->networkAccessManager(); - wgtreply = nam->get(QNetworkRequest(url)); - connect(wgtreply,SIGNAL(finished()),this,SLOT(unpackWgt())); -#endif -} - -#ifdef QDECLARATIVEVIEWER_ZIP_SUPPORT -static void removeRecursive(const QString& dirname) -{ - QDir dir(dirname); - QFileInfoList entries(dir.entryInfoList(QDir::Dirs|QDir::Files|QDir::NoDotAndDotDot)); - for (int i = 0; i < entries.count(); ++i) - if (entries[i].isDir()) - removeRecursive(entries[i].filePath()); - else - dir.remove(entries[i].fileName()); - QDir().rmdir(dirname); -} -#endif - -void QDeclarativeViewer::unpackWgt() -{ -#ifdef QDECLARATIVEVIEWER_ZIP_SUPPORT - QByteArray all = wgtreply->readAll(); - QBuffer buf(&all); - buf.open(QIODevice::ReadOnly); - QZipReader zip(&buf); - /* - for (int i=0; i<zip.count(); ++i) { - QZipReader::FileInfo info = zip.entryInfoAt(i); - qDebug() << "zip:" << info.filePath; - } - */ - wgtdir = QDir::tempPath()+QDir::separator()+QLatin1String("qml-wgt"); - removeRecursive(wgtdir); - QDir().mkpath(wgtdir); - zip.extractAll(wgtdir); - - QString rootfile; - - if (wgtreply->header(QNetworkRequest::ContentTypeHeader).toString() == "application/widget" || wgtreply->url().path().endsWith(".wgt",Qt::CaseInsensitive)) { - // W3C Draft http://www.w3.org/TR/2009/CR-widgets-20091201 - QFile configfile(wgtdir+QDir::separator()+"config.xml"); - if (configfile.open(QIODevice::ReadOnly)) { - QXmlStreamReader config(&configfile); - if (config.readNextStartElement() && config.name() == "widget") { - while (config.readNextStartElement()) { - if (config.name() == "content") { - rootfile = wgtdir + QDir::separator(); - rootfile += config.attributes().value(QLatin1String("src")); - } - // XXX process other config - - config.skipCurrentElement(); - } - } - } else { - qWarning("No config.xml found - non-standard WGT file"); - } - if (rootfile.isEmpty()) { - QString def = wgtdir+QDir::separator()+"index.qml"; - if (QFile::exists(def)) - rootfile = def; - } - } else { - // Just find index.qml, preferably at the root - for (int i=0; i<zip.count(); ++i) { - QZipReader::FileInfo info = zip.entryInfoAt(i); - if (info.filePath.compare(QLatin1String("index.qml"),Qt::CaseInsensitive)==0) - rootfile = wgtdir+QDir::separator()+info.filePath; - if (rootfile.isEmpty() && info.filePath.endsWith("/index.qml",Qt::CaseInsensitive)) - rootfile = wgtdir+QDir::separator()+info.filePath; - } - } - - openQml(rootfile); -#endif + open(currentFileOrUrl); } void QDeclarativeViewer::openFile() { QString cur = canvas->source().toLocalFile(); if (useQmlFileBrowser) { - openQml("qrc:/content/Browser.qml"); + open("qrc:/content/Browser.qml"); } else { QString fileName = QFileDialog::getOpenFileName(this, tr("Open QML file"), cur, tr("QML Files (*.qml)")); if (!fileName.isEmpty()) { QFileInfo fi(fileName); - openQml(fi.absoluteFilePath()); + open(fi.absoluteFilePath()); } } } @@ -1034,10 +935,10 @@ void QDeclarativeViewer::statusChanged() void QDeclarativeViewer::launch(const QString& file_or_url) { - QMetaObject::invokeMethod(this, "openQml", Qt::QueuedConnection, Q_ARG(QString, file_or_url)); + QMetaObject::invokeMethod(this, "open", Qt::QueuedConnection, Q_ARG(QString, file_or_url)); } -void QDeclarativeViewer::openQml(const QString& file_or_url) +bool QDeclarativeViewer::open(const QString& file_or_url) { currentFileOrUrl = file_or_url; @@ -1070,7 +971,7 @@ void QDeclarativeViewer::openQml(const QString& file_or_url) if (fi.exists()) { if (fi.suffix().toLower() != QLatin1String("qml")) { qWarning() << "qml cannot open non-QML file" << fileName; - return; + return false; } QDir dir(fi.path()+"/dummydata", "*.qml"); @@ -1101,7 +1002,7 @@ void QDeclarativeViewer::openQml(const QString& file_or_url) } } else { qWarning() << "qml cannot find file:" << fileName; - return; + return false; } } @@ -1112,9 +1013,7 @@ void QDeclarativeViewer::openQml(const QString& file_or_url) qWarning() << "Wall startup time:" << t.elapsed(); -#ifdef QTOPIA - show(); -#endif + return true; } void QDeclarativeViewer::startNetwork() @@ -1500,8 +1399,13 @@ void QDeclarativeViewer::setUseNativeFileBrowser(bool use) void QDeclarativeViewer::registerTypes() { - // registering only for exposing the DeviceOrientation::Orientation enum - qmlRegisterUncreatableType<DeviceOrientation>("Qt",4,6,"Orientation"); + static bool registered = false; + + if (!registered) { + // registering only for exposing the DeviceOrientation::Orientation enum + qmlRegisterUncreatableType<DeviceOrientation>("Qt",4,6,"Orientation"); + registered = true; + } } QT_END_NAMESPACE diff --git a/tools/qml/qmlruntime.h b/tools/qml/qmlruntime.h index 1ae771a..2089dda 100644 --- a/tools/qml/qmlruntime.h +++ b/tools/qml/qmlruntime.h @@ -105,11 +105,11 @@ public: QMenuBar *menuBar() const; + QDeclarativeView *view() const; + public slots: void sceneResized(QSize size); - void open(const QString&); - void openWgt(const QString&); - void openQml(const QString&); + bool open(const QString&); void openFile(); void reload(); void takeSnapShot(); @@ -142,7 +142,6 @@ private slots: void toggleOrientation(); void startNetwork(); void toggleFullScreen(); - void unpackWgt(); private: QString getVideoFileName(); |