summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/qmlviewer/qmlviewer.cpp18
-rw-r--r--tools/qmlviewer/qmlviewer.h3
2 files changed, 15 insertions, 6 deletions
diff --git a/tools/qmlviewer/qmlviewer.cpp b/tools/qmlviewer/qmlviewer.cpp
index b115abb..3157377 100644
--- a/tools/qmlviewer/qmlviewer.cpp
+++ b/tools/qmlviewer/qmlviewer.cpp
@@ -606,7 +606,7 @@ void QmlViewer::addLibraryPath(const QString& lib)
void QmlViewer::reload()
{
- openQml(canvas->url());
+ openQml(currentFileOrUrl);
}
void QmlViewer::open()
@@ -615,7 +615,7 @@ void QmlViewer::open()
QString fileName = QFileDialog::getOpenFileName(this, tr("Open QML file"), cur, tr("QML Files (*.qml)"));
if (!fileName.isEmpty()) {
QFileInfo fi(fileName);
- openQml(QUrl::fromLocalFile(fi.absoluteFilePath()));
+ openQml(fi.absoluteFilePath());
}
}
@@ -624,16 +624,24 @@ void QmlViewer::executeErrors()
if (tester) tester->executefailure();
}
-void QmlViewer::openQml(const QUrl& url)
+void QmlViewer::openQml(const QString& file_or_url)
{
- QString fileName = url.toLocalFile();
- setWindowTitle(tr("%1 - Qt Declarative UI Viewer").arg(fileName.isEmpty() ? url.toString() : fileName));
+ currentFileOrUrl = file_or_url;
+
+ QUrl url;
+ QFileInfo fi(file_or_url);
+ if (fi.exists())
+ url = QUrl::fromLocalFile(fi.absoluteFilePath());
+ else
+ url = QUrl(file_or_url);
+ setWindowTitle(tr("%1 - Qt Declarative UI Viewer").arg(file_or_url));
if (!m_script.isEmpty())
tester = new QFxTester(m_script, m_scriptOptions, canvas);
canvas->reset();
+ QString fileName = url.toLocalFile();
if (!fileName.isEmpty()) {
QFileInfo fi(fileName);
if (fi.exists()) {
diff --git a/tools/qmlviewer/qmlviewer.h b/tools/qmlviewer/qmlviewer.h
index 50495db..e1f53f9 100644
--- a/tools/qmlviewer/qmlviewer.h
+++ b/tools/qmlviewer/qmlviewer.h
@@ -63,7 +63,7 @@ public:
public slots:
void sceneResized(QSize size);
- void openQml(const QUrl&);
+ void openQml(const QString&);
void open();
void reload();
void takeSnapShot();
@@ -97,6 +97,7 @@ private:
PreviewDeviceSkin *skin;
QSize skinscreensize;
QmlView *canvas;
+ QString currentFileOrUrl;
QmlTimer recordTimer;
QString frame_fmt;
QImage frame;