Allegati: elenco, salvataggio in Download e apertura (0.4.0)

- bridge: attachments() legge nome/lunghezza/byte come la vista originale e
  li tiene in cache; saveAttachment() scrive in Download con QSaveFile e
  scarta i percorsi nel nome scelto dal mittente
- MessagePage: sezione con nome e dimensione, un tocco salva e apre
- permesso SailJail Downloads nel desktop file
This commit is contained in:
Carlo Baratto committed 2026-11-11 13:04:34 +01:00
1 parent 639bb9880d
commit 5e1f73774f
7 files changed
+171 -8

No files matched your search

+65
View File
@@ -18,6 +18,7 @@ Page {
property string quando: ""
property string indirizzo: ""
property string corpo: ""
property var allegati: []
Component.onCompleted: leggi()
@@ -33,9 +34,28 @@ Page {
page.quando = engine.cell(page.cartella, page.riga, 5);
page.oggetto = engine.cell(page.cartella, page.riga, 7);
page.corpo = engine.body(page.cartella, page.riga);
page.allegati = engine.attachments(page.cartella, page.riga);
page.totale = engine.messages(page.cartella).length;
}
function salvaAllegato(indice) {
var path = engine.saveAttachment(page.cartella, page.riga, indice);
if (path.length > 0) {
avviso.text = qsTr("Salvato in %1").arg(path);
avvisoTimer.restart();
Qt.openUrlExternally("file://" + path);
} else {
avviso.text = qsTr("Non e' stato possibile salvare l'allegato");
avvisoTimer.restart();
}
}
function dimensione(bytes) {
if (bytes < 1024) return bytes + " B";
if (bytes < 1048576) return Math.round(bytes / 1024) + " KB";
return (bytes / 1048576).toFixed(1) + " MB";
}
function vai(delta) {
var nuovo = page.riga + delta;
if (nuovo < 0 || nuovo >= page.totale) {
@@ -105,6 +125,51 @@ Page {
color: Theme.primaryColor
bottomPadding: Theme.paddingLarge
}
// Allegati: un tocco li salva in Download e li apre con l'app
// associata. I nomi li sceglie il mittente, quindi il bridge
// scarta ogni percorso.
SectionHeader {
visible: page.allegati.length > 0
text: page.allegati.length === 1 ? qsTr("1 allegato")
: qsTr("%1 allegati").arg(page.allegati.length)
}
Repeater {
model: page.allegati
delegate: BackgroundItem {
width: contenuto.width
height: Theme.itemSizeSmall
onClicked: page.salvaAllegato(modelData.indice)
Row {
anchors.verticalCenter: parent.verticalCenter
spacing: Theme.paddingMedium
Image {
anchors.verticalCenter: parent.verticalCenter
width: Theme.iconSizeExtraSmall
height: width
source: "qrc:/images/icona-allegato.png"
smooth: false
}
Label {
anchors.verticalCenter: parent.verticalCenter
text: modelData.nome
font.pixelSize: Theme.fontSizeSmall
color: Theme.primaryColor
truncationMode: TruncationMode.Fade
}
Label {
anchors.verticalCenter: parent.verticalCenter
text: page.dimensione(modelData.dimensione)
font.pixelSize: Theme.fontSizeExtraSmall
color: Theme.secondaryColor
}
}
}
}
}
PullDownMenu {