Sul telefono le icone delle cartelle e la graffetta non comparivano: le immagini erano riferite con un percorso relativo. Ora stanno in images.qrc compilato nel binario e la QML le legge da qrc:/images/... — 0.1.2
145 lines
4.9 KiB
QML
145 lines
4.9 KiB
QML
import QtQuick 2.0
|
|
import Sailfish.Silica 1.0
|
|
import "../js/dati.js" as Dati
|
|
|
|
// Cartelle: l'albero di Eudora (account -> cartelle -> sottocartelle)
|
|
// appiattito in una lista, con i non letti che risalgono fino all'account.
|
|
Page {
|
|
id: page
|
|
|
|
ListModel { id: cartelle }
|
|
|
|
Component.onCompleted: {
|
|
for (var i = 0; i < Dati.MAILBOXES.length; i++) {
|
|
var m = Dati.MAILBOXES[i];
|
|
cartelle.append({
|
|
nome: m.name,
|
|
livello: m.depth,
|
|
nonLetti: m.unread,
|
|
tipo: m.kind,
|
|
mailbox: m.mailbox
|
|
});
|
|
}
|
|
}
|
|
|
|
function apriCartella(nome, box) {
|
|
if (box === "") return; // l'account non e' una cartella
|
|
pageStack.push(Qt.resolvedUrl("MessagesPage.qml"),
|
|
{ cartella: box, titolo: nome });
|
|
}
|
|
|
|
// Le icone vengono dagli sprite dell'originale (icons/ di GrumpyDove,
|
|
// BSD 3-Clause, © Computer History Museum): cartella, In, Out, Trash,
|
|
// Junk, account.
|
|
// Sono compilate nel binario come risorse (images.qrc): nessun percorso
|
|
// da risolvere, nessuna dipendenza dalla cartella qml installata.
|
|
function iconaDi(tipo) {
|
|
var radice = "qrc:/images/";
|
|
if (tipo === "account") return radice + "icona-account.png";
|
|
if (tipo === "in") return radice + "icona-in.png";
|
|
if (tipo === "out") return radice + "icona-out.png";
|
|
if (tipo === "trash") return radice + "icona-trash.png";
|
|
if (tipo === "junk") return radice + "icona-junk.png";
|
|
return radice + "icona-cartella.png";
|
|
}
|
|
|
|
SilicaListView {
|
|
id: lista
|
|
anchors.fill: parent
|
|
model: cartelle
|
|
|
|
header: PageHeader {
|
|
title: qsTr("Cartelle")
|
|
description: qsTr("%1 non letti").arg(Dati.totalUnread())
|
|
}
|
|
|
|
PullDownMenu {
|
|
MenuItem {
|
|
text: qsTr("Scarica la posta")
|
|
onClicked: page.carica() // nel prototipo non fa nulla
|
|
}
|
|
MenuItem {
|
|
text: qsTr("Nuovo messaggio")
|
|
onClicked: pageStack.push(Qt.resolvedUrl("ComposePage.qml"))
|
|
}
|
|
}
|
|
|
|
delegate: BackgroundItem {
|
|
id: riga
|
|
|
|
height: Math.max(Theme.itemSizeMedium, etichetta.implicitHeight + Theme.paddingLarge)
|
|
onClicked: page.apriCartella(model.nome, model.mailbox)
|
|
|
|
// Rientro per profondita': la gerarchia si vede dall'icona.
|
|
Image {
|
|
id: icona
|
|
x: Theme.horizontalPageMargin + model.livello * Theme.paddingLarge
|
|
width: Theme.iconSizeSmall
|
|
height: width
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
source: page.iconaDi(model.tipo)
|
|
// pixel art dell'originale: niente sfumature inventate
|
|
smooth: false
|
|
}
|
|
|
|
Column {
|
|
id: etichetta
|
|
anchors.left: icona.right
|
|
anchors.leftMargin: Theme.paddingMedium
|
|
anchors.right: conteggio.left
|
|
anchors.rightMargin: Theme.paddingMedium
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
Label {
|
|
width: parent.width
|
|
text: model.nome
|
|
font.bold: model.nonLetti > 0 || model.tipo === "account"
|
|
truncationMode: TruncationMode.Fade
|
|
color: riga.highlighted ? Theme.highlightColor : Theme.primaryColor
|
|
}
|
|
Label {
|
|
width: parent.width
|
|
visible: model.tipo === "account"
|
|
text: qsTr("account")
|
|
font.pixelSize: Theme.fontSizeExtraSmall
|
|
color: Theme.secondaryColor
|
|
}
|
|
}
|
|
|
|
Label {
|
|
id: conteggio
|
|
anchors.right: parent.right
|
|
anchors.rightMargin: Theme.horizontalPageMargin
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
// Out e Trash non si marcano mai: e' la regola di Eudora.
|
|
text: (model.nonLetti > 0 && model.tipo !== "out" && model.tipo !== "trash")
|
|
? model.nonLetti : ""
|
|
font.bold: true
|
|
color: model.tipo === "junk" ? Theme.secondaryHighlightColor
|
|
: Theme.highlightColor
|
|
}
|
|
}
|
|
|
|
VerticalScrollDecorator { }
|
|
}
|
|
|
|
function carica() {
|
|
avviso.text = qsTr("Controllo la posta...")
|
|
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 = ""
|
|
}
|
|
}
|