diff options
Diffstat (limited to 'examples/quick/extras/gallery')
36 files changed, 2344 insertions, 0 deletions
diff --git a/examples/quick/extras/gallery/fonts/LICENSE.txt b/examples/quick/extras/gallery/fonts/LICENSE.txt new file mode 100644 index 00000000..d6456956 --- /dev/null +++ b/examples/quick/extras/gallery/fonts/LICENSE.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/examples/quick/extras/gallery/fonts/OpenSans-Regular.ttf b/examples/quick/extras/gallery/fonts/OpenSans-Regular.ttf Binary files differnew file mode 100644 index 00000000..db433349 --- /dev/null +++ b/examples/quick/extras/gallery/fonts/OpenSans-Regular.ttf diff --git a/examples/quick/extras/gallery/gallery.pro b/examples/quick/extras/gallery/gallery.pro new file mode 100644 index 00000000..3c50a7c2 --- /dev/null +++ b/examples/quick/extras/gallery/gallery.pro @@ -0,0 +1,31 @@ +TEMPLATE = app +TARGET = gallery +INCLUDEPATH += . +QT += quick + +SOURCES += \ + main.cpp + +RESOURCES += \ + gallery.qrc + +OTHER_FILES += \ + qml/BlackButtonBackground.qml \ + qml/BlackButtonStyle.qml \ + qml/CircularGaugeDarkStyle.qml \ + qml/CircularGaugeDefaultStyle.qml \ + qml/CircularGaugeLightStyle.qml \ + qml/CircularGaugeView.qml \ + qml/ControlLabel.qml \ + qml/ControlView.qml \ + qml/ControlViewToolBar.qml \ + qml/CustomizerSwitch.qml \ + qml/CustomizerLabel.qml \ + qml/CustomizerSlider.qml \ + qml/FlickableMoreIndicator.qml \ + qml/gallery.qml \ + qml/PieMenuControlView.qml \ + qml/PieMenuDefaultStyle.qml \ + qml/PieMenuDarkStyle.qml \ + qml/StylePicker.qml \ + gallery.qrc diff --git a/examples/quick/extras/gallery/gallery.qrc b/examples/quick/extras/gallery/gallery.qrc new file mode 100644 index 00000000..97beb6b1 --- /dev/null +++ b/examples/quick/extras/gallery/gallery.qrc @@ -0,0 +1,36 @@ +<RCC> + <qresource prefix="/"> + <file>fonts/OpenSans-Regular.ttf</file> + <file>images/background-light.png</file> + <file>images/background.png</file> + <file>images/center-light.png</file> + <file>images/center.png</file> + <file>images/icon-go.png</file> + <file>images/icon-settings.png</file> + <file>images/info.png</file> + <file>images/needle-light.png</file> + <file>images/needle.png</file> + <file>images/qt-logo.png</file> + <file>images/zoom_in.png</file> + <file>images/zoom_out.png</file> + <file>qml/BlackButtonBackground.qml</file> + <file>qml/BlackButtonStyle.qml</file> + <file>qml/CircularGaugeDarkStyle.qml</file> + <file>qml/CircularGaugeDefaultStyle.qml</file> + <file>qml/CircularGaugeLightStyle.qml</file> + <file>qml/CircularGaugeView.qml</file> + <file>qml/ControlView.qml</file> + <file>qml/ControlViewToolbar.qml</file> + <file>qml/CustomizerSwitch.qml</file> + <file>qml/CustomizerLabel.qml</file> + <file>qml/CustomizerSlider.qml</file> + <file>qml/FlickableMoreIndicator.qml</file> + <file>qml/gallery.qml</file> + <file>qml/PieMenuControlView.qml</file> + <file>qml/StylePicker.qml</file> + <file>qml/PieMenuDarkStyle.qml</file> + <file>qml/PieMenuDefaultStyle.qml</file> + <file>qml/ControlLabel.qml</file> + <file>images/icon-back.png</file> + </qresource> +</RCC> diff --git a/examples/quick/extras/gallery/images/background-light.png b/examples/quick/extras/gallery/images/background-light.png Binary files differnew file mode 100644 index 00000000..2f769845 --- /dev/null +++ b/examples/quick/extras/gallery/images/background-light.png diff --git a/examples/quick/extras/gallery/images/background.png b/examples/quick/extras/gallery/images/background.png Binary files differnew file mode 100644 index 00000000..a3f4302b --- /dev/null +++ b/examples/quick/extras/gallery/images/background.png diff --git a/examples/quick/extras/gallery/images/center-light.png b/examples/quick/extras/gallery/images/center-light.png Binary files differnew file mode 100644 index 00000000..75add20c --- /dev/null +++ b/examples/quick/extras/gallery/images/center-light.png diff --git a/examples/quick/extras/gallery/images/center.png b/examples/quick/extras/gallery/images/center.png Binary files differnew file mode 100644 index 00000000..b18a5fa8 --- /dev/null +++ b/examples/quick/extras/gallery/images/center.png diff --git a/examples/quick/extras/gallery/images/icon-back.png b/examples/quick/extras/gallery/images/icon-back.png Binary files differnew file mode 100644 index 00000000..0b037ff6 --- /dev/null +++ b/examples/quick/extras/gallery/images/icon-back.png diff --git a/examples/quick/extras/gallery/images/icon-go.png b/examples/quick/extras/gallery/images/icon-go.png Binary files differnew file mode 100644 index 00000000..bcb2a822 --- /dev/null +++ b/examples/quick/extras/gallery/images/icon-go.png diff --git a/examples/quick/extras/gallery/images/icon-settings.png b/examples/quick/extras/gallery/images/icon-settings.png Binary files differnew file mode 100644 index 00000000..7763ba20 --- /dev/null +++ b/examples/quick/extras/gallery/images/icon-settings.png diff --git a/examples/quick/extras/gallery/images/info.png b/examples/quick/extras/gallery/images/info.png Binary files differnew file mode 100644 index 00000000..5c7a9df3 --- /dev/null +++ b/examples/quick/extras/gallery/images/info.png diff --git a/examples/quick/extras/gallery/images/needle-light.png b/examples/quick/extras/gallery/images/needle-light.png Binary files differnew file mode 100644 index 00000000..d486d9e5 --- /dev/null +++ b/examples/quick/extras/gallery/images/needle-light.png diff --git a/examples/quick/extras/gallery/images/needle.png b/examples/quick/extras/gallery/images/needle.png Binary files differnew file mode 100644 index 00000000..6b10c604 --- /dev/null +++ b/examples/quick/extras/gallery/images/needle.png diff --git a/examples/quick/extras/gallery/images/qt-logo.png b/examples/quick/extras/gallery/images/qt-logo.png Binary files differnew file mode 100644 index 00000000..14ddf2a0 --- /dev/null +++ b/examples/quick/extras/gallery/images/qt-logo.png diff --git a/examples/quick/extras/gallery/images/zoom_in.png b/examples/quick/extras/gallery/images/zoom_in.png Binary files differnew file mode 100644 index 00000000..41282106 --- /dev/null +++ b/examples/quick/extras/gallery/images/zoom_in.png diff --git a/examples/quick/extras/gallery/images/zoom_out.png b/examples/quick/extras/gallery/images/zoom_out.png Binary files differnew file mode 100644 index 00000000..772d6ac1 --- /dev/null +++ b/examples/quick/extras/gallery/images/zoom_out.png diff --git a/examples/quick/extras/gallery/main.cpp b/examples/quick/extras/gallery/main.cpp new file mode 100644 index 00000000..5b1dbfee --- /dev/null +++ b/examples/quick/extras/gallery/main.cpp @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** 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 and its Subsidiary(-ies) 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 <QtGui/QGuiApplication> +#include <QtQml/QQmlApplicationEngine> + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + QQmlApplicationEngine engine(QUrl("qrc:/qml/gallery.qml")); + return app.exec(); +} diff --git a/examples/quick/extras/gallery/qml/BlackButtonBackground.qml b/examples/quick/extras/gallery/qml/BlackButtonBackground.qml new file mode 100644 index 00000000..983554a2 --- /dev/null +++ b/examples/quick/extras/gallery/qml/BlackButtonBackground.qml @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** 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 and its Subsidiary(-ies) 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.2 +import QtQuick.Controls 1.1 +import QtQuick.Controls.Styles 1.1 + +Rectangle { + property bool pressed: false + + gradient: Gradient { + GradientStop { + color: pressed ? "#222" : "#333" + position: 0 + } + GradientStop { + color: "#222" + position: 1 + } + } + Rectangle { + height: 1 + width: parent.width + anchors.top: parent.top + color: "#444" + visible: !pressed + } + Rectangle { + height: 1 + width: parent.width + anchors.bottom: parent.bottom + color: "#000" + } +} diff --git a/examples/quick/extras/gallery/qml/BlackButtonStyle.qml b/examples/quick/extras/gallery/qml/BlackButtonStyle.qml new file mode 100644 index 00000000..8bc561a7 --- /dev/null +++ b/examples/quick/extras/gallery/qml/BlackButtonStyle.qml @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** 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 and its Subsidiary(-ies) 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.2 +import QtQuick.Controls 1.1 +import QtQuick.Controls.Styles 1.1 + +ButtonStyle { + property color fontColor + + property url rightAlignedIconSource + + background: BlackButtonBackground { + pressed: control.pressed + } + label: Item { + implicitWidth: row.implicitWidth + implicitHeight: row.implicitHeight + baselineOffset: row.y + text.y + text.baselineOffset + + Row { + id: row + anchors.left: control.text.length === 0 ? undefined : parent.left + anchors.leftMargin: control.text.length === 0 ? 0 : textSingleton.implicitHeight + anchors.verticalCenter: parent.verticalCenter + anchors.horizontalCenter: control.text.length === 0 ? parent.horizontalCenter : undefined + + Image { + source: control.iconSource + width: Math.min(sourceSize.width, height) + height: text.implicitHeight + fillMode: Image.PreserveAspectFit + } + Text { + id: text + text: control.text + color: fontColor + font.pixelSize: control.height * 0.25 + font.family: openSans.name + horizontalAlignment: Text.AlignLeft + verticalAlignment: Text.AlignVCenter + anchors.verticalCenter: parent.verticalCenter + } + } + + Loader { + active: rightAlignedIconSource.toString().length !== 0 + anchors.verticalCenter: parent.verticalCenter + anchors.right: parent.right + anchors.rightMargin: textSingleton.implicitHeight + + sourceComponent: Image { + width: Math.min(sourceSize.width, height) + height: text.implicitHeight + fillMode: Image.PreserveAspectFit + source: rightAlignedIconSource + } + } + } +} diff --git a/examples/quick/extras/gallery/qml/CircularGaugeDarkStyle.qml b/examples/quick/extras/gallery/qml/CircularGaugeDarkStyle.qml new file mode 100644 index 00000000..04e9233f --- /dev/null +++ b/examples/quick/extras/gallery/qml/CircularGaugeDarkStyle.qml @@ -0,0 +1,96 @@ +/**************************************************************************** +** +** 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 and its Subsidiary(-ies) 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.2 +import QtQuick.Extras.Styles 1.3 + +CircularGaugeStyle { + id: root + tickmarkStepSize: 10 + minorTickmarkCount: 1 + labelStepSize: 20 + tickmarkInset: outerRadius * 0.06 + minorTickmarkInset: tickmarkInset + labelInset: outerRadius * 0.23 + + background: Image { + source: "qrc:/images/background.png" + } + + needle: Image { + id: needleImage + transformOrigin: Item.Bottom + source: "qrc:/images/needle.png" + scale: { + var distanceFromLabelToRadius = labelInset / 2; + var idealHeight = outerRadius - distanceFromLabelToRadius; + var originalImageHeight = needleImage.sourceSize.height; + idealHeight / originalImageHeight; + } + } + + foreground: Item { + Image { + anchors.centerIn: parent + source: "qrc:/images/center.png" + scale: (outerRadius * 0.25) / sourceSize.height + } + } + + tickmark: Rectangle { + implicitWidth: outerRadius * 0.02 + antialiasing: true + implicitHeight: outerRadius * 0.05 + color: "#888" + } + + minorTickmark: Rectangle { + implicitWidth: outerRadius * 0.01 + antialiasing: true + implicitHeight: outerRadius * 0.02 + color: "#444" + } + + tickmarkLabel: Text { + font.pixelSize: Math.max(6, outerRadius * 0.1) + text: styleData.value + color: "white" + } +} diff --git a/examples/quick/extras/gallery/qml/CircularGaugeDefaultStyle.qml b/examples/quick/extras/gallery/qml/CircularGaugeDefaultStyle.qml new file mode 100644 index 00000000..2f276163 --- /dev/null +++ b/examples/quick/extras/gallery/qml/CircularGaugeDefaultStyle.qml @@ -0,0 +1,46 @@ +/**************************************************************************** +** +** 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 and its Subsidiary(-ies) 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.2 +import QtQuick.Extras.Styles 1.3 + +CircularGaugeStyle { + labelStepSize: 20 +} diff --git a/examples/quick/extras/gallery/qml/CircularGaugeLightStyle.qml b/examples/quick/extras/gallery/qml/CircularGaugeLightStyle.qml new file mode 100644 index 00000000..d31e831a --- /dev/null +++ b/examples/quick/extras/gallery/qml/CircularGaugeLightStyle.qml @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** 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 and its Subsidiary(-ies) 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.2 +import QtQuick.Extras.Styles 1.3 + +CircularGaugeStyle { + id: root + tickmarkStepSize: 10 + minorTickmarkCount: 2 + labelStepSize: 40 + tickmarkInset: outerRadius * 0.06 + minorTickmarkInset: tickmarkInset + labelInset: outerRadius * 0.23 + + background: Image { + source: "qrc:/images/background-light.png" + } + + needle: Image { + id: needleImage + source: "qrc:/images/needle-light.png" + transformOrigin: Item.Bottom + scale: { + var distanceFromLabelToRadius = labelInset / 2; + var idealHeight = outerRadius - distanceFromLabelToRadius; + var originalImageHeight = needleImage.sourceSize.height; + idealHeight / originalImageHeight; + } + } + + foreground: Item { + Image { + anchors.centerIn: parent + source: "qrc:/images/center-light.png" + scale: (outerRadius * 0.25) / sourceSize.height + } + } + + tickmark: Rectangle { + implicitWidth: outerRadius * 0.01 + antialiasing: true + implicitHeight: outerRadius * 0.04 + color: "#999" + } + + minorTickmark: Rectangle { + implicitWidth: outerRadius * 0.01 + antialiasing: true + implicitHeight: outerRadius * 0.02 + color: "#bbb" + } + + tickmarkLabel: Text { + font.family: "Helvetica neue" + font.pixelSize: Math.max(6, outerRadius * 0.1) + text: styleData.value + color: "#333" + } +} diff --git a/examples/quick/extras/gallery/qml/CircularGaugeView.qml b/examples/quick/extras/gallery/qml/CircularGaugeView.qml new file mode 100644 index 00000000..e763e7b9 --- /dev/null +++ b/examples/quick/extras/gallery/qml/CircularGaugeView.qml @@ -0,0 +1,230 @@ +/**************************************************************************** +** +** 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 and its Subsidiary(-ies) 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.2 +import QtQuick.Controls 1.1 +import QtQuick.Extras 1.3 + +ControlView { + id: controlView + darkBackground: customizerItem.currentStyleDark + + property color fontColor: darkBackground ? "white" : "black" + + property bool accelerating: false + + Keys.onSpacePressed: accelerating = true + Keys.onReleased: { + if (event.key === Qt.Key_Space) { + accelerating = false; + event.accepted = true; + } + } + + Button { + id: accelerate + text: "Accelerate" + anchors.horizontalCenter: parent.horizontalCenter + anchors.bottom: parent.bottom + height: root.height * 0.125 + + onPressedChanged: accelerating = pressed + + style: BlackButtonStyle { + background: BlackButtonBackground { + pressed: control.pressed + } + label: Text { + text: control.text + color: "white" + font.pixelSize: Math.max(textSingleton.font.pixelSize, root.toPixels(0.04)) + font.family: openSans.name + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + } + } + } + + control: CircularGauge { + id: gauge + minimumValue: customizerItem.minimumValue + maximumValue: customizerItem.maximumValue + width: controlBounds.width + height: controlBounds.height + + value: accelerating ? maximumValue : 0 + style: styleMap[customizerItem.currentStylePath] + + // This stops the styles being recreated when a new one is chosen. + property var styleMap: { + var styles = {}; + for (var i = 0; i < customizerItem.allStylePaths.length; ++i) { + var path = customizerItem.allStylePaths[i]; + styles[path] = Qt.createComponent(path, gauge); + } + styles; + } + + // Called to update the style after the user has edited a property. + Connections { + target: customizerItem + onMinimumValueAngleChanged: __style.minimumValueAngle = customizerItem.minimumValueAngle + onMaximumValueAngleChanged: __style.maximumValueAngle = customizerItem.maximumValueAngle + onLabelStepSizeChanged: __style.tickmarkStepSize = __style.labelStepSize = customizerItem.labelStepSize + } + + Behavior on value { + NumberAnimation { + easing.type: Easing.OutCubic + duration: 6000 + } + } + } + + customizer: Column { + readonly property var allStylePaths: { + var paths = []; + for (var i = 0; i < stylePicker.model.count; ++i) { + paths.push(stylePicker.model.get(i).path); + } + paths; + } + property alias currentStylePath: stylePicker.currentStylePath + property alias currentStyleDark: stylePicker.currentStyleDark + property alias minimumValue: minimumValueSlider.value + property alias maximumValue: maximumValueSlider.value + property alias minimumValueAngle: minimumAngleSlider.value + property alias maximumValueAngle: maximumAngleSlider.value + property alias labelStepSize: labelStepSizeSlider.value + + id: circularGaugeColumn + spacing: customizerPropertySpacing + + readonly property bool isDefaultStyle: stylePicker.model.get(stylePicker.currentIndex).name === "Default" + + Item { + id: stylePickerBottomSpacing + width: parent.width + height: stylePicker.height + textSingleton.implicitHeight + + StylePicker { + id: stylePicker + currentIndex: 1 + + model: ListModel { + ListElement { + name: "Default" + path: "CircularGaugeDefaultStyle.qml" + dark: true + } + ListElement { + name: "Dark" + path: "CircularGaugeDarkStyle.qml" + dark: true + } + ListElement { + name: "Light" + path: "CircularGaugeLightStyle.qml" + dark: false + } + } + } + } + + CustomizerLabel { + text: "Minimum angle" + } + + CustomizerSlider { + id: minimumAngleSlider + minimumValue: -180 + value: -145 + maximumValue: 180 + width: parent.width + } + + CustomizerLabel { + text: "Maximum angle" + } + + CustomizerSlider { + id: maximumAngleSlider + minimumValue: -180 + value: 145 + maximumValue: 180 + } + + CustomizerLabel { + text: "Minimum value" + } + + CustomizerSlider { + id: minimumValueSlider + minimumValue: 0 + value: 0 + maximumValue: 360 + stepSize: 1 + } + + CustomizerLabel { + text: "Maximum value" + } + + CustomizerSlider { + id: maximumValueSlider + minimumValue: 0 + value: 240 + maximumValue: 300 + stepSize: 1 + } + + CustomizerLabel { + text: "Label step size" + } + + CustomizerSlider { + id: labelStepSizeSlider + minimumValue: 10 + value: 20 + maximumValue: 100 + stepSize: 20 + } + } +} diff --git a/examples/quick/extras/gallery/qml/ControlLabel.qml b/examples/quick/extras/gallery/qml/ControlLabel.qml new file mode 100644 index 00000000..b13c2a04 --- /dev/null +++ b/examples/quick/extras/gallery/qml/ControlLabel.qml @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** 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 and its Subsidiary(-ies) 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.2 +import QtQuick.Extras 1.3 + +Text { + font.pixelSize: Math.max(textSingleton.font.pixelSize, Math.min(32, root.toPixels(0.045))) + color: "#4e4e4e" + styleColor: "#ffffff" + style: Text.Raised +} diff --git a/examples/quick/extras/gallery/qml/ControlView.qml b/examples/quick/extras/gallery/qml/ControlView.qml new file mode 100644 index 00000000..cc479439 --- /dev/null +++ b/examples/quick/extras/gallery/qml/ControlView.qml @@ -0,0 +1,188 @@ +/**************************************************************************** +** +** 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 and its Subsidiary(-ies) 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.2 +import QtQuick.Controls 1.1 + +Rectangle { + id: view + color: darkBackground ? "transparent" : lightBackgroundColor + + Keys.onReleased: { + if (event.key === Qt.Key_Back) { + stackView.pop(); + event.accepted = true; + } + } + + property bool darkBackground: true + + property Component control + property Component customizer + + property alias controlItem: controlLoader.item + property alias customizerItem: customizerLoader.item + + property bool isCustomizerVisible: false + + property real margin: root.toPixels(0.05) + + property rect controlBounds: Qt.rect(largestControlItem.x + controlBoundsItem.x, + largestControlItem.y + controlBoundsItem.y, controlBoundsItem.width, controlBoundsItem.height) + + Item { + id: largestControlItem + x: margin + y: margin + width: isCustomizerVisible ? widthWhenCustomizing : widthWhenNotCustomizing + height: isCustomizerVisible ? heightWhenCustomizing : heightWhenNotCustomizing + + readonly property real widthWhenCustomizing: (!isScreenPortrait ? parent.width / 2 : parent.width) - margin * 2 + readonly property real heightWhenCustomizing: (isScreenPortrait ? parent.height / 2 : parent.height - toolbar.height) - margin * 2 + readonly property real widthWhenNotCustomizing: parent.width - margin * 2 + readonly property real heightWhenNotCustomizing: parent.height - toolbar.height - margin * 2 + + Item { + id: controlBoundsItem + x: parent.width / 2 - controlBoundsItem.width / 2 + y: customizer && customizerItem.visible ? 0 : (isScreenPortrait ? (parent.height / 2) - (controlBoundsItem.height / 2) : 0) + width: Math.min(parent.widthWhenCustomizing, parent.widthWhenNotCustomizing) + height: Math.min(parent.heightWhenCustomizing, parent.heightWhenNotCustomizing) + + Behavior on x { + id: controlXBehavior + enabled: false + NumberAnimation {} + } + + Behavior on y { + id: controlYBehavior + enabled: false + NumberAnimation {} + } + + Loader { + id: controlLoader + sourceComponent: control + anchors.centerIn: parent + + property alias view: view + } + } + } + + Flickable { + id: flickable + // Hide the customizer on the right of the screen if it's not visible. + x: (isScreenPortrait ? 0 : (isCustomizerVisible ? largestControlItem.x + largestControlItem.width + margin : view.width)) + margin + y: (isScreenPortrait ? largestControlItem.y + largestControlItem.height : 0) + margin + width: largestControlItem.width + height: parent.height - y - toolbar.height - margin + anchors.leftMargin: margin + anchors.rightMargin: margin + visible: customizerLoader.opacity > 0 + + flickableDirection: Flickable.VerticalFlick + + clip: true + contentWidth: width + contentHeight: customizerLoader.height + + Behavior on x { + id: flickableXBehavior + enabled: false + NumberAnimation {} + } + + Behavior on y { + id: flickableYBehavior + enabled: false + NumberAnimation {} + } + + Loader { + id: customizerLoader + sourceComponent: customizer + opacity: 0 + width: flickable.width + + property alias view: view + + Behavior on opacity { + NumberAnimation { + duration: 300 + } + } + } + } + + ControlViewToolbar { + id: toolbar + + onCustomizeClicked: { + controlXBehavior.enabled = !isScreenPortrait; + controlYBehavior.enabled = isScreenPortrait; + + isCustomizerVisible = !isCustomizerVisible; + + if (isScreenPortrait) { + flickableXBehavior.enabled = false; + flickableYBehavior.enabled = true; + } else { + flickableXBehavior.enabled = true; + flickableYBehavior.enabled = false; + } + + customizerLoader.opacity = isCustomizerVisible ? 1 : 0; + } + } + + FlickableMoreIndicator { + flickable: flickable + atTop: true + gradientColor: view.darkBackground ? darkBackgroundColor : lightBackgroundColor + } + + FlickableMoreIndicator { + flickable: flickable + atTop: false + gradientColor: view.darkBackground ? darkBackgroundColor : lightBackgroundColor + } +} diff --git a/examples/quick/extras/gallery/qml/ControlViewToolbar.qml b/examples/quick/extras/gallery/qml/ControlViewToolbar.qml new file mode 100644 index 00000000..7df5103c --- /dev/null +++ b/examples/quick/extras/gallery/qml/ControlViewToolbar.qml @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** 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 and its Subsidiary(-ies) 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.2 +import QtQuick.Controls 1.1 + +BlackButtonBackground { + anchors.bottom: parent.bottom + anchors.left: parent.left + anchors.right: parent.right + height: root.height * 0.125 + + signal customizeClicked + + gradient: Gradient { + GradientStop { + color: "#333" + position: 0 + } + GradientStop { + color: "#222" + position: 1 + } + } + + Button { + id: back + width: parent.height + height: parent.height + anchors.left: parent.left + anchors.bottom: parent.bottom + iconSource: "qrc:/images/icon-back.png" + onClicked: stackView.pop() + + style: BlackButtonStyle { + } + + } + + Button { + id: customize + width: parent.height + height: parent.height + anchors.right: parent.right + anchors.bottom: parent.bottom + iconSource: "qrc:/images/icon-settings.png" + visible: customizer + + style: BlackButtonStyle { + } + + onClicked: customizeClicked() + } +} diff --git a/examples/quick/extras/gallery/qml/CustomizerLabel.qml b/examples/quick/extras/gallery/qml/CustomizerLabel.qml new file mode 100644 index 00000000..1640f86c --- /dev/null +++ b/examples/quick/extras/gallery/qml/CustomizerLabel.qml @@ -0,0 +1,48 @@ +/**************************************************************************** +** +** 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 and its Subsidiary(-ies) 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.2 + +Text { + color: darkBackground ? root.darkFontColor : root.lightFontColor + font.pixelSize: root.toPixels(0.04) + font.family: openSans.name + anchors.horizontalCenter: parent.horizontalCenter +} diff --git a/examples/quick/extras/gallery/qml/CustomizerSlider.qml b/examples/quick/extras/gallery/qml/CustomizerSlider.qml new file mode 100644 index 00000000..54b85ca9 --- /dev/null +++ b/examples/quick/extras/gallery/qml/CustomizerSlider.qml @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** 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 and its Subsidiary(-ies) 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.1 +import QtQuick.Controls 1.1 +import QtQuick.Controls.Styles 1.1 + +Slider { + id: slider + width: parent.width + height: root.toPixels(0.1) + + style: SliderStyle { + handle: Rectangle { + height: root.toPixels(0.06) + width: height + radius: width/2 + color: "#fff" + } + + groove: Rectangle { + implicitHeight: root.toPixels(0.015) + implicitWidth: 100 + radius: height/2 + border.color: "#333" + color: "#222" + Rectangle { + height: parent.height + width: styleData.handlePosition + implicitHeight: 6 + implicitWidth: 100 + radius: height/2 + color: "#555" + } + } + + } +} diff --git a/examples/quick/extras/gallery/qml/CustomizerSwitch.qml b/examples/quick/extras/gallery/qml/CustomizerSwitch.qml new file mode 100644 index 00000000..2586b63f --- /dev/null +++ b/examples/quick/extras/gallery/qml/CustomizerSwitch.qml @@ -0,0 +1,46 @@ +/**************************************************************************** +** +** 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 and its Subsidiary(-ies) 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.2 +import QtQuick.Controls 1.1 + +Switch { + anchors.horizontalCenter: parent.horizontalCenter +} diff --git a/examples/quick/extras/gallery/qml/FlickableMoreIndicator.qml b/examples/quick/extras/gallery/qml/FlickableMoreIndicator.qml new file mode 100644 index 00000000..649e9715 --- /dev/null +++ b/examples/quick/extras/gallery/qml/FlickableMoreIndicator.qml @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** 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 and its Subsidiary(-ies) 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.2 + +Rectangle { + anchors.top: atTop ? flickable.top : undefined + anchors.bottom: atTop ? undefined : flickable.bottom + anchors.left: isScreenPortrait ? parent.left : parent.horizontalCenter + anchors.right: parent.right + height: 30 + visible: flickable.visible + opacity: atTop + ? (flickable.contentY > showDistance ? 1 : 0) + : (flickable.contentY < flickable.contentHeight - showDistance ? 1 : 0) + scale: atTop ? 1 : -1 + + readonly property real showDistance: 0 + property Flickable flickable + property color gradientColor + /*! \c true if this indicator is at the top of the item */ + property bool atTop + + Behavior on opacity { + NumberAnimation { + } + } + + gradient: Gradient { + GradientStop { + position: 0.0 + color: gradientColor + } + GradientStop { + position: 1.0 + color: "transparent" + } + } +} diff --git a/examples/quick/extras/gallery/qml/PieMenuControlView.qml b/examples/quick/extras/gallery/qml/PieMenuControlView.qml new file mode 100644 index 00000000..f486431a --- /dev/null +++ b/examples/quick/extras/gallery/qml/PieMenuControlView.qml @@ -0,0 +1,187 @@ +/**************************************************************************** +** +** 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 and its Subsidiary(-ies) 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.2 +import QtGraphicalEffects 1.0 +import QtQuick.Controls 1.1 +import QtQuick.Extras 1.3 + +Rectangle { + id: view + color: customizerItem.currentStyleDark ? "#111" : "#555" + + Behavior on color { + ColorAnimation {} + } + + Keys.onReleased: { + if (event.key === Qt.Key_Back) { + stackView.pop(); + event.accepted = true; + } + } + + property bool darkBackground: true + + property Component mouseArea + + property Component customizer: Item { + property alias currentStylePath: stylePicker.currentStylePath + property alias currentStyleDark: stylePicker.currentStyleDark + + StylePicker { + id: stylePicker + currentIndex: 0 + width: Math.round(Math.max(textSingleton.implicitHeight * 6 * 2, parent.width * 0.5)) + anchors.centerIn: parent + + model: ListModel { + ListElement { + name: "Default" + path: "PieMenuDefaultStyle.qml" + dark: false + } + ListElement { + name: "Dark" + path: "PieMenuDarkStyle.qml" + dark: true + } + } + } + } + + property alias controlItem: pieMenu + property alias customizerItem: customizerLoader.item + + Item { + id: controlBoundsItem + width: parent.width + height: parent.height - toolbar.height + visible: customizerLoader.opacity === 0 + + Image { + id: bgImage + anchors.centerIn: parent + height: 48 + Text { + id: bgLabel + anchors.top: parent.bottom + anchors.topMargin: 20 + anchors.horizontalCenter: parent.horizontalCenter + text: "Tap to open" + color: "#999" + font.pointSize: 20 + } + } + + MouseArea { + id: touchArea + anchors.fill: parent + onClicked: pieMenu.popup(touchArea.mouseX, touchArea.mouseY) + } + + PieMenu { + id: pieMenu + triggerMode: TriggerMode.TriggerOnClick + width: Math.min(controlBoundsItem.width, controlBoundsItem.height) * 0.5 + height: width + + style: Qt.createComponent(customizerItem.currentStylePath) + + MenuItem { + text: "Zoom In" + onTriggered: { + bgImage.source = iconSource + bgLabel.text = text + " selected" + } + iconSource: "qrc:/images/zoom_in.png" + } + MenuItem { + text: "Zoom Out" + onTriggered: { + bgImage.source = iconSource + bgLabel.text = text + " selected" + } + iconSource: "qrc:/images/zoom_out.png" + } + MenuItem { + text: "Info" + onTriggered: { + bgImage.source = iconSource + bgLabel.text = text + " selected" + } + iconSource: "qrc:/images/info.png" + } + } + } + Loader { + id: customizerLoader + sourceComponent: customizer + opacity: 0 + anchors.left: parent.left + anchors.right: parent.right + anchors.leftMargin: 30 + anchors.rightMargin: 30 + y: parent.height / 2 - height / 2 - toolbar.height + visible: customizerLoader.opacity > 0 + + property alias view: view + + Behavior on y { + NumberAnimation { + duration: 300 + } + } + + Behavior on opacity { + NumberAnimation { + duration: 300 + } + } + } + + ControlViewToolbar { + id: toolbar + + onCustomizeClicked: { + customizerLoader.opacity = customizerLoader.opacity == 0 ? 1 : 0; + } + } +} diff --git a/examples/quick/extras/gallery/qml/PieMenuDarkStyle.qml b/examples/quick/extras/gallery/qml/PieMenuDarkStyle.qml new file mode 100644 index 00000000..b5905192 --- /dev/null +++ b/examples/quick/extras/gallery/qml/PieMenuDarkStyle.qml @@ -0,0 +1,46 @@ +/**************************************************************************** +** +** 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 and its Subsidiary(-ies) 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.Extras.Styles 1.3 + +PieMenuStyle { + backgroundColor: "#222" + shadowColor: Qt.rgba(1, 1, 1, 0.26) +} diff --git a/examples/quick/extras/gallery/qml/PieMenuDefaultStyle.qml b/examples/quick/extras/gallery/qml/PieMenuDefaultStyle.qml new file mode 100644 index 00000000..f34584fe --- /dev/null +++ b/examples/quick/extras/gallery/qml/PieMenuDefaultStyle.qml @@ -0,0 +1,44 @@ +/**************************************************************************** +** +** 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 and its Subsidiary(-ies) 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.Extras.Styles 1.3 + +PieMenuStyle { +} diff --git a/examples/quick/extras/gallery/qml/StylePicker.qml b/examples/quick/extras/gallery/qml/StylePicker.qml new file mode 100644 index 00000000..4606cb97 --- /dev/null +++ b/examples/quick/extras/gallery/qml/StylePicker.qml @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** 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 and its Subsidiary(-ies) 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.2 +import QtQuick.Controls 1.1 +import QtQuick.Controls.Styles 1.1 +import QtQuick.Extras 1.3 +import QtQuick.Extras.Styles 1.3 + +ListView { + id: stylePicker + width: parent.width + height: root.height * 0.06 + interactive: false + spacing: -1 + + orientation: ListView.Horizontal + + readonly property string currentStylePath: stylePicker.model.get(stylePicker.currentIndex).path + readonly property bool currentStyleDark: stylePicker.model.get(stylePicker.currentIndex).dark !== undefined + ? stylePicker.model.get(stylePicker.currentIndex).dark + : true + + ExclusiveGroup { + id: styleExclusiveGroup + } + + delegate: Button { + width: Math.round(stylePicker.width / stylePicker.model.count) + height: stylePicker.height + checkable: true + checked: index === ListView.view.currentIndex + exclusiveGroup: styleExclusiveGroup + + onCheckedChanged: { + if (checked) { + ListView.view.currentIndex = index; + } + } + + style: ButtonStyle { + background: Rectangle { + readonly property color checkedColor: currentStyleDark ? "#444" : "#777" + readonly property color uncheckedColor: currentStyleDark ? "#222" : "#bbb" + color: checked ? checkedColor : uncheckedColor + border.color: checkedColor + border.width: 1 + radius: 1 + } + + label: Text { + text: name + color: currentStyleDark ? "white" : (checked ? "white" : "black") + font.pixelSize: root.toPixels(0.04) + font.family: openSans.name + anchors.centerIn: parent + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + } + } + } +} diff --git a/examples/quick/extras/gallery/qml/gallery.qml b/examples/quick/extras/gallery/qml/gallery.qml new file mode 100644 index 00000000..d29b8997 --- /dev/null +++ b/examples/quick/extras/gallery/qml/gallery.qml @@ -0,0 +1,440 @@ +/**************************************************************************** +** +** 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 and its Subsidiary(-ies) 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.2 +import QtGraphicalEffects 1.0 +import QtQuick.Controls 1.1 +import QtQuick.Controls.Styles 1.1 +import QtQuick.Dialogs 1.0 +import QtQuick.Extras 1.3 +import QtQuick.Extras.Styles 1.3 +import QtQuick.Layouts 1.0 +import QtQuick.Window 2.1 + +Window { + id: root + objectName: "window" + visible: true + width: 480 + height: 800 + + color: "#161616" + title: "Qt Quick Extras Demo" + + function toPixels(percentage) { + return percentage * Math.min(root.width, root.height); + } + + property bool isScreenPortrait: height > width + property color lightFontColor: "#222" + property color darkFontColor: "#e7e7e7" + readonly property color lightBackgroundColor: "#cccccc" + readonly property color darkBackgroundColor: "#161616" + property real customizerPropertySpacing: 10 + property real colorPickerRowSpacing: 8 + + Text { + id: textSingleton + } + + property Component circularGauge: CircularGaugeView {} + + property Component dial: ControlView { + darkBackground: false + + control: Column { + id: dialColumn + width: controlBounds.width + height: controlBounds.height - spacing + spacing: root.toPixels(0.05) + + ColumnLayout { + id: volumeColumn + width: parent.width + height: (dialColumn.height - dialColumn.spacing) / 2 + spacing: height * 0.025 + + Dial { + id: volumeDial + anchors.horizontalCenter: parent.horizontalCenter + Layout.fillWidth: true + Layout.fillHeight: true + + /*! + Determines whether the dial animates its rotation to the new value when + a single click or touch is received on the dial. + */ + property bool animate: customizerItem.animate + + Behavior on value { + enabled: volumeDial.animate && !volumeDial.pressed + NumberAnimation { + duration: 300 + easing.type: Easing.OutSine + } + } + } + + ControlLabel { + id: volumeText + text: "Volume" + anchors.horizontalCenter: parent.horizontalCenter + } + } + + ColumnLayout { + id: trebleColumn + width: parent.width + height: (dialColumn.height - dialColumn.spacing) / 2 + spacing: height * 0.025 + + Dial { + id: dial2 + anchors.horizontalCenter: parent.horizontalCenter + Layout.fillWidth: true + Layout.fillHeight: true + + stepSize: 1 + maximumValue: 10 + + style: DialStyle { + labelInset: outerRadius * 0 + } + } + + ControlLabel { + id: trebleText + text: "Treble" + anchors.horizontalCenter: parent.horizontalCenter + } + } + } + + customizer: Column { + spacing: customizerPropertySpacing + + property alias animate: animateCheckBox.checked + + CustomizerLabel { + text: "Animate" + } + + CustomizerSwitch { + id: animateCheckBox + } + } + } + + property Component delayButton: ControlView { + darkBackground: false + + control: DelayButton { + text: "Alarm" + anchors.centerIn: parent + } + } + + property Component gauge: ControlView { + id: gaugeView + control: Gauge { + id: gauge + width: orientation === Qt.Vertical ? implicitWidth : gaugeView.controlBounds.width + height: orientation === Qt.Vertical ? gaugeView.controlBounds.height : implicitHeight + anchors.centerIn: parent + + minimumValue: 0 + value: customizerItem.value + maximumValue: 100 + orientation: customizerItem.orientationFlag ? Qt.Vertical : Qt.Horizontal + tickmarkAlignment: orientation === Qt.Vertical + ? (customizerItem.alignFlag ? Qt.AlignLeft : Qt.AlignRight) + : (customizerItem.alignFlag ? Qt.AlignTop : Qt.AlignBottom) + } + + customizer: Column { + spacing: customizerPropertySpacing + + property alias value: valueSlider.value + property alias orientationFlag: orientationCheckBox.checked + property alias alignFlag: alignCheckBox.checked + + CustomizerLabel { + text: "Value" + } + + CustomizerSlider { + id: valueSlider + minimumValue: 0 + value: 50 + maximumValue: 100 + } + + CustomizerLabel { + text: "Vertical orientation" + } + + CustomizerSwitch { + id: orientationCheckBox + checked: true + } + + CustomizerLabel { + text: controlItem.orientation === Qt.Vertical ? "Left align" : "Top align" + } + + CustomizerSwitch { + id: alignCheckBox + checked: true + } + } + } + + property Component toggleButton: ControlView { + darkBackground: false + + control: ToggleButton { + text: checked ? "On" : "Off" + anchors.centerIn: parent + } + } + + property Component pieMenu: PieMenuControlView {} + + property Component statusIndicator: ControlView { + id: statusIndicatorView + darkBackground: false + + Timer { + id: recordingFlashTimer + running: true + repeat: true + interval: 1000 + } + + ColumnLayout { + id: indicatorLayout + width: statusIndicatorView.controlBounds.width * 0.25 + height: statusIndicatorView.controlBounds.height * 0.75 + anchors.centerIn: parent + + Repeater { + model: ListModel { + id: indicatorModel + ListElement { + name: "Power" + indicatorColor: "#35e02f" + } + ListElement { + name: "Recording" + indicatorColor: "red" + } + } + + ColumnLayout { + Layout.preferredWidth: indicatorLayout.width + spacing: 0 + + StatusIndicator { + id: indicator + color: indicatorColor + Layout.preferredWidth: statusIndicatorView.controlBounds.width * 0.07 + Layout.preferredHeight: Layout.preferredWidth + Layout.alignment: Qt.AlignHCenter + on: true + + Connections { + target: recordingFlashTimer + onTriggered: if (name == "Recording") indicator.active = !indicator.active + } + } + ControlLabel { + id: indicatorLabel + text: name + Layout.alignment: Qt.AlignHCenter + Layout.maximumWidth: parent.width + horizontalAlignment: Text.AlignHCenter + } + } + } + } + } + + property Component tumbler: ControlView { + id: tumblerView + darkBackground: false + + Tumbler { + id: tumbler + anchors.centerIn: parent + + // TODO: Use FontMetrics with 5.4 + Label { + id: characterMetrics + font.bold: true + font.pixelSize: textSingleton.font.pixelSize * 1.25 + font.family: openSans.name + visible: false + text: "M" + } + + readonly property real delegateTextMargins: characterMetrics.width * 1.5 + readonly property var days: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] + + TumblerColumn { + id: tumblerDayColumn + + function updateModel() { + var previousIndex = tumblerDayColumn.currentIndex; + var newDays = tumbler.days[monthColumn.currentIndex]; + + if (!model) { + var array = []; + for (var i = 0; i < newDays; ++i) { + array.push(i + 1); + } + model = array; + } else { + // If we've already got days in the model, just add or remove + // the minimum amount necessary to make spinning the month column fast. + var difference = model.length - newDays; + if (model.length > newDays) { + model.splice(model.length - 1, difference); + } else { + var lastDay = model[model.length - 1]; + for (i = lastDay; i < lastDay + difference; ++i) { + model.push(i + 1); + } + } + } + + tumbler.setCurrentIndexAt(0, Math.min(newDays - 1, previousIndex)); + } + } + TumblerColumn { + id: monthColumn + width: characterMetrics.width * 3 + tumbler.delegateTextMargins + model: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] + onCurrentIndexChanged: tumblerDayColumn.updateModel() + } + TumblerColumn { + width: characterMetrics.width * 4 + tumbler.delegateTextMargins + model: ListModel { + Component.onCompleted: { + for (var i = 2000; i < 2100; ++i) { + append({value: i.toString()}); + } + } + } + } + } + } + + + FontLoader { + id: openSans + source: "qrc:/fonts/OpenSans-Regular.ttf" + } + + property var componentMap: { + "CircularGauge": circularGauge, + "DelayButton": delayButton, + "Dial": dial, + "Gauge": gauge, + "PieMenu": pieMenu, + "StatusIndicator": statusIndicator, + "ToggleButton": toggleButton, + "Tumbler": tumbler + } + + StackView { + id: stackView + anchors.fill: parent + + initialItem: ListView { + model: ListModel { + ListElement { + title: "CircularGauge" + } + ListElement { + title: "DelayButton" + } + ListElement { + title: "Dial" + } + ListElement { + title: "Gauge" + } + ListElement { + title: "PieMenu" + } + ListElement { + title: "StatusIndicator" + } + ListElement { + title: "ToggleButton" + } + ListElement { + title: "Tumbler" + } + } + + delegate: Button { + width: stackView.width + height: root.height * 0.125 + text: title + + style: BlackButtonStyle { + fontColor: root.darkFontColor + rightAlignedIconSource: "qrc:/images/icon-go.png" + } + + onClicked: { + if (stackView.depth == 1) { + // Only push the control view if we haven't already pushed it... + stackView.push({item: componentMap[title]}); + stackView.currentItem.forceActiveFocus(); + } + } + } + } + } +} + + |