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

0001 import QtQuick 2.15
0002 import QtQuick.Controls 2.15
0003 import QtQuick.Layouts 1.3
0004 import QtQuick.Templates 2.15 as T
0005 
0006 import org.mauikit.controls 1.3 as Maui
0007 
0008 /*!
0009  \ since org.mauikit.controls.*labs 1.0
0010  \inqmlmodule org.mauikit.controls.labs
0011  */
0012 T.ItemDelegate
0013 {
0014     id: control
0015     
0016     Maui.Theme.colorSet: Maui.Theme.Tooltip 
0017     
0018     hoverEnabled: !Maui.Handy.isMobile
0019     implicitHeight: _layout.implicitHeight + topPadding + bottomPadding
0020     implicitWidth: _layout.implicitWidth + leftPadding + rightPadding
0021     
0022     padding: Maui.Style.defaultPadding
0023     spacing: Maui.Style.space.small
0024     
0025     icon.height: Maui.Style.iconSize
0026     icon.width: Maui.Style.iconSize
0027 
0028     property alias label : _label1
0029     property alias iconSource : control.icon.name
0030     
0031     property bool showCloseButton : false
0032     
0033     property color color : Maui.Theme.backgroundColor
0034     
0035     ToolTip.visible: hovered &&  ToolTip.text.length > 0
0036     
0037     signal close()
0038     
0039     background: Rectangle
0040     {
0041         id: _background
0042         //         opacity: 0.5
0043         
0044         color:  control.checked ? Maui.Theme.highlightColor : (control.pressed ? Qt.darker(control.color) : (control.hovered ? Qt.lighter(control.color): control.color))
0045         radius:  Maui.Style.radiusV   
0046     }
0047     
0048     contentItem: RowLayout
0049     {
0050         id: _layout
0051         spacing: control.spacing        
0052 
0053             Maui.Icon
0054             {
0055                 id: _icon
0056                 visible: valid
0057                 implicitWidth: control.icon.width
0058                 implicitHeight: control.icon.height
0059                 color: _label1.color
0060                 source: control.icon.name
0061             }            
0062 
0063         
0064         Label
0065         {
0066             id: _label1
0067             text: control.text
0068             Layout.fillHeight: true
0069             Layout.fillWidth: true
0070             verticalAlignment: Qt.AlignVCenter
0071             color: Maui.ColorUtils.brightnessForColor(_background.color) === Maui.ColorUtils.Light ? "#333" :"#fafafa"
0072             wrapMode: Text.Wrap
0073         }
0074         
0075         Loader
0076         {
0077             active: control.showCloseButton
0078             visible: active
0079             
0080             asynchronous: true
0081             
0082             Layout.alignment: Qt.AlignRight
0083             
0084             sourceComponent: Maui.CloseButton
0085             {
0086                 icon.width: 16
0087                 icon.height: 16
0088                 icon.color: hovered ? Maui.Theme.negativeTextColor : _label1.color
0089                 
0090                 padding: 0
0091                 onClicked: control.close()
0092             }
0093         }     
0094     }
0095 }