2023-02-26 23:47:07 +08:00
|
|
|
|
import QtQuick 2.0
|
|
|
|
|
import QtQuick.Controls 2.0
|
2023-02-28 18:29:00 +08:00
|
|
|
|
import FluentUI 1.0
|
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
|
|
|
|
width: 40
|
|
|
|
|
implicitWidth: 40
|
|
|
|
|
height: 20
|
|
|
|
|
implicitHeight: 20
|
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-12 21:49:11 +08:00
|
|
|
|
background : Rectangle {
|
2023-03-12 22:36:31 +08:00
|
|
|
|
width: control.width
|
|
|
|
|
height: control.height
|
2023-02-26 23:47:07 +08:00
|
|
|
|
radius: height / 2
|
2023-03-12 21:49:11 +08:00
|
|
|
|
FluFocusRectangle{
|
2023-03-12 22:36:31 +08:00
|
|
|
|
visible: control.visualFocus
|
2023-03-12 21:49:11 +08:00
|
|
|
|
radius: 20
|
|
|
|
|
}
|
2023-02-27 23:04:52 +08:00
|
|
|
|
color: {
|
2023-03-06 14:22:13 +08:00
|
|
|
|
if(FluTheme.isDark){
|
2023-03-12 22:36:31 +08:00
|
|
|
|
if(selected){
|
2023-03-06 12:09:06 +08:00
|
|
|
|
return FluTheme.primaryColor.dark
|
2023-02-27 23:04:52 +08:00
|
|
|
|
}
|
2023-03-12 21:49:11 +08:00
|
|
|
|
if(hovered){
|
2023-02-27 23:04:52 +08:00
|
|
|
|
return "#3E3E3C"
|
|
|
|
|
}
|
|
|
|
|
return "#323232"
|
|
|
|
|
}else{
|
2023-03-12 22:36:31 +08:00
|
|
|
|
if(selected){
|
2023-03-06 12:09:06 +08:00
|
|
|
|
return FluTheme.primaryColor.dark
|
2023-02-28 18:29:00 +08:00
|
|
|
|
}
|
2023-03-12 21:49:11 +08:00
|
|
|
|
if(hovered){
|
2023-02-27 23:04:52 +08:00
|
|
|
|
return "#F4F4F4"
|
|
|
|
|
}
|
2023-02-28 18:29:00 +08:00
|
|
|
|
return "#FFFFFF"
|
2023-02-27 23:04:52 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-02-26 23:47:07 +08:00
|
|
|
|
border.width: 1
|
2023-03-12 22:36:31 +08:00
|
|
|
|
border.color: selected ? Qt.lighter(FluTheme.primaryColor.dark,1.2) : "#666666"
|
2023-02-26 23:47:07 +08:00
|
|
|
|
Rectangle {
|
2023-03-12 22:36:31 +08:00
|
|
|
|
x: selected ? control.implicitWidth - width - 4 : 4
|
|
|
|
|
width: control.height - 8
|
|
|
|
|
height: control.height - 8
|
2023-02-26 23:47:07 +08:00
|
|
|
|
radius: width / 2
|
2023-03-12 21:49:11 +08:00
|
|
|
|
scale: hovered ? 1.2 : 1.0
|
2023-02-26 23:47:07 +08:00
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
2023-03-12 22:36:31 +08:00
|
|
|
|
color: selected ? "#FFFFFF" : "#666666"
|
2023-02-26 23:47:07 +08:00
|
|
|
|
Behavior on x {
|
|
|
|
|
NumberAnimation { duration: 200 }
|
|
|
|
|
}
|
2023-03-16 14:34:20 +08:00
|
|
|
|
Behavior on scale {
|
|
|
|
|
NumberAnimation { duration: 150 }
|
|
|
|
|
}
|
2023-02-26 23:47:07 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-03-12 22:36:31 +08:00
|
|
|
|
|
2023-02-26 23:47:07 +08:00
|
|
|
|
}
|