MauiKit Controls

PieButton.qml
1/*
2 * Copyright 2018 Camilo Higuita <milo.h@aol.com>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Library General Public License as
6 * published by the Free Software Foundation; either version 2, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details
13 *
14 * You should have received a copy of the GNU Library General Public
15 * License along with this program; if not, write to the
16 * Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19
20import QtQuick
21import QtQuick.Controls
22
23import org.mauikit.controls as Maui
24
25import QtQuick.Layouts
26import QtQuick.Effects
27
28/**
29 * @inherit QtQuick.Controls.Control
30 * @brief A group of actions positioned in a plegable ribbon that fold/unfolds from a big floating colored button.
31 *
32 * <a href="https://doc.qt.io/qt-6/qml-qtquick-controls-control.html">This control inherits from QQC2 Control, to checkout its inherited properties refer to the Qt Docs.</a>
33 *
34 * @image html Misc/piebutton.gif
35 *
36 * @code
37 * Maui.PieButton
38 * {
39 * Maui.Theme.inherit: false
40 * anchors.right: parent.right
41 * anchors.bottom: parent.bottom
42 * anchors.margins: Maui.Style.space.big
43 *
44 * icon.name: "list-add"
45 *
46 * Action
47 * {
48 * icon.name: "love"
49 * }
50 *
51 * Action
52 * {
53 * icon.name: "folder"
54 * }
55 *
56 * Action
57 * {
58 * icon.name: "anchor"
59 * }
60 * }
61 * @endcode
62 *
63 * <a href="https://invent.kde.org/maui/mauikit/-/blob/qt6-2/examples/PieButton.qml">You can find a more complete example at this link.</a>
64 *
65 */
66Control
67{
68 id: control
69
70 /**
71 * @brief The action children of this control.
72 */
73 default property list<Action> actions
75 /**
76 * @brief The icon group property alias to set the icon name, color, and size.
77 * @note See Qt documentation on the icon group.
78 * @property icon PieButton::icon
79 */
80 property alias icon : _button.icon
81
82 /**
83 * @brief The text to be use in the main floating button.
84 * @property string PieButton::text
85 */
86 property alias text: _button.text
87
88 /**
89 * @brief How to display the text and the icon of the main floating button.
90 * By default this is set to `ToolButton.IconOnly`
91 * @property enum PieButton::display
92 */
93 property alias display: _button.display
94
95 implicitWidth: implicitContentWidth + leftPadding + rightPadding
96 implicitHeight: implicitContentHeight + topPadding + bottomPadding
97
98 // Behavior on implicitWidth
99 // {
100 // NumberAnimation
101 // {
102 // duration: Maui.Style.units.longDuration
103 // easing.type: Easing.InOutQuad
104 // }
105 // }
106
107 background: Rectangle
108 {
109 id: _background
110 visible: control.implicitWidth > height
111
112 color: Maui.Theme.backgroundColor
113 radius: Maui.Style.radiusV
114 layer.enabled: GraphicsInfo.api !== GraphicsInfo.Software
115 layer.effect: MultiEffect
116 {
117 autoPaddingEnabled: true
118 shadowEnabled: true
119 shadowColor: "#80000000"
120 }
121 }
122
123 contentItem: RowLayout
124 {
125 id: _layout
126
127 Maui.ToolBar
128 {
129 id: _actionsBar
130 visible: false
131
132 background: null
133
134 middleContent: Repeater
135 {
136 model: control.actions
137
138 ToolButton
139 {
140 Layout.fillHeight: true
141 action: modelData
142 display: ToolButton.TextUnderIcon
143 onClicked: control.close()
144 }
145 }
146 }
147
148 Maui.FloatingButton
149 {
150 id: _button
151 Layout.alignment:Qt.AlignRight
152
153 onClicked: _actionsBar.visible = !_actionsBar.visible
154 }
155 }
156
157 /**
158 * @brief Forces to open the ribbon containing the action buttons.
159 */
160 function open()
161 {
162 _actionsBar.visible = true
163 }
164
165 /**
166 * @brief Forces to close the ribbon containing the action buttons.
167 */
168 function close()
169 {
170 _actionsBar.visible = false
171 }
172}
173
174
175
176
alias display
How to display the text and the icon of the main floating button.
Definition PieButton.qml:85
alias text
The text to be use in the main floating button.
Definition PieButton.qml:79
alias icon
The icon group property alias to set the icon name, color, and size.
Definition PieButton.qml:74
list< Action > actions
The action children of this control.
Definition PieButton.qml:68
const QList< QKeySequence > & close()
const QList< QKeySequence > & open()
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.