Gallery example: Add disable option
A "disable" option has been introduced. This allows users to view the disabled state of all controls. Pick-to: 6.10 Change-Id: If2fa5b673ac9db7acf805203046d111dda13f435 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
This commit is contained in:
parent
ac6cdf8286
commit
2a1aff4aa0
|
@ -12,6 +12,8 @@ qt_add_executable(galleryexample WIN32 MACOSX_BUNDLE
|
||||||
gallery.cpp
|
gallery.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
set_source_files_properties(pages/GalleryConfig.qml PROPERTIES QT_QML_SINGLETON_TYPE TRUE)
|
||||||
|
|
||||||
qt_add_qml_module(galleryexample
|
qt_add_qml_module(galleryexample
|
||||||
URI gallery
|
URI gallery
|
||||||
NO_RESOURCE_TARGET_PATH
|
NO_RESOURCE_TARGET_PATH
|
||||||
|
@ -28,6 +30,7 @@ qt_add_qml_module(galleryexample
|
||||||
"pages/DialPage.qml"
|
"pages/DialPage.qml"
|
||||||
"pages/DialogPage.qml"
|
"pages/DialogPage.qml"
|
||||||
"pages/FramePage.qml"
|
"pages/FramePage.qml"
|
||||||
|
"pages/GalleryConfig.qml"
|
||||||
"pages/GroupBoxPage.qml"
|
"pages/GroupBoxPage.qml"
|
||||||
"pages/PageIndicatorPage.qml"
|
"pages/PageIndicatorPage.qml"
|
||||||
"pages/ProgressBarPage.qml"
|
"pages/ProgressBarPage.qml"
|
||||||
|
|
|
@ -240,6 +240,7 @@ ApplicationWindow {
|
||||||
standardButtons: Dialog.Ok | Dialog.Cancel
|
standardButtons: Dialog.Ok | Dialog.Cancel
|
||||||
onAccepted: {
|
onAccepted: {
|
||||||
settings.style = styleBox.displayText
|
settings.style = styleBox.displayText
|
||||||
|
GalleryConfig.disabled = disableControlsCheckBox.checked
|
||||||
settingsDialog.close()
|
settingsDialog.close()
|
||||||
}
|
}
|
||||||
onRejected: {
|
onRejected: {
|
||||||
|
@ -317,6 +318,13 @@ ApplicationWindow {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CheckBox {
|
||||||
|
id: disableControlsCheckBox
|
||||||
|
checked: GalleryConfig.disabled
|
||||||
|
text: qsTr("Disable Controls")
|
||||||
|
Layout.fillWidth: true
|
||||||
|
}
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
text: qsTr("Restart required")
|
text: qsTr("Restart required")
|
||||||
color: "#e41e25"
|
color: "#e41e25"
|
||||||
|
|
|
@ -26,19 +26,16 @@ ScrollablePage {
|
||||||
|
|
||||||
Button {
|
Button {
|
||||||
text: qsTr("First")
|
text: qsTr("First")
|
||||||
|
enabled: !GalleryConfig.disabled
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
}
|
}
|
||||||
Button {
|
Button {
|
||||||
id: button
|
id: button
|
||||||
text: qsTr("Second")
|
text: qsTr("Second")
|
||||||
|
enabled: !GalleryConfig.disabled
|
||||||
highlighted: true
|
highlighted: true
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
}
|
}
|
||||||
Button {
|
|
||||||
text: qsTr("Third")
|
|
||||||
enabled: false
|
|
||||||
Layout.fillWidth: true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,17 +24,14 @@ ScrollablePage {
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
|
||||||
CheckBox {
|
CheckBox {
|
||||||
|
enabled: !GalleryConfig.disabled
|
||||||
text: qsTr("First")
|
text: qsTr("First")
|
||||||
checked: true
|
checked: true
|
||||||
}
|
}
|
||||||
CheckBox {
|
CheckBox {
|
||||||
|
enabled: !GalleryConfig.disabled
|
||||||
text: qsTr("Second")
|
text: qsTr("Second")
|
||||||
}
|
}
|
||||||
CheckBox {
|
|
||||||
text: qsTr("Third")
|
|
||||||
checked: true
|
|
||||||
enabled: false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ ScrollablePage {
|
||||||
}
|
}
|
||||||
|
|
||||||
ComboBox {
|
ComboBox {
|
||||||
|
enabled: !GalleryConfig.disabled
|
||||||
model: [qsTr("First"), qsTr("Second"), qsTr("Third")]
|
model: [qsTr("First"), qsTr("Second"), qsTr("Third")]
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
}
|
}
|
||||||
|
@ -35,6 +36,7 @@ ScrollablePage {
|
||||||
ComboBox {
|
ComboBox {
|
||||||
id: comboBox
|
id: comboBox
|
||||||
|
|
||||||
|
enabled: !GalleryConfig.disabled
|
||||||
editable: true
|
editable: true
|
||||||
model: ListModel {
|
model: ListModel {
|
||||||
ListElement { text: qsTr("Banana") }
|
ListElement { text: qsTr("Banana") }
|
||||||
|
|
|
@ -20,6 +20,7 @@ ScrollablePage {
|
||||||
}
|
}
|
||||||
|
|
||||||
DelayButton {
|
DelayButton {
|
||||||
|
enabled: !GalleryConfig.disabled
|
||||||
text: qsTr("DelayButton")
|
text: qsTr("DelayButton")
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,6 +85,7 @@ Pane {
|
||||||
id: itemDelegateComponent
|
id: itemDelegateComponent
|
||||||
|
|
||||||
ItemDelegate {
|
ItemDelegate {
|
||||||
|
enabled: !GalleryConfig.disabled
|
||||||
text: delegateLoader.value
|
text: delegateLoader.value
|
||||||
width: delegateLoader.width
|
width: delegateLoader.width
|
||||||
}
|
}
|
||||||
|
@ -95,6 +96,7 @@ Pane {
|
||||||
|
|
||||||
SwipeDelegate {
|
SwipeDelegate {
|
||||||
id: swipeDelegate
|
id: swipeDelegate
|
||||||
|
enabled: !GalleryConfig.disabled
|
||||||
text: delegateLoader.value
|
text: delegateLoader.value
|
||||||
width: delegateLoader.width
|
width: delegateLoader.width
|
||||||
|
|
||||||
|
@ -152,6 +154,7 @@ Pane {
|
||||||
id: checkDelegateComponent
|
id: checkDelegateComponent
|
||||||
|
|
||||||
CheckDelegate {
|
CheckDelegate {
|
||||||
|
enabled: !GalleryConfig.disabled
|
||||||
text: delegateLoader.value
|
text: delegateLoader.value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -160,6 +163,7 @@ Pane {
|
||||||
id: radioDelegateComponent
|
id: radioDelegateComponent
|
||||||
|
|
||||||
RadioDelegate {
|
RadioDelegate {
|
||||||
|
enabled: !GalleryConfig.disabled
|
||||||
text: delegateLoader.value
|
text: delegateLoader.value
|
||||||
|
|
||||||
ButtonGroup.group: radioButtonGroup
|
ButtonGroup.group: radioButtonGroup
|
||||||
|
@ -170,6 +174,7 @@ Pane {
|
||||||
id: switchDelegateComponent
|
id: switchDelegateComponent
|
||||||
|
|
||||||
SwitchDelegate {
|
SwitchDelegate {
|
||||||
|
enabled: !GalleryConfig.disabled
|
||||||
text: delegateLoader.value
|
text: delegateLoader.value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ ScrollablePage {
|
||||||
}
|
}
|
||||||
|
|
||||||
Dial {
|
Dial {
|
||||||
|
enabled: !GalleryConfig.disabled
|
||||||
value: 0.5
|
value: 0.5
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@ ScrollablePage {
|
||||||
|
|
||||||
Dialog {
|
Dialog {
|
||||||
id: messageDialog
|
id: messageDialog
|
||||||
|
enabled: !GalleryConfig.disabled
|
||||||
|
|
||||||
x: (parent.width - width) / 2
|
x: (parent.width - width) / 2
|
||||||
y: (parent.height - height) / 2
|
y: (parent.height - height) / 2
|
||||||
|
@ -51,6 +52,7 @@ ScrollablePage {
|
||||||
|
|
||||||
Dialog {
|
Dialog {
|
||||||
id: confirmationDialog
|
id: confirmationDialog
|
||||||
|
enabled: !GalleryConfig.disabled
|
||||||
|
|
||||||
x: (parent.width - width) / 2
|
x: (parent.width - width) / 2
|
||||||
y: (parent.height - height) / 2
|
y: (parent.height - height) / 2
|
||||||
|
@ -82,6 +84,7 @@ ScrollablePage {
|
||||||
|
|
||||||
Dialog {
|
Dialog {
|
||||||
id: contentDialog
|
id: contentDialog
|
||||||
|
enabled: !GalleryConfig.disabled
|
||||||
|
|
||||||
x: (parent.width - width) / 2
|
x: (parent.width - width) / 2
|
||||||
y: (parent.height - height) / 2
|
y: (parent.height - height) / 2
|
||||||
|
@ -144,6 +147,7 @@ ScrollablePage {
|
||||||
|
|
||||||
Dialog {
|
Dialog {
|
||||||
id: inputDialog
|
id: inputDialog
|
||||||
|
enabled: !GalleryConfig.disabled
|
||||||
|
|
||||||
x: (parent.width - width) / 2
|
x: (parent.width - width) / 2
|
||||||
y: (parent.height - height) / 2
|
y: (parent.height - height) / 2
|
||||||
|
|
|
@ -21,6 +21,7 @@ ScrollablePage {
|
||||||
}
|
}
|
||||||
|
|
||||||
Frame {
|
Frame {
|
||||||
|
enabled: !GalleryConfig.disabled
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
// Copyright (C) 2025 The Qt Company Ltd.
|
||||||
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
||||||
|
|
||||||
|
pragma Singleton
|
||||||
|
import QtQuick
|
||||||
|
|
||||||
|
QtObject {
|
||||||
|
property bool disabled: false
|
||||||
|
}
|
|
@ -21,6 +21,7 @@ ScrollablePage {
|
||||||
}
|
}
|
||||||
|
|
||||||
GroupBox {
|
GroupBox {
|
||||||
|
enabled: !GalleryConfig.disabled
|
||||||
title: qsTr("Title")
|
title: qsTr("Title")
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
|
||||||
|
|
|
@ -25,10 +25,12 @@ ScrollablePage {
|
||||||
|
|
||||||
RadioButton {
|
RadioButton {
|
||||||
text: qsTr("First")
|
text: qsTr("First")
|
||||||
|
enabled: !GalleryConfig.disabled
|
||||||
}
|
}
|
||||||
RadioButton {
|
RadioButton {
|
||||||
text: qsTr("Second")
|
text: qsTr("Second")
|
||||||
checked: true
|
checked: true
|
||||||
|
enabled: !GalleryConfig.disabled
|
||||||
}
|
}
|
||||||
RadioButton {
|
RadioButton {
|
||||||
text: qsTr("Third")
|
text: qsTr("Third")
|
||||||
|
|
|
@ -19,13 +19,14 @@ ScrollablePage {
|
||||||
}
|
}
|
||||||
|
|
||||||
RangeSlider {
|
RangeSlider {
|
||||||
id: slider
|
enabled: !GalleryConfig.disabled
|
||||||
first.value: 0.25
|
first.value: 0.25
|
||||||
second.value: 0.75
|
second.value: 0.75
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
}
|
}
|
||||||
|
|
||||||
RangeSlider {
|
RangeSlider {
|
||||||
|
enabled: !GalleryConfig.disabled
|
||||||
orientation: Qt.Vertical
|
orientation: Qt.Vertical
|
||||||
first.value: 0.25
|
first.value: 0.25
|
||||||
second.value: 0.75
|
second.value: 0.75
|
||||||
|
|
|
@ -6,7 +6,7 @@ import QtQuick.Controls
|
||||||
|
|
||||||
Flickable {
|
Flickable {
|
||||||
id: flickable
|
id: flickable
|
||||||
|
enabled: !GalleryConfig.disabled
|
||||||
contentHeight: pane.height
|
contentHeight: pane.height
|
||||||
|
|
||||||
Pane {
|
Pane {
|
||||||
|
|
|
@ -6,7 +6,7 @@ import QtQuick.Controls
|
||||||
|
|
||||||
Flickable {
|
Flickable {
|
||||||
id: flickable
|
id: flickable
|
||||||
|
enabled: !GalleryConfig.disabled
|
||||||
contentHeight: pane.height
|
contentHeight: pane.height
|
||||||
|
|
||||||
Pane {
|
Pane {
|
||||||
|
|
|
@ -19,12 +19,13 @@ ScrollablePage {
|
||||||
}
|
}
|
||||||
|
|
||||||
Slider {
|
Slider {
|
||||||
id: slider
|
enabled: !GalleryConfig.disabled
|
||||||
value: 0.5
|
value: 0.5
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
}
|
}
|
||||||
|
|
||||||
Slider {
|
Slider {
|
||||||
|
enabled: !GalleryConfig.disabled
|
||||||
orientation: Qt.Vertical
|
orientation: Qt.Vertical
|
||||||
value: 0.5
|
value: 0.5
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
|
|
@ -20,7 +20,7 @@ ScrollablePage {
|
||||||
}
|
}
|
||||||
|
|
||||||
SpinBox {
|
SpinBox {
|
||||||
id: box
|
enabled: !GalleryConfig.disabled
|
||||||
value: 50
|
value: 50
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
editable: true
|
editable: true
|
||||||
|
|
|
@ -9,6 +9,7 @@ import QtQuick.Controls
|
||||||
StackView {
|
StackView {
|
||||||
id: stackView
|
id: stackView
|
||||||
initialItem: page
|
initialItem: page
|
||||||
|
enabled: !GalleryConfig.disabled
|
||||||
|
|
||||||
Component {
|
Component {
|
||||||
id: page
|
id: page
|
||||||
|
|
|
@ -11,6 +11,7 @@ Pane {
|
||||||
id: view
|
id: view
|
||||||
currentIndex: 1
|
currentIndex: 1
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
enabled: !GalleryConfig.disabled
|
||||||
|
|
||||||
Repeater {
|
Repeater {
|
||||||
model: 3
|
model: 3
|
||||||
|
|
|
@ -24,16 +24,14 @@ ScrollablePage {
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
|
||||||
Switch {
|
Switch {
|
||||||
|
enabled: !GalleryConfig.disabled
|
||||||
text: qsTr("First")
|
text: qsTr("First")
|
||||||
}
|
}
|
||||||
Switch {
|
Switch {
|
||||||
|
enabled: !GalleryConfig.disabled
|
||||||
text: qsTr("Second")
|
text: qsTr("Second")
|
||||||
checked: true
|
checked: true
|
||||||
}
|
}
|
||||||
Switch {
|
|
||||||
text: qsTr("Third")
|
|
||||||
enabled: false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import QtQuick.Controls
|
||||||
|
|
||||||
Page {
|
Page {
|
||||||
id: page
|
id: page
|
||||||
|
enabled: !GalleryConfig.disabled
|
||||||
|
|
||||||
SwipeView {
|
SwipeView {
|
||||||
id: swipeView
|
id: swipeView
|
||||||
|
|
|
@ -19,6 +19,7 @@ ScrollablePage {
|
||||||
}
|
}
|
||||||
|
|
||||||
TextArea {
|
TextArea {
|
||||||
|
enabled: !GalleryConfig.disabled
|
||||||
width: page.availableWidth / 3
|
width: page.availableWidth / 3
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ ScrollablePage {
|
||||||
}
|
}
|
||||||
|
|
||||||
TextField {
|
TextField {
|
||||||
id: field
|
enabled: !GalleryConfig.disabled
|
||||||
placeholderText: qsTr("TextField")
|
placeholderText: qsTr("TextField")
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ ScrollablePage {
|
||||||
}
|
}
|
||||||
|
|
||||||
Tumbler {
|
Tumbler {
|
||||||
|
enabled: !GalleryConfig.disabled
|
||||||
model: 10
|
model: 10
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue