import QtQuick as Quick import QtQuick.Controls as Controls import QtQuick.Layouts import Fluent Controls.Button { display: Controls.Button.IconOnly property int iconSize: 20 property int iconSource property bool disabled: false property int radius:4 property string contentDescription: "" property Quick.color hoverColor: Theme.itemHoverColor property Quick.color pressedColor: Theme.itemPressColor property Quick.color normalColor: Theme.itemNormalColor property Quick.color disableColor: Theme.itemNormalColor property Quick.Component iconDelegate: com_icon property Quick.color color: { if(!enabled){ return disableColor } if(pressed){ return pressedColor } return hovered ? hoverColor : normalColor } property Quick.color iconColor: { if(Theme.dark){ if(!enabled){ return Qt.rgba(130/255,130/255,130/255,1) } return Qt.rgba(1,1,1,1) }else{ if(!enabled){ return Qt.rgba(161/255,161/255,161/255,1) } return Qt.rgba(0,0,0,1) } } property Quick.color textColor: Theme.fontPrimaryColor Quick.Accessible.role: Quick.Accessible.Button Quick.Accessible.name: control.text Quick.Accessible.description: contentDescription Quick.Accessible.onPressAction: control.clicked() id:control focusPolicy:Qt.TabFocus padding: 0 verticalPadding: 8 horizontalPadding: 8 enabled: !disabled font:TextStyle.Caption background: Quick.Rectangle{ implicitWidth: 30 implicitHeight: 30 radius: control.radius color:control.color FocusRectangle{ visible: control.activeFocus } } Quick.Component{ id:com_icon Icon { id:text_icon font.pixelSize: iconSize iconSize: control.iconSize horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter iconColor: control.iconColor iconSource: control.iconSource } } Quick.Component{ id:com_row RowLayout{ Loader{ sourceComponent: iconDelegate Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter visible: display !== Button.TextOnly } Text{ text:control.text Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter visible: display !== Button.IconOnly color: control.textColor font: control.font } } } Quick.Component{ id:com_column ColumnLayout{ Loader{ sourceComponent: iconDelegate Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter visible: display !== Button.TextOnly } Text{ text:control.text Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter visible: display !== Button.IconOnly color: control.textColor font: control.font } } } contentItem:Loader{ sourceComponent: { if(display === Button.TextUnderIcon){ return com_column } return com_row } } Tooltip{ id:tool_tip visible: { if(control.text === ""){ return false } if(control.display !== Button.IconOnly){ return false } return hovered } text:control.text delay: 1000 } }