2023-03-25 13:35:21 +08:00
|
|
|
|
import QtQuick 2.0
|
|
|
|
|
import QtQuick.Controls 2.0
|
2023-03-30 21:52:55 +08:00
|
|
|
|
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
|
|
|
|
|
FluFocusRectangle{
|
|
|
|
|
visible: control.visualFocus
|
|
|
|
|
radius: 20
|
|
|
|
|
}
|
|
|
|
|
color: {
|
2023-03-28 21:37:10 +08:00
|
|
|
|
if(FluTheme.dark){
|
2023-03-20 18:22:32 +08:00
|
|
|
|
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 {
|
2023-03-30 11:43:35 +08:00
|
|
|
|
width: pressed ? control.height - 4 : control.height - 8
|
|
|
|
|
anchors{
|
|
|
|
|
left: selected ? undefined : parent.left
|
|
|
|
|
leftMargin: selected ? control_backgound.width - width - 4 : 4
|
|
|
|
|
right: selected ? parent.right : undefined
|
|
|
|
|
rightMargin: selected ? 4 : control_backgound.width - width - 4
|
|
|
|
|
}
|
2023-03-20 18:22:32 +08:00
|
|
|
|
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"
|
2023-03-30 11:43:35 +08:00
|
|
|
|
Behavior on anchors.leftMargin {
|
|
|
|
|
NumberAnimation { duration: 150 }
|
|
|
|
|
}
|
|
|
|
|
Behavior on anchors.rightMargin {
|
2023-03-29 21:43:01 +08:00
|
|
|
|
NumberAnimation { duration: 150 }
|
|
|
|
|
}
|
|
|
|
|
Behavior on width {
|
|
|
|
|
NumberAnimation { duration: 150 }
|
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
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|