Prova connessione: timeout 30s, busy indicator, normalizzazione https://, log qDebug per debug su device

This commit is contained in:
2026-08-12 10:58:34 +02:00
parent 40fa34a0d2
commit 5f97cb45bf
2 changed files with 39 additions and 2 deletions
+20 -1
View File
@@ -6,6 +6,7 @@ Page {
property string testResult: ""
property bool testOk: false
property bool testing: false
SilicaFlickable {
anchors.fill: parent
@@ -58,9 +59,20 @@ Page {
Button {
anchors.horizontalCenter: parent.horizontalCenter
text: "Prova connessione"
enabled: !page.testing
onClicked: testConnection()
}
Item {
width: parent.width
height: page.testing ? Theme.itemSizeSmall : 0
BusyIndicator {
anchors.horizontalCenter: parent.horizontalCenter
running: page.testing
size: BusyIndicatorSize.Small
}
}
Label {
x: Theme.horizontalPageMargin
width: parent.width - 2 * Theme.horizontalPageMargin
@@ -75,12 +87,17 @@ Page {
}
function testConnection() {
var base = appSettings.baseUrl
var base = appSettings.serverUrl.trim()
if (base.length === 0) {
page.testResult = "Inserisci l'indirizzo del server"
page.testOk = false
return
}
// normalizza: senza schema aggiunge https:// e lo salva nel campo
if (base.indexOf("http://") !== 0 && base.indexOf("https://") !== 0)
base = "https://" + base
appSettings.serverUrl = base
page.testing = true
page.testResult = "Verifica in corso…"
apiClient.getFeed(base + "/opds")
}
@@ -90,12 +107,14 @@ Page {
onFeedReady: {
if (pageStack.currentPage !== page)
return
page.testing = false
page.testOk = true
page.testResult = "Connessione OK: " + entries.length + " sezioni trovate"
}
onFeedError: {
if (pageStack.currentPage !== page)
return
page.testing = false
page.testOk = false
page.testResult = message
}