diff options
Diffstat (limited to 'examples/quickcontrols2/sidepanel')
-rw-r--r-- | examples/quickcontrols2/sidepanel/CMakeLists.txt | 59 | ||||
-rw-r--r-- | examples/quickcontrols2/sidepanel/doc/images/qtquickcontrols2-sidepanel-landscape.png | bin | 0 -> 55216 bytes | |||
-rw-r--r-- | examples/quickcontrols2/sidepanel/doc/images/qtquickcontrols2-sidepanel-portrait.png | bin | 0 -> 32060 bytes | |||
-rw-r--r-- | examples/quickcontrols2/sidepanel/doc/src/qtquickcontrols2-sidepanel.qdoc | 83 | ||||
-rw-r--r-- | examples/quickcontrols2/sidepanel/images/qt-logo.png | bin | 0 -> 1301 bytes | |||
-rw-r--r-- | examples/quickcontrols2/sidepanel/images/qt-logo@2x.png | bin | 0 -> 2611 bytes | |||
-rw-r--r-- | examples/quickcontrols2/sidepanel/images/qt-logo@3x.png | bin | 0 -> 4155 bytes | |||
-rw-r--r-- | examples/quickcontrols2/sidepanel/images/qt-logo@4x.png | bin | 0 -> 5916 bytes | |||
-rw-r--r-- | examples/quickcontrols2/sidepanel/qtquickcontrols2.conf | 2 | ||||
-rw-r--r-- | examples/quickcontrols2/sidepanel/sidepanel.cpp | 64 | ||||
-rw-r--r-- | examples/quickcontrols2/sidepanel/sidepanel.pro | 19 | ||||
-rw-r--r-- | examples/quickcontrols2/sidepanel/sidepanel.qml | 179 |
12 files changed, 406 insertions, 0 deletions
diff --git a/examples/quickcontrols2/sidepanel/CMakeLists.txt b/examples/quickcontrols2/sidepanel/CMakeLists.txt new file mode 100644 index 0000000000..19d8eb860a --- /dev/null +++ b/examples/quickcontrols2/sidepanel/CMakeLists.txt @@ -0,0 +1,59 @@ +# Generated from sidepanel.pro. + +cmake_minimum_required(VERSION 3.14) +project(sidepanel LANGUAGES CXX) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_AUTOUIC ON) + +if(NOT DEFINED INSTALL_EXAMPLESDIR) + set(INSTALL_EXAMPLESDIR "examples") +endif() + +set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quickcontrols2/sidepanel") + +find_package(Qt6 COMPONENTS Core) +find_package(Qt6 COMPONENTS Gui) +find_package(Qt6 COMPONENTS Quick) + +qt_add_executable(sidepanel + sidepanel.cpp +) +set_target_properties(sidepanel PROPERTIES + WIN32_EXECUTABLE TRUE + MACOSX_BUNDLE TRUE +) +target_link_libraries(sidepanel PUBLIC + Qt::Core + Qt::Gui + Qt::Quick +) + + +# Resources: +set(qmake_immediate_resource_files + "doc/images/qtquickcontrols2-sidepanel-landscape.png" + "doc/images/qtquickcontrols2-sidepanel-portrait.png" + "images/qt-logo.png" + "images/qt-logo@2x.png" + "images/qt-logo@3x.png" + "images/qt-logo@4x.png" + "qtquickcontrols2.conf" + "sidepanel.qml" +) + +qt6_add_resources(sidepanel "qmake_immediate" + PREFIX + "/" + FILES + ${qmake_immediate_resource_files} +) + +install(TARGETS sidepanel + RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" + LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" +) diff --git a/examples/quickcontrols2/sidepanel/doc/images/qtquickcontrols2-sidepanel-landscape.png b/examples/quickcontrols2/sidepanel/doc/images/qtquickcontrols2-sidepanel-landscape.png Binary files differnew file mode 100644 index 0000000000..86907591b2 --- /dev/null +++ b/examples/quickcontrols2/sidepanel/doc/images/qtquickcontrols2-sidepanel-landscape.png diff --git a/examples/quickcontrols2/sidepanel/doc/images/qtquickcontrols2-sidepanel-portrait.png b/examples/quickcontrols2/sidepanel/doc/images/qtquickcontrols2-sidepanel-portrait.png Binary files differnew file mode 100644 index 0000000000..cf1ed2efd0 --- /dev/null +++ b/examples/quickcontrols2/sidepanel/doc/images/qtquickcontrols2-sidepanel-portrait.png diff --git a/examples/quickcontrols2/sidepanel/doc/src/qtquickcontrols2-sidepanel.qdoc b/examples/quickcontrols2/sidepanel/doc/src/qtquickcontrols2-sidepanel.qdoc new file mode 100644 index 0000000000..49e997fb5d --- /dev/null +++ b/examples/quickcontrols2/sidepanel/doc/src/qtquickcontrols2-sidepanel.qdoc @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \example sidepanel + \keyword Qt Quick Controls - Side Panel + \title Qt Quick Controls - Side Panel + \keyword Qt Quick Controls 2 - Side Panel + \ingroup qtquickcontrols2-examples + \brief A persistent side panel with Drawer. + + This example demonstrates how \l Drawer can be used as a persistent side + panel. + + \raw HTML + <div class="table"><table style="background:transparent; border:0px"> + <tr><td style="border:0px"> + \endraw + \image qtquickcontrols2-sidepanel-portrait.png + \caption An interactive Drawer in portrait mode + \raw HTML + </td><td style="border:0px"> + \endraw + \image qtquickcontrols2-sidepanel-landscape.png + \caption A non-interactive Drawer in landscape mode + \raw HTML + </td></tr> + </table></div> + \endraw + + When the application is in portrait mode, the drawer is an interactive + side panel that can be swiped open from the left edge. It appears on + top of the content, blocking user interaction through its modal + background. When the application is in landscape mode, the drawer and + the content are laid out side-by-side. + + The current orientation of the application is determined by comparing + the width and height of the window: + + \snippet sidepanel/sidepanel.qml orientation + + This is used to determine whether the drawer should be \l {Popup::}{modal} + and \l {Drawer::}{interactive}, and to configure its \l {Drawer::}{position} + and \l {Popup::visible}{visibility} accordingly. + + \quotefromfile sidepanel/sidepanel.qml + \skipto Drawer + \printline Drawer + \dots 8 + \codeline + \skipto modal + \printuntil visible + \dots 8 + \skipuntil ScrollIndicator + \skipuntil } + \printline } + + \include examples-run.qdocinc +*/ diff --git a/examples/quickcontrols2/sidepanel/images/qt-logo.png b/examples/quickcontrols2/sidepanel/images/qt-logo.png Binary files differnew file mode 100644 index 0000000000..dff7729515 --- /dev/null +++ b/examples/quickcontrols2/sidepanel/images/qt-logo.png diff --git a/examples/quickcontrols2/sidepanel/images/qt-logo@2x.png b/examples/quickcontrols2/sidepanel/images/qt-logo@2x.png Binary files differnew file mode 100644 index 0000000000..dbd73aab77 --- /dev/null +++ b/examples/quickcontrols2/sidepanel/images/qt-logo@2x.png diff --git a/examples/quickcontrols2/sidepanel/images/qt-logo@3x.png b/examples/quickcontrols2/sidepanel/images/qt-logo@3x.png Binary files differnew file mode 100644 index 0000000000..68e763b597 --- /dev/null +++ b/examples/quickcontrols2/sidepanel/images/qt-logo@3x.png diff --git a/examples/quickcontrols2/sidepanel/images/qt-logo@4x.png b/examples/quickcontrols2/sidepanel/images/qt-logo@4x.png Binary files differnew file mode 100644 index 0000000000..08fd882572 --- /dev/null +++ b/examples/quickcontrols2/sidepanel/images/qt-logo@4x.png diff --git a/examples/quickcontrols2/sidepanel/qtquickcontrols2.conf b/examples/quickcontrols2/sidepanel/qtquickcontrols2.conf new file mode 100644 index 0000000000..b6c7c87ea1 --- /dev/null +++ b/examples/quickcontrols2/sidepanel/qtquickcontrols2.conf @@ -0,0 +1,2 @@ +[Controls] +Style=Material diff --git a/examples/quickcontrols2/sidepanel/sidepanel.cpp b/examples/quickcontrols2/sidepanel/sidepanel.cpp new file mode 100644 index 0000000000..4b328d1dd4 --- /dev/null +++ b/examples/quickcontrols2/sidepanel/sidepanel.cpp @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QGuiApplication> +#include <QQmlApplicationEngine> + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + + QQmlApplicationEngine engine; + engine.load(QUrl("qrc:/sidepanel.qml")); + if (engine.rootObjects().isEmpty()) + return -1; + + return app.exec(); +} diff --git a/examples/quickcontrols2/sidepanel/sidepanel.pro b/examples/quickcontrols2/sidepanel/sidepanel.pro new file mode 100644 index 0000000000..3ae9cd8d6b --- /dev/null +++ b/examples/quickcontrols2/sidepanel/sidepanel.pro @@ -0,0 +1,19 @@ +TEMPLATE = app +TARGET = sidepanel +QT += quick + +SOURCES += \ + sidepanel.cpp + +RESOURCES += \ + doc/images/qtquickcontrols2-sidepanel-landscape.png \ + doc/images/qtquickcontrols2-sidepanel-portrait.png \ + images/qt-logo@2x.png \ + images/qt-logo@3x.png \ + images/qt-logo@4x.png \ + images/qt-logo.png \ + qtquickcontrols2.conf \ + sidepanel.qml + +target.path = $$[QT_INSTALL_EXAMPLES]/quickcontrols2/sidepanel +INSTALLS += target diff --git a/examples/quickcontrols2/sidepanel/sidepanel.qml b/examples/quickcontrols2/sidepanel/sidepanel.qml new file mode 100644 index 0000000000..33e8515992 --- /dev/null +++ b/examples/quickcontrols2/sidepanel/sidepanel.qml @@ -0,0 +1,179 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick +import QtQuick.Controls + +ApplicationWindow { + id: window + width: 360 + height: 520 + visible: true + title: qsTr("Side Panel") + + //! [orientation] + readonly property bool inPortrait: window.width < window.height + //! [orientation] + + ToolBar { + id: overlayHeader + + z: 1 + width: parent.width + parent: Overlay.overlay + + Label { + id: label + anchors.centerIn: parent + text: "Qt Quick Controls" + } + } + + Drawer { + id: drawer + + y: overlayHeader.height + width: window.width / 2 + height: window.height - overlayHeader.height + + modal: inPortrait + interactive: inPortrait + position: inPortrait ? 0 : 1 + visible: !inPortrait + + ListView { + id: listView + anchors.fill: parent + + headerPositioning: ListView.OverlayHeader + header: Pane { + id: header + z: 2 + width: parent.width + + contentHeight: logo.height + + Image { + id: logo + width: parent.width + source: "images/qt-logo.png" + fillMode: implicitWidth > width ? Image.PreserveAspectFit : Image.Pad + } + + MenuSeparator { + parent: header + width: parent.width + anchors.verticalCenter: parent.bottom + visible: !listView.atYBeginning + } + } + + footer: ItemDelegate { + id: footer + text: qsTr("Footer") + width: parent.width + + MenuSeparator { + parent: footer + width: parent.width + anchors.verticalCenter: parent.top + } + } + + model: 10 + + delegate: ItemDelegate { + text: qsTr("Title %1").arg(index + 1) + width: listView.width + } + + ScrollIndicator.vertical: ScrollIndicator { } + } + } + + Flickable { + id: flickable + + anchors.fill: parent + anchors.topMargin: overlayHeader.height + anchors.leftMargin: !inPortrait ? drawer.width : undefined + + topMargin: 20 + bottomMargin: 20 + contentHeight: column.height + + Column { + id: column + spacing: 20 + anchors.margins: 20 + anchors.left: parent.left + anchors.right: parent.right + + Label { + font.pixelSize: 22 + width: parent.width + elide: Label.ElideRight + horizontalAlignment: Qt.AlignHCenter + text: qsTr("Side Panel Example") + } + + Label { + width: parent.width + wrapMode: Label.WordWrap + text: qsTr("This example demonstrates how Drawer can be used as a non-closable persistent side panel.\n\n" + + "When the application is in portrait mode, the drawer is an interactive side panel that can " + + "be swiped open from the left edge. When the application is in landscape mode, the drawer " + + "and the content are laid out side by side.\n\nThe application is currently in %1 mode.").arg(inPortrait ? qsTr("portrait") : qsTr("landscape")) + } + } + + ScrollIndicator.vertical: ScrollIndicator { } + } +} |