Files
amnezia-client/client/ui/qml/Controls2/VerticalRadioButton.qml
T

147 lines
3.5 KiB
QML
Raw Normal View History

import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import Qt5Compat.GraphicalEffects
2023-06-01 11:25:33 +08:00
import "TextTypes"
RadioButton {
id: root
property int textMaximumLineCount: 2
property int textElide: Qt.ElideRight
property string descriptionText
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)
2023-06-01 11:25:33 +08:00
property string textColor: "#D7D8DB"
property string selectedTextColor: "#FBB26A"
2023-06-01 11:25:33 +08:00
property string imageSource
property bool showImage
hoverEnabled: true
indicator: Rectangle {
2023-04-26 18:37:56 +03:00
id: background
2023-06-01 11:25:33 +08:00
anchors.verticalCenter: parent.verticalCenter
implicitWidth: 56
implicitHeight: 56
radius: 16
color: {
if (root.enabled) {
2023-04-26 18:37:56 +03:00
if (root.hovered) {
return hoveredColor
} else if (root.checked) {
return selectedColor
}
return defaultColor
} else {
return disabledColor
}
}
Behavior on color {
PropertyAnimation { duration: 200 }
}
2023-06-01 11:25:33 +08:00
Image {
2023-06-13 20:03:20 +09:00
source: {
if (showImage) {
return imageSource
} else if (root.pressed) {
return "qrc:/images/controls/radio-button-inner-circle-pressed.png"
} else if (root.checked) {
return "qrc:/images/controls/radio-button-inner-circle.png"
}
return ""
}
2023-06-01 11:25:33 +08:00
anchors.centerIn: parent
width: 24
height: 24
}
2023-08-18 14:14:45 +05:00
2023-06-13 20:03:20 +09:00
Image {
source: {
if (showImage) {
return ""
} else if (root.pressed || root.checked) {
return "qrc:/images/controls/radio-button-pressed.svg"
} else {
return "qrc:/images/controls/radio-button.svg"
}
}
2023-06-13 20:03:20 +09:00
anchors.centerIn: parent
2023-06-13 20:03:20 +09:00
width: 24
height: 24
}
}
contentItem: Item {
2024-03-25 22:30:44 +05:00
anchors.left: parent.left
anchors.right: parent.right
2023-04-26 18:37:56 +03:00
anchors.leftMargin: 8 + background.width
2024-03-25 22:30:44 +05:00
implicitHeight: content.implicitHeight
ColumnLayout {
id: content
anchors.left: parent.left
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
2023-06-01 11:25:33 +08:00
spacing: 4
ListItemTitleType {
text: root.text
maximumLineCount: root.textMaximumLineCount
elide: root.textElide
color: {
if (root.checked) {
return selectedTextColor
}
return textColor
2023-06-01 11:25:33 +08:00
}
Layout.fillWidth: true
2023-06-01 11:25:33 +08:00
Behavior on color {
PropertyAnimation { duration: 200 }
}
2023-06-01 11:25:33 +08:00
}
CaptionTextType {
id: description
2023-06-01 11:25:33 +08:00
color: "#878B91"
text: root.descriptionText
visible: root.descriptionText !== ""
Layout.fillWidth: true
}
}
}
MouseArea {
2023-04-26 18:37:56 +03:00
anchors.fill: root
cursorShape: Qt.PointingHandCursor
2023-04-26 18:37:56 +03:00
enabled: false
}
}
2023-04-26 18:37:56 +03:00