Files
amnezia-client/client/ui/qml/Pages2/PageSettingsApiLanguageList.qml
T

106 lines
3.0 KiB
QML
Raw Normal View History

import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import QtQuick.Dialogs
import PageEnum 1.0
import Style 1.0
import "./"
import "../Controls2"
import "../Controls2/TextTypes"
import "../Config"
import "../Components"
PageType {
id: root
ListView {
id: menuContent
property bool isFocusable: true
width: parent.width
height: parent.height
clip: true
interactive: true
model: ApiCountryModel
ButtonGroup {
id: containersRadioButtonGroup
}
2024-12-31 04:16:52 +01:00
delegate: ColumnLayout {
id: content
width: menuContent.width
height: content.implicitHeight
2024-12-31 04:16:52 +01:00
RowLayout {
VerticalRadioButton {
id: containerRadioButton
2024-12-31 04:16:52 +01:00
Layout.fillWidth: true
Layout.leftMargin: 16
2024-12-31 04:16:52 +01:00
text: countryName
2024-12-31 04:16:52 +01:00
ButtonGroup.group: containersRadioButtonGroup
2024-12-31 04:16:52 +01:00
imageSource: "qrc:/images/controls/download.svg"
2024-12-31 04:16:52 +01:00
checked: index === ApiCountryModel.currentIndex
checkable: !ConnectionController.isConnected
2024-12-31 04:16:52 +01:00
onClicked: {
if (ConnectionController.isConnected) {
PageController.showNotificationMessage(qsTr("Unable change server location while there is an active connection"))
return
}
2024-12-31 04:16:52 +01:00
if (index !== ApiCountryModel.currentIndex) {
PageController.showBusyIndicator(true)
var prevIndex = ApiCountryModel.currentIndex
ApiCountryModel.currentIndex = index
if (!InstallController.updateServiceFromApi(ServersModel.defaultIndex, countryCode, countryName)) {
ApiCountryModel.currentIndex = prevIndex
}
}
2024-12-31 04:16:52 +01:00
}
2024-12-31 04:16:52 +01:00
MouseArea {
anchors.fill: containerRadioButton
cursorShape: Qt.PointingHandCursor
enabled: false
}
2024-12-31 04:16:52 +01:00
Keys.onEnterPressed: {
if (checkable) {
checked = true
}
2024-12-31 04:16:52 +01:00
containerRadioButton.clicked()
}
Keys.onReturnPressed: {
if (checkable) {
checked = true
}
2024-12-31 04:16:52 +01:00
containerRadioButton.clicked()
}
2024-12-31 04:16:52 +01:00
}
2024-12-31 04:16:52 +01:00
Image {
Layout.rightMargin: 32
Layout.alignment: Qt.AlignRight
2024-12-31 04:16:52 +01:00
source: "qrc:/countriesFlags/images/flagKit/" + countryImageCode + ".svg"
}
2024-12-31 04:16:52 +01:00
}
2024-12-31 04:16:52 +01:00
DividerType {
Layout.fillWidth: true
}
}
}
}