amnezia-client/client/ui/qml/Controls2/HorizontalRadioButton.qml

97 lines
2.3 KiB
QML

import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import "TextTypes"
RadioButton {
id: root
property string hoveredColor: Qt.rgba(1, 1, 1, 0.05)
property string defaultColor: Qt.rgba(1, 1, 1, 0)
property string disabledColor: Qt.rgba(1, 1, 1, 0)
property string selectedColor: Qt.rgba(1, 1, 1, 0)
property string textColor: "#0E0E11"
property string pressedBorderColor: "#494B50"
property string selectedBorderColor: "#FBB26A"
property string defaultBodredColor: "transparent"
property int borderWidth: 0
implicitWidth: content.implicitWidth
implicitHeight: content.implicitHeight
hoverEnabled: true
indicator: Rectangle {
anchors.fill: parent
radius: 16
color: {
if (root.enabled) {
if (root.hovered) {
return hoveredColor
} else if (root.checked) {
return selectedColor
}
return defaultColor
} else {
return disabledColor
}
}
border.color: {
if (root.enabled) {
if (root.pressed) {
return pressedBorderColor
} else if (root.checked) {
return selectedBorderColor
}
}
return defaultBodredColor
}
border.width: {
if (root.enabled) {
if(root.checked) {
return 1
}
return root.pressed ? 1 : 0
} else {
return 0
}
}
Behavior on color {
PropertyAnimation { duration: 200 }
}
Behavior on border.color {
PropertyAnimation { duration: 200 }
}
}
ColumnLayout {
id: content
anchors.fill: parent
spacing: 16
ButtonTextType {
text: root.text
Layout.fillWidth: true
Layout.rightMargin: 16
Layout.leftMargin: 16
Layout.topMargin: 16
Layout.bottomMargin: 16
horizontalAlignment: Qt.AlignHCenter
}
}
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
enabled: false
}
}