diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2019-04-24 21:05:32 +0200 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2019-04-25 08:40:45 +0000 |
commit | 8d9a7e47aaa03efe2d3eddfc9ac37d02a99affc7 (patch) | |
tree | 721e4823dcbee6d07bdc8d0ce7b3e80e51353086 /tools/qml/conf | |
parent | 6a03d300be399a09de6cc02a6e3731b51ed5c6da (diff) |
qml runtime tool: support alternate conf; add resizeToItem conf
The qmlscene --resize-to-root feature has always been missing from
the qml runtime tool; however it was already possible to add it by
writing a custom configuration file. Now we support loading different
configurations from resources as well as from the filesystem, and
the first new configuration being added here is resizeToItem.qml
which provides behavior equivalent to qmlscene --resize-to-root.
When the argument given to --config ends with .qml, by convention
it's to be loaded from the filesystem; whereas configurations from
resources are specified without the .qml extension (to make the
command line shorter).
[ChangeLog][QtQml][qml] The QML Runtime tool now has default behavior
matching qmlscene when the root QML object is an Item: it will be
wrapped in a Window which will resize the Item when the Window is
resized. But you can alternatively use the --config resizeToItem
option, resulting in the same behavior as qmlscene --resizeToRoot:
resizing the root Item programmatically causes the wrapping Window to
be resized. Behavior can still be customized in other ways using the
--config option with an external QML configuration file.
Task-number: QTBUG-53557
Change-Id: Icdcbbd12258105c33b64634049d735e022dfbd06
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tools/qml/conf')
-rw-r--r-- | tools/qml/conf/content/resizeItemToWindow.qml | 70 | ||||
-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.qml | 57 |
4 files changed, 132 insertions, 5 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" + } +} |