Files
amnezia-client/client/ui/qml/Components/SelectLanguageDrawer.qml
T

146 lines
4.4 KiB
QML
Raw Normal View History

import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import "../Controls2"
import "../Controls2/TextTypes"
2024-02-16 15:24:06 +05:00
DrawerType2 {
id: root
2024-02-16 15:24:06 +05:00
expandedContent: Item {
id: container
2024-02-16 15:24:06 +05:00
implicitHeight: root.height * 0.9
2024-02-16 15:24:06 +05:00
Component.onCompleted: {
root.expandedHeight = container.implicitHeight
}
ColumnLayout {
id: backButton
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 16
2024-02-16 15:24:06 +05:00
BackButtonType {
backButtonImage: "qrc:/images/controls/arrow-left.svg"
backButtonFunction: function() {
root.close()
}
}
}
2024-02-16 15:24:06 +05:00
FlickableType {
anchors.top: backButton.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
contentHeight: content.implicitHeight
2024-02-16 15:24:06 +05:00
ColumnLayout {
id: content
2024-02-16 15:24:06 +05:00
anchors.fill: parent
2024-02-16 15:24:06 +05:00
Header2Type {
id: header
Layout.fillWidth: true
Layout.topMargin: 16
Layout.rightMargin: 16
Layout.leftMargin: 16
2024-02-16 15:24:06 +05:00
headerText: qsTr("Choose language")
}
2024-02-16 15:24:06 +05:00
ListView {
id: listView
2024-02-16 15:24:06 +05:00
Layout.fillWidth: true
height: listView.contentItem.height
2024-02-16 15:24:06 +05:00
clip: true
interactive: false
2024-02-16 15:24:06 +05:00
model: LanguageModel
currentIndex: LanguageModel.currentLanguageIndex
2024-02-16 15:24:06 +05:00
ButtonGroup {
id: buttonGroup
}
2024-02-16 15:24:06 +05:00
delegate: Item {
implicitWidth: root.width
implicitHeight: delegateContent.implicitHeight
2024-02-16 15:24:06 +05:00
ColumnLayout {
id: delegateContent
2024-02-16 15:24:06 +05:00
anchors.fill: parent
2024-02-16 15:24:06 +05:00
RadioButton {
id: radioButton
2024-02-16 15:24:06 +05:00
implicitWidth: parent.width
implicitHeight: radioButtonContent.implicitHeight
2024-02-16 15:24:06 +05:00
hoverEnabled: true
2024-02-16 15:24:06 +05:00
indicator: Rectangle {
anchors.fill: parent
color: radioButton.hovered ? "#2C2D30" : "#1C1D21"
2024-02-16 15:24:06 +05:00
Behavior on color {
PropertyAnimation { duration: 200 }
}
}
2024-02-16 15:24:06 +05:00
RowLayout {
id: radioButtonContent
anchors.fill: parent
2024-02-16 15:24:06 +05:00
anchors.rightMargin: 16
anchors.leftMargin: 16
2024-02-16 15:24:06 +05:00
spacing: 0
2024-02-16 15:24:06 +05:00
z: 1
2024-02-16 15:24:06 +05:00
ParagraphTextType {
Layout.fillWidth: true
Layout.topMargin: 20
Layout.bottomMargin: 20
2024-02-16 15:24:06 +05:00
text: languageName
}
2024-02-16 15:24:06 +05:00
Image {
source: "qrc:/images/controls/check.svg"
visible: radioButton.checked
2024-02-16 15:24:06 +05:00
width: 24
height: 24
2024-02-16 15:24:06 +05:00
Layout.rightMargin: 8
}
}
2024-02-16 15:24:06 +05:00
ButtonGroup.group: buttonGroup
checked: listView.currentIndex === index
2024-02-16 15:24:06 +05:00
onClicked: {
listView.currentIndex = index
LanguageModel.changeLanguage(languageIndex)
root.close()
}
}
}
}
}
}
}
}
}