MauiKit Controls

CSDControls.qml
1import QtQuick
2import QtQuick.Controls
3import QtQuick.Window
4
5import org.mauikit.controls 1.3 as Maui
6
7/**
8 * @inherit QtQuick.Controls.Control
9 * @since org.mauikit.controls
10 * @brief CSD Window control buttons.
11 *
12 * @warning This is an implementation template for the CSD window control buttons, for a complete and final implementation please use the WindowControls component.
13 * @see WindowControlsLinux
14 *
15 * @section notes Notes
16 *
17 * @subsection customize Customize
18 * The window control buttons can be customized, by creating a new theme of button assets, or by picking one from the existing ones.
19 *
20 * Creating a new theme is simple. There is three important aspects:
21 * - The config file where the relative paths to the image assets is described.
22 *
23 * The following snippet is an example of a config file for the Nitrux CSD theme.
24 * The file name must be named 'config.conf'
25 * @code
26 * [Close]
27 * Normal=close.svg
28 * Hover=close-hover.svg
29 * Pressed=close-pressed.svg
30 * Backdrop=close-backdrop.svg
31 *
32 * [Maximize]
33 * Normal=maximize.svg
34 * Hover=maximize-hover.svg
35 * Pressed=maximize-pressed.svg
36 * Backdrop=maximize-backdrop.svg
37 *
38 * [Restore]
39 * Normal=restore.svg
40 * Hover=restore-hover.svg
41 * Pressed=restore-pressed.svg
42 * Backdrop=restore-backdrop.svg
43 *
44 * [Minimize]
45 * Normal=minimize.svg
46 * Hover=minimize-hover.svg
47 * Pressed=minimize-pressed.svg
48 * Backdrop=minimize-backdrop.svg
49 *
50 * [FullScreen]
51 * Normal=fullscreen.svg
52 *
53 * [Decoration]
54 * BorderRadius=8
55 * Source=CSD.qml
56 * @endcode
57 *
58 * - The second part is the QML source file, named CSD.qml by convection. If the theme you imagine is not that different from the regular layout, the following snippet of code will do it.
59 *
60 * The code consists of a horizontal row layout, where we feed the buttons model and set the component delegate to draw the button.
61 * @see CSDButton
62 * @code
63 * Control
64 * {
65 * id: control
66 *
67 * implicitHeight: _layout.implicitHeight + topPadding + bottomPadding
68 * implicitWidth: _layout.implicitWidth + leftPadding + rightPadding
69 *
70 * spacing: Maui.Style.space.small
71 * padding: Maui.Style.defaultPadding
72 *
73 * background: null
74 *
75 * contentItem: Row
76 * {
77 * id: _layout
78 * spacing: control.spacing
79 *
80 * ToolSeparator
81 * {
82 * height: 8
83 * anchors.verticalCenter: parent.verticalCenter
84 * }
85 *
86 * Repeater
87 * {
88 * model: buttonsModel
89 * delegate: pluginButton
90 * }
91 * }
92 *
93 * Component
94 * {
95 * id: pluginButton
96 *
97 * AbstractButton
98 * {
99 * id: _button
100 *
101 * visible: modelData === "A" ? canMaximize : true
102 *
103 * hoverEnabled: true
104 *
105 * implicitWidth: 22
106 * implicitHeight: 22
107 *
108 * focusPolicy: Qt.NoFocus
109 *
110 * Maui.CSDButton
111 * {
112 * id: button
113 * style: "Nitrux"
114 * type: mapType(modelData)
115 * isHovered: _button.hovered
116 * isPressed: _button.pressed
117 * isFocused: isActiveWindow
118 * isMaximized: maximized
119 * }
120 *
121 * contentItem: Maui.Icon
122 * {
123 * smooth: true
124 *
125 * source: button.source
126 *
127 * color: Maui.Theme.textColor
128 * Behavior on color
129 * {
130 * Maui.ColorTransition{}
131 * }
132 * }
133 *
134 *
135 * onClicked:
136 * {
137 * console.log("NITRUX CSD BUTTON CLICKED", button.type)
138 * buttonClicked(button.type)
139 * }
140 * }
141 * }
142 * }
143 * @endcode
144 *
145 * - And the last part are the actual image assets for the buttons.
146 *
147 */
148Loader
149{
150 id: control
151 asynchronous: true
152
153 property bool maximized : Window.window.visibility === Window.Maximized
154 property bool isActiveWindow : Window.window.active
155 readonly property bool canMaximize: !(Window.window.isDialog)
156 readonly property bool canMinimize : !(Window.window.isDialog)
157 readonly property var buttonsModel : Maui.CSD.rightWindowControls
159
160 /**
161 * A window control button has been clicked. This signal is public and can be mapped to any arbitrary value. Be carefull.
162 */
163 signal buttonClicked(var type)
164 source: Maui.CSD.source
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 17 2024 11:56:16 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.