FluentUI/src/controls/FluButton.qml

56 lines
1.6 KiB
QML
Raw Normal View History

2023-03-24 20:44:38 +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-12 14:26:03 +08:00
property color normalColor: FluTheme.isDark ? Qt.rgba(62/255,62/255,62/255,1) : Qt.rgba(254/255,254/255,254/255,1)
property color hoverColor: FluTheme.isDark ? Qt.rgba(68/255,68/255,68/255,1) : Qt.rgba(251/255,251/255,251/255,1)
property color disableColor: FluTheme.isDark ? Qt.rgba(59/255,59/255,59/255,1) : Qt.rgba(252/255,252/255,252/255,1)
2023-03-12 22:36:31 +08:00
id: control
2023-03-12 14:26:03 +08:00
topPadding:5
bottomPadding:5
leftPadding:15
rightPadding:15
2023-03-12 21:49:11 +08:00
enabled: !disabled
2023-03-12 22:36:31 +08:00
focusPolicy:Qt.TabFocus
Keys.onSpacePressed: control.visualFocus&&clicked()
2023-03-12 14:26:03 +08:00
background: Rectangle{
border.color: FluTheme.isDark ? "#505050" : "#DFDFDF"
border.width: 1
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-27 18:46:39 +08:00
if(disabled){
2023-03-12 14:26:03 +08:00
return disableColor
2023-02-27 18:46:39 +08:00
}
2023-03-12 14:26:03 +08:00
return hovered ? hoverColor :normalColor
2023-02-27 18:46:39 +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-06 14:22:13 +08:00
if(FluTheme.isDark){
2023-02-28 18:29:00 +08:00
if(disabled){
return Qt.rgba(131/255,131/255,131/255,1)
}
return Qt.rgba(1,1,1,1)
}else{
if(disabled){
return Qt.rgba(160/255,160/255,160/255,1)
}
return Qt.rgba(0,0,0,1)
}
}
2023-02-24 18:44:29 +08:00
}
}