MauiKit Controls

SettingsDialog.qml
1import QtQuick.Controls
2import QtQuick.Layouts
3import QtQuick
4
5import org.mauikit.controls as Maui
6
7/**
8 * @inherit QtQuick.Loader
9 *
10 * @brief A popup page with a scrollable vertical layout, and support for a stack of multiple pages.
11 * The default container fo this control is a MauiKit SettingsPage, and the popup will snap to the window full size on constrained spaces.
12 * @see SettingsPage
13 *
14 * You can add multiple sub pages to this control by making use of the SettingsPage control and the `addPage` function.
15 * By using the SettingsPage you can expect to have a way to navigate between the control sub pages.
16 * The code snippet below shows a quick demo on how to do it.
17 * @see addPage
18 *
19 * @image html Misc/settingsdialog.png
20 *
21 * @note This control is mostly use for presenting a group of configuration settings to the user. Usually it is populated with sections SectionGroup containing FlexSectionItem.
22 *
23 * @code
24 * Maui.SettingsDialog
25 * {
26 * id: _settingsDialog
27 *
28 * Maui.FlexSectionItem
29 * {
30 * label1.text: "SSetting Subpage"
31 * label2.text: "Click me to add a new page"
32 *
33 * ToolButton
34 * {
35 * icon.name: "go-next"
36 * checkable: true
37 * onToggled: _settingsDialog.addPage(_settingsPage2)
38 * }
39 * }
40 *
41 * Maui.SectionGroup
42 * {
43 * title: "First Section"
44 *
45 * Maui.FlexSectionItem
46 * {
47 * label1.text: "Configuration title"
48 * label2.text: "Description text"
49 *
50 * Button
51 * {
52 * text: "Test"
53 * }
54 * }
55 *
56 * Maui.FlexSectionItem
57 * {
58 * label1.text: "Configuration title"
59 * label2.text: "Description text"
60 *
61 * Switch {}
62 * }
63 *
64 * Maui.FlexSectionItem
65 * {
66 * label1.text: "Configuration title"
67 * label2.text: "Description text"
68 *
69 * Switch {}
70 * }
71 * }
72 *
73 * Maui.SectionGroup
74 * {
75 * title: "A Second Section"
76 *
77 * Maui.FlexSectionItem
78 * {
79 * label1.text: "Configuration title"
80 * label2.text: "Description text"
81 *
82 * Switch {}
83 * }
84 *
85 * Maui.FlexSectionItem
86 * {
87 * label1.text: "Configuration title"
88 * label2.text: "Description text"
89 * wide: false
90 * TextField
91 * {
92 * Layout.fillWidth: true
93 * }
94 * }
95 *
96 * Maui.FlexSectionItem
97 * {
98 * label1.text: "Configuration title"
99 * label2.text: "Description text"
100 *
101 * Switch {}
102 * }
103 * }
104 *
105 * Component
106 * {
107 * id: _settingsPage2
108 *
109 * Maui.SettingsPage
110 * {
111 * title: "Page2"
112 *
113 * Maui.FlexSectionItem
114 * {
115 * label1.text: "Configuration title"
116 * label2.text: "Description text"
117 *
118 * Switch {}
119 * }
120 * }
121 * }
122 * }
123 * @endcode
124 *
125 * <a href="https://invent.kde.org/maui/mauikit/-/blob/qt6-2/examples/SettingsDialog.qml">You can find a more complete example at this link.</a>
126 */
127Maui.PopupPage
128{
129 id: control
130 Maui.Controls.title: i18n("Settings")
131 default property alias content: _content.content
132 maxHeight: implicitHeight
133 maxWidth: 500
134
135 hint: 1
136
137 page.title: _stackView.currentItem.title ? _stackView.currentItem.title : ""
138
139 headBar.visible: true
140
141 headBar.leftContent: ToolButton
142 {
143 icon.name: "go-previous"
144 visible: _stackView.depth > 1
145
146 onClicked: _stackView.pop()
147 }
149 stack: StackView
150 {
151 id: _stackView
152 Layout.fillHeight: true
153 Layout.fillWidth: true
154 implicitHeight: Math.max(_content.implicitHeight, currentItem.implicitHeight)+topPadding +bottomPadding
155
156 initialItem: Maui.SettingsPage
157 {
158 id: _content
159 title: control.Maui.Controls.title
160 }
161 }
162
163 /**
164 * @brief Adds a new sub page to the control. Use a MauiKit SettingsPage for the component.
165 * @param component the QQC2 Component wrapping a MauiKit SettingsPage
166 * @param properties optional properties map for the newly added sub page component
167 *
168 * @note The optional properties argument specifies a map of initial property values for the pushed item. For dynamically created items, these values are applied before the creation is finalized. This is more efficient than setting property values after creation, particularly where large sets of property values are defined, and also allows property bindings to be set up (using Qt.binding()) before the item is created.
169 * Checkout QT documentation on the StackView methods.
170 */
171 function addPage(component, properties)
172 {
173 _stackView.push(component, properties)
174 }
175}
176
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri May 2 2025 11:57:11 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.