Selettore lingua (System/EN/IT) nelle impostazioni con QTranslator in main.cpp (pattern quill); fix 'Close book' con pop fino alla prima pagina

This commit is contained in:
2026-08-19 16:27:36 +02:00
parent e3ba9b5e87
commit d8584f2de4
7 changed files with 176 additions and 71 deletions
+4 -1
View File
@@ -57,7 +57,10 @@ Page {
text: qsTr("Close book")
onClicked: {
page.maybeSave(true)
pageStack.popTo(null)
// torna alla prima pagina dello stack (MainPage):
// popTo(null) non è affidabile su questa Silica
while (pageStack.depth > 1)
pageStack.pop()
}
}
}
+38
View File
@@ -7,6 +7,7 @@ Page {
property string testResult: ""
property bool testOk: false
property bool testing: false
property string languageNotice: ""
SilicaFlickable {
anchors.fill: parent
@@ -111,6 +112,43 @@ Page {
visible: text.length > 0
}
SectionHeader { text: qsTr("Language") }
ComboBox {
id: langBox
width: parent.width
label: qsTr("Language")
currentIndex: appSettings.language === "it" ? 2 : (appSettings.language === "en" ? 1 : 0)
menu: ContextMenu {
MenuItem { text: qsTr("System (default)") }
MenuItem { text: "English" }
MenuItem { text: "Italiano" }
}
onCurrentIndexChanged: {
var v = currentIndex === 2 ? "it" : (currentIndex === 1 ? "en" : "system")
if (v !== appSettings.language) {
appSettings.language = v
page.languageNotice = qsTr("Language will be applied after restarting the app")
langNoticeTimer.restart()
}
}
}
Label {
x: Theme.horizontalPageMargin
width: parent.width - 2 * Theme.horizontalPageMargin
text: page.languageNotice
color: Theme.highlightColor
wrapMode: Text.Wrap
visible: text.length > 0
}
Timer {
id: langNoticeTimer
interval: 4000
onTriggered: page.languageNotice = ""
}
Item { width: 1; height: Theme.paddingLarge }
}
}