Client OPDS per Calibre Web (Sailfish OS): core C++ testato, UI Silica, packaging RPM
This commit is contained in:
@@ -0,0 +1,103 @@
|
||||
import QtQuick 2.0
|
||||
import Sailfish.Silica 1.0
|
||||
|
||||
Page {
|
||||
id: page
|
||||
|
||||
property string testResult: ""
|
||||
property bool testOk: false
|
||||
|
||||
SilicaFlickable {
|
||||
anchors.fill: parent
|
||||
contentHeight: column.height
|
||||
|
||||
Column {
|
||||
id: column
|
||||
width: parent.width
|
||||
|
||||
PageHeader { title: "Impostazioni" }
|
||||
|
||||
SectionHeader { text: "Server" }
|
||||
|
||||
TextField {
|
||||
id: serverField
|
||||
width: parent.width
|
||||
label: "Indirizzo Calibre Web"
|
||||
placeholderText: "https://calibre.example.com"
|
||||
text: appSettings.serverUrl
|
||||
inputMethodHints: Qt.ImhUrlCharactersOnly
|
||||
onTextChanged: appSettings.serverUrl = text
|
||||
}
|
||||
|
||||
TextField {
|
||||
id: userField
|
||||
width: parent.width
|
||||
label: "Utente (vuoto = accesso anonimo)"
|
||||
text: appSettings.username
|
||||
onTextChanged: appSettings.username = text
|
||||
}
|
||||
|
||||
TextField {
|
||||
id: passField
|
||||
width: parent.width
|
||||
label: "Password"
|
||||
text: appSettings.password
|
||||
echoMode: TextInput.Password
|
||||
onTextChanged: appSettings.password = text
|
||||
}
|
||||
|
||||
Switch {
|
||||
text: "Ignora errori certificato SSL"
|
||||
description: "Da attivare se il server usa un certificato autofirmato"
|
||||
checked: appSettings.ignoreSslErrors
|
||||
onCheckedChanged: appSettings.ignoreSslErrors = checked
|
||||
}
|
||||
|
||||
SectionHeader { text: "Connessione" }
|
||||
|
||||
Button {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
text: "Prova connessione"
|
||||
onClicked: testConnection()
|
||||
}
|
||||
|
||||
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.baseUrl
|
||||
if (base.length === 0) {
|
||||
page.testResult = "Inserisci l'indirizzo del server"
|
||||
page.testOk = false
|
||||
return
|
||||
}
|
||||
page.testResult = "Verifica in corso…"
|
||||
apiClient.getFeed(base + "/opds")
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: apiClient
|
||||
onFeedReady: {
|
||||
if (pageStack.currentPage !== page)
|
||||
return
|
||||
page.testOk = true
|
||||
page.testResult = "Connessione OK: " + entries.length + " sezioni trovate"
|
||||
}
|
||||
onFeedError: {
|
||||
if (pageStack.currentPage !== page)
|
||||
return
|
||||
page.testOk = false
|
||||
page.testResult = message
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user