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
|
||||
)
|
||||
|
||||
set_source_files_properties(pages/GalleryConfig.qml PROPERTIES QT_QML_SINGLETON_TYPE TRUE)
|
||||
|
||||
qt_add_qml_module(galleryexample
|
||||
URI gallery
|
||||
NO_RESOURCE_TARGET_PATH
|
||||
|
@ -28,6 +30,7 @@ qt_add_qml_module(galleryexample
|
|||
"pages/DialPage.qml"
|
||||
"pages/DialogPage.qml"
|
||||
"pages/FramePage.qml"
|
||||
"pages/GalleryConfig.qml"
|
||||
"pages/GroupBoxPage.qml"
|
||||
"pages/PageIndicatorPage.qml"
|
||||
"pages/ProgressBarPage.qml"
|
||||
|
|
|
@ -240,6 +240,7 @@ ApplicationWindow {
|
|||
standardButtons: Dialog.Ok | Dialog.Cancel
|
||||
onAccepted: {
|
||||
settings.style = styleBox.displayText
|
||||
GalleryConfig.disabled = disableControlsCheckBox.checked
|
||||
settingsDialog.close()
|
||||
}
|
||||
onRejected: {
|
||||
|
@ -317,6 +318,13 @@ ApplicationWindow {
|
|||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
CheckBox {
|
||||
id: disableControlsCheckBox
|
||||
checked: GalleryConfig.disabled
|
||||
text: qsTr("Disable Controls")
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
Label {
|
||||
text: qsTr("Restart required")
|
||||
color: "#e41e25"
|
||||
|
|
|
@ -26,19 +26,16 @@ ScrollablePage {
|
|||
|
||||
Button {
|
||||
text: qsTr("First")
|
||||
enabled: !GalleryConfig.disabled
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
Button {
|
||||
id: button
|
||||
text: qsTr("Second")
|
||||
enabled: !GalleryConfig.disabled
|
||||
highlighted: true
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
Button {
|
||||
text: qsTr("Third")
|
||||
enabled: false
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,17 +24,14 @@ ScrollablePage {
|
|||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
|
||||
CheckBox {
|
||||
enabled: !GalleryConfig.disabled
|
||||
text: qsTr("First")
|
||||
checked: true
|
||||
}
|
||||
CheckBox {
|
||||
enabled: !GalleryConfig.disabled
|
||||
text: qsTr("Second")
|
||||
}
|
||||
CheckBox {
|
||||
text: qsTr("Third")
|
||||
checked: true
|
||||
enabled: false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ ScrollablePage {
|
|||
}
|
||||
|
||||
ComboBox {
|
||||
enabled: !GalleryConfig.disabled
|
||||
model: [qsTr("First"), qsTr("Second"), qsTr("Third")]
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
|
@ -35,6 +36,7 @@ ScrollablePage {
|
|||
ComboBox {
|
||||
id: comboBox
|
||||
|
||||
enabled: !GalleryConfig.disabled
|
||||
editable: true
|
||||
model: ListModel {
|
||||
ListElement { text: qsTr("Banana") }
|
||||
|
|
|
@ -20,6 +20,7 @@ ScrollablePage {
|
|||
}
|
||||
|
||||
DelayButton {
|
||||
enabled: !GalleryConfig.disabled
|
||||
text: qsTr("DelayButton")
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
|
|
|
@ -85,6 +85,7 @@ Pane {
|
|||
id: itemDelegateComponent
|
||||
|
||||
ItemDelegate {
|
||||
enabled: !GalleryConfig.disabled
|
||||
text: delegateLoader.value
|
||||
width: delegateLoader.width
|
||||
}
|
||||
|
@ -95,6 +96,7 @@ Pane {
|
|||
|
||||
SwipeDelegate {
|
||||
id: swipeDelegate
|
||||
enabled: !GalleryConfig.disabled
|
||||
text: delegateLoader.value
|
||||
width: delegateLoader.width
|
||||
|
||||
|
@ -152,6 +154,7 @@ Pane {
|
|||
id: checkDelegateComponent
|
||||
|
||||
CheckDelegate {
|
||||
enabled: !GalleryConfig.disabled
|
||||
text: delegateLoader.value
|
||||
}
|
||||
}
|
||||
|
@ -160,6 +163,7 @@ Pane {
|
|||
id: radioDelegateComponent
|
||||
|
||||
RadioDelegate {
|
||||
enabled: !GalleryConfig.disabled
|
||||
text: delegateLoader.value
|
||||
|
||||
ButtonGroup.group: radioButtonGroup
|
||||
|
@ -170,6 +174,7 @@ Pane {
|
|||
id: switchDelegateComponent
|
||||
|
||||
SwitchDelegate {
|
||||
enabled: !GalleryConfig.disabled
|
||||
text: delegateLoader.value
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ ScrollablePage {
|
|||
}
|
||||
|
||||
Dial {
|
||||
enabled: !GalleryConfig.disabled
|
||||
value: 0.5
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ ScrollablePage {
|
|||
|
||||
Dialog {
|
||||
id: messageDialog
|
||||
enabled: !GalleryConfig.disabled
|
||||
|
||||
x: (parent.width - width) / 2
|
||||
y: (parent.height - height) / 2
|
||||
|
@ -51,6 +52,7 @@ ScrollablePage {
|
|||
|
||||
Dialog {
|
||||
id: confirmationDialog
|
||||
enabled: !GalleryConfig.disabled
|
||||
|
||||
x: (parent.width - width) / 2
|
||||
y: (parent.height - height) / 2
|
||||
|
@ -82,6 +84,7 @@ ScrollablePage {
|
|||
|
||||
Dialog {
|
||||
id: contentDialog
|
||||
enabled: !GalleryConfig.disabled
|
||||
|
||||
x: (parent.width - width) / 2
|
||||
y: (parent.height - height) / 2
|
||||
|
@ -144,6 +147,7 @@ ScrollablePage {
|
|||
|
||||
Dialog {
|
||||
id: inputDialog
|
||||
enabled: !GalleryConfig.disabled
|
||||
|
||||
x: (parent.width - width) / 2
|
||||
y: (parent.height - height) / 2
|
||||
|
|
|
@ -21,6 +21,7 @@ ScrollablePage {
|
|||
}
|
||||
|
||||
Frame {
|
||||
enabled: !GalleryConfig.disabled
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
|
||||
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 {
|
||||
enabled: !GalleryConfig.disabled
|
||||
title: qsTr("Title")
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
|
||||
|
|
|
@ -25,10 +25,12 @@ ScrollablePage {
|
|||
|
||||
RadioButton {
|
||||
text: qsTr("First")
|
||||
enabled: !GalleryConfig.disabled
|
||||
}
|
||||
RadioButton {
|
||||
text: qsTr("Second")
|
||||
checked: true
|
||||
enabled: !GalleryConfig.disabled
|
||||
}
|
||||
RadioButton {
|
||||
text: qsTr("Third")
|
||||
|
|
|
@ -19,13 +19,14 @@ ScrollablePage {
|
|||
}
|
||||
|
||||
RangeSlider {
|
||||
id: slider
|
||||
enabled: !GalleryConfig.disabled
|
||||
first.value: 0.25
|
||||
second.value: 0.75
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
|
||||
RangeSlider {
|
||||
enabled: !GalleryConfig.disabled
|
||||
orientation: Qt.Vertical
|
||||
first.value: 0.25
|
||||
second.value: 0.75
|
||||
|
|
|
@ -6,7 +6,7 @@ import QtQuick.Controls
|
|||
|
||||
Flickable {
|
||||
id: flickable
|
||||
|
||||
enabled: !GalleryConfig.disabled
|
||||
contentHeight: pane.height
|
||||
|
||||
Pane {
|
||||
|
|
|
@ -6,7 +6,7 @@ import QtQuick.Controls
|
|||
|
||||
Flickable {
|
||||
id: flickable
|
||||
|
||||
enabled: !GalleryConfig.disabled
|
||||
contentHeight: pane.height
|
||||
|
||||
Pane {
|
||||
|
|
|
@ -19,12 +19,13 @@ ScrollablePage {
|
|||
}
|
||||
|
||||
Slider {
|
||||
id: slider
|
||||
enabled: !GalleryConfig.disabled
|
||||
value: 0.5
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
|
||||
Slider {
|
||||
enabled: !GalleryConfig.disabled
|
||||
orientation: Qt.Vertical
|
||||
value: 0.5
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
|
|
|
@ -20,7 +20,7 @@ ScrollablePage {
|
|||
}
|
||||
|
||||
SpinBox {
|
||||
id: box
|
||||
enabled: !GalleryConfig.disabled
|
||||
value: 50
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
editable: true
|
||||
|
|
|
@ -9,6 +9,7 @@ import QtQuick.Controls
|
|||
StackView {
|
||||
id: stackView
|
||||
initialItem: page
|
||||
enabled: !GalleryConfig.disabled
|
||||
|
||||
Component {
|
||||
id: page
|
||||
|
|
|
@ -11,6 +11,7 @@ Pane {
|
|||
id: view
|
||||
currentIndex: 1
|
||||
anchors.fill: parent
|
||||
enabled: !GalleryConfig.disabled
|
||||
|
||||
Repeater {
|
||||
model: 3
|
||||
|
|
|
@ -24,16 +24,14 @@ ScrollablePage {
|
|||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
|
||||
Switch {
|
||||
enabled: !GalleryConfig.disabled
|
||||
text: qsTr("First")
|
||||
}
|
||||
Switch {
|
||||
enabled: !GalleryConfig.disabled
|
||||
text: qsTr("Second")
|
||||
checked: true
|
||||
}
|
||||
Switch {
|
||||
text: qsTr("Third")
|
||||
enabled: false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import QtQuick.Controls
|
|||
|
||||
Page {
|
||||
id: page
|
||||
enabled: !GalleryConfig.disabled
|
||||
|
||||
SwipeView {
|
||||
id: swipeView
|
||||
|
|
|
@ -19,6 +19,7 @@ ScrollablePage {
|
|||
}
|
||||
|
||||
TextArea {
|
||||
enabled: !GalleryConfig.disabled
|
||||
width: page.availableWidth / 3
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ ScrollablePage {
|
|||
}
|
||||
|
||||
TextField {
|
||||
id: field
|
||||
enabled: !GalleryConfig.disabled
|
||||
placeholderText: qsTr("TextField")
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ ScrollablePage {
|
|||
}
|
||||
|
||||
Tumbler {
|
||||
enabled: !GalleryConfig.disabled
|
||||
model: 10
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue