diff options
author | Martin Jones <martin.jones@nokia.com> | 2009-12-06 23:50:38 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2009-12-06 23:50:38 (GMT) |
commit | 1f002c8af75f0c66ab2c8581421c29320241a7aa (patch) | |
tree | df18354ff70aaea5b853557666e99ed4a9386b5c /tools/qmlviewer/qmlviewer.cpp | |
parent | 9c5fa063666c31c2dd3a15d40038f73788a14dda (diff) | |
download | Qt-1f002c8af75f0c66ab2c8581421c29320241a7aa.zip Qt-1f002c8af75f0c66ab2c8581421c29320241a7aa.tar.gz Qt-1f002c8af75f0c66ab2c8581421c29320241a7aa.tar.bz2 |
Add QML based file browser to qmlviewer.
Diffstat (limited to 'tools/qmlviewer/qmlviewer.cpp')
-rw-r--r-- | tools/qmlviewer/qmlviewer.cpp | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/tools/qmlviewer/qmlviewer.cpp b/tools/qmlviewer/qmlviewer.cpp index 98a9702..8d8d66a 100644 --- a/tools/qmlviewer/qmlviewer.cpp +++ b/tools/qmlviewer/qmlviewer.cpp @@ -329,7 +329,7 @@ QString QmlViewer::getVideoFileName() QmlViewer::QmlViewer(QWidget *parent, Qt::WindowFlags flags) : QWidget(parent, flags), frame_stream(0), scaleSkin(true), mb(0) , portraitOrientation(0), landscapeOrientation(0) - , m_scriptOptions(0), tester(0) + , m_scriptOptions(0), tester(0), useQmlFileBrowser(true) { devicemode = false; skin = 0; @@ -714,10 +714,19 @@ void QmlViewer::reload() void QmlViewer::open() { QString cur = canvas->url().toLocalFile(); - QString fileName = QFileDialog::getOpenFileName(this, tr("Open QML file"), cur, tr("QML Files (*.qml)")); - if (!fileName.isEmpty()) { - QFileInfo fi(fileName); - openQml(fi.absoluteFilePath()); + if (useQmlFileBrowser) { +#ifdef Q_OS_SYMBIAN + canvas->rootContext()->setContextProperty("initialFolder", "E:\\"); // Documents on your S60 phone +#else + canvas->rootContext()->setContextProperty("initialFolder", QDir::currentPath()); +#endif + openQml("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()); + } } } @@ -726,6 +735,11 @@ void QmlViewer::executeErrors() if (tester) tester->executefailure(); } +void QmlViewer::launch(const QString& file_or_url) +{ + QMetaObject::invokeMethod(this, "openQml", Qt::QueuedConnection, Q_ARG(QString, file_or_url)); +} + void QmlViewer::openQml(const QString& file_or_url) { currentFileOrUrl = file_or_url; @@ -742,6 +756,8 @@ void QmlViewer::openQml(const QString& file_or_url) tester = new QmlGraphicsTester(m_script, m_scriptOptions, canvas); canvas->reset(); + QmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("qmlViewer", this); QString fileName = url.toLocalFile(); if (!fileName.isEmpty()) { @@ -752,7 +768,6 @@ void QmlViewer::openQml(const QString& file_or_url) return; } - QmlContext *ctxt = canvas->rootContext(); QDir dir(fi.path()+"/dummydata", "*.qml"); QStringList list = dir.entryList(); for (int i = 0; i < list.size(); ++i) { |