Kylin/Fluent/qml/FilledButton.qml

61 lines
1.9 KiB
QML
Raw Normal View History

2024-08-31 04:13:21 +08:00
import QtQuick as Quick
import QtQuick.Controls
import Fluent
Button {
property bool disabled: false
property string contentDescription: ""
property Quick.color normalColor: Theme.primaryColor
property Quick.color hoverColor: Theme.dark ? Qt.darker(normalColor,1.1) : Qt.lighter(normalColor,1.1)
property Quick.color disableColor: Theme.dark ? Qt.rgba(82/255,82/255,82/255,1) : Qt.rgba(199/255,199/255,199/255,1)
property Quick.color pressedColor: Theme.dark ? Qt.darker(normalColor,1.2) : Qt.lighter(normalColor,1.2)
property Quick.color textColor: {
if(Theme.dark){
if(!enabled){
return Qt.rgba(173/255,173/255,173/255,1)
}
return Qt.rgba(0,0,0,1)
}else{
return Qt.rgba(1,1,1,1)
}
}
Quick.Accessible.role: Quick.Accessible.Button
Quick.Accessible.name: control.text
Quick.Accessible.description: contentDescription
Quick.Accessible.onPressAction: control.clicked()
id: control
enabled: !disabled
focusPolicy:Qt.TabFocus
font:TextStyle.Body
verticalPadding: 0
horizontalPadding:12
background: ControlBackground{
implicitWidth: 30
implicitHeight: 30
radius: 4
bottomMargin: enabled ? 2 : 0
border.width: enabled ? 1 : 0
border.color: enabled ? Qt.darker(control.normalColor,1.2) : disableColor
color:{
if(!enabled){
return disableColor
}
if(pressed){
return pressedColor
}
return hovered ? hoverColor :normalColor
}
FocusRectangle{
visible: control.visualFocus
radius:4
}
}
contentItem: Text {
text: control.text
font: control.font
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
color: control.textColor
}
}