Warning, /maui/mauikit/src/controls.6/FloatingButton.qml is written in an unsupported language. File is not indexed.

0001 /*
0002  *   Copyright 2018 Camilo Higuita <milo.h@aol.com>
0003  *
0004  *   This program is free software; you can redistribute it and/or modify
0005  *   it under the terms of the GNU Library General Public License as
0006  *   published by the Free Software Foundation; either version 2, or
0007  *   (at your option) any later version.
0008  *
0009  *   This program is distributed in the hope that it will be useful,
0010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0012  *   GNU General Public License for more details
0013  *
0014  *   You should have received a copy of the GNU Library General Public
0015  *   License along with this program; if not, write to the
0016  *   Free Software Foundation, Inc.,
0017  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
0018  */
0019 
0020 import QtQuick
0021 import QtQuick.Controls
0022 
0023 import org.mauikit.controls 1.3 as Maui
0024 
0025 import Qt5Compat.GraphicalEffects
0026 
0027 /**
0028  * @inherit QtQuick.Controls.ToolButton
0029  * @brief A button styled to be used "floating" above other elements.
0030  * 
0031  *   <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>
0032  * 
0033  * 
0034  * 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.
0035  * 
0036  * Typically this button is placed on a corner of a pane.
0037  * By default the button background color is picked from the style accent color, but this can be modify ad set any custom color.
0038  * @see color
0039  *  
0040  *    
0041  *  @image html Misc/floatingbutton.png
0042  *  
0043  * @code
0044  * Maui.Page
0045  * {
0046  *    id: _page
0047  * 
0048  *    anchors.fill: parent
0049  *    Maui.Controls.showCSD: true
0050  *    Maui.Theme.colorSet: Maui.Theme.Window
0051  *    headBar.forceCenterMiddleContent: true
0052  * 
0053  *    Maui.FloatingButton
0054  *    {
0055  *        anchors.right: parent.right
0056  *        anchors.bottom: parent.bottom
0057  *        anchors.margins: Maui.Style.space.big
0058  * 
0059  *        icon.name: "list-add"
0060  *    }
0061  * 
0062  * }
0063  * @endcode
0064  * 
0065  *   <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>
0066  * 
0067  * 
0068  */
0069 ToolButton
0070 {
0071     id: control
0072     
0073     padding: Maui.Style.defaultPadding * 2
0074     
0075     icon.height: Maui.Style.iconSize
0076     icon.width: Maui.Style.iconSize
0077     
0078     icon.color: Maui.Theme.highlightedTextColor
0079     
0080     display: ToolButton.IconOnly
0081     
0082     /**
0083      * @brief The background color of the button.
0084      * 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.
0085      * 
0086      * By default the color used is the accent color represented by `Theme.highlightColor`
0087      */
0088     property color color : control.hovered || control.pressed ? Qt.lighter( Maui.Theme.highlightColor, 1.2) : Maui.Theme.highlightColor
0089     
0090     background: Rectangle
0091     {
0092         id: _rec
0093         radius: Maui.Style.radiusV
0094         color: control.color
0095     }
0096     
0097     layer.enabled: true
0098     layer.effect: DropShadow
0099     {
0100         id: rectShadow
0101         cached: true
0102         horizontalOffset: 0
0103         verticalOffset: 0
0104         radius: 8.0
0105         samples: 16
0106         color:  "#80000000"
0107         smooth: true
0108     }
0109 }