diff options
author | J-P Nurmi <jpnurmi@theqtcompany.com> | 2015-09-30 17:47:36 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@theqtcompany.com> | 2015-10-01 09:03:42 +0000 |
commit | 3f2ac678971694fe6144a4e15197aff2ca38639b (patch) | |
tree | 06440cbf63932fb008f3aab29835b07d0310bada /examples/labs | |
parent | b948c83255239a6fe49fca58a98f90e796ce9047 (diff) |
Rename QtQuick.Controls 2.0 to Qt.labs.controls 1.0
Change-Id: I142622dd85e95ef70b11132e77ccf48701f2cabc
Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
Diffstat (limited to 'examples/labs')
25 files changed, 1164 insertions, 5 deletions
diff --git a/examples/labs/calendar/DateTimePicker.qml b/examples/labs/calendar/DateTimePicker.qml index e7b2c227..ab0b3085 100644 --- a/examples/labs/calendar/DateTimePicker.qml +++ b/examples/labs/calendar/DateTimePicker.qml @@ -40,7 +40,7 @@ import QtQuick 2.6 import Qt.labs.calendar 1.0 -import QtQuick.Controls 2.0 +import Qt.labs.controls 1.0 import Qt.labs.templates 1.0 as T Item { diff --git a/examples/labs/calendar/EventView.qml b/examples/labs/calendar/EventView.qml index 3991e5eb..e47e7486 100644 --- a/examples/labs/calendar/EventView.qml +++ b/examples/labs/calendar/EventView.qml @@ -39,7 +39,7 @@ ****************************************************************************/ import QtQuick 2.6 -import QtQuick.Controls 2.0 +import Qt.labs.controls 1.0 Rectangle { border.color: Theme.frameColor diff --git a/examples/labs/calendar/TumblerDelegate.qml b/examples/labs/calendar/TumblerDelegate.qml index fb360cd5..e7d3ee47 100644 --- a/examples/labs/calendar/TumblerDelegate.qml +++ b/examples/labs/calendar/TumblerDelegate.qml @@ -39,7 +39,7 @@ ****************************************************************************/ import QtQuick 2.6 -import QtQuick.Controls 2.0 +import Qt.labs.controls 1.0 import Qt.labs.templates 1.0 as T Text { diff --git a/examples/labs/calendar/main.qml b/examples/labs/calendar/main.qml index d543aeb5..490dc4d1 100644 --- a/examples/labs/calendar/main.qml +++ b/examples/labs/calendar/main.qml @@ -39,7 +39,7 @@ ****************************************************************************/ import QtQuick 2.6 -import QtQuick.Controls 2.0 +import Qt.labs.controls 1.0 import Qt.labs.calendar 1.0 import Qt.labs.templates 1.0 as T import QtQuick.Layouts 1.0 diff --git a/examples/labs/controls/controls.pro b/examples/labs/controls/controls.pro new file mode 100644 index 00000000..950309a6 --- /dev/null +++ b/examples/labs/controls/controls.pro @@ -0,0 +1,6 @@ +TEMPLATE = subdirs +SUBDIRS += \ + mirroring \ + theme \ + tabs \ + drawer diff --git a/examples/labs/controls/drawer/drawer.pro b/examples/labs/controls/drawer/drawer.pro new file mode 100644 index 00000000..02e40200 --- /dev/null +++ b/examples/labs/controls/drawer/drawer.pro @@ -0,0 +1,15 @@ +TEMPLATE = app +TARGET = drawer +QT += quick + +SOURCES += \ + main.cpp + +OTHER_FILES += \ + main.qml + +RESOURCES += \ + drawer.qrc + +target.path = $$[QT_INSTALL_EXAMPLES]/labs/controls/drawer +INSTALLS += target diff --git a/examples/labs/controls/drawer/drawer.qrc b/examples/labs/controls/drawer/drawer.qrc new file mode 100644 index 00000000..25cc5cbe --- /dev/null +++ b/examples/labs/controls/drawer/drawer.qrc @@ -0,0 +1,7 @@ +<RCC> + <qresource prefix="/"> + <file>main.qml</file> + <file>images/arrow.png</file> + <file>images/qt-logo.png</file> + </qresource> +</RCC> diff --git a/examples/labs/controls/drawer/images/arrow.png b/examples/labs/controls/drawer/images/arrow.png Binary files differnew file mode 100644 index 00000000..4981e0de --- /dev/null +++ b/examples/labs/controls/drawer/images/arrow.png diff --git a/examples/labs/controls/drawer/images/qt-logo.png b/examples/labs/controls/drawer/images/qt-logo.png Binary files differnew file mode 100644 index 00000000..cf350dad --- /dev/null +++ b/examples/labs/controls/drawer/images/qt-logo.png diff --git a/examples/labs/controls/drawer/main.cpp b/examples/labs/controls/drawer/main.cpp new file mode 100644 index 00000000..2abdc16d --- /dev/null +++ b/examples/labs/controls/drawer/main.cpp @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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$ +** +****************************************************************************/ + +#include <QGuiApplication> +#include <QQmlApplicationEngine> + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + QQmlApplicationEngine engine; + engine.load(QUrl("qrc:/main.qml")); + if (engine.rootObjects().isEmpty()) + return -1; + return app.exec(); +} diff --git a/examples/labs/controls/drawer/main.qml b/examples/labs/controls/drawer/main.qml new file mode 100644 index 00000000..5b30a098 --- /dev/null +++ b/examples/labs/controls/drawer/main.qml @@ -0,0 +1,157 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 2.6 +import Qt.labs.controls 1.0 + +ApplicationWindow { + id: window + width: 360 + height: 520 + visible: true + title: "Qt Labs Controls - Drawer Example" + + Rectangle { + id: content + anchors.fill: parent + anchors.margins: -1 + border.color: Theme.frameColor + + Image { + width: window.width / 2 + height: window.height / 2 + anchors.centerIn: parent + anchors.horizontalCenterOffset: window.width > window.height ? width / 2 : 0 + anchors.verticalCenterOffset: window.width < window.height ? -height / 4 : 0 + fillMode: Image.PreserveAspectFit + source: "qrc:/images/qt-logo.png" + } + + Image { + width: window.width / 2 + anchors.bottom: parent.bottom + anchors.bottomMargin: height / 2 + fillMode: Image.PreserveAspectFit + source: "qrc:/images/arrow.png" + } + + transform: Translate { + x: effect.current === uncover ? drawer.position * listview.width : + effect.current === push ? drawer.position * listview.width * 0.5 : 0 + } + + z: effect.current === uncover ? 2 : 0 + } + + Drawer { + id: drawer + anchors.fill: parent + + ListView { + id: listview + + width: window.width / 3 * 2 + height: window.height + + ExclusiveGroup { + id: effect + } + + model: VisualItemModel { + Label { + text: "Settings" + x: 6 + width: parent.width - 12 + lineHeight: 2.0 + color: Theme.accentColor + verticalAlignment: Text.AlignVCenter + } + Rectangle { width: parent.width; height: 1; color: Theme.frameColor } + Switch { + id: dim + text: "Dim" + checked: true + width: parent.width + layoutDirection: Qt.RightToLeft + enabled: effect.current != uncover + } + Rectangle { width: parent.width; height: 1; color: Theme.frameColor } + RadioButton { + id: overlay + text: "Overlay" + checked: true + width: parent.width + ExclusiveGroup.group: effect + layoutDirection: Qt.RightToLeft + } + RadioButton { + id: push + text: "Push" + width: parent.width + ExclusiveGroup.group: effect + layoutDirection: Qt.RightToLeft + } + RadioButton { + id: uncover + text: "Uncover" + width: parent.width + ExclusiveGroup.group: effect + layoutDirection: Qt.RightToLeft + } + Rectangle { width: parent.width; height: 1; color: Theme.frameColor } + } + Rectangle { + z: -1 + anchors.fill: parent + anchors.topMargin: -1 + anchors.bottomMargin: -1 + border.color: Theme.frameColor + } + + transform: Translate { + x: effect.current === uncover ? (1.0 - drawer.position) * listview.width : 0 + } + } + + background.visible: dim.checked + + onClicked: close() + } +} diff --git a/examples/labs/controls/mirroring/main.cpp b/examples/labs/controls/mirroring/main.cpp new file mode 100644 index 00000000..2abdc16d --- /dev/null +++ b/examples/labs/controls/mirroring/main.cpp @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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$ +** +****************************************************************************/ + +#include <QGuiApplication> +#include <QQmlApplicationEngine> + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + QQmlApplicationEngine engine; + engine.load(QUrl("qrc:/main.qml")); + if (engine.rootObjects().isEmpty()) + return -1; + return app.exec(); +} diff --git a/examples/labs/controls/mirroring/main.qml b/examples/labs/controls/mirroring/main.qml new file mode 100644 index 00000000..835304a8 --- /dev/null +++ b/examples/labs/controls/mirroring/main.qml @@ -0,0 +1,238 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 2.6 +import QtQuick.Layouts 1.0 +import Qt.labs.controls 1.0 +import Qt.labs.templates 1.0 as T + +ApplicationWindow { + id: window + width: 360 + height: 520 + visible: true + title: "Qt Labs Controls - Mirroring Example" + + ListView { + id: listview + anchors.fill: parent + + LayoutMirroring.enabled: headerItem.mirror + LayoutMirroring.childrenInherit: true + + headerPositioning: ListView.PullBackHeader + header: Rectangle { + property alias mirror: mirrorSwitch.checked + + z: 2 + width: parent.width + height: label.implicitHeight + 96 + + Label { + id: label + text: "Beyond the essentials." + color: Theme.accentColor + anchors.fill: parent + anchors.margins: 48 + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + wrapMode: Text.WordWrap + font.pointSize: 26 + } + + Switch { + id: mirrorSwitch + text: "Mirror" + anchors.right: parent.right + anchors.bottom: parent.bottom + layoutDirection: Qt.RightToLeft + LayoutMirroring.enabled: false + } + + Rectangle { + width: parent.width + height: 1 + anchors.bottom: parent.bottom + color: Theme.frameColor + } + } + + model: VisualItemModel { + + Item { width: 1; height: 24 } + + Flow { + id: flow + spacing: 12 + width: Math.min(window.width, window.height) - 24 + anchors.horizontalCenter: parent.horizontalCenter + + GroupBox { + title: "CheckBox" + readonly property real preferredWidth: (flow.width - 12) / 2 + width: window.width > window.height || contentWidth > preferredWidth ? flow.width : preferredWidth + ColumnLayout { + width: parent.width + CheckBox { + width: parent.width + text: "E-mail" + checked: true + } + CheckBox { + width: parent.width + text: "Calendar" + checked: true + } + CheckBox { + width: parent.width + text: "Contacts" + } + } + } + + GroupBox { + title: "RadioButton" + readonly property real preferredWidth: (flow.width - 12) / 2 + width: window.width > window.height || contentWidth > preferredWidth ? flow.width : preferredWidth + ExclusiveGroup { id: eg } + ColumnLayout { + width: parent.width + RadioButton { + width: parent.width + text: "Portrait" + ExclusiveGroup.group: eg + } + RadioButton { + width: parent.width + text: "Landscape" + ExclusiveGroup.group: eg + } + RadioButton { + width: parent.width + text: "Automatic" + checked: true + ExclusiveGroup.group: eg + } + } + } + + GroupBox { + title: "Button" + width: flow.width + Row { + width: parent.width + spacing: 6 + readonly property real availableWidth: (flow.width - 12) / 2 + readonly property real contentWidth: okButton.implicitWidth + cancelButton.implicitWidth + 12 + readonly property real buttonWidth: implicitWidth > availableWidth ? (width / 2 - spacing) : (width / 2 - 2 * spacing) / 2 + Button { + id: okButton + text: "Ok" + width: parent.buttonWidth + } + Button { + id: cancelButton + text: "Cancel" + width: parent.buttonWidth + } + } + } + + GroupBox { + title: "Switch" + width: flow.width + Column { + width: parent.width + Switch { + width: parent.width + text: "Wifi" + checked: true + } + Switch { + width: parent.width + text: "Bluetooth" + } + } + } + + GroupBox { + title: "ProgressBar" + width: flow.width + Column { + width: parent.width + spacing: 6 + ProgressBar { + width: parent.width + indeterminate: true + } + ProgressBar { + width: parent.width + value: slider.position + } + } + } + + GroupBox { + title: "Slider" + width: flow.width + Column { + width: parent.width + spacing: 6 + Slider { + id: slider + value: 0.4 + width: parent.width + } + Slider { + width: parent.width + snapMode: Slider.SnapAlways + stepSize: 0.2 + value: 0.8 + } + } + } + } + + Item { width: 1; height: 12 } + } + + T.ScrollIndicator.vertical: ScrollIndicator { anchors.right: parent.right } + } +} diff --git a/examples/labs/controls/mirroring/mirroring.pro b/examples/labs/controls/mirroring/mirroring.pro new file mode 100644 index 00000000..60b73f94 --- /dev/null +++ b/examples/labs/controls/mirroring/mirroring.pro @@ -0,0 +1,15 @@ +TEMPLATE = app +TARGET = mirroring +QT += quick + +SOURCES += \ + main.cpp + +OTHER_FILES += \ + main.qml + +RESOURCES += \ + mirroring.qrc + +target.path = $$[QT_INSTALL_EXAMPLES]/labs/controls/mirroring +INSTALLS += target diff --git a/examples/labs/controls/mirroring/mirroring.qrc b/examples/labs/controls/mirroring/mirroring.qrc new file mode 100644 index 00000000..5f6483ac --- /dev/null +++ b/examples/labs/controls/mirroring/mirroring.qrc @@ -0,0 +1,5 @@ +<RCC> + <qresource prefix="/"> + <file>main.qml</file> + </qresource> +</RCC> diff --git a/examples/labs/controls/tabs/images/qt-logo.png b/examples/labs/controls/tabs/images/qt-logo.png Binary files differnew file mode 100644 index 00000000..cf350dad --- /dev/null +++ b/examples/labs/controls/tabs/images/qt-logo.png diff --git a/examples/labs/controls/tabs/main.cpp b/examples/labs/controls/tabs/main.cpp new file mode 100644 index 00000000..2abdc16d --- /dev/null +++ b/examples/labs/controls/tabs/main.cpp @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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$ +** +****************************************************************************/ + +#include <QGuiApplication> +#include <QQmlApplicationEngine> + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + QQmlApplicationEngine engine; + engine.load(QUrl("qrc:/main.qml")); + if (engine.rootObjects().isEmpty()) + return -1; + return app.exec(); +} diff --git a/examples/labs/controls/tabs/main.qml b/examples/labs/controls/tabs/main.qml new file mode 100644 index 00000000..50fcde16 --- /dev/null +++ b/examples/labs/controls/tabs/main.qml @@ -0,0 +1,291 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 2.6 +import QtQuick.Layouts 1.0 +import Qt.labs.controls 1.0 +import Qt.labs.templates 1.0 as T +import QtQuick.XmlListModel 2.0 + +ApplicationWindow { + id: window + width: 360 + height: 520 + visible: true + title: "Qt Labs Controls - Tabs Example" + + header: TabBar { + id: bar + currentIndex: view.currentIndex + TabButton { + text: "Home" + } + TabButton { + text: "Discover" + } + TabButton { + text: "Activity" + } + } + + SwipeView { + id: view + + spacing: 1 + anchors.fill: parent + currentIndex: bar.currentIndex + background: Rectangle { color: Theme.frameColor } + + Rectangle { + Image { + id: logo + width: window.width / 2 + height: window.height / 2 + anchors.centerIn: parent + fillMode: Image.PreserveAspectFit + source: "qrc:/images/qt-logo.png" + } + + Label { + text: "Things just got better" + color: Theme.accentColor + anchors.margins: 40 + anchors.top: logo.bottom + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + wrapMode: Text.WordWrap + font.pointSize: 26 + } + } + + Rectangle { + ListView { + anchors.fill: parent + anchors.topMargin: -1 + model: XmlListModel { + id: feedModel + query: "/rss/channel/item" + source: "http://blog.qt.io/feed/" + namespaceDeclarations: "declare namespace dc='http://purl.org/dc/elements/1.1/';" + XmlRole { name: "title"; query: "title/string()" } + XmlRole { name: "link"; query: "link/string()" } + XmlRole { name: "pubDate"; query: "pubDate/string()" } + XmlRole { name: "creator"; query: "dc:creator/string()" } + XmlRole { name: "description"; query: "description/string()" } + } + + delegate: Item { + width: parent.width + height: feedItem.height + Column { + id: feedItem + width: parent.width + spacing: 6 + Rectangle { + width: parent.width + height: 1 + color: Theme.frameColor + visible: index == 0 + } + Item { width: 1; height: 6 } + Label { + text: model.title + x: 6 + width: parent.width - 12 + elide: Text.ElideRight + color: Theme.accentColor + font.pointSize: 20 + lineHeight: 0.75 + } + Label { + text: model.description + textFormat: Text.StyledText + x: 6 + width: parent.width - 12 + wrapMode: Text.WordWrap + } + RowLayout { + x: 6 + width: parent.width - 12 + spacing: 6 + Label { + id: discoverCreator + text: model.creator + height: parent.height + verticalAlignment: Text.AlignVCenter + color: Theme.focusColor + font.pointSize: 8 + } + Label { + text: model.pubDate + height: parent.height + elide: Text.ElideRight + verticalAlignment: Text.AlignVCenter + color: Theme.disabledColor + font.pointSize: 8 + Layout.preferredWidth: parent.width - discoverCreator.width - discoverMore.width - 2 * parent.spacing + visible: Layout.preferredWidth > 0 + } + Button { + id: discoverMore + text: "Read more..." + onClicked: Qt.openUrlExternally(model.link) + } + } + Rectangle { + width: parent.width + height: 1 + color: Theme.frameColor + } + } + } + + T.ScrollIndicator.vertical: ScrollIndicator { } + } + + BusyIndicator { + anchors.centerIn: parent + running: feedModel.status === XmlListModel.Loading + } + } + + Rectangle { + ListView { + anchors.fill: parent + anchors.topMargin: -1 + model: XmlListModel { + id: commentModel + query: "/rss/channel/item" + source: "http://blog.qt.io/comments/feed/" + namespaceDeclarations: "declare namespace dc='http://purl.org/dc/elements/1.1/';" + XmlRole { name: "title"; query: "title/string()" } + XmlRole { name: "link"; query: "link/string()" } + XmlRole { name: "pubDate"; query: "pubDate/string()" } + XmlRole { name: "creator"; query: "dc:creator/string()" } + XmlRole { name: "description"; query: "description/string()" } + } + + delegate: Rectangle { + width: parent.width + height: commentItem.height + Column { + id: commentItem + width: parent.width + spacing: 6 + Rectangle { + width: parent.width + height: 1 + color: Theme.frameColor + visible: index == 0 + } + Item { width: 1; height: 6 } + Label { + text: model.title + x: 6 + width: parent.width - 12 + elide: Text.ElideRight + color: Theme.accentColor + font.pointSize: 14 + lineHeight: 0.75 + } + Item { width: 1; height: 6 } + Label { + text: model.description + textFormat: Text.StyledText + x: 6 + width: parent.width - 12 + wrapMode: Text.WordWrap + } + RowLayout { + x: 6 + width: parent.width - 12 + spacing: 6 + Label { + id: activityCreator + text: model.creator + height: parent.height + verticalAlignment: Text.AlignVCenter + color: Theme.focusColor + font.pointSize: 8 + } + Label { + text: model.pubDate + height: parent.height + elide: Text.ElideRight + verticalAlignment: Text.AlignVCenter + color: Theme.disabledColor + font.pointSize: 8 + Layout.preferredWidth: parent.width - activityCreator.width - activityMore.width - 2 * parent.spacing + visible: Layout.preferredWidth > 0 + } + Button { + id: activityMore + text: "Read more..." + onClicked: Qt.openUrlExternally(model.link) + } + } + Rectangle { + width: parent.width + height: 1 + color: Theme.frameColor + } + } + } + + T.ScrollIndicator.vertical: ScrollIndicator { } + } + + BusyIndicator { + anchors.centerIn: parent + running: feedModel.status === XmlListModel.Loading + } + } + } + + PageIndicator { + count: view.count + currentIndex: view.currentIndex + anchors.bottom: parent.bottom + anchors.horizontalCenter: parent.horizontalCenter + } +} diff --git a/examples/labs/controls/tabs/tabs.pro b/examples/labs/controls/tabs/tabs.pro new file mode 100644 index 00000000..f9b85c1a --- /dev/null +++ b/examples/labs/controls/tabs/tabs.pro @@ -0,0 +1,15 @@ +TEMPLATE = app +TARGET = tabs +QT += quick + +SOURCES += \ + main.cpp + +OTHER_FILES += \ + main.qml + +RESOURCES += \ + tabs.qrc + +target.path = $$[QT_INSTALL_EXAMPLES]/labs/controls/tabs +INSTALLS += target diff --git a/examples/labs/controls/tabs/tabs.qrc b/examples/labs/controls/tabs/tabs.qrc new file mode 100644 index 00000000..b48259b1 --- /dev/null +++ b/examples/labs/controls/tabs/tabs.qrc @@ -0,0 +1,6 @@ +<RCC> + <qresource prefix="/"> + <file>main.qml</file> + <file>images/qt-logo.png</file> + </qresource> +</RCC> diff --git a/examples/labs/controls/theme/main.cpp b/examples/labs/controls/theme/main.cpp new file mode 100644 index 00000000..2abdc16d --- /dev/null +++ b/examples/labs/controls/theme/main.cpp @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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$ +** +****************************************************************************/ + +#include <QGuiApplication> +#include <QQmlApplicationEngine> + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + QQmlApplicationEngine engine; + engine.load(QUrl("qrc:/main.qml")); + if (engine.rootObjects().isEmpty()) + return -1; + return app.exec(); +} diff --git a/examples/labs/controls/theme/main.qml b/examples/labs/controls/theme/main.qml new file mode 100644 index 00000000..d3a3f7a0 --- /dev/null +++ b/examples/labs/controls/theme/main.qml @@ -0,0 +1,175 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 2.6 +import Qt.labs.controls 1.0 +import Qt.labs.templates 1.0 as T + +ApplicationWindow { + id: window + width: 360 + height: 520 + visible: true + title: "Qt Labs Controls - Theme Example" + + header: ToolBar { + ToolButton { + label: Text { + // \u25C0 (black left-pointing triangle is) missing in some fonts + // => use a rotated \u25B2 (black up-pointing triangle) instead + text: "\u25B2" + rotation: -90 + color: enabled ? Theme.accentColor : Theme.frameColor + anchors.centerIn: parent + } + enabled: stackview.depth > 1 + onClicked: stackview.pop() + } + } + + StackView { + id: stackview + anchors.fill: parent + initialItem: pageComponent + } + + Component { + id: pageComponent + Rectangle { + id: page + Theme.accentColor: Qt.hsla(colorSlider.position, 0.5, 0.5, 1.0) + Theme.backgroundColor: darkButton.checked ? "#444" : "#fff" + Theme.frameColor: darkButton.checked ? "#666" : "#ccc" + Theme.textColor: darkButton.checked ? "#eee" : "#111" + Theme.pressColor: darkButton.checked ? "#33ffffff" : "#33333333" + Theme.baseColor: darkButton.checked ? "#444" : "#eee" + color: Theme.backgroundColor + Flickable { + anchors.fill: parent + contentHeight: column.height + 48 + + Column { + id: column + + x: (window.width - width) / 2 + y: 24 + width: window.width / 2 + spacing: 12 + + Label { + text: "Code less. Create more." + color: Theme.accentColor + width: parent.width + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + wrapMode: Text.WordWrap + font.pointSize: 26 + } + + Item { width: 1; height: 48 } + + Rectangle { + width: parent.width + height: 1 + color: Theme.frameColor + } + + Column { + spacing: 6 + width: parent.width + Label { + text: "Accent color" + color: Theme.textColor + } + Slider { + id: colorSlider + width: parent.width + value: 0.275 + } + } + + Rectangle { + width: parent.width + height: 1 + color: Theme.frameColor + } + + ExclusiveGroup { + id: themeGroup + } + + Column { + width: parent.width + spacing: 6 + RadioButton { + id: lightButton + text: "Light" + width: parent.width + checked: true + layoutDirection: Qt.RightToLeft + ExclusiveGroup.group: themeGroup + } + RadioButton { + id: darkButton + text: "Dark" + width: parent.width + layoutDirection: Qt.RightToLeft + ExclusiveGroup.group: themeGroup + } + } + + Rectangle { + width: parent.width + height: 1 + color: Theme.frameColor + } + + Button { + text: "Push" + anchors.right: parent.right + onClicked: stackview.push(pageComponent) + } + } + + T.ScrollIndicator.vertical: ScrollIndicator { } + } + } + } +} diff --git a/examples/labs/controls/theme/theme.pro b/examples/labs/controls/theme/theme.pro new file mode 100644 index 00000000..7672a2cb --- /dev/null +++ b/examples/labs/controls/theme/theme.pro @@ -0,0 +1,15 @@ +TEMPLATE = app +TARGET = theme +QT += quick + +SOURCES += \ + main.cpp + +OTHER_FILES += \ + main.qml + +RESOURCES += \ + theme.qrc + +target.path = $$[QT_INSTALL_EXAMPLES]/labs/controls/theme +INSTALLS += target diff --git a/examples/labs/controls/theme/theme.qrc b/examples/labs/controls/theme/theme.qrc new file mode 100644 index 00000000..5f6483ac --- /dev/null +++ b/examples/labs/controls/theme/theme.qrc @@ -0,0 +1,5 @@ +<RCC> + <qresource prefix="/"> + <file>main.qml</file> + </qresource> +</RCC> diff --git a/examples/labs/labs.pro b/examples/labs/labs.pro index 88683726..80f94e86 100644 --- a/examples/labs/labs.pro +++ b/examples/labs/labs.pro @@ -1,3 +1,4 @@ TEMPLATE = subdirs SUBDIRS += \ - calendar + calendar \ + controls |