import QtQuick 2.0 import Sailfish.Silica 1.0 Page { id: page property string testResult: "" property bool testOk: false property bool testing: false SilicaFlickable { anchors.fill: parent contentHeight: column.height Column { id: column width: parent.width PageHeader { title: "Impostazioni" } SectionHeader { text: "Server" } TextField { id: serverField anchors.left: parent.left anchors.right: parent.right label: "Indirizzo Calibre Web" placeholderText: "https://calibre.example.com" text: appSettings.serverUrl inputMethodHints: Qt.ImhUrlCharactersOnly onTextChanged: appSettings.serverUrl = text } TextField { id: userField anchors.left: parent.left anchors.right: parent.right label: "Utente (vuoto = accesso anonimo)" text: appSettings.username onTextChanged: appSettings.username = text } TextField { id: passField anchors.left: parent.left anchors.right: parent.right label: "Password" text: appSettings.password echoMode: TextInput.Password onTextChanged: appSettings.password = text } TextSwitch { text: "Ignora errori certificato SSL" description: "Da attivare se il server usa un certificato autofirmato" checked: appSettings.ignoreSslErrors onCheckedChanged: appSettings.ignoreSslErrors = checked } SectionHeader { text: "Lettore" } Slider { id: marginSlider label: "Margini del testo" minimumValue: 0 maximumValue: 80 stepSize: 4 value: appSettings.readerMargin valueText: value + " px" onValueChanged: appSettings.readerMargin = value } SectionHeader { text: "Connessione" } 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 text: page.testResult color: page.testOk ? Theme.secondaryHighlightColor : Theme.errorColor wrapMode: Text.Wrap visible: text.length > 0 } Item { width: 1; height: Theme.paddingLarge } } } function testConnection() { 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") } Connections { target: apiClient 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 } } }