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

173 lines
5.1 KiB
QML
Raw Normal View History

import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
2024-07-07 13:42:38 +03:00
import Style 1.0
import "../Controls2"
import "../Controls2/TextTypes"
2024-04-18 17:54:55 +04:00
import "../Config"
2024-02-16 15:24:06 +05:00
DrawerType2 {
id: root
2024-12-31 04:16:52 +01:00
expandedStateContent: Item {
2024-02-16 15:24:06 +05:00
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 {
2024-04-18 17:54:55 +04:00
id: backButtonLayout
2024-02-16 15:24:06 +05:00
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 16
2024-02-16 15:24:06 +05:00
BackButtonType {
2024-04-18 17:54:55 +04:00
id: backButton
2024-12-31 04:16:52 +01:00
Layout.fillWidth: true
2024-02-16 15:24:06 +05:00
backButtonImage: "qrc:/images/controls/arrow-left.svg"
2024-12-31 04:16:52 +01:00
backButtonFunction: function() { root.closeTriggered() }
}
Header2Type {
id: header
Layout.fillWidth: true
Layout.topMargin: 16
Layout.rightMargin: 16
Layout.leftMargin: 16
headerText: qsTr("Choose language")
}
}
ListViewType {
2024-12-31 04:16:52 +01:00
id: listView
2024-04-18 17:54:55 +04:00
anchors.top: backButtonLayout.bottom
2024-02-16 15:24:06 +05:00
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
2024-12-31 04:16:52 +01:00
property int selectedIndex: LanguageModel.currentLanguageIndex
2024-12-31 04:16:52 +01:00
model: LanguageModel
2024-12-31 04:16:52 +01:00
ButtonGroup {
id: buttonGroup
}
2024-12-31 04:16:52 +01:00
delegate: Item {
implicitWidth: root.width
implicitHeight: delegateContent.implicitHeight
2024-12-31 04:16:52 +01:00
ColumnLayout {
id: delegateContent
2024-12-31 04:16:52 +01:00
anchors.fill: parent
2024-12-31 04:16:52 +01:00
RadioButton {
id: radioButton
2024-12-31 04:16:52 +01:00
implicitWidth: parent.width
implicitHeight: radioButtonContent.implicitHeight
2024-04-18 17:54:55 +04:00
2024-12-31 04:16:52 +01:00
hoverEnabled: true
2024-04-18 17:54:55 +04:00
2024-12-31 04:16:52 +01:00
property bool isFocusable: true
2024-04-18 17:54:55 +04:00
Keys.onTabPressed: {
2024-12-31 04:16:52 +01:00
FocusController.nextKeyTabItem()
2024-04-18 17:54:55 +04:00
}
2024-12-31 04:16:52 +01:00
Keys.onBacktabPressed: {
FocusController.previousKeyTabItem()
2024-04-18 17:54:55 +04:00
}
2024-12-31 04:16:52 +01:00
Keys.onUpPressed: {
FocusController.nextKeyUpItem()
2024-04-18 17:54:55 +04:00
}
2024-12-31 04:16:52 +01:00
Keys.onDownPressed: {
FocusController.nextKeyDownItem()
}
2024-12-31 04:16:52 +01:00
Keys.onLeftPressed: {
FocusController.nextKeyLeftItem()
}
2024-12-31 04:16:52 +01:00
Keys.onRightPressed: {
FocusController.nextKeyRightItem()
}
2024-12-31 04:16:52 +01:00
indicator: Rectangle {
width: parent.width - 1
height: parent.height
color: radioButton.hovered ? AmneziaStyle.color.slateGray : AmneziaStyle.color.onyxBlack
border.color: radioButton.focus ? AmneziaStyle.color.paleGray : AmneziaStyle.color.transparent
border.width: radioButton.focus ? 1 : 0
2024-12-31 04:16:52 +01:00
Behavior on color {
PropertyAnimation { duration: 200 }
}
Behavior on border.color {
PropertyAnimation { duration: 200 }
}
}
2024-12-31 04:16:52 +01:00
RowLayout {
id: radioButtonContent
anchors.fill: parent
2024-12-31 04:16:52 +01:00
anchors.rightMargin: 16
anchors.leftMargin: 16
2024-12-31 04:16:52 +01:00
spacing: 0
2024-12-31 04:16:52 +01:00
z: 1
2024-12-31 04:16:52 +01:00
ParagraphTextType {
Layout.fillWidth: true
Layout.topMargin: 20
Layout.bottomMargin: 20
2024-12-31 04:16:52 +01:00
text: languageName
}
2024-12-31 04:16:52 +01:00
Image {
source: "qrc:/images/controls/check.svg"
visible: radioButton.checked
2024-12-31 04:16:52 +01:00
width: 24
height: 24
2024-12-31 04:16:52 +01:00
Layout.rightMargin: 8
}
}
2024-04-18 17:54:55 +04:00
2024-12-31 04:16:52 +01:00
ButtonGroup.group: buttonGroup
checked: listView.selectedIndex === index
onClicked: {
listView.selectedIndex = index
LanguageModel.changeLanguage(languageIndex)
root.closeTriggered()
}
}
}
2024-12-31 04:16:52 +01:00
Keys.onEnterPressed: radioButton.clicked()
Keys.onReturnPressed: radioButton.clicked()
}
}
}
}