FluentUI/src/controls/FluFilledButton.qml

50 lines
1.4 KiB
QML
Raw Normal View History

2023-03-30 21:52:55 +08:00
import QtQuick
import QtQuick.Controls
import FluentUI
2023-02-24 18:44:29 +08:00
2023-03-12 21:49:11 +08:00
Button {
2023-02-24 18:44:29 +08:00
property bool disabled: false
2023-03-28 21:37:10 +08:00
property color normalColor: FluTheme.dark ? FluTheme.primaryColor.lighter : FluTheme.primaryColor.dark
property color hoverColor: FluTheme.dark ? Qt.darker(normalColor,1.1) : Qt.lighter(normalColor,1.1)
property color disableColor: FluTheme.dark ? Qt.rgba(82/255,82/255,82/255,1) : Qt.rgba(199/255,199/255,199/255,1)
2023-03-12 14:26:03 +08:00
2023-03-27 18:24:35 +08:00
id: control
2023-03-12 21:49:11 +08:00
enabled: !disabled
2023-03-12 14:26:03 +08:00
topPadding:5
bottomPadding:5
leftPadding:15
rightPadding:15
2023-03-12 22:36:31 +08:00
Keys.onSpacePressed: control.visualFocus&&clicked()
focusPolicy:Qt.TabFocus
2023-03-12 14:26:03 +08:00
background: Rectangle{
radius: 4
FluFocusRectangle{
2023-03-12 22:36:31 +08:00
visible: control.visualFocus
2023-03-12 14:26:03 +08:00
radius:8
}
color:{
2023-02-28 18:29:00 +08:00
if(disabled){
2023-03-12 14:26:03 +08:00
return disableColor
2023-02-28 18:29:00 +08:00
}
2023-03-12 14:26:03 +08:00
return hovered ? hoverColor :normalColor
2023-02-26 23:47:07 +08:00
}
}
2023-03-12 14:26:03 +08:00
contentItem: FluText {
text: control.text
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
2023-02-28 18:29:00 +08:00
color: {
2023-03-28 21:37:10 +08:00
if(FluTheme.dark){
2023-02-28 18:29:00 +08:00
if(disabled){
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)
}
}
2023-02-27 18:46:39 +08:00
font.pixelSize: 14
2023-02-24 18:44:29 +08:00
}
}