Files

71 lines
2.2 KiB
QML
Raw Permalink Normal View History

2026-02-13 20:53:08 +01:00
import QtQuick
import QtQuick.Controls.Basic as QQC2
import "../Flowee" as Flowee
Page {
id: root
headerText: qsTr("Select Language")
Flowee.TextField {
id: searchField
width: parent.width
placeholderText: qsTr("Search languages...")
onDisplayTextChanged: {
if (text === "") listView.model = listView.allLanguages
var query = displayText.toLowerCase()
if (query === "") {
listView.model = Pay.languageList
} else {
listView.model = Pay.languageList.filter(function(item) {
var displayName = item.split(";")[0]
return displayName.toLowerCase().indexOf(query) !== -1
})
}
}
Flowee.Dialog {
id: requestExit
property int newLanguage: 1
title: qsTr("Restart Pay?")
text: qsTr("Pay needs to restart to apply the selected language")
onAccepted: mainWindow.close()
onRejected: thePile.pop()
standardButtons: QQC2.DialogButtonBox.Yes | QQC2.DialogButtonBox.No
}
}
ListView {
id: listView
width: parent.width
anchors.top: searchField.bottom
anchors.topMargin: 10
anchors.bottom: parent.bottom
property var allLanguages: Pay.languageList
property int current: Pay.userLanguage
model: allLanguages
delegate: Rectangle {
width: ListView.view.width
height: 56
color: selected ? palette.highlight : "transparent"
radius: 6
property bool selected: listView.current === parseInt(modelData.split(";")[1])
Flowee.Label {
x: 10
text: modelData.split(";")[0]
anchors.verticalCenter: parent.verticalCenter
font.pixelSize: root.font.pixelSize * 1.3
color: parent.selected ? palette.highlightedText : palette.text
}
MouseArea {
anchors.fill: parent
onClicked: {
Pay.userLanguage = parseInt(modelData.split(";")[1])
requestExit.visible = true
}
}
}
}
}