aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/qml/conf/content/resizeItemToWindow.qml70
-rw-r--r--tools/qml/conf/content/resizeWindowToItem.qml (renamed from tools/qml/conf/qtquick.qml)6
-rw-r--r--tools/qml/conf/default.qml (renamed from tools/qml/conf/configuration.qml)4
-rw-r--r--tools/qml/conf/resizeToItem.qml57
-rw-r--r--tools/qml/main.cpp50
-rw-r--r--tools/qml/qml.qrc6
6 files changed, 173 insertions, 20 deletions
diff --git a/tools/qml/conf/content/resizeItemToWindow.qml b/tools/qml/conf/content/resizeItemToWindow.qml
new file mode 100644
index 0000000000..a645cf8ea9
--- /dev/null
+++ b/tools/qml/conf/content/resizeItemToWindow.qml
@@ -0,0 +1,70 @@
+/*****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+*****************************************************************************/
+import QtQuick.Window 2.0
+import QtQuick 2.0
+
+Window {
+ property Item containedObject: null
+ property bool __resizeGuard: false
+ onContainedObjectChanged: {
+ if (containedObject == undefined || containedObject == null) {
+ visible = false;
+ return;
+ }
+ __resizeGuard = true
+ width = containedObject.width;
+ height = containedObject.height;
+ containedObject.parent = contentItem;
+ visible = true;
+ __resizeGuard = false
+ }
+ onWidthChanged: if (!__resizeGuard && containedObject) containedObject.width = width
+ onHeightChanged: if (!__resizeGuard && containedObject) containedObject.height = height
+}
diff --git a/tools/qml/conf/qtquick.qml b/tools/qml/conf/content/resizeWindowToItem.qml
index ef7a46eb2f..cd03e5065a 100644
--- a/tools/qml/conf/qtquick.qml
+++ b/tools/qml/conf/content/resizeWindowToItem.qml
@@ -1,6 +1,6 @@
/*****************************************************************************
**
-** Copyright (C) 2017 The Qt Company Ltd.
+** Copyright (C) 2019 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtQuick module of the Qt Toolkit.
@@ -57,8 +57,8 @@ Window {
visible = false;
return;
}
- width = containedObject.width;
- height = containedObject.height;
+ width = Qt.binding(function() { return containedObject.width });
+ height = Qt.binding(function() { return containedObject.height });
containedObject.parent = contentItem;
visible = true;
}
diff --git a/tools/qml/conf/configuration.qml b/tools/qml/conf/default.qml
index e12fa39a3e..be44ee79b4 100644
--- a/tools/qml/conf/configuration.qml
+++ b/tools/qml/conf/default.qml
@@ -1,6 +1,6 @@
/*****************************************************************************
**
-** Copyright (C) 2017 The Qt Company Ltd.
+** Copyright (C) 2019 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtQuick module of the Qt Toolkit.
@@ -52,6 +52,6 @@ import QmlRuntime.Config 1.0
Configuration {
PartialScene {
itemType: "QQuickItem"
- container: "qtquick.qml"
+ container: "content/resizeItemToWindow.qml"
}
}
diff --git a/tools/qml/conf/resizeToItem.qml b/tools/qml/conf/resizeToItem.qml
new file mode 100644
index 0000000000..480995a6b0
--- /dev/null
+++ b/tools/qml/conf/resizeToItem.qml
@@ -0,0 +1,57 @@
+/*****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+*****************************************************************************/
+import QmlRuntime.Config 1.0
+
+Configuration {
+ PartialScene {
+ itemType: "QQuickItem"
+ container: "content/resizeWindowToItem.qml"
+ }
+}
diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp
index 1d520b8fde..1e367d91bf 100644
--- a/tools/qml/main.cpp
+++ b/tools/qml/main.cpp
@@ -95,12 +95,13 @@ static QQmlApplicationEngine *qae = nullptr;
static int exitTimerId = -1;
#endif
static const QString iconResourcePath(QStringLiteral(":/qt-project.org/QmlRuntime/resources/qml-64.png"));
+static const QString confResourcePath(QStringLiteral(":/qt-project.org/QmlRuntime/conf/"));
static bool verboseMode = false;
static bool quietMode = false;
static void loadConf(const QString &override, bool quiet) // Terminates app on failure
{
- const QString defaultFileName = QLatin1String("configuration.qml");
+ const QString defaultFileName = QLatin1String("default.qml");
QUrl settingsUrl;
bool builtIn = false; //just for keeping track of the warning
if (override.isEmpty()) {
@@ -110,29 +111,38 @@ static void loadConf(const QString &override, bool quiet) // Terminates app on f
settingsUrl = QUrl::fromLocalFile(fi.absoluteFilePath());
} else {
// ### If different built-in configs are needed per-platform, just apply QFileSelector to the qrc conf.qml path
- settingsUrl = QUrl(QLatin1String("qrc:///qt-project.org/QmlRuntime/conf/") + defaultFileName);
+ fi.setFile(confResourcePath + defaultFileName);
+ settingsUrl = QUrl::fromLocalFile(fi.absoluteFilePath());
builtIn = true;
}
} else {
QFileInfo fi;
- fi.setFile(override);
- if (!fi.exists()) {
- printf("qml: Couldn't find required configuration file: %s\n",
- qPrintable(QDir::toNativeSeparators(fi.absoluteFilePath())));
- exit(1);
+ fi.setFile(confResourcePath + override + QLatin1String(".qml"));
+ if (fi.exists()) {
+ settingsUrl = QUrl::fromLocalFile(fi.absoluteFilePath());
+ builtIn = true;
+ } else {
+ fi.setFile(override);
+ if (!fi.exists()) {
+ printf("qml: Couldn't find required configuration file: %s\n",
+ qPrintable(QDir::toNativeSeparators(fi.absoluteFilePath())));
+ exit(1);
+ }
+ settingsUrl = QUrl::fromLocalFile(fi.absoluteFilePath());
}
- settingsUrl = QUrl::fromLocalFile(fi.absoluteFilePath());
}
if (!quiet) {
printf("qml: %s\n", QLibraryInfo::build());
- if (builtIn)
- printf("qml: Using built-in configuration.\n");
- else
- printf("qml: Using configuration file: %s\n",
+ if (builtIn) {
+ printf("qml: Using built-in configuration: %s\n",
+ qPrintable(override.isEmpty() ? defaultFileName : override));
+ } else {
+ printf("qml: Using configuration: %s\n",
qPrintable(settingsUrl.isLocalFile()
? QDir::toNativeSeparators(settingsUrl.toLocalFile())
: settingsUrl.toString()));
+ }
}
// TODO: When we have better engine control, ban QtQuick* imports on this engine
@@ -153,6 +163,15 @@ void noFilesGiven()
exit(1);
}
+static void listConfFiles()
+{
+ QDir confResourceDir(confResourcePath);
+ printf("%s\n", qPrintable(QCoreApplication::translate("main", "Built-in configurations:")));
+ for (const QFileInfo &fi : confResourceDir.entryInfoList(QDir::Files))
+ printf(" %s\n", qPrintable(fi.baseName()));
+ exit(0);
+}
+
#ifdef QT_GUI_LIB
// Loads qml after receiving a QFileOpenEvent
@@ -435,8 +454,11 @@ int main(int argc, char *argv[])
QCoreApplication::translate("main", "Load the given file as a QML file."), QStringLiteral("file"));
parser.addOption(qmlFileOption);
QCommandLineOption configOption(QStringList() << QStringLiteral("c") << QStringLiteral("config"),
- QCoreApplication::translate("main", "Load the given file as the configuration file."), QStringLiteral("file"));
+ QCoreApplication::translate("main", "Load the given built-in configuration or configuration file."), QStringLiteral("file"));
parser.addOption(configOption);
+ QCommandLineOption listConfOption(QStringList() << QStringLiteral("list-conf"),
+ QCoreApplication::translate("main", "List the built-in configurations."));
+ parser.addOption(listConfOption);
QCommandLineOption translationOption(QStringLiteral("translation"),
QCoreApplication::translate("main", "Load the given file as the translations file."), QStringLiteral("file"));
parser.addOption(translationOption);
@@ -486,6 +508,8 @@ int main(int argc, char *argv[])
parser.showVersion();
if (parser.isSet(helpOption))
parser.showHelp();
+ if (parser.isSet(listConfOption))
+ listConfFiles();
if (applicationType == QmlApplicationTypeUnknown) {
#ifdef QT_WIDGETS_LIB
qWarning() << QCoreApplication::translate("main", "--apptype must be followed by one of the following: core gui widget\n");
diff --git a/tools/qml/qml.qrc b/tools/qml/qml.qrc
index e4be1793d4..69aa4a5756 100644
--- a/tools/qml/qml.qrc
+++ b/tools/qml/qml.qrc
@@ -1,7 +1,9 @@
<RCC>
<qresource prefix="qt-project.org/QmlRuntime">
- <file>conf/configuration.qml</file>
- <file>conf/qtquick.qml</file>
+ <file>conf/default.qml</file>
+ <file>conf/resizeToItem.qml</file>
+ <file>conf/content/resizeItemToWindow.qml</file>
+ <file>conf/content/resizeWindowToItem.qml</file>
<file>resources/qml-64.png</file>
</qresource>
</RCC>