Bozze: salva in Drafts, riprendi, sostituisci per id (0.15.0)

Compose con Queue=0 scrive il messaggio senza metterlo in coda; la cartella e'
Drafts (nuovo tipo 'draft' in folders()). Riprendendo una bozza il motore la
sostituisce per id (Draft), non ne crea una seconda; dopo l'invio va nel
cestino. Foglio di composizione estratto in foglioMessaggio(), usato da invio
e bozza.
This commit is contained in:
Carlo Baratto committed 2026-11-17 12:12:23 +01:00
1 parent 69f97d99b8
commit d7549cedd0
6 files changed
+187 -22

No files matched your search

+44
View File
@@ -10,6 +10,7 @@ Page {
property string destinatario: ""
property string copia: ""
property string bcc: ""
property string oggetto: ""
property string corpo: ""
property string mittente: ""
@@ -19,6 +20,10 @@ Page {
property var suggerimenti: []
// Percorsi dei file da allegare: li legge il motore dal disco.
property var allegati: []
// Bozza che si sta riprendendo: cartella e riga; -1 = messaggio nuovo.
property int bozzaCartella: -1
property int bozzaRiga: -1
property int bozzaId: -1
// Il "Da" si vede e si può correggere qui: se il campo in Account non è
// stato salvato, l'invio non resta bloccato senza spiegazione.
@@ -27,6 +32,31 @@ Page {
page.mittente = account.mittente;
else if (account.persona.indexOf("@") > 0)
page.mittente = account.persona;
if (page.bozzaRiga >= 0) page.riprendi();
}
// Riprendere una bozza: i campi tornano come erano, allegati compresi.
function riprendi() {
var b = engine.bozza(page.bozzaCartella, page.bozzaRiga);
page.destinatario = b.a;
page.copia = b.cc;
page.bcc = b.bcc;
page.oggetto = b.oggetto;
page.corpo = b.corpo;
page.allegati = b.allegati ? b.allegati : [];
if (b.da.length > 0) page.mittente = b.da;
// L'id serve al motore per sostituire questa bozza invece di
// crearne una seconda.
page.bozzaId = engine.idOf(page.bozzaCartella, page.bozzaRiga);
}
function salvaBozza() {
page.errore = engine.salvaBozza(campoA.text, campoCc.text,
campoBcc.text, campoDa.text,
campoOggetto.text, campoCorpo.text,
page.allegati, page.bozzaId);
if (page.errore.length === 0)
pageStack.pop();
}
SilicaFlickable {
@@ -113,6 +143,7 @@ Page {
anchors.horizontalCenter: parent.horizontalCenter
label: qsTr("Bcc")
placeholderText: qsTr("destinatari nascosti, facoltativo")
text: page.bcc
inputMethodHints: Qt.ImhEmailCharactersOnly | Qt.ImhNoAutoUppercase
EnterKey.enabled: true
EnterKey.iconSource: "image://theme/icon-m-enter-next"
@@ -172,6 +203,15 @@ Page {
}
}
Button {
id: pulsanteBozza
anchors.horizontalCenter: parent.horizontalCenter
text: qsTr("Salva bozza")
preferredWidth: Theme.buttonWidthSmall
enabled: !page.inviando
onClicked: page.salvaBozza()
}
Button {
id: pulsanteInvia
anchors.horizontalCenter: parent.horizontalCenter
@@ -284,6 +324,10 @@ Page {
page.errore = motivo;
return;
}
// Se il messaggio partiva da una bozza, la bozza ha finito il suo
// lavoro: la si toglie di mezzo, altrimenti resta lì a confondere.
if (page.bozzaRiga >= 0)
engine.moveToTrash(page.bozzaCartella, page.bozzaRiga);
page.inviando = true;
}