2023-03-24 20:44:38 +08:00
|
|
|
|
import QtQuick
|
|
|
|
|
import QtQuick.Controls
|
|
|
|
|
import FluentUI
|
|
|
|
|
import QtQuick.Layouts
|
2023-02-26 23:47:07 +08:00
|
|
|
|
|
2023-03-12 21:49:11 +08:00
|
|
|
|
Button {
|
2023-03-12 22:36:31 +08:00
|
|
|
|
|
|
|
|
|
property bool selected: false
|
|
|
|
|
property var clickFunc
|
|
|
|
|
|
|
|
|
|
id: control
|
2023-02-27 18:46:39 +08:00
|
|
|
|
height: 20
|
2023-03-20 18:22:32 +08:00
|
|
|
|
implicitHeight: height
|
2023-03-12 22:36:31 +08:00
|
|
|
|
focusPolicy:Qt.TabFocus
|
|
|
|
|
Keys.onSpacePressed: control.visualFocus&&clicked()
|
|
|
|
|
onClicked: {
|
|
|
|
|
if(clickFunc){
|
|
|
|
|
clickFunc()
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
selected = !selected
|
|
|
|
|
}
|
2023-03-20 18:22:32 +08:00
|
|
|
|
|
|
|
|
|
contentItem: Item{}
|
|
|
|
|
|
|
|
|
|
background : RowLayout{
|
|
|
|
|
spacing: 0
|
|
|
|
|
Rectangle {
|
|
|
|
|
id:control_backgound
|
|
|
|
|
width: 40
|
|
|
|
|
height: control.height
|
|
|
|
|
radius: height / 2
|
|
|
|
|
smooth: true
|
|
|
|
|
antialiasing: true
|
|
|
|
|
FluFocusRectangle{
|
|
|
|
|
visible: control.visualFocus
|
|
|
|
|
radius: 20
|
|
|
|
|
}
|
|
|
|
|
color: {
|
|
|
|
|
if(FluTheme.isDark){
|
|
|
|
|
if(selected){
|
|
|
|
|
return FluTheme.primaryColor.dark
|
|
|
|
|
}
|
|
|
|
|
if(hovered){
|
|
|
|
|
return "#3E3E3C"
|
|
|
|
|
}
|
|
|
|
|
return "#323232"
|
|
|
|
|
}else{
|
|
|
|
|
if(selected){
|
|
|
|
|
return FluTheme.primaryColor.dark
|
|
|
|
|
}
|
|
|
|
|
if(hovered){
|
|
|
|
|
return "#F4F4F4"
|
|
|
|
|
}
|
|
|
|
|
return "#FFFFFF"
|
2023-02-27 23:04:52 +08:00
|
|
|
|
}
|
2023-03-20 18:22:32 +08:00
|
|
|
|
}
|
|
|
|
|
border.width: 1
|
|
|
|
|
border.color: selected ? Qt.lighter(FluTheme.primaryColor.dark,1.2) : "#666666"
|
|
|
|
|
Rectangle {
|
|
|
|
|
x: selected ? control_backgound.width - width - 4 : 4
|
|
|
|
|
width: control.height - 8
|
|
|
|
|
height: control.height - 8
|
|
|
|
|
radius: width / 2
|
|
|
|
|
antialiasing: true
|
|
|
|
|
scale: hovered ? 1.2 : 1.0
|
|
|
|
|
smooth: true
|
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
|
color: selected ? "#FFFFFF" : "#666666"
|
|
|
|
|
Behavior on x {
|
|
|
|
|
NumberAnimation { duration: 200 }
|
2023-02-28 18:29:00 +08:00
|
|
|
|
}
|
2023-03-20 18:22:32 +08:00
|
|
|
|
Behavior on scale {
|
|
|
|
|
NumberAnimation { duration: 150 }
|
2023-02-27 23:04:52 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-03-20 18:22:32 +08:00
|
|
|
|
|
|
|
|
|
FluText{
|
|
|
|
|
text: control.text
|
|
|
|
|
Layout.leftMargin: 5
|
|
|
|
|
visible: text !== ""
|
2023-02-26 23:47:07 +08:00
|
|
|
|
}
|
2023-03-20 18:22:32 +08:00
|
|
|
|
|
2023-02-26 23:47:07 +08:00
|
|
|
|
}
|
2023-03-12 22:36:31 +08:00
|
|
|
|
|
2023-02-26 23:47:07 +08:00
|
|
|
|
}
|