summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/qml/qml.pri29
-rw-r--r--tools/qml/qml.pro35
-rw-r--r--tools/qml/qmlruntime.cpp114
-rw-r--r--tools/qml/qmlruntime.h2
4 files changed, 44 insertions, 136 deletions
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..0a0ad9b 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;
@@ -896,103 +893,7 @@ void QDeclarativeViewer::reload()
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
+ openQml(doc);
}
void QDeclarativeViewer::openFile()
@@ -1500,8 +1401,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..8792d0c 100644
--- a/tools/qml/qmlruntime.h
+++ b/tools/qml/qmlruntime.h
@@ -108,7 +108,6 @@ public:
public slots:
void sceneResized(QSize size);
void open(const QString&);
- void openWgt(const QString&);
void openQml(const QString&);
void openFile();
void reload();
@@ -142,7 +141,6 @@ private slots:
void toggleOrientation();
void startNetwork();
void toggleFullScreen();
- void unpackWgt();
private:
QString getVideoFileName();