2024-10-15 19:26:12 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Controls 2.15
|
|
|
|
import QtQuick.Layouts 1.15
|
2021-09-28 15:04:06 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
2021-10-27 21:27:49 +00:00
|
|
|
import shared 1.0
|
|
|
|
import shared.panels 1.0
|
2021-07-21 13:11:27 +00:00
|
|
|
|
2024-10-15 19:26:12 +00:00
|
|
|
import StatusQ.Core.Theme 0.1
|
2021-10-25 12:30:23 +00:00
|
|
|
import StatusQ.Controls 0.1
|
2021-07-21 13:11:27 +00:00
|
|
|
|
|
|
|
Rectangle {
|
2023-06-15 18:34:25 +00:00
|
|
|
id: root
|
|
|
|
|
2021-07-21 13:11:27 +00:00
|
|
|
property var buttonGroup
|
2022-04-04 11:26:30 +00:00
|
|
|
property string btnText: qsTr("TODO")
|
2021-07-21 13:11:27 +00:00
|
|
|
property bool checkedByDefault: false
|
2022-02-09 09:43:23 +00:00
|
|
|
|
2021-07-21 13:11:27 +00:00
|
|
|
signal checked()
|
|
|
|
signal toggled(bool checked)
|
|
|
|
|
2023-06-15 18:34:25 +00:00
|
|
|
function toggle() {
|
2021-07-21 13:11:27 +00:00
|
|
|
radioBtn.toggle()
|
|
|
|
}
|
|
|
|
|
2024-10-15 19:26:12 +00:00
|
|
|
border.color: mouseArea.containsMouse || radioBtn.checked ? Theme.palette.primaryColor1 : Theme.palette.border
|
2021-07-21 13:11:27 +00:00
|
|
|
border.width: 1
|
2024-10-15 19:26:12 +00:00
|
|
|
color: Theme.palette.transparent
|
2023-06-15 18:34:25 +00:00
|
|
|
implicitWidth: 130
|
|
|
|
implicitHeight: 120
|
2024-10-15 19:26:12 +00:00
|
|
|
radius: Theme.radius
|
2021-07-21 13:11:27 +00:00
|
|
|
|
|
|
|
StatusRadioButton {
|
|
|
|
id: radioBtn
|
|
|
|
ButtonGroup.group: buttonGroup
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: 14
|
|
|
|
checked: root.checkedByDefault
|
|
|
|
onCheckedChanged: {
|
|
|
|
if (checked) {
|
|
|
|
root.checked()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StyledText {
|
|
|
|
id: txt
|
|
|
|
text: btnText
|
|
|
|
font.pixelSize: 15
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
anchors.top: radioBtn.bottom
|
|
|
|
anchors.topMargin: 6
|
|
|
|
}
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
id: mouseArea
|
|
|
|
anchors.fill: parent
|
|
|
|
hoverEnabled: true
|
|
|
|
onClicked: {
|
2023-06-15 18:34:25 +00:00
|
|
|
if (radioBtn.checked)
|
|
|
|
return
|
2021-07-21 13:11:27 +00:00
|
|
|
radioBtn.toggle()
|
|
|
|
root.toggled(radioBtn.checked)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|