From 1694a4a71d03faf7e952535f9af86f886bb223d4 Mon Sep 17 00:00:00 2001 From: Oliver Eftevaag Date: Mon, 8 Nov 2021 14:59:43 +0100 Subject: Keyinteraction example: use qt_add_qml_module() in CMakeLists.txt We want to use the new cmake api instead of qt6_add_resources() The file structure has also been flattened a bit. Task-number: QTBUG-98130 Change-Id: I1651d25e2902bf6932b78c2224ee4ffe454b658d Reviewed-by: Ulf Hermann (cherry picked from commit 750e7d946ca8c059151e91c57da243bdc787ea6e) --- examples/quick/keyinteraction/CMakeLists.txt | 51 ++---- examples/quick/keyinteraction/ContextMenu.qml | 76 +++++++++ examples/quick/keyinteraction/GridMenu.qml | 122 ++++++++++++++ examples/quick/keyinteraction/ListMenu.qml | 119 +++++++++++++ examples/quick/keyinteraction/ListViewDelegate.qml | 102 +++++++++++ examples/quick/keyinteraction/TabMenu.qml | 118 +++++++++++++ examples/quick/keyinteraction/focus.qml | 187 +++++++++++++++++++++ .../keyinteraction/focus/Core/ContextMenu.qml | 76 --------- .../quick/keyinteraction/focus/Core/GridMenu.qml | 117 ------------- .../quick/keyinteraction/focus/Core/ListMenu.qml | 119 ------------- .../keyinteraction/focus/Core/ListViewDelegate.qml | 97 ----------- .../quick/keyinteraction/focus/Core/TabMenu.qml | 113 ------------- .../keyinteraction/focus/Core/images/arrow.png | Bin 411 -> 0 bytes .../keyinteraction/focus/Core/images/qt-logo.png | Bin 5149 -> 0 bytes examples/quick/keyinteraction/focus/focus.qml | 177 ------------------- examples/quick/keyinteraction/images/arrow.png | Bin 0 -> 411 bytes examples/quick/keyinteraction/images/qt-logo.png | Bin 0 -> 5149 bytes examples/quick/keyinteraction/keyinteraction.qml | 6 +- examples/quick/keyinteraction/keyinteraction.qrc | 16 +- 19 files changed, 753 insertions(+), 743 deletions(-) create mode 100644 examples/quick/keyinteraction/ContextMenu.qml create mode 100644 examples/quick/keyinteraction/GridMenu.qml create mode 100644 examples/quick/keyinteraction/ListMenu.qml create mode 100644 examples/quick/keyinteraction/ListViewDelegate.qml create mode 100644 examples/quick/keyinteraction/TabMenu.qml create mode 100644 examples/quick/keyinteraction/focus.qml delete mode 100644 examples/quick/keyinteraction/focus/Core/ContextMenu.qml delete mode 100644 examples/quick/keyinteraction/focus/Core/GridMenu.qml delete mode 100644 examples/quick/keyinteraction/focus/Core/ListMenu.qml delete mode 100644 examples/quick/keyinteraction/focus/Core/ListViewDelegate.qml delete mode 100644 examples/quick/keyinteraction/focus/Core/TabMenu.qml delete mode 100644 examples/quick/keyinteraction/focus/Core/images/arrow.png delete mode 100644 examples/quick/keyinteraction/focus/Core/images/qt-logo.png delete mode 100644 examples/quick/keyinteraction/focus/focus.qml create mode 100644 examples/quick/keyinteraction/images/arrow.png create mode 100644 examples/quick/keyinteraction/images/qt-logo.png diff --git a/examples/quick/keyinteraction/CMakeLists.txt b/examples/quick/keyinteraction/CMakeLists.txt index ffb8c8924a..e338c11024 100644 --- a/examples/quick/keyinteraction/CMakeLists.txt +++ b/examples/quick/keyinteraction/CMakeLists.txt @@ -1,13 +1,9 @@ -# Generated from keyinteraction.pro. - cmake_minimum_required(VERSION 3.16) project(keyinteraction 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") @@ -15,47 +11,36 @@ endif() set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quick/keyinteraction") -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Quick) -find_package(Qt6 COMPONENTS Qml) +find_package(Qt6 COMPONENTS Core Gui Quick Qml) -qt_add_executable(keyinteraction +qt_add_executable(keyinteractionexample WIN32 MACOSX_BUNDLE main.cpp ) -set_target_properties(keyinteraction PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) -target_link_libraries(keyinteraction PUBLIC +target_link_libraries(keyinteractionexample PRIVATE Qt::Core Qt::Gui Qt::Qml Qt::Quick ) - # Resources: -set(keyinteraction_resource_files - "focus/Core/ContextMenu.qml" - "focus/Core/GridMenu.qml" - "focus/Core/ListMenu.qml" - "focus/Core/ListViewDelegate.qml" - "focus/Core/TabMenu.qml" - "focus/Core/images/arrow.png" - "focus/Core/images/qt-logo.png" - "focus/focus.qml" - "keyinteraction.qml" -) - -qt6_add_resources(keyinteraction "keyinteraction" - PREFIX - "/keyinteraction" - FILES - ${keyinteraction_resource_files} +qt_add_qml_module(keyinteractionexample + URI keyinteraction + VERSION 1.0 + QML_FILES + "ContextMenu.qml" + "GridMenu.qml" + "ListMenu.qml" + "ListViewDelegate.qml" + "TabMenu.qml" + "focus.qml" + "keyinteraction.qml" + RESOURCES + "images/arrow.png" + "images/qt-logo.png" ) -install(TARGETS keyinteraction +install(TARGETS keyinteractionexample RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" diff --git a/examples/quick/keyinteraction/ContextMenu.qml b/examples/quick/keyinteraction/ContextMenu.qml new file mode 100644 index 0000000000..66dcdf3fe8 --- /dev/null +++ b/examples/quick/keyinteraction/ContextMenu.qml @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2021 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 + +FocusScope { + id: container + required property Item keyRightTarget + + property bool open: false + + Item { + anchors.fill: parent + + Rectangle { + anchors.fill: parent + color: "#D1DBBD" + focus: true + Keys.onRightPressed: container.keyRightTarget.focus = true + + Text { + anchors { top: parent.top; horizontalCenter: parent.horizontalCenter; margins: 30 } + color: "black" + font.pixelSize: 14 + text: "Context Menu" + } + } + } +} diff --git a/examples/quick/keyinteraction/GridMenu.qml b/examples/quick/keyinteraction/GridMenu.qml new file mode 100644 index 0000000000..4b05785e1d --- /dev/null +++ b/examples/quick/keyinteraction/GridMenu.qml @@ -0,0 +1,122 @@ +/**************************************************************************** +** +** Copyright (C) 2021 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 + +FocusScope { + id: menu + property alias interactive: gridView.interactive + required property Item keyUpTarget + required property Item keyDownTarget + required property Item keyLeftTarget + + Rectangle { + anchors.fill: parent + clip: true + gradient: Gradient { + GradientStop { position: 0.0; color: "#193441" } + GradientStop { position: 1.0; color: Qt.darker("#193441") } + } + + GridView { + id: gridView + anchors.fill: parent; anchors.leftMargin: 20; anchors.rightMargin: 20 + cellWidth: 152; cellHeight: 152 + focus: true + model: 12 + + KeyNavigation.up: menu.keyUpTarget + KeyNavigation.down: menu.keyDownTarget + KeyNavigation.left: menu.keyLeftTarget + + delegate: Item { + id: container + width: GridView.view.cellWidth + height: GridView.view.cellHeight + required property int index + + Rectangle { + id: content + color: "transparent" + antialiasing: true + anchors.fill: parent; anchors.margins: 20; radius: 10 + + Rectangle { color: "#91AA9D"; anchors.fill: parent; anchors.margins: 3; radius: 8; antialiasing: true } + Image { source: "images/qt-logo.png"; anchors.centerIn: parent } + } + + MouseArea { + id: mouseArea + anchors.fill: parent + hoverEnabled: true + + onClicked: { + container.GridView.view.currentIndex = container.index + container.forceActiveFocus() + } + } + + states: State { + name: "active"; when: container.activeFocus + PropertyChanges { + content { + color: "#FCFFF5" + scale: 1.1 + } + } + } + + transitions: Transition { + NumberAnimation { properties: "scale"; duration: 100 } + } + } + } + } +} diff --git a/examples/quick/keyinteraction/ListMenu.qml b/examples/quick/keyinteraction/ListMenu.qml new file mode 100644 index 0000000000..97a37a714b --- /dev/null +++ b/examples/quick/keyinteraction/ListMenu.qml @@ -0,0 +1,119 @@ +/**************************************************************************** +** +** Copyright (C) 2021 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 QtQml +import QtQuick + +FocusScope { + id: menu + clip: true + required property Item keyUpTarget + required property Item keyLeftTarget + + ListView { + id: list1 + y: activeFocus ? 10 : 40; width: parent.width / 3; height: parent.height - 20 + focus: true + KeyNavigation.up: menu.keyUpTarget + KeyNavigation.left: menu.keyLeftTarget + KeyNavigation.right: list2 + model: 10; cacheBuffer: 200 + delegate: ListViewDelegate {} + + Behavior on y { + NumberAnimation { duration: 600; easing.type: Easing.OutQuint } + } + } + + ListView { + id: list2 + y: activeFocus ? 10 : 40; x: parseInt(parent.width / 3); width: parent.width / 3; height: parent.height - 20 + KeyNavigation.up: menu.keyUpTarget + KeyNavigation.left: list1 + KeyNavigation.right: list3 + model: 10; cacheBuffer: 200 + delegate: ListViewDelegate {} + + Behavior on y { + NumberAnimation { duration: 600; easing.type: Easing.OutQuint } + } + } + + ListView { + id: list3 + y: activeFocus ? 10 : 40; x: parseInt(2 * parent.width / 3); width: parent.width / 3; height: parent.height - 20 + KeyNavigation.up: menu.keyUpTarget + KeyNavigation.left: list2 + model: 10; cacheBuffer: 200 + delegate: ListViewDelegate {} + + Behavior on y { + NumberAnimation { duration: 600; easing.type: Easing.OutQuint } + } + } + + Rectangle { width: parent.width; height: 1; color: "#D1DBBD" } + + Rectangle { + y: 1; width: parent.width; height: 10 + gradient: Gradient { + GradientStop { position: 0.0; color: "#3E606F" } + GradientStop { position: 1.0; color: "transparent" } + } + } + + Rectangle { + y: parent.height - 10; width: parent.width; height: 10 + gradient: Gradient { + GradientStop { position: 1.0; color: "#3E606F" } + GradientStop { position: 0.0; color: "transparent" } + } + } +} diff --git a/examples/quick/keyinteraction/ListViewDelegate.qml b/examples/quick/keyinteraction/ListViewDelegate.qml new file mode 100644 index 0000000000..9fe4949282 --- /dev/null +++ b/examples/quick/keyinteraction/ListViewDelegate.qml @@ -0,0 +1,102 @@ +/**************************************************************************** +** +** Copyright (C) 2021 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 + +Item { + id: container + required property int index + + width: ListView.view.width; height: 60; anchors.leftMargin: 10; anchors.rightMargin: 10 + + Rectangle { + id: content + anchors.centerIn: parent; width: container.width - 40; height: container.height - 10 + color: "transparent" + antialiasing: true + radius: 10 + + Rectangle { anchors.fill: parent; anchors.margins: 3; color: "#91AA9D"; antialiasing: true; radius: 8 } + } + + Text { + id: label + anchors.centerIn: content + text: "List element " + (container.index + 1) + color: "#193441" + font.pixelSize: 14 + } + + MouseArea { + id: mouseArea + anchors.fill: parent + hoverEnabled: true + + onClicked: { + container.ListView.view.currentIndex = container.index + container.forceActiveFocus() + } + } + + states: State { + name: "active"; when: container.activeFocus + PropertyChanges { + content { + color: "#FCFFF5" + scale: 1.1 + } + label.font.pixelSize: 16 + } + } + + transitions: Transition { + NumberAnimation { properties: "scale"; duration: 100 } + } +} diff --git a/examples/quick/keyinteraction/TabMenu.qml b/examples/quick/keyinteraction/TabMenu.qml new file mode 100644 index 0000000000..7aa70a7dcb --- /dev/null +++ b/examples/quick/keyinteraction/TabMenu.qml @@ -0,0 +1,118 @@ +/**************************************************************************** +** +** Copyright (C) 2021 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 + +FocusScope { + id: menu + required property Item keyUpTarget + required property Item keyDownTarget + + Rectangle { + anchors.fill: parent + clip: true + gradient: Gradient { + GradientStop { position: 0.0; color: "#193441" } + GradientStop { position: 1.0; color: Qt.darker("#193441") } + } + + Row { + id: tabView + anchors.fill: parent; anchors.leftMargin: 20; anchors.rightMargin: 20 + Repeater { + activeFocusOnTab: false + model: 5 + Item { + id: container + width: 152; height: 152 + activeFocusOnTab: true + focus: true + + KeyNavigation.up: menu.keyUpTarget + KeyNavigation.down: menu.keyDownTarget + + Rectangle { + id: content + color: "transparent" + antialiasing: true + anchors.fill: parent; anchors.margins: 20; radius: 10 + + Rectangle { color: "#91AA9D"; anchors.fill: parent; anchors.margins: 3; radius: 8; antialiasing: true } + Image { source: "images/qt-logo.png"; anchors.centerIn: parent } + } + + MouseArea { + id: mouseArea + anchors.fill: parent + hoverEnabled: true + + onClicked: { + container.forceActiveFocus() + } + } + + states: State { + name: "active"; when: container.activeFocus + PropertyChanges { + content { + color: "#FCFFF5" + scale: 1.1 + } + } + } + + transitions: Transition { + NumberAnimation { properties: "scale"; duration: 100 } + } + } + } + } + } +} diff --git a/examples/quick/keyinteraction/focus.qml b/examples/quick/keyinteraction/focus.qml new file mode 100644 index 0000000000..1eef9b9981 --- /dev/null +++ b/examples/quick/keyinteraction/focus.qml @@ -0,0 +1,187 @@ +/**************************************************************************** +** +** Copyright (C) 2021 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 QtQml +import QtQuick + +Rectangle { + id: window + + width: 800; height: 640 + color: "#3E606F" + + FocusScope { + id: mainView + + width: parent.width; height: parent.height + focus: true + + TabMenu { + id: tabMenu + y: 160; width: parent.width; height: 160 + + keyUpTarget: listMenu + keyDownTarget: gridMenu + + focus: true + activeFocusOnTab: true + + onActiveFocusChanged: { + if (activeFocus) + mainView.state = "showTabViews" + } + } + + GridMenu { + id: gridMenu + y: 320; width: parent.width; height: 320 + activeFocusOnTab: true + + keyUpTarget: tabMenu + keyDownTarget: listMenu + keyLeftTarget: contextMenu + + onActiveFocusChanged: { + if (activeFocus) + mainView.state = "showGridViews" + } + } + + ListMenu { + id: listMenu + y: 640; width: parent.width; height: 320 + activeFocusOnTab: true + + keyUpTarget: gridMenu + keyLeftTarget: contextMenu + + onActiveFocusChanged: { + if (activeFocus) + mainView.state = "showListViews" + } + } + + Rectangle { + id: shade + anchors.fill: parent + color: "black" + opacity: 0 + } + + states: [ + State { + name: "showTabViews" + PropertyChanges { + tabMenu.y: 160 + gridMenu.y: 320 + listMenu.y: 640 + } + }, + + State { + name: "showGridViews" + PropertyChanges { + tabMenu.y: 0 + gridMenu.y: 160 + listMenu.y: 480 + } + }, + + State { + name: "showListViews" + PropertyChanges { + tabMenu.y: -160 + gridMenu.y: 0 + listMenu.y: 320 + } + } + ] + + transitions: Transition { + NumberAnimation { properties: "y"; duration: 600; easing.type: Easing.OutQuint } + } + } + + Image { + source: "images/arrow.png" + rotation: 90 + anchors.verticalCenter: parent.verticalCenter + + MouseArea { + anchors.fill: parent; anchors.margins: -10 + onClicked: contextMenu.focus = true + } + } + + ContextMenu { + keyRightTarget: mainView + id: contextMenu + x: -265 + width: 260 + height: parent.height + } + + states: State { + name: "contextMenuOpen" + when: !mainView.activeFocus + PropertyChanges { + contextMenu { + x: 0 + open: true + } + mainView.x: 130 + shade.opacity: 0.25 + } + } + + transitions: Transition { + NumberAnimation { properties: "x,opacity"; duration: 600; easing.type: Easing.OutQuint } + } +} diff --git a/examples/quick/keyinteraction/focus/Core/ContextMenu.qml b/examples/quick/keyinteraction/focus/Core/ContextMenu.qml deleted file mode 100644 index 31b5e1b83d..0000000000 --- a/examples/quick/keyinteraction/focus/Core/ContextMenu.qml +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** 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 2.1 - -FocusScope { - id: container - required property Item keyRightTarget - - property bool open: false - - Item { - anchors.fill: parent - - Rectangle { - anchors.fill: parent - color: "#D1DBBD" - focus: true - Keys.onRightPressed: container.keyRightTarget.focus = true - - Text { - anchors { top: parent.top; horizontalCenter: parent.horizontalCenter; margins: 30 } - color: "black" - font.pixelSize: 14 - text: "Context Menu" - } - } - } -} diff --git a/examples/quick/keyinteraction/focus/Core/GridMenu.qml b/examples/quick/keyinteraction/focus/Core/GridMenu.qml deleted file mode 100644 index 78d6654957..0000000000 --- a/examples/quick/keyinteraction/focus/Core/GridMenu.qml +++ /dev/null @@ -1,117 +0,0 @@ -/**************************************************************************** -** -** 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 2.1 - -FocusScope { - id: menu - property alias interactive: gridView.interactive - required property Item keyUpTarget - required property Item keyDownTarget - required property Item keyLeftTarget - - Rectangle { - anchors.fill: parent - clip: true - gradient: Gradient { - GradientStop { position: 0.0; color: "#193441" } - GradientStop { position: 1.0; color: Qt.darker("#193441") } - } - - GridView { - id: gridView - anchors.fill: parent; anchors.leftMargin: 20; anchors.rightMargin: 20 - cellWidth: 152; cellHeight: 152 - focus: true - model: 12 - - KeyNavigation.up: menu.keyUpTarget - KeyNavigation.down: menu.keyDownTarget - KeyNavigation.left: menu.keyLeftTarget - - delegate: Item { - id: container - width: GridView.view.cellWidth - height: GridView.view.cellHeight - required property int index - - Rectangle { - id: content - color: "transparent" - antialiasing: true - anchors.fill: parent; anchors.margins: 20; radius: 10 - - Rectangle { color: "#91AA9D"; anchors.fill: parent; anchors.margins: 3; radius: 8; antialiasing: true } - Image { source: "images/qt-logo.png"; anchors.centerIn: parent } - } - - MouseArea { - id: mouseArea - anchors.fill: parent - hoverEnabled: true - - onClicked: { - container.GridView.view.currentIndex = container.index - container.forceActiveFocus() - } - } - - states: State { - name: "active"; when: container.activeFocus - PropertyChanges { target: content; color: "#FCFFF5"; scale: 1.1 } - } - - transitions: Transition { - NumberAnimation { properties: "scale"; duration: 100 } - } - } - } - } -} diff --git a/examples/quick/keyinteraction/focus/Core/ListMenu.qml b/examples/quick/keyinteraction/focus/Core/ListMenu.qml deleted file mode 100644 index 694ae3cac6..0000000000 --- a/examples/quick/keyinteraction/focus/Core/ListMenu.qml +++ /dev/null @@ -1,119 +0,0 @@ -/**************************************************************************** -** -** 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 QtQml 2.1 -import QtQuick 2.1 - -FocusScope { - id: menu - clip: true - required property Item keyUpTarget - required property Item keyLeftTarget - - ListView { - id: list1 - y: activeFocus ? 10 : 40; width: parent.width / 3; height: parent.height - 20 - focus: true - KeyNavigation.up: menu.keyUpTarget - KeyNavigation.left: menu.keyLeftTarget - KeyNavigation.right: list2 - model: 10; cacheBuffer: 200 - delegate: ListViewDelegate {} - - Behavior on y { - NumberAnimation { duration: 600; easing.type: Easing.OutQuint } - } - } - - ListView { - id: list2 - y: activeFocus ? 10 : 40; x: parseInt(parent.width / 3); width: parent.width / 3; height: parent.height - 20 - KeyNavigation.up: menu.keyUpTarget - KeyNavigation.left: list1 - KeyNavigation.right: list3 - model: 10; cacheBuffer: 200 - delegate: ListViewDelegate {} - - Behavior on y { - NumberAnimation { duration: 600; easing.type: Easing.OutQuint } - } - } - - ListView { - id: list3 - y: activeFocus ? 10 : 40; x: parseInt(2 * parent.width / 3); width: parent.width / 3; height: parent.height - 20 - KeyNavigation.up: menu.keyUpTarget - KeyNavigation.left: list2 - model: 10; cacheBuffer: 200 - delegate: ListViewDelegate {} - - Behavior on y { - NumberAnimation { duration: 600; easing.type: Easing.OutQuint } - } - } - - Rectangle { width: parent.width; height: 1; color: "#D1DBBD" } - - Rectangle { - y: 1; width: parent.width; height: 10 - gradient: Gradient { - GradientStop { position: 0.0; color: "#3E606F" } - GradientStop { position: 1.0; color: "transparent" } - } - } - - Rectangle { - y: parent.height - 10; width: parent.width; height: 10 - gradient: Gradient { - GradientStop { position: 1.0; color: "#3E606F" } - GradientStop { position: 0.0; color: "transparent" } - } - } -} diff --git a/examples/quick/keyinteraction/focus/Core/ListViewDelegate.qml b/examples/quick/keyinteraction/focus/Core/ListViewDelegate.qml deleted file mode 100644 index 5a2957eab0..0000000000 --- a/examples/quick/keyinteraction/focus/Core/ListViewDelegate.qml +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************** -** -** 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 2.1 - -Item { - id: container - required property int index - - width: ListView.view.width; height: 60; anchors.leftMargin: 10; anchors.rightMargin: 10 - - Rectangle { - id: content - anchors.centerIn: parent; width: container.width - 40; height: container.height - 10 - color: "transparent" - antialiasing: true - radius: 10 - - Rectangle { anchors.fill: parent; anchors.margins: 3; color: "#91AA9D"; antialiasing: true; radius: 8 } - } - - Text { - id: label - anchors.centerIn: content - text: "List element " + (container.index + 1) - color: "#193441" - font.pixelSize: 14 - } - - MouseArea { - id: mouseArea - anchors.fill: parent - hoverEnabled: true - - onClicked: { - container.ListView.view.currentIndex = container.index - container.forceActiveFocus() - } - } - - states: State { - name: "active"; when: container.activeFocus - PropertyChanges { target: content; color: "#FCFFF5"; scale: 1.1 } - PropertyChanges { target: label; font.pixelSize: 16 } - } - - transitions: Transition { - NumberAnimation { properties: "scale"; duration: 100 } - } -} diff --git a/examples/quick/keyinteraction/focus/Core/TabMenu.qml b/examples/quick/keyinteraction/focus/Core/TabMenu.qml deleted file mode 100644 index 11b3d005c3..0000000000 --- a/examples/quick/keyinteraction/focus/Core/TabMenu.qml +++ /dev/null @@ -1,113 +0,0 @@ -/**************************************************************************** -** -** 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 2.1 - -FocusScope { - id: menu - required property Item keyUpTarget - required property Item keyDownTarget - - Rectangle { - anchors.fill: parent - clip: true - gradient: Gradient { - GradientStop { position: 0.0; color: "#193441" } - GradientStop { position: 1.0; color: Qt.darker("#193441") } - } - - Row { - id: tabView - anchors.fill: parent; anchors.leftMargin: 20; anchors.rightMargin: 20 - Repeater { - activeFocusOnTab: false - model: 5 - Item { - id: container - width: 152; height: 152 - activeFocusOnTab: true - focus: true - - KeyNavigation.up: menu.keyUpTarget - KeyNavigation.down: menu.keyDownTarget - - Rectangle { - id: content - color: "transparent" - antialiasing: true - anchors.fill: parent; anchors.margins: 20; radius: 10 - - Rectangle { color: "#91AA9D"; anchors.fill: parent; anchors.margins: 3; radius: 8; antialiasing: true } - Image { source: "images/qt-logo.png"; anchors.centerIn: parent } - } - - MouseArea { - id: mouseArea - anchors.fill: parent - hoverEnabled: true - - onClicked: { - container.forceActiveFocus() - } - } - - states: State { - name: "active"; when: container.activeFocus - PropertyChanges { target: content; color: "#FCFFF5"; scale: 1.1 } - } - - transitions: Transition { - NumberAnimation { properties: "scale"; duration: 100 } - } - } - } - } - } -} diff --git a/examples/quick/keyinteraction/focus/Core/images/arrow.png b/examples/quick/keyinteraction/focus/Core/images/arrow.png deleted file mode 100644 index 20ee200f5f..0000000000 Binary files a/examples/quick/keyinteraction/focus/Core/images/arrow.png and /dev/null differ diff --git a/examples/quick/keyinteraction/focus/Core/images/qt-logo.png b/examples/quick/keyinteraction/focus/Core/images/qt-logo.png deleted file mode 100644 index 14ddf2a028..0000000000 Binary files a/examples/quick/keyinteraction/focus/Core/images/qt-logo.png and /dev/null differ diff --git a/examples/quick/keyinteraction/focus/focus.qml b/examples/quick/keyinteraction/focus/focus.qml deleted file mode 100644 index 9db9ab48bc..0000000000 --- a/examples/quick/keyinteraction/focus/focus.qml +++ /dev/null @@ -1,177 +0,0 @@ -/**************************************************************************** -** -** 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 QtQml 2.1 -import QtQuick 2.1 -import "Core" - -Rectangle { - id: window - - width: 800; height: 640 - color: "#3E606F" - - FocusScope { - id: mainView - - width: parent.width; height: parent.height - focus: true - - TabMenu { - id: tabMenu - y: 160; width: parent.width; height: 160 - - keyUpTarget: listMenu - keyDownTarget: gridMenu - - focus: true - activeFocusOnTab: true - - onActiveFocusChanged: { - if (activeFocus) - mainView.state = "showTabViews" - } - } - - GridMenu { - id: gridMenu - y: 320; width: parent.width; height: 320 - activeFocusOnTab: true - - keyUpTarget: tabMenu - keyDownTarget: listMenu - keyLeftTarget: contextMenu - - onActiveFocusChanged: { - if (activeFocus) - mainView.state = "showGridViews" - } - } - - ListMenu { - id: listMenu - y: 640; width: parent.width; height: 320 - activeFocusOnTab: true - - keyUpTarget: gridMenu - keyLeftTarget: contextMenu - - onActiveFocusChanged: { - if (activeFocus) - mainView.state = "showListViews" - } - } - - Rectangle { - id: shade - anchors.fill: parent - color: "black" - opacity: 0 - } - - states: [ - State { - name: "showTabViews" - PropertyChanges { target: tabMenu; y: 160 } - PropertyChanges { target: gridMenu; y: 320 } - PropertyChanges { target: listMenu; y: 640 } - }, - - State { - name: "showGridViews" - PropertyChanges { target: tabMenu; y: 0 } - PropertyChanges { target: gridMenu; y: 160 } - PropertyChanges { target: listMenu; y: 480 } - }, - - State { - name: "showListViews" - PropertyChanges { target: tabMenu; y: -160 } - PropertyChanges { target: gridMenu; y: 0 } - PropertyChanges { target: listMenu; y: 320 } - } - ] - - transitions: Transition { - NumberAnimation { properties: "y"; duration: 600; easing.type: Easing.OutQuint } - } - } - - Image { - source: "Core/images/arrow.png" - rotation: 90 - anchors.verticalCenter: parent.verticalCenter - - MouseArea { - anchors.fill: parent; anchors.margins: -10 - onClicked: contextMenu.focus = true - } - } - - ContextMenu { - keyRightTarget: mainView - id: contextMenu - x: -265 - width: 260 - height: parent.height - } - - states: State { - name: "contextMenuOpen" - when: !mainView.activeFocus - PropertyChanges { target: contextMenu; x: 0; open: true } - PropertyChanges { target: mainView; x: 130 } - PropertyChanges { target: shade; opacity: 0.25 } - } - - transitions: Transition { - NumberAnimation { properties: "x,opacity"; duration: 600; easing.type: Easing.OutQuint } - } -} diff --git a/examples/quick/keyinteraction/images/arrow.png b/examples/quick/keyinteraction/images/arrow.png new file mode 100644 index 0000000000..20ee200f5f Binary files /dev/null and b/examples/quick/keyinteraction/images/arrow.png differ diff --git a/examples/quick/keyinteraction/images/qt-logo.png b/examples/quick/keyinteraction/images/qt-logo.png new file mode 100644 index 0000000000..14ddf2a028 Binary files /dev/null and b/examples/quick/keyinteraction/images/qt-logo.png differ diff --git a/examples/quick/keyinteraction/keyinteraction.qml b/examples/quick/keyinteraction/keyinteraction.qml index 7fa3078803..c79ba7217e 100644 --- a/examples/quick/keyinteraction/keyinteraction.qml +++ b/examples/quick/keyinteraction/keyinteraction.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. @@ -48,10 +48,10 @@ ** ****************************************************************************/ -import QtQuick 2.1 +import QtQuick Loader {//Just loader, since there's only one. - source: "focus/focus.qml" + source: "focus.qml" focus: true // Exception to the standard sizing, because this is primarily a desktop // example and it benefits from being able to see everything at once. diff --git a/examples/quick/keyinteraction/keyinteraction.qrc b/examples/quick/keyinteraction/keyinteraction.qrc index c719654835..8738ef9826 100644 --- a/examples/quick/keyinteraction/keyinteraction.qrc +++ b/examples/quick/keyinteraction/keyinteraction.qrc @@ -1,13 +1,13 @@ keyinteraction.qml - focus/focus.qml - focus/Core/images/arrow.png - focus/Core/images/qt-logo.png - focus/Core/ContextMenu.qml - focus/Core/GridMenu.qml - focus/Core/ListMenu.qml - focus/Core/ListViewDelegate.qml - focus/Core/TabMenu.qml + focus.qml + ContextMenu.qml + GridMenu.qml + ListMenu.qml + ListViewDelegate.qml + TabMenu.qml + images/arrow.png + images/qt-logo.png -- cgit v1.2.3