FluentUI/src/controls/FluTextButton.qml

45 lines
1.2 KiB
QML
Raw Normal View History

2023-03-03 18:19:48 +08:00
import QtQuick 2.15
2023-03-21 18:19:46 +08:00
import QtQuick.Controls 2.15
2023-03-03 18:19:48 +08:00
import FluentUI 1.0
2023-03-21 18:19:46 +08:00
Button {
property bool disabled: false
property color normalColor: FluTheme.isDark ? FluTheme.primaryColor.lighter : FluTheme.primaryColor.dark
property color hoverColor: FluTheme.isDark ? Qt.darker(normalColor,1.3) : Qt.lighter(normalColor,1.3)
property color disableColor: FluTheme.isDark ? Qt.rgba(82/255,82/255,82/255,1) : Qt.rgba(199/255,199/255,199/255,1)
property bool textBold: true
id: control
topPadding:5
bottomPadding:5
2023-03-23 17:52:08 +08:00
leftPadding:0
rightPadding:0
2023-03-21 18:19:46 +08:00
enabled: !disabled
focusPolicy:Qt.TabFocus
Keys.onSpacePressed: control.visualFocus&&clicked()
background: Item{
FluFocusRectangle{
visible: control.visualFocus
radius:8
2023-03-03 18:19:48 +08:00
}
}
2023-03-21 18:19:46 +08:00
contentItem: FluText {
text: control.text
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
font.bold: control.textBold
color: {
color:{
if(disabled){
return disableColor
}
return hovered ? hoverColor :normalColor
}
2023-03-03 18:19:48 +08:00
}
}
}