2022-08-24 07:25:36 +00:00
|
|
|
// Copyright (C) 2022 The Qt Company Ltd.
|
2022-05-13 13:12:05 +00:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
2015-12-14 18:06:53 +00:00
|
|
|
|
2023-02-22 08:53:32 +00:00
|
|
|
pragma ComponentBehavior: Bound
|
|
|
|
|
2022-08-24 07:25:36 +00:00
|
|
|
import QtCore
|
2020-03-26 16:01:51 +00:00
|
|
|
import QtQuick
|
|
|
|
import QtQuick.Layouts
|
|
|
|
import QtQuick.Controls
|
2015-12-14 18:06:53 +00:00
|
|
|
|
2020-08-27 11:28:07 +00:00
|
|
|
import "." as App
|
|
|
|
|
2015-12-14 18:06:53 +00:00
|
|
|
ApplicationWindow {
|
|
|
|
id: window
|
|
|
|
width: 360
|
|
|
|
height: 520
|
|
|
|
visible: true
|
2023-02-23 13:17:52 +00:00
|
|
|
title: qsTr("Qt Quick Controls")
|
2015-12-14 18:06:53 +00:00
|
|
|
|
2023-02-22 08:53:32 +00:00
|
|
|
//! [orientation]
|
2023-07-08 08:15:09 +00:00
|
|
|
readonly property bool portraitMode: !orientationCheckBox.checked || window.width < window.height
|
2023-02-22 08:53:32 +00:00
|
|
|
//! [orientation]
|
|
|
|
|
2020-01-28 12:59:11 +00:00
|
|
|
function help() {
|
|
|
|
let displayingControl = listView.currentIndex !== -1
|
|
|
|
let currentControlName = displayingControl
|
|
|
|
? listView.model.get(listView.currentIndex).title.toLowerCase() : ""
|
2022-06-02 15:47:20 +00:00
|
|
|
let url = "https://doc.qt.io/qt-6/"
|
2020-01-28 12:59:11 +00:00
|
|
|
+ (displayingControl
|
|
|
|
? "qml-qtquick-controls2-" + currentControlName + ".html"
|
2020-01-09 10:33:12 +00:00
|
|
|
: "qtquick-controls2-qmlmodule.html");
|
|
|
|
Qt.openUrlExternally(url)
|
|
|
|
}
|
|
|
|
|
2021-03-18 15:04:41 +00:00
|
|
|
required property var builtInStyles
|
|
|
|
|
2015-12-14 18:06:53 +00:00
|
|
|
Settings {
|
|
|
|
id: settings
|
2021-03-18 15:04:41 +00:00
|
|
|
property string style
|
2015-12-14 18:06:53 +00:00
|
|
|
}
|
|
|
|
|
2016-10-21 21:31:02 +00:00
|
|
|
Shortcut {
|
2017-04-06 07:45:46 +00:00
|
|
|
sequences: ["Esc", "Back"]
|
2016-10-21 21:31:02 +00:00
|
|
|
enabled: stackView.depth > 1
|
2019-08-26 18:06:14 +00:00
|
|
|
onActivated: navigateBackAction.trigger()
|
|
|
|
}
|
|
|
|
|
2020-01-09 10:33:12 +00:00
|
|
|
Shortcut {
|
2025-03-31 11:15:33 +00:00
|
|
|
sequences: [StandardKey.HelpContents]
|
2023-02-22 08:53:32 +00:00
|
|
|
onActivated: window.help()
|
2020-01-09 10:33:12 +00:00
|
|
|
}
|
|
|
|
|
2019-08-26 18:06:14 +00:00
|
|
|
Action {
|
|
|
|
id: navigateBackAction
|
|
|
|
icon.name: stackView.depth > 1 ? "back" : "drawer"
|
|
|
|
onTriggered: {
|
|
|
|
if (stackView.depth > 1) {
|
|
|
|
stackView.pop()
|
|
|
|
listView.currentIndex = -1
|
|
|
|
} else {
|
|
|
|
drawer.open()
|
|
|
|
}
|
2016-10-21 21:31:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-26 18:06:14 +00:00
|
|
|
Action {
|
|
|
|
id: optionsMenuAction
|
|
|
|
icon.name: "menu"
|
|
|
|
onTriggered: optionsMenu.open()
|
2017-04-06 09:16:55 +00:00
|
|
|
}
|
|
|
|
|
2020-08-27 11:28:07 +00:00
|
|
|
header: App.ToolBar {
|
2015-12-14 18:06:53 +00:00
|
|
|
RowLayout {
|
|
|
|
spacing: 20
|
|
|
|
anchors.fill: parent
|
2023-02-22 08:53:32 +00:00
|
|
|
anchors.leftMargin: !window.portraitMode ? drawer.width : undefined
|
2015-12-14 18:06:53 +00:00
|
|
|
|
|
|
|
ToolButton {
|
2019-08-26 18:06:14 +00:00
|
|
|
action: navigateBackAction
|
2023-02-22 08:53:32 +00:00
|
|
|
visible: window.portraitMode
|
2015-12-14 18:06:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Label {
|
|
|
|
id: titleLabel
|
2023-02-23 13:17:52 +00:00
|
|
|
text: listView.currentItem ? (listView.currentItem as ItemDelegate).text : qsTr("Gallery")
|
2015-12-14 18:06:53 +00:00
|
|
|
font.pixelSize: 20
|
|
|
|
elide: Label.ElideRight
|
|
|
|
horizontalAlignment: Qt.AlignHCenter
|
|
|
|
verticalAlignment: Qt.AlignVCenter
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
|
|
|
|
ToolButton {
|
2019-08-26 18:06:14 +00:00
|
|
|
action: optionsMenuAction
|
2016-01-22 14:20:04 +00:00
|
|
|
|
|
|
|
Menu {
|
|
|
|
id: optionsMenu
|
|
|
|
x: parent.width - width
|
2016-01-25 10:49:24 +00:00
|
|
|
transformOrigin: Menu.TopRight
|
2016-01-22 14:20:04 +00:00
|
|
|
|
2019-08-26 18:06:14 +00:00
|
|
|
Action {
|
2023-02-23 13:17:52 +00:00
|
|
|
text: qsTr("Settings")
|
2016-05-21 08:17:39 +00:00
|
|
|
onTriggered: settingsDialog.open()
|
2016-01-22 14:20:04 +00:00
|
|
|
}
|
2020-01-09 10:33:12 +00:00
|
|
|
Action {
|
2023-02-23 13:17:52 +00:00
|
|
|
text: qsTr("Help")
|
2023-02-22 08:53:32 +00:00
|
|
|
onTriggered: window.help()
|
2020-01-09 10:33:12 +00:00
|
|
|
}
|
2019-08-26 18:06:14 +00:00
|
|
|
Action {
|
2023-02-23 13:17:52 +00:00
|
|
|
text: qsTr("About")
|
2016-01-22 14:20:04 +00:00
|
|
|
onTriggered: aboutDialog.open()
|
|
|
|
}
|
|
|
|
}
|
2015-12-14 18:06:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Drawer {
|
|
|
|
id: drawer
|
2023-02-22 08:53:32 +00:00
|
|
|
|
2016-02-26 12:52:56 +00:00
|
|
|
width: Math.min(window.width, window.height) / 3 * 2
|
|
|
|
height: window.height
|
2023-02-22 08:53:32 +00:00
|
|
|
modal: window.portraitMode
|
|
|
|
interactive: window.portraitMode ? (stackView.depth === 1) : false
|
|
|
|
position: window.portraitMode ? 0 : 1
|
|
|
|
visible: !window.portraitMode
|
2015-12-14 18:06:53 +00:00
|
|
|
|
2016-02-26 12:52:56 +00:00
|
|
|
ListView {
|
|
|
|
id: listView
|
2016-09-29 17:52:55 +00:00
|
|
|
|
|
|
|
focus: true
|
2016-02-26 12:52:56 +00:00
|
|
|
currentIndex: -1
|
|
|
|
anchors.fill: parent
|
2015-12-14 18:06:53 +00:00
|
|
|
|
2016-02-26 12:52:56 +00:00
|
|
|
model: ListModel {
|
2023-02-23 13:17:52 +00:00
|
|
|
ListElement { title: qsTr("BusyIndicator"); source: "qrc:/pages/BusyIndicatorPage.qml" }
|
|
|
|
ListElement { title: qsTr("Button"); source: "qrc:/pages/ButtonPage.qml" }
|
|
|
|
ListElement { title: qsTr("CheckBox"); source: "qrc:/pages/CheckBoxPage.qml" }
|
|
|
|
ListElement { title: qsTr("ComboBox"); source: "qrc:/pages/ComboBoxPage.qml" }
|
|
|
|
ListElement { title: qsTr("DelayButton"); source: "qrc:/pages/DelayButtonPage.qml" }
|
|
|
|
ListElement { title: qsTr("Dial"); source: "qrc:/pages/DialPage.qml" }
|
|
|
|
ListElement { title: qsTr("Dialog"); source: "qrc:/pages/DialogPage.qml" }
|
|
|
|
ListElement { title: qsTr("Delegates"); source: "qrc:/pages/DelegatePage.qml" }
|
|
|
|
ListElement { title: qsTr("Frame"); source: "qrc:/pages/FramePage.qml" }
|
|
|
|
ListElement { title: qsTr("GroupBox"); source: "qrc:/pages/GroupBoxPage.qml" }
|
|
|
|
ListElement { title: qsTr("PageIndicator"); source: "qrc:/pages/PageIndicatorPage.qml" }
|
|
|
|
ListElement { title: qsTr("ProgressBar"); source: "qrc:/pages/ProgressBarPage.qml" }
|
|
|
|
ListElement { title: qsTr("RadioButton"); source: "qrc:/pages/RadioButtonPage.qml" }
|
|
|
|
ListElement { title: qsTr("RangeSlider"); source: "qrc:/pages/RangeSliderPage.qml" }
|
|
|
|
ListElement { title: qsTr("ScrollBar"); source: "qrc:/pages/ScrollBarPage.qml" }
|
|
|
|
ListElement { title: qsTr("ScrollIndicator"); source: "qrc:/pages/ScrollIndicatorPage.qml" }
|
2024-12-30 15:14:56 +00:00
|
|
|
ListElement { title: qsTr("SearchField"); source: "qrc:/pages/SearchFieldPage.qml" }
|
2023-02-23 13:17:52 +00:00
|
|
|
ListElement { title: qsTr("Slider"); source: "qrc:/pages/SliderPage.qml" }
|
|
|
|
ListElement { title: qsTr("SpinBox"); source: "qrc:/pages/SpinBoxPage.qml" }
|
|
|
|
ListElement { title: qsTr("StackView"); source: "qrc:/pages/StackViewPage.qml" }
|
|
|
|
ListElement { title: qsTr("SwipeView"); source: "qrc:/pages/SwipeViewPage.qml" }
|
|
|
|
ListElement { title: qsTr("Switch"); source: "qrc:/pages/SwitchPage.qml" }
|
|
|
|
ListElement { title: qsTr("TabBar"); source: "qrc:/pages/TabBarPage.qml" }
|
|
|
|
ListElement { title: qsTr("TextArea"); source: "qrc:/pages/TextAreaPage.qml" }
|
|
|
|
ListElement { title: qsTr("TextField"); source: "qrc:/pages/TextFieldPage.qml" }
|
|
|
|
ListElement { title: qsTr("ToolTip"); source: "qrc:/pages/ToolTipPage.qml" }
|
|
|
|
ListElement { title: qsTr("Tumbler"); source: "qrc:/pages/TumblerPage.qml" }
|
2015-12-14 18:06:53 +00:00
|
|
|
}
|
2016-02-26 12:52:56 +00:00
|
|
|
|
2023-02-22 08:53:32 +00:00
|
|
|
delegate: ItemDelegate {
|
|
|
|
id: delegateItem
|
|
|
|
width: ListView.view.width
|
|
|
|
text: title
|
|
|
|
highlighted: ListView.isCurrentItem
|
|
|
|
|
|
|
|
required property int index
|
|
|
|
required property var model
|
|
|
|
required property string title
|
|
|
|
required property string source
|
|
|
|
|
|
|
|
onClicked: {
|
2025-01-28 09:03:16 +00:00
|
|
|
if (stackView.depth > 1)
|
|
|
|
return
|
|
|
|
|
2023-02-22 08:53:32 +00:00
|
|
|
listView.currentIndex = index
|
|
|
|
stackView.push(source)
|
|
|
|
if (window.portraitMode)
|
|
|
|
drawer.close()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-26 12:52:56 +00:00
|
|
|
ScrollIndicator.vertical: ScrollIndicator { }
|
2015-12-14 18:06:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StackView {
|
|
|
|
id: stackView
|
2023-02-22 08:53:32 +00:00
|
|
|
|
2015-12-14 18:06:53 +00:00
|
|
|
anchors.fill: parent
|
2023-02-22 08:53:32 +00:00
|
|
|
anchors.leftMargin: !window.portraitMode ? drawer.width : undefined
|
2015-12-14 18:06:53 +00:00
|
|
|
|
|
|
|
initialItem: Pane {
|
|
|
|
id: pane
|
|
|
|
|
|
|
|
Image {
|
|
|
|
id: logo
|
|
|
|
width: pane.availableWidth / 2
|
|
|
|
height: pane.availableHeight / 2
|
|
|
|
anchors.centerIn: parent
|
|
|
|
anchors.verticalCenterOffset: -50
|
|
|
|
fillMode: Image.PreserveAspectFit
|
2016-10-20 09:04:25 +00:00
|
|
|
source: "images/qt-logo.png"
|
2015-12-14 18:06:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Label {
|
2023-02-23 13:17:52 +00:00
|
|
|
text: qsTr("Qt Quick Controls provides a set of controls that can be used to build complete interfaces in Qt Quick.")
|
2015-12-14 18:06:53 +00:00
|
|
|
anchors.margins: 20
|
|
|
|
anchors.top: logo.bottom
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.bottom: arrow.top
|
|
|
|
horizontalAlignment: Label.AlignHCenter
|
|
|
|
verticalAlignment: Label.AlignVCenter
|
|
|
|
wrapMode: Label.Wrap
|
|
|
|
}
|
|
|
|
|
|
|
|
Image {
|
|
|
|
id: arrow
|
2016-10-20 09:04:25 +00:00
|
|
|
source: "images/arrow.png"
|
2015-12-14 18:06:53 +00:00
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.bottom: parent.bottom
|
2023-02-22 08:53:32 +00:00
|
|
|
visible: window.portraitMode
|
2015-12-14 18:06:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-15 20:04:24 +00:00
|
|
|
Dialog {
|
2016-05-21 08:17:39 +00:00
|
|
|
id: settingsDialog
|
2016-07-15 14:02:47 +00:00
|
|
|
x: Math.round((window.width - width) / 2)
|
|
|
|
y: Math.round(window.height / 6)
|
2015-12-14 18:06:53 +00:00
|
|
|
modal: true
|
|
|
|
focus: true
|
2023-02-23 13:17:52 +00:00
|
|
|
title: qsTr("Settings")
|
2015-12-14 18:06:53 +00:00
|
|
|
|
2016-06-15 20:04:24 +00:00
|
|
|
standardButtons: Dialog.Ok | Dialog.Cancel
|
|
|
|
onAccepted: {
|
|
|
|
settings.style = styleBox.displayText
|
2025-05-23 08:23:27 +00:00
|
|
|
GalleryConfig.disabled = disableControlsCheckBox.checked
|
2016-06-15 20:04:24 +00:00
|
|
|
settingsDialog.close()
|
|
|
|
}
|
|
|
|
onRejected: {
|
|
|
|
styleBox.currentIndex = styleBox.styleIndex
|
|
|
|
settingsDialog.close()
|
|
|
|
}
|
|
|
|
|
2016-01-22 11:10:12 +00:00
|
|
|
contentItem: ColumnLayout {
|
|
|
|
id: settingsColumn
|
|
|
|
spacing: 20
|
2015-12-14 18:06:53 +00:00
|
|
|
|
2016-01-22 11:10:12 +00:00
|
|
|
RowLayout {
|
|
|
|
spacing: 10
|
2015-12-14 18:06:53 +00:00
|
|
|
|
|
|
|
Label {
|
2023-02-23 13:17:52 +00:00
|
|
|
text: qsTr("Style:")
|
2015-12-14 18:06:53 +00:00
|
|
|
}
|
|
|
|
|
2016-01-22 11:10:12 +00:00
|
|
|
ComboBox {
|
|
|
|
id: styleBox
|
|
|
|
property int styleIndex: -1
|
2021-03-18 15:04:41 +00:00
|
|
|
model: window.builtInStyles
|
2016-01-22 11:10:12 +00:00
|
|
|
Component.onCompleted: {
|
2016-03-15 14:32:54 +00:00
|
|
|
styleIndex = find(settings.style, Qt.MatchFixedString)
|
2016-01-22 11:10:12 +00:00
|
|
|
if (styleIndex !== -1)
|
|
|
|
currentIndex = styleIndex
|
2015-12-14 18:06:53 +00:00
|
|
|
}
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
2016-01-22 11:10:12 +00:00
|
|
|
}
|
|
|
|
|
2024-05-07 15:38:48 +00:00
|
|
|
RowLayout {
|
|
|
|
id: colorSchemes
|
|
|
|
// Some Qt Quick styles prioritize the respective design system guidelines
|
|
|
|
// over the system palette.
|
2025-03-26 12:51:11 +00:00
|
|
|
enabled: ["FluentWinUI3", "Fusion", "iOS", "Basic"].includes(styleBox.currentText)
|
2024-05-07 15:38:48 +00:00
|
|
|
CheckBox {
|
|
|
|
id: autoColorScheme
|
|
|
|
checked: true
|
|
|
|
text: qsTr("Auto")
|
|
|
|
}
|
|
|
|
CheckBox {
|
|
|
|
id: darkColorScheme
|
|
|
|
text: qsTr("Dark Mode")
|
|
|
|
}
|
|
|
|
CheckBox {
|
|
|
|
id: lightColorScheme
|
|
|
|
text: qsTr("Light Mode")
|
|
|
|
}
|
|
|
|
ButtonGroup {
|
|
|
|
exclusive: true
|
|
|
|
buttons: colorSchemes.children
|
|
|
|
onCheckedButtonChanged: {
|
|
|
|
let scheme;
|
|
|
|
switch (checkedButton) {
|
|
|
|
case autoColorScheme:
|
|
|
|
scheme = Qt.Unknown
|
|
|
|
break;
|
|
|
|
case darkColorScheme:
|
|
|
|
scheme = Qt.Dark
|
|
|
|
break;
|
|
|
|
case lightColorScheme:
|
|
|
|
scheme = Qt.Light
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
Qt.styleHints.colorScheme = scheme
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-08 08:15:09 +00:00
|
|
|
CheckBox {
|
|
|
|
id: orientationCheckBox
|
|
|
|
text: qsTr("Enable Landscape")
|
|
|
|
checked: false
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
|
2025-05-23 08:23:27 +00:00
|
|
|
CheckBox {
|
|
|
|
id: disableControlsCheckBox
|
|
|
|
checked: GalleryConfig.disabled
|
|
|
|
text: qsTr("Disable Controls")
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
|
2016-01-22 11:10:12 +00:00
|
|
|
Label {
|
2023-02-23 13:17:52 +00:00
|
|
|
text: qsTr("Restart required")
|
2016-01-28 10:26:16 +00:00
|
|
|
color: "#e41e25"
|
2016-01-22 11:10:12 +00:00
|
|
|
opacity: styleBox.currentIndex !== styleBox.styleIndex ? 1.0 : 0.0
|
|
|
|
horizontalAlignment: Label.AlignHCenter
|
|
|
|
verticalAlignment: Label.AlignVCenter
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
}
|
2015-12-14 18:06:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-15 20:04:24 +00:00
|
|
|
Dialog {
|
2015-12-14 18:06:53 +00:00
|
|
|
id: aboutDialog
|
|
|
|
modal: true
|
|
|
|
focus: true
|
2023-02-23 13:17:52 +00:00
|
|
|
title: qsTr("About")
|
2016-01-22 11:10:12 +00:00
|
|
|
x: (window.width - width) / 2
|
2016-01-23 13:16:22 +00:00
|
|
|
y: window.height / 6
|
2016-01-22 11:10:12 +00:00
|
|
|
width: Math.min(window.width, window.height) / 3 * 2
|
2016-01-23 13:16:22 +00:00
|
|
|
contentHeight: aboutColumn.height
|
2015-12-14 18:06:53 +00:00
|
|
|
|
2016-01-23 13:16:22 +00:00
|
|
|
Column {
|
2016-01-22 11:10:12 +00:00
|
|
|
id: aboutColumn
|
|
|
|
spacing: 20
|
2015-12-14 18:06:53 +00:00
|
|
|
|
2016-01-22 11:10:12 +00:00
|
|
|
Label {
|
2016-01-23 13:16:22 +00:00
|
|
|
width: aboutDialog.availableWidth
|
2023-02-23 13:17:52 +00:00
|
|
|
text: qsTr("The Qt Quick Controls module delivers the next generation user interface controls based on Qt Quick.")
|
2016-01-22 11:10:12 +00:00
|
|
|
wrapMode: Label.Wrap
|
|
|
|
font.pixelSize: 12
|
|
|
|
}
|
2015-12-14 18:06:53 +00:00
|
|
|
|
2016-01-22 11:10:12 +00:00
|
|
|
Label {
|
2016-01-23 13:16:22 +00:00
|
|
|
width: aboutDialog.availableWidth
|
2023-02-23 13:17:52 +00:00
|
|
|
text: qsTr("In comparison to Qt Quick Controls 1, Qt Quick Controls "
|
|
|
|
+ "are an order of magnitude simpler, lighter, and faster.")
|
2016-01-22 11:10:12 +00:00
|
|
|
wrapMode: Label.Wrap
|
|
|
|
font.pixelSize: 12
|
2015-12-14 18:06:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|