status-desktop/ui/app/AppLayouts/Profile/controls/BloomSelectorButton.qml

67 lines
1.5 KiB
QML
Raw Permalink Normal View History

2021-07-21 13:11:27 +00:00
import QtQuick 2.13
import QtQuick.Controls 2.13
import QtQuick.Layouts 1.13
import utils 1.0
import shared 1.0
import shared.panels 1.0
2021-07-21 13:11:27 +00:00
import StatusQ.Controls 0.1
2021-07-21 13:11:27 +00:00
Rectangle {
id: root
2021-07-21 13:11:27 +00:00
property var buttonGroup
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)
function toggle() {
2021-07-21 13:11:27 +00:00
radioBtn.toggle()
}
border.color: mouseArea.containsMouse || radioBtn.checked ? Style.current.primary : Style.current.border
2021-07-21 13:11:27 +00:00
border.width: 1
color: Style.current.transparent
implicitWidth: 130
implicitHeight: 120
2021-07-21 13:11:27 +00:00
radius: Style.current.radius
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: {
if (radioBtn.checked)
return
2021-07-21 13:11:27 +00:00
radioBtn.toggle()
root.toggled(radioBtn.checked)
}
}
}