Files
harbour-grumpydove/qml/pages/SettingsPage.qml
T
Carlo Baratto 906f9e1cff Tornare all'utente e alla password dedotti (0.24.8)
Il campo vuoto non cancella una password: accanto ai due campi SMTP c'e' ora un
collegamento per tornare all'utente dedotto e alla password della posta.
2026-11-24 21:50:10 +01:00

404 lines
16 KiB
QML

import QtQuick 2.0
import Sailfish.Silica 1.0
// Configurazione dell'account. Nel client originale queste voci stavano in
// Tools > Personalities: qui sono i campi di un server IMAP e di uno SMTP,
// salvati in ~/.config/harbour/grumpydove/grumpydove.conf.
Page {
id: page
SilicaFlickable {
anchors.fill: parent
contentHeight: colonna.height + Theme.paddingLarge
PageHeader {
id: intestazione
title: qsTr("Account")
description: qsTr("Server di posta in arrivo e in partenza")
}
Column {
id: colonna
anchors.top: intestazione.bottom
width: parent.width
spacing: Theme.paddingMedium
// Con più account i campi qui sotto sono quelli di questo: si
// sceglie in cima e il resto della pagina non cambia.
ComboBox {
width: parent.width - 2 * Theme.horizontalPageMargin
anchors.horizontalCenter: parent.horizontalCenter
label: qsTr("Account da modificare")
currentIndex: account.indiceCorrente
menu: ContextMenu {
Repeater {
model: account.nomiAccount()
MenuItem {
text: modelData
onClicked: account.seleziona(index)
}
}
}
}
Row {
anchors.horizontalCenter: parent.horizontalCenter
spacing: Theme.paddingMedium
Button {
text: qsTr("Nuovo account")
onClicked: account.aggiungiAccount()
}
Button {
text: qsTr("Elimina questo")
enabled: account.quanti > 1
onClicked: Remorse.itemAction(page, qsTr("Eliminare «%1»?").arg(account.persona),
function() { account.eliminaAccount(account.indiceCorrente) })
}
}
TextField {
width: parent.width - 2 * Theme.horizontalPageMargin
anchors.horizontalCenter: parent.horizontalCenter
label: qsTr("Nome dell'account")
placeholderText: qsTr("per esempio: casa")
text: account.persona
onTextChanged: account.persona = text
}
TextField {
width: parent.width - 2 * Theme.horizontalPageMargin
anchors.horizontalCenter: parent.horizontalCenter
label: qsTr("Indirizzo del mittente")
placeholderText: qsTr("nome@example.org")
inputMethodHints: Qt.ImhEmailCharactersOnly | Qt.ImhNoAutoUppercase
text: account.mittente
onTextChanged: account.mittente = text.trim()
}
// Firma: testo semplice, aggiunto in fondo ai messaggi nuovi.
TextArea {
width: parent.width - 2 * Theme.horizontalPageMargin
anchors.horizontalCenter: parent.horizontalCenter
label: qsTr("Firma")
placeholderText: qsTr("facoltativa: due righe al massimo si leggono meglio")
text: account.firma
height: Math.max(Theme.itemSizeLarge * 2,
implicitHeight + Theme.paddingLarge)
onTextChanged: account.firma = text
}
SectionHeader { text: qsTr("Posta in arrivo (IMAP)") }
TextField {
width: parent.width - 2 * Theme.horizontalPageMargin
anchors.horizontalCenter: parent.horizontalCenter
label: qsTr("Server")
placeholderText: qsTr("imap.example.org")
inputMethodHints: Qt.ImhUrlCharactersOnly | Qt.ImhNoAutoUppercase
text: account.imapHost
onTextChanged: account.imapHost = text.trim()
}
TextField {
width: parent.width - 2 * Theme.horizontalPageMargin
anchors.horizontalCenter: parent.horizontalCenter
label: qsTr("Porta")
inputMethodHints: Qt.ImhDigitsOnly
text: account.imapPort
onTextChanged: {
var n = parseInt(text);
if (n > 0) account.imapPort = n;
}
}
ComboBox {
width: parent.width - 2 * Theme.horizontalPageMargin
anchors.horizontalCenter: parent.horizontalCenter
label: qsTr("Sicurezza")
currentIndex: account.imapSecurity
menu: ContextMenu {
MenuItem { text: qsTr("Nessuna") }
MenuItem { text: qsTr("STARTTLS") }
MenuItem { text: qsTr("TLS") }
}
onCurrentIndexChanged: account.imapSecurity = currentIndex
}
TextField {
width: parent.width - 2 * Theme.horizontalPageMargin
anchors.horizontalCenter: parent.horizontalCenter
label: qsTr("Utente")
inputMethodHints: Qt.ImhEmailCharactersOnly | Qt.ImhNoAutoUppercase
text: account.user
onTextChanged: account.user = text
}
PasswordField {
width: parent.width - 2 * Theme.horizontalPageMargin
anchors.horizontalCenter: parent.horizontalCenter
label: qsTr("Password")
text: account.password
showEchoModeToggle: true
// Una password vuota nel campo non deve cancellare quella
// salvata: al salvataggio il valore resterebbe vuoto e il
// client smetterebbe di autenticare senza dire niente.
onTextChanged: if (text.length > 0) account.password = text
}
SectionHeader { text: qsTr("Posta in partenza (SMTP)") }
TextField {
width: parent.width - 2 * Theme.horizontalPageMargin
anchors.horizontalCenter: parent.horizontalCenter
label: qsTr("Server")
placeholderText: qsTr("smtp.example.org")
inputMethodHints: Qt.ImhUrlCharactersOnly | Qt.ImhNoAutoUppercase
text: account.smtpHost
onTextChanged: account.smtpHost = text.trim()
}
TextField {
width: parent.width - 2 * Theme.horizontalPageMargin
anchors.horizontalCenter: parent.horizontalCenter
label: qsTr("Porta")
inputMethodHints: Qt.ImhDigitsOnly
text: account.smtpPort
onTextChanged: {
var n = parseInt(text);
if (n > 0) account.smtpPort = n;
}
}
ComboBox {
width: parent.width - 2 * Theme.horizontalPageMargin
anchors.horizontalCenter: parent.horizontalCenter
label: qsTr("Sicurezza")
currentIndex: account.smtpSecurity
menu: ContextMenu {
MenuItem { text: qsTr("Nessuna") }
MenuItem { text: qsTr("STARTTLS") }
MenuItem { text: qsTr("TLS") }
}
onCurrentIndexChanged: account.smtpSecurity = currentIndex
}
// Non sempre l'invio usa lo stesso utente della posta in arrivo:
// capita che voglia l'indirizzo intero invece del nome corto.
TextField {
width: parent.width - 2 * Theme.horizontalPageMargin
anchors.horizontalCenter: parent.horizontalCenter
label: qsTr("Utente per l'invio")
placeholderText: qsTr("vuoto = utente della posta")
inputMethodHints: Qt.ImhEmailCharactersOnly | Qt.ImhNoAutoUppercase
text: account.smtpUser
onTextChanged: account.smtpUser = text.trim()
}
Label {
x: Theme.horizontalPageMargin
width: parent.width - 2 * Theme.horizontalPageMargin
visible: account.smtpUser.length > 0
wrapMode: Text.WordWrap
font.pixelSize: Theme.fontSizeExtraSmall
color: Theme.highlightColor
text: qsTr("Torna all'utente dedotto")
MouseArea {
anchors.fill: parent
onClicked: account.smtpUser = ""
}
}
TextField {
width: parent.width - 2 * Theme.horizontalPageMargin
anchors.horizontalCenter: parent.horizontalCenter
label: qsTr("Password per l'invio")
placeholderText: qsTr("vuota = password della posta")
echoMode: TextInput.Password
text: account.smtpPassword
onTextChanged: if (text.length > 0) account.smtpPassword = text
}
// Il campo vuoto non cancella (una password non si perde per un
// tocco sbagliato): per tornare a quella della posta c'e' questo.
Label {
x: Theme.horizontalPageMargin
width: parent.width - 2 * Theme.horizontalPageMargin
visible: account.smtpPassword.length > 0
wrapMode: Text.WordWrap
font.pixelSize: Theme.fontSizeExtraSmall
color: Theme.highlightColor
text: qsTr("Torna alla password della posta")
MouseArea {
anchors.fill: parent
onClicked: account.smtpPassword = ""
}
}
TextField {
width: parent.width - 2 * Theme.horizontalPageMargin
anchors.horizontalCenter: parent.horizontalCenter
label: qsTr("Messaggi da tenere per cartella")
description: qsTr("0 = tutti")
inputMethodHints: Qt.ImhDigitsOnly
text: account.keep
onTextChanged: {
var n = parseInt(text);
if (!isNaN(n)) account.keep = n;
}
}
SectionHeader { text: qsTr("Controllo automatico") }
TextField {
width: parent.width - 2 * Theme.horizontalPageMargin
anchors.horizontalCenter: parent.horizontalCenter
label: qsTr("Ogni quanti minuti")
description: qsTr("0 = solo quando lo chiedi tu")
inputMethodHints: Qt.ImhDigitsOnly
text: engine.minutiControllo()
onTextChanged: {
var n = parseInt(text);
if (!isNaN(n)) engine.setMinutiControllo(n);
}
}
SectionHeader { text: qsTr("Notifiche push") }
Label {
width: parent.width - 2 * Theme.horizontalPageMargin
anchors.horizontalCenter: parent.horizontalCenter
wrapMode: Text.Wrap
font.pixelSize: Theme.fontSizeExtraSmall
color: Theme.secondaryColor
text: pushService.endpoint.length > 0
? qsTr("Registrato. Questo è l'indirizzo da mettere nel watcher del server:")
: qsTr("Non registrato: serve il distributore UnifiedPush (FogHorn). Senza push la posta si controlla ogni N minuti.")
}
Label {
width: parent.width - 2 * Theme.horizontalPageMargin
anchors.horizontalCenter: parent.horizontalCenter
wrapMode: Text.WrapAnywhere
visible: pushService.endpoint.length > 0
text: pushService.endpoint
font.pixelSize: Theme.fontSizeExtraSmall
color: Theme.primaryColor
}
SectionHeader { text: qsTr("Rubrica (CardDAV)") }
TextField {
width: parent.width - 2 * Theme.horizontalPageMargin
anchors.horizontalCenter: parent.horizontalCenter
label: qsTr("Indirizzo del libro")
placeholderText: qsTr("https://…/addressbooks/user/contacts/")
inputMethodHints: Qt.ImhUrlCharactersOnly | Qt.ImhNoAutoUppercase
text: account.bookUrl
onTextChanged: account.bookUrl = text.trim()
}
TextField {
width: parent.width - 2 * Theme.horizontalPageMargin
anchors.horizontalCenter: parent.horizontalCenter
label: qsTr("Utente del libro")
placeholderText: qsTr("vuoto = utente della posta")
text: account.bookUser
onTextChanged: account.bookUser = text.trim()
}
TextField {
width: parent.width - 2 * Theme.horizontalPageMargin
anchors.horizontalCenter: parent.horizontalCenter
label: qsTr("Password del libro")
placeholderText: qsTr("vuota = password della posta")
echoMode: TextInput.Password
text: account.bookPassword
onTextChanged: if (text.length > 0) account.bookPassword = text
}
SectionHeader { text: qsTr("Stazioni (testi pronti)") }
Label {
x: Theme.horizontalPageMargin
width: parent.width - 2 * Theme.horizontalPageMargin
wrapMode: Text.WordWrap
font.pixelSize: Theme.fontSizeExtraSmall
color: Theme.secondaryColor
visible: account.nomiStazioni().length === 0
text: qsTr("Si creano scrivendo un messaggio: menu → «Salva il testo come stazione».")
}
Repeater {
model: account.nomiStazioni()
Item {
width: parent.width
height: Theme.itemSizeSmall
Label {
anchors.left: parent.left
anchors.leftMargin: Theme.horizontalPageMargin
anchors.verticalCenter: parent.verticalCenter
text: modelData
}
IconButton {
anchors.right: parent.right
anchors.rightMargin: Theme.horizontalPageMargin
anchors.verticalCenter: parent.verticalCenter
icon.source: "image://theme/icon-m-delete"
onClicked: Remorse.itemAction(page, qsTr("Eliminare la stazione «%1»?").arg(modelData),
function() { account.eliminaStazione(index) })
}
}
}
Button {
anchors.horizontalCenter: parent.horizontalCenter
text: qsTr("Salva")
preferredWidth: Theme.buttonWidthSmall
onClicked: page.salva()
}
Label {
width: parent.width - 2 * Theme.horizontalPageMargin
anchors.horizontalCenter: parent.horizontalCenter
horizontalAlignment: Text.AlignHCenter
text: account.configPath()
font.pixelSize: Theme.fontSizeExtraSmall
color: Theme.secondaryColor
wrapMode: Text.Wrap
}
Label {
width: parent.width - 2 * Theme.horizontalPageMargin
anchors.horizontalCenter: parent.horizontalCenter
horizontalAlignment: Text.AlignHCenter
text: qsTr("GrumpyDove Mobile %1").arg(appVersion)
font.pixelSize: Theme.fontSizeExtraSmall
color: Theme.secondaryColor
}
}
VerticalScrollDecorator { }
}
function salva() {
account.save();
avviso.text = qsTr("Account salvato");
avvisoTimer.restart();
}
Label {
id: avviso
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: parent.bottom
anchors.bottomMargin: Theme.paddingLarge
font.pixelSize: Theme.fontSizeSmall
color: Theme.highlightColor
}
Timer {
id: avvisoTimer
interval: 1500
onTriggered: avviso.text = ""
}
}