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 1.3 as Maui
24
25import QtQuick.Layouts
26import Qt5Compat.GraphicalEffects
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: true
115
116 layer.effect: DropShadow
117 {
118 cached: true
119 horizontalOffset: 0
120 verticalOffset: 0
121 radius: 8.0
122 samples: 16
123 color: "#333"
124 opacity: 0.5
125 smooth: true
126 source: _background
127 }
128 }
129
130 contentItem: RowLayout
131 {
132 id: _layout
133
134 Maui.ToolBar
135 {
136 id: _actionsBar
137 visible: false
138
139 background: null
140
141 middleContent: Repeater
142 {
143 model: control.actions
144
145 ToolButton
146 {
147 Layout.fillHeight: true
148 action: modelData
149 display: ToolButton.TextUnderIcon
150 onClicked: control.close()
151 }
152 }
153 }
154
155 Maui.FloatingButton
156 {
157 id: _button
158 Layout.alignment:Qt.AlignRight
159
160 onClicked: _actionsBar.visible = !_actionsBar.visible
161 }
162 }
163
164 /**
165 * @brief Forces to open the ribbon containing the action buttons.
166 */
167 function open()
168 {
169 _actionsBar.visible = true
170 }
171
172 /**
173 * @brief Forces to close the ribbon containing the action buttons.
174 */
175 function close()
176 {
177 _actionsBar.visible = false
178 }
179}
180
181
182
183
QAction * close(const QObject *recvr, const char *slot, QObject *parent)
QAction * open(const QObject *recvr, const char *slot, QObject *parent)
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.