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

0001 /*
0002  *   Copyright 2020 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 
0021 //this basic toolbutton provides a basic anima
0022 
0023 import QtQuick 2.13
0024 import QtQuick.Controls 2.13
0025 import QtQuick.Layouts 1.3
0026 
0027 import org.mauikit.controls 1.3 as Maui
0028 import QtQuick.Templates 2.15 as T
0029 
0030 
0031 Item
0032 {
0033     id: control
0034     
0035     implicitWidth: _layoutButton.implicitWidth + leftPadding + rightPadding
0036     implicitHeight: _layoutButton.implicitHeight + topPadding + bottomPadding
0037     
0038     property color color 
0039     property string text
0040     property var icon 
0041     property int display : ToolButton.IconOnly
0042     property int alignment : Qt.AlignLeft
0043     
0044     // font.pointSize: control.display === ToolButton.TextUnderIcon ? Maui.Style.fontSizes.small : Maui.Style.fontSizes.medium            
0045     
0046     property int padding : 0
0047     property int leftPadding: padding
0048     property int rightPadding: padding
0049     property int bottomPadding: padding
0050     property int topPadding: padding
0051     
0052     property int spacing: Maui.Style.space.small
0053     property font font : Maui.Style.defaultFont
0054     
0055 GridLayout
0056 {
0057     id: _layoutButton
0058     
0059 //     width: control.width 
0060 //     height: control.height
0061 //     
0062 //     x: control.leftPadding
0063 //     y: control.topPadding
0064     
0065     anchors.fill: parent
0066     anchors.leftMargin: control.leftPadding
0067     anchors.rightMargin: control.rightPadding
0068     anchors.bottomMargin: control.bottomPadding
0069     anchors.topMargin: control.topPadding
0070     
0071     rowSpacing: control.spacing
0072     columnSpacing: control.spacing
0073         
0074         columns: control.display === ToolButton.TextUnderIcon ? 1 : 2
0075         
0076     Maui.Icon
0077     {
0078         id: _icon
0079         
0080         implicitHeight: visible && control.icon ? control.icon.height : 0
0081         implicitWidth: visible && control.icon ? control.icon.width : 0
0082       
0083         Layout.alignment: Qt.AlignCenter
0084         
0085         visible: String(_icon.source).length > 0 && (control.display !== ToolButton.TextOnly)        
0086         
0087         color: control.icon ? control.icon.color : control.color       
0088         source: control.icon ? control.icon.name || control.icon.source : ""        
0089     }    
0090     
0091     Label
0092     {
0093         id: _label
0094        
0095         text: control.text
0096         
0097         visible: text.length && (control.display === ToolButton.TextOnly || control.display === ToolButton.TextBesideIcon || control.display === ToolButton.TextUnderIcon || !_icon.visible)
0098         
0099         opacity: visible ? ( enabled ? 1 : 0.5) : 0
0100         
0101         horizontalAlignment: control.alignment
0102         
0103         Layout.fillWidth: true
0104         // Layout.preferredWidth: implicitWidth 
0105         
0106         color: control.color
0107         font: control.font
0108         
0109         elide: Text.ElideRight
0110         wrapMode: Text.NoWrap
0111         
0112         Behavior on opacity
0113         {
0114             NumberAnimation
0115             {
0116                 duration: Maui.Style.units.shortDuration
0117                 easing.type: Easing.InQuad
0118             }
0119         }
0120     }
0121 }
0122 
0123 }