diff options
Diffstat (limited to 'tests/manual/quickcontrols/material')
-rw-r--r-- | tests/manual/quickcontrols/material/CMakeLists.txt | 34 | ||||
-rw-r--r-- | tests/manual/quickcontrols/material/Constants.qml | 11 | ||||
-rw-r--r-- | tests/manual/quickcontrols/material/material.cpp | 32 | ||||
-rw-r--r-- | tests/manual/quickcontrols/material/material.qml | 126 | ||||
-rw-r--r-- | tests/manual/quickcontrols/material/pages/ButtonPage.qml | 125 | ||||
-rw-r--r-- | tests/manual/quickcontrols/material/pages/DelayButtonPage.qml | 73 | ||||
-rw-r--r-- | tests/manual/quickcontrols/material/pages/RoundButtonPage.qml | 93 | ||||
-rw-r--r-- | tests/manual/quickcontrols/material/qmldir | 2 |
8 files changed, 496 insertions, 0 deletions
diff --git a/tests/manual/quickcontrols/material/CMakeLists.txt b/tests/manual/quickcontrols/material/CMakeLists.txt new file mode 100644 index 0000000000..1cd3a98d0f --- /dev/null +++ b/tests/manual/quickcontrols/material/CMakeLists.txt @@ -0,0 +1,34 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +if (NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) + cmake_minimum_required(VERSION 3.16) + project(material LANGUAGES C CXX ASM) + find_package(Qt6BuildInternals COMPONENTS STANDALONE_TEST) +endif() + +qt_internal_add_manual_test(material + GUI + SOURCES + material.cpp + LIBRARIES + Qt::Gui + Qt::Qml + Qt::QuickControls2 +) + +set(qmake_immediate_resource_files + "material.qml" + "Constants.qml" + "pages/ButtonPage.qml" + "pages/DelayButtonPage.qml" + "pages/RoundButtonPage.qml" + "qmldir" +) + +qt_internal_add_resource(material "qmake_immediate" + PREFIX + "/" + FILES + ${qmake_immediate_resource_files} +) diff --git a/tests/manual/quickcontrols/material/Constants.qml b/tests/manual/quickcontrols/material/Constants.qml new file mode 100644 index 0000000000..51b9b6ff23 --- /dev/null +++ b/tests/manual/quickcontrols/material/Constants.qml @@ -0,0 +1,11 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause +pragma Singleton + +import QtQml + +QtObject { + readonly property url iconSource: "qrc:/qt-project.org/imports/QtQuick/Controls/Basic/images/check.png" + readonly property int pageTopPadding: 20 + readonly property int spacing: 40 +} diff --git a/tests/manual/quickcontrols/material/material.cpp b/tests/manual/quickcontrols/material/material.cpp new file mode 100644 index 0000000000..2e257b0902 --- /dev/null +++ b/tests/manual/quickcontrols/material/material.cpp @@ -0,0 +1,32 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause +#include <QGuiApplication> +#include <QQmlApplicationEngine> +#include <QSettings> + +int main(int argc, char *argv[]) +{ + QGuiApplication::setApplicationName("material"); + QGuiApplication::setOrganizationName("QtProject"); + + QGuiApplication app(argc, argv); + + const char *variantEnvVar = "QT_QUICK_CONTROLS_MATERIAL_VARIANT"; + if (!qEnvironmentVariableIsSet(variantEnvVar)) { + QSettings settings; + const char *variant = "variant"; + if (settings.contains(variant)) + qputenv(variantEnvVar, settings.value(variant).toByteArray()); + } + + QQmlApplicationEngine engine; + const QUrl url(QStringLiteral("qrc:/material.qml")); + QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, + &app, [url](QObject *obj, const QUrl &objUrl) { + if (!obj && url == objUrl) + QCoreApplication::exit(-1); + }, Qt::QueuedConnection); + engine.load(url); + + return app.exec(); +} diff --git a/tests/manual/quickcontrols/material/material.qml b/tests/manual/quickcontrols/material/material.qml new file mode 100644 index 0000000000..720ff0a5ec --- /dev/null +++ b/tests/manual/quickcontrols/material/material.qml @@ -0,0 +1,126 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause +import QtCore +import QtQuick +import QtQuick.Controls.Material +import QtQuick.Layouts + +ApplicationWindow { + id: window + title: "Material" + width: screen.desktopAvailableWidth * 0.8 + height: screen.desktopAvailableHeight * 0.8 + visible: true + + Material.theme: settings.theme + + Settings { + id: settings + + property alias windowX: window.x + property alias windowY: window.y + property alias windowWidth: window.width + property alias windowHeight: window.height + + property int theme: darkThemeSwitch.checked ? Material.Dark : Material.Light + property string variant: denseSwitch.checked ? "Dense" : "Normal" + + property alias currentControlIndex: listView.currentIndex + } + + Shortcut { + sequences: ["Esc", "Back"] + onActivated: openDrawerAction.trigger() + } + + Shortcut { + sequence: "Ctrl+Q" + onActivated: Qt.quit() + } + + Action { + id: openDrawerAction + text: "Controls" + onTriggered: drawer.open() + } + + header: ToolBar { + RowLayout { + spacing: 20 + anchors.fill: parent + + Material.theme: Material.Dark + + ToolButton { + action: openDrawerAction + } + + Label { + id: titleLabel + text: listView.currentItem ? listView.currentItem.text : "Material" + font.pixelSize: 20 + elide: Label.ElideRight + horizontalAlignment: Qt.AlignHCenter + verticalAlignment: Qt.AlignVCenter + Layout.fillWidth: true + } + + Item { + Layout.fillWidth: true + } + + Switch { + id: darkThemeSwitch + text: "Dark" + checked: settings.theme === Material.Dark + } + + Switch { + id: denseSwitch + text: "Dense" + checked: settings.variant === "Dense" + + ToolTip.text: "Requires restart" + ToolTip.visible: hovered + } + } + } + + Drawer { + id: drawer + width: window.width / 3 + height: window.height + interactive: stackView.depth === 1 + + ListView { + id: listView + focus: true + currentIndex: settings.currentControlIndex + anchors.fill: parent + model: ["Button", "DelayButton", "RoundButton"] + delegate: ItemDelegate { + width: listView.width + text: modelData + highlighted: ListView.isCurrentItem + onClicked: listView.currentIndex = index + } + + ScrollIndicator.vertical: ScrollIndicator { } + + // Need to wait until our count is non-zero before setting a default currentIndex. + // This also allows us to use an alias for the settings property. + Component.onCompleted: if (currentIndex === -1) currentIndex = 0 + + onCurrentIndexChanged: { + if (currentIndex >= 0 && currentIndex < count) + stackView.replace("qrc:/pages/" + model[currentIndex] + "Page.qml") + drawer.close() + } + } + } + + StackView { + id: stackView + anchors.fill: parent + } +} diff --git a/tests/manual/quickcontrols/material/pages/ButtonPage.qml b/tests/manual/quickcontrols/material/pages/ButtonPage.qml new file mode 100644 index 0000000000..3f861e7a70 --- /dev/null +++ b/tests/manual/quickcontrols/material/pages/ButtonPage.qml @@ -0,0 +1,125 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause +import QtQuick +import QtQuick.Controls.Material +import QtQuick.Layouts + +import ".." + +Page { + topPadding: 20 + + property var backgroundColor + + header: RowLayout { + CheckBox { + id: iconCheckBox + text: "Icon" + } + + CheckBox { + id: disabledCheckBox + text: "Disabled" + } + + Item { + Layout.fillWidth: true + } + } + + component RoundedScaleLayout: ColumnLayout { + id: roundedScaleLayout + enabled: !disabledCheckBox.checked + + property bool allowFlat + property var backgroundColor: undefined + property var foregroundColor: undefined + + property int contentLeftMargin + property int contentRightMargin + + RowLayout { + enabled: roundedScaleLayout.allowFlat + + CheckBox { + id: flatCheckBox + text: "Flat" + + Layout.leftMargin: roundedScaleLayout.contentLeftMargin + } + } + + RowLayout { + spacing: Constants.spacing + + Repeater { + id: roundedScaleRepeater + model: ListModel { + ListElement { displayName: "NotRounded"; roundedScale: Material.NotRounded } + ListElement { displayName: "ExtraSmall"; roundedScale: Material.ExtraSmallScale } + ListElement { displayName: "Small"; roundedScale: Material.SmallScale } + ListElement { displayName: "Medium"; roundedScale: Material.MediumScale } + ListElement { displayName: "Large"; roundedScale: Material.LargeScale } + ListElement { displayName: "ExtraLarge"; roundedScale: Material.ExtraLargeScale } + ListElement { displayName: "Full"; roundedScale: Material.FullScale } + } + + // Workaround for QTBUG-98859. + delegate: Component { + ColumnLayout { + id: scaleLayout + spacing: Constants.spacing + + required property int index + required property string displayName + required property int roundedScale + + Layout.leftMargin: index === 0 ? roundedScaleLayout.contentLeftMargin : 0 + Layout.rightMargin: index === roundedScaleRepeater.count - 1 ? roundedScaleLayout.contentRightMargin : 0 + Layout.bottomMargin: Constants.spacing + + Label { + text: scaleLayout.displayName + + Layout.alignment: Qt.AlignHCenter + } + + Repeater { + model: 13 + + Button { + text: modelData + flat: flatCheckBox.checked + icon.source: iconCheckBox.checked ? "qrc:/qt-project.org/imports/QtQuick/Controls/Basic/images/check.png" : "" + + Material.background: roundedScaleLayout.backgroundColor + Material.foreground: roundedScaleLayout.foregroundColor + Material.elevation: modelData + Material.roundedScale: scaleLayout.roundedScale + } + } + } + } + } + } + } + + ScrollView { + anchors.fill: parent + + RowLayout { + spacing: Constants.spacing + + RoundedScaleLayout { + contentLeftMargin: Constants.spacing + allowFlat: true + } + + RoundedScaleLayout { + backgroundColor: Material.Teal + foregroundColor: "white" + contentRightMargin: Constants.spacing + } + } + } +} diff --git a/tests/manual/quickcontrols/material/pages/DelayButtonPage.qml b/tests/manual/quickcontrols/material/pages/DelayButtonPage.qml new file mode 100644 index 0000000000..ee9c12f446 --- /dev/null +++ b/tests/manual/quickcontrols/material/pages/DelayButtonPage.qml @@ -0,0 +1,73 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause +import QtQuick +import QtQuick.Controls.Material +import QtQuick.Layouts + +import ".." + +Page { + topPadding: 20 + + property var backgroundColor + + header: RowLayout { + CheckBox { + id: disabledCheckBox + text: "Disabled" + } + + Item { + Layout.fillWidth: true + } + } + + component ElevationLayout: ColumnLayout { + id: elevationLayout + enabled: !disabledCheckBox.checked + + property var backgroundColor: undefined + property var foregroundColor: undefined + + property int contentLeftMargin + property int contentRightMargin + + ColumnLayout { + spacing: Constants.spacing + + Repeater { + model: 13 + + DelayButton { + text: modelData + + Material.background: elevationLayout.backgroundColor + Material.foreground: elevationLayout.foregroundColor + Material.elevation: modelData + + Layout.leftMargin: elevationLayout.contentLeftMargin + } + } + + Layout.bottomMargin: Constants.spacing + } + } + + ScrollView { + anchors.fill: parent + + RowLayout { + spacing: Constants.spacing + + ElevationLayout { + contentLeftMargin: Constants.spacing + } + + ElevationLayout { + backgroundColor: Material.Teal + foregroundColor: "white" + contentRightMargin: Constants.spacing + } + } + } +} diff --git a/tests/manual/quickcontrols/material/pages/RoundButtonPage.qml b/tests/manual/quickcontrols/material/pages/RoundButtonPage.qml new file mode 100644 index 0000000000..1fbcbf2e45 --- /dev/null +++ b/tests/manual/quickcontrols/material/pages/RoundButtonPage.qml @@ -0,0 +1,93 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause +import QtQuick +import QtQuick.Controls.Material +import QtQuick.Layouts + +import ".." + +Page { + topPadding: 20 + + property var backgroundColor + + header: RowLayout { + CheckBox { + id: iconCheckBox + text: "Icon" + } + + CheckBox { + id: disabledCheckBox + text: "Disabled" + } + + Item { + Layout.fillWidth: true + } + } + + component ElevationLayout: ColumnLayout { + id: elevationLayout + enabled: !disabledCheckBox.checked + + property bool allowFlat + property var backgroundColor: undefined + property var foregroundColor: undefined + + property int contentLeftMargin + property int contentRightMargin + + RowLayout { + enabled: elevationLayout.allowFlat + + CheckBox { + id: flatCheckBox + text: "Flat" + + Layout.leftMargin: elevationLayout.contentLeftMargin + } + } + + ColumnLayout { + spacing: Constants.spacing + + Repeater { + model: 13 + + RoundButton { + text: iconCheckBox.checked ? "" : modelData + flat: flatCheckBox.checked + icon.source: iconCheckBox.checked ? Constants.iconSource : "" + + Material.background: elevationLayout.backgroundColor + Material.foreground: elevationLayout.foregroundColor + Material.elevation: modelData + + Layout.leftMargin: elevationLayout.contentLeftMargin + } + } + + Layout.bottomMargin: Constants.spacing + } + } + + ScrollView { + anchors.fill: parent + + RowLayout { + spacing: Constants.spacing + + ElevationLayout { + contentLeftMargin: Constants.spacing + allowFlat: true + } + + ElevationLayout { + backgroundColor: Material.Teal + foregroundColor: "white" + contentRightMargin: Constants.spacing + } + } + } +} diff --git a/tests/manual/quickcontrols/material/qmldir b/tests/manual/quickcontrols/material/qmldir new file mode 100644 index 0000000000..e56896abb6 --- /dev/null +++ b/tests/manual/quickcontrols/material/qmldir @@ -0,0 +1,2 @@ +module MaterialHelper +singleton Constants 1.0 Constants.qml |