FluentUI/src/controls/FluButton.qml

55 lines
1.5 KiB
QML
Raw Normal View History

2023-02-24 18:44:29 +08:00
import QtQuick 2.15
import QtQuick.Controls 2.15
2023-03-12 14:26:03 +08:00
import FluentUI 1.0
2023-02-24 18:44:29 +08:00
2023-03-12 21:49:11 +08:00
Button {
2023-03-12 14:26:03 +08:00
id: control
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)
topPadding:5
bottomPadding:5
leftPadding:15
rightPadding:15
2023-03-12 21:49:11 +08:00
enabled: !disabled
2023-03-12 14:26:03 +08:00
background: Rectangle{
border.color: FluTheme.isDark ? "#505050" : "#DFDFDF"
border.width: 1
radius: 4
FluFocusRectangle{
visible: control.visualFocus
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
2023-02-24 18:44:29 +08:00
anchors.centerIn: parent
2023-03-12 14:26:03 +08:00
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
}
}