2023-02-28 18:29:00 +08:00
|
|
|
|
import QtQuick 2.15
|
2023-03-02 18:21:43 +08:00
|
|
|
|
import QtQuick.Layouts 1.15
|
2023-02-28 18:29:00 +08:00
|
|
|
|
import FluentUI 1.0
|
2023-02-26 23:47:07 +08:00
|
|
|
|
|
|
|
|
|
Item {
|
|
|
|
|
|
2023-03-02 18:21:43 +08:00
|
|
|
|
id:root
|
|
|
|
|
property bool checked: false
|
|
|
|
|
property string text: "Check Box"
|
2023-03-07 23:27:32 +08:00
|
|
|
|
property var checkClicked
|
2023-03-08 11:46:40 +08:00
|
|
|
|
property bool hovered: mouse_area.containsMouse
|
2023-03-02 18:21:43 +08:00
|
|
|
|
width: childrenRect.width
|
|
|
|
|
height: childrenRect.height
|
|
|
|
|
|
|
|
|
|
RowLayout{
|
|
|
|
|
spacing: 4
|
|
|
|
|
Rectangle{
|
|
|
|
|
width: 22
|
|
|
|
|
height: 22
|
|
|
|
|
radius: 4
|
|
|
|
|
border.color: {
|
2023-03-06 14:22:13 +08:00
|
|
|
|
if(FluTheme.isDark){
|
2023-03-02 18:21:43 +08:00
|
|
|
|
if(checked){
|
2023-03-06 12:09:06 +08:00
|
|
|
|
return FluTheme.primaryColor.lighter
|
2023-03-02 18:21:43 +08:00
|
|
|
|
}
|
|
|
|
|
return Qt.rgba(160/255,160/255,160/255,1)
|
|
|
|
|
}else{
|
|
|
|
|
if(checked){
|
|
|
|
|
if(mouse_area.containsMouse){
|
|
|
|
|
return Qt.rgba(25/255,117/255,187/255,1)
|
|
|
|
|
}
|
2023-03-06 12:09:06 +08:00
|
|
|
|
return FluTheme.primaryColor.dark
|
2023-03-02 18:21:43 +08:00
|
|
|
|
}
|
|
|
|
|
return Qt.rgba(136/255,136/255,136/255,1)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
border.width: 1
|
|
|
|
|
color: {
|
2023-03-06 14:22:13 +08:00
|
|
|
|
if(FluTheme.isDark){
|
2023-03-02 18:21:43 +08:00
|
|
|
|
if(checked){
|
|
|
|
|
if(mouse_area.containsMouse){
|
|
|
|
|
return Qt.rgba(74/255,149/255,207/255,1)
|
|
|
|
|
}
|
2023-03-06 12:09:06 +08:00
|
|
|
|
return FluTheme.primaryColor.lighter
|
2023-03-02 18:21:43 +08:00
|
|
|
|
}
|
|
|
|
|
if(mouse_area.containsMouse){
|
|
|
|
|
return Qt.rgba(62/255,62/255,62/255,1)
|
|
|
|
|
}
|
|
|
|
|
return Qt.rgba(45/255,45/255,45/255,1)
|
|
|
|
|
}else{
|
|
|
|
|
if(checked){
|
|
|
|
|
if(mouse_area.containsMouse){
|
|
|
|
|
return Qt.rgba(25/255,117/255,187/255,1)
|
|
|
|
|
}
|
2023-03-06 12:09:06 +08:00
|
|
|
|
return FluTheme.primaryColor.dark
|
2023-03-02 18:21:43 +08:00
|
|
|
|
}
|
|
|
|
|
if(mouse_area.containsMouse){
|
|
|
|
|
return Qt.rgba(244/255,244/255,244/255,1)
|
|
|
|
|
}
|
|
|
|
|
return Qt.rgba(247/255,247/255,247/255,1)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FluIcon {
|
|
|
|
|
anchors.centerIn: parent
|
|
|
|
|
icon: FluentIcons.FA_check
|
|
|
|
|
iconSize: 15
|
|
|
|
|
visible: checked
|
2023-03-06 14:22:13 +08:00
|
|
|
|
color: FluTheme.isDark ? Qt.rgba(0,0,0,1) : Qt.rgba(1,1,1,1)
|
2023-03-02 18:21:43 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
FluText{
|
|
|
|
|
text:root.text
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MouseArea{
|
|
|
|
|
id:mouse_area
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
hoverEnabled: true
|
|
|
|
|
onClicked: {
|
2023-03-07 23:27:32 +08:00
|
|
|
|
if(checkClicked){
|
|
|
|
|
checkClicked()
|
|
|
|
|
return
|
|
|
|
|
}
|
2023-03-02 18:21:43 +08:00
|
|
|
|
checked = !checked
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-26 23:47:07 +08:00
|
|
|
|
}
|