MauiKit Controls

FloatingButton.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 Qt5Compat.GraphicalEffects
26
27/**
28 * @inherit QtQuick.Controls.ToolButton
29 * @brief A button styled to be used "floating" above other elements.
30 *
31 * <a href="https://doc.qt.io/qt-6/qml-qtquick-controls-toolbutton.html">This controls inherits from QQC2 ToolButton, to checkout its inherited properties refer to the Qt Docs.</a>
32 *
33 *
34 * This button has a colorful background and drops a shadow, this is meant to elevate it over the surface and to distinguish it form other elements, since it is meant o be used above other UI elements.
35 *
36 * Typically this button is placed on a corner of a pane.
37 * By default the button background color is picked from the style accent color, but this can be modify ad set any custom color.
38 * @see color
39 *
40 *
41 * @image html Misc/floatingbutton.png
42 *
43 * @code
44 * Maui.Page
45 * {
46 * id: _page
47 *
48 * anchors.fill: parent
49 * Maui.Controls.showCSD: true
50 * Maui.Theme.colorSet: Maui.Theme.Window
51 * headBar.forceCenterMiddleContent: true
52 *
53 * Maui.FloatingButton
54 * {
55 * anchors.right: parent.right
56 * anchors.bottom: parent.bottom
57 * anchors.margins: Maui.Style.space.big
58 *
59 * icon.name: "list-add"
60 * }
61 *
62 * }
63 * @endcode
64 *
65 * <a href="https://invent.kde.org/maui/mauikit/-/blob/qt6-2/examples/FloatingButton.qml">You can find a more complete example at this link.</a>
66 *
67 *
68 */
69ToolButton
70{
71 id: control
72
73 padding: Maui.Style.defaultPadding * 2
74
75 icon.height: Maui.Style.iconSize
76 icon.width: Maui.Style.iconSize
77
78 icon.color: Maui.Theme.highlightedTextColor
79
80 display: ToolButton.IconOnly
81
82 /**
83 * @brief The background color of the button.
84 * This can be set to any color, but contrast with the icon should be manually adjusted by using the `icon.color` property or checking the current style, to see if it is dark or light. See `Style.styleType === Style.Dark` for example.
85 *
86 * By default the color used is the accent color represented by `Theme.highlightColor`
87 */
88 property color color : control.hovered || control.pressed ? Qt.lighter( Maui.Theme.highlightColor, 1.2) : Maui.Theme.highlightColor
89
90 background: Rectangle
91 {
92 id: _rec
93 radius: Maui.Style.radiusV
94 color: control.color
95 }
96
97 layer.enabled: true
98 layer.effect: DropShadow
99 {
100 id: rectShadow
101 cached: true
102 horizontalOffset: 0
103 verticalOffset: 0
104 radius: 8.0
105 samples: 16
106 color: "#80000000"
107 smooth: true
108 }
109}
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.