Prototipo interfaccia Sailfish per GrumpyDove: cartelle, lista, lettura con paginazione a tap, compose, copertina; dati finti e piano di porting
This commit is contained in:
commit
696b61319c
20 files changed
+1146
No files matched your search
@@ -0,0 +1,111 @@
|
||||
import QtQuick 2.0
|
||||
import Sailfish.Silica 1.0
|
||||
|
||||
// Composizione. Nel prototipo l'invio e' finto: mostra la conferma e torna
|
||||
// indietro, per valutare il flusso dei campi su telefono.
|
||||
Page {
|
||||
id: page
|
||||
|
||||
property string destinatario: ""
|
||||
property string oggetto: ""
|
||||
property string corpo: ""
|
||||
|
||||
SilicaFlickable {
|
||||
anchors.fill: parent
|
||||
contentHeight: colonna.height + Theme.paddingLarge
|
||||
|
||||
PageHeader { title: qsTr("Nuovo messaggio") }
|
||||
|
||||
Column {
|
||||
id: colonna
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: Theme.itemSizeLarge
|
||||
width: parent.width
|
||||
spacing: Theme.paddingMedium
|
||||
|
||||
TextField {
|
||||
id: campoA
|
||||
width: parent.width - 2 * Theme.horizontalPageMargin
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
label: qsTr("A")
|
||||
placeholderText: qsTr("indirizzo")
|
||||
text: page.destinatario
|
||||
inputMethodHints: Qt.ImhEmailCharactersOnly | Qt.ImhNoAutoUppercase
|
||||
EnterKey.enabled: true
|
||||
EnterKey.iconSource: "image://theme/icon-m-enter-next"
|
||||
EnterKey.onClicked: campoOggetto.forceActiveFocus()
|
||||
}
|
||||
|
||||
TextField {
|
||||
id: campoOggetto
|
||||
width: parent.width - 2 * Theme.horizontalPageMargin
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
label: qsTr("Oggetto")
|
||||
text: page.oggetto
|
||||
EnterKey.enabled: true
|
||||
EnterKey.iconSource: "image://theme/icon-m-enter-next"
|
||||
EnterKey.onClicked: campoCorpo.forceActiveFocus()
|
||||
}
|
||||
|
||||
TextArea {
|
||||
id: campoCorpo
|
||||
width: parent.width - 2 * Theme.horizontalPageMargin
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
label: qsTr("Testo")
|
||||
text: page.corpo
|
||||
// Il campo cresce con il testo: nessuno scroll annidato.
|
||||
height: Math.max(Theme.itemSizeLarge * 4,
|
||||
implicitHeight + Theme.paddingLarge)
|
||||
}
|
||||
|
||||
Button {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
text: qsTr("Invia")
|
||||
preferredWidth: Theme.buttonWidthSmall
|
||||
onClicked: page.invia()
|
||||
}
|
||||
|
||||
Label {
|
||||
width: parent.width - 2 * Theme.horizontalPageMargin
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
text: qsTr("Nel prototipo non parte nulla: i dati sono finti.")
|
||||
font.pixelSize: Theme.fontSizeExtraSmall
|
||||
color: Theme.secondaryColor
|
||||
wrapMode: Text.Wrap
|
||||
}
|
||||
}
|
||||
|
||||
VerticalScrollDecorator { }
|
||||
}
|
||||
|
||||
function invia() {
|
||||
if (campoA.text.length === 0) {
|
||||
avviso.text = qsTr("Manca il destinatario");
|
||||
avvisoTimer.restart();
|
||||
return;
|
||||
}
|
||||
avviso.text = qsTr("Messaggio inviato");
|
||||
avvisoTimer.restart();
|
||||
timerPop.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 = ""
|
||||
}
|
||||
Timer {
|
||||
id: timerPop
|
||||
interval: 700
|
||||
onTriggered: pageStack.pop()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
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 });
|
||||
}
|
||||
|
||||
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, non si spiega.
|
||||
Rectangle {
|
||||
id: barra
|
||||
x: Theme.horizontalPageMargin + model.livello * Theme.paddingLarge
|
||||
width: Theme.paddingSmall / 3
|
||||
height: parent.height - Theme.paddingMedium
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
color: model.tipo === "account" ? Theme.highlightColor : "transparent"
|
||||
visible: model.tipo !== "account"
|
||||
}
|
||||
|
||||
Column {
|
||||
id: etichetta
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: Theme.horizontalPageMargin + model.livello * Theme.paddingLarge
|
||||
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 = ""
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,182 @@
|
||||
import QtQuick 2.0
|
||||
import Sailfish.Silica 1.0
|
||||
import "../js/dati.js" as Dati
|
||||
|
||||
// Lettura di un messaggio. Paginazione a tap: un tocco sul lato destro passa
|
||||
// al messaggio successivo, sul sinistro al precedente. Il corpo resta
|
||||
// scorrevole al centro, cosi' i due gesti non si rubano.
|
||||
Page {
|
||||
id: page
|
||||
|
||||
property string cartella: "in"
|
||||
property int indice: 0
|
||||
property string titolo: "In"
|
||||
|
||||
property var messaggio: ({})
|
||||
property int totale: 0
|
||||
|
||||
Component.onCompleted: leggi()
|
||||
|
||||
function leggi() {
|
||||
var lista = Dati.messagesOf(page.cartella);
|
||||
page.totale = lista.length;
|
||||
page.messaggio = (page.indice >= 0 && page.indice < lista.length)
|
||||
? lista[page.indice] : ({});
|
||||
avviso.text = "";
|
||||
}
|
||||
|
||||
function vai(delta) {
|
||||
var nuovo = page.indice + delta;
|
||||
if (nuovo < 0 || nuovo >= page.totale) {
|
||||
avviso.text = delta < 0 ? qsTr("Primo messaggio")
|
||||
: qsTr("Ultimo messaggio");
|
||||
avvisoTimer.restart();
|
||||
return;
|
||||
}
|
||||
pageStack.replace(Qt.resolvedUrl("MessagePage.qml"), {
|
||||
cartella: page.cartella,
|
||||
indice: nuovo,
|
||||
titolo: page.titolo
|
||||
});
|
||||
}
|
||||
|
||||
SilicaFlickable {
|
||||
anchors.fill: parent
|
||||
contentHeight: contenuto.height + Theme.paddingLarge
|
||||
|
||||
PageHeader {
|
||||
id: intestazione
|
||||
title: page.messaggio.subject ? page.messaggio.subject : ""
|
||||
description: qsTr("%1 di %2").arg(page.indice + 1).arg(page.totale)
|
||||
}
|
||||
|
||||
Column {
|
||||
id: contenuto
|
||||
anchors.top: intestazione.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.leftMargin: Theme.horizontalPageMargin
|
||||
anchors.rightMargin: Theme.horizontalPageMargin
|
||||
spacing: Theme.paddingSmall
|
||||
|
||||
Label {
|
||||
width: parent.width
|
||||
text: qsTr("Da: %1").arg(page.messaggio.sender ? page.messaggio.sender : "")
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.highlightColor
|
||||
truncationMode: TruncationMode.Fade
|
||||
}
|
||||
Label {
|
||||
width: parent.width
|
||||
text: page.messaggio.address ? page.messaggio.address : ""
|
||||
font.pixelSize: Theme.fontSizeExtraSmall
|
||||
color: Theme.secondaryColor
|
||||
truncationMode: TruncationMode.Fade
|
||||
}
|
||||
Label {
|
||||
width: parent.width
|
||||
text: qsTr("A: me — %1").arg(page.messaggio.date ? page.messaggio.date : "")
|
||||
font.pixelSize: Theme.fontSizeExtraSmall
|
||||
color: Theme.secondaryColor
|
||||
}
|
||||
|
||||
Item {
|
||||
width: parent.width
|
||||
height: Theme.paddingMedium
|
||||
}
|
||||
|
||||
Label {
|
||||
width: parent.width
|
||||
text: page.messaggio.body ? page.messaggio.body : ""
|
||||
wrapMode: Text.Wrap
|
||||
textFormat: Text.PlainText
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.primaryColor
|
||||
bottomPadding: Theme.paddingLarge
|
||||
}
|
||||
}
|
||||
|
||||
PullDownMenu {
|
||||
MenuItem {
|
||||
text: qsTr("Rispondi")
|
||||
onClicked: pageStack.push(Qt.resolvedUrl("ComposePage.qml"),
|
||||
{ destinatario: page.messaggio.address,
|
||||
oggetto: "Re: " + page.messaggio.subject })
|
||||
}
|
||||
MenuItem {
|
||||
text: qsTr("Inoltra")
|
||||
onClicked: pageStack.push(Qt.resolvedUrl("ComposePage.qml"),
|
||||
{ oggetto: "Fwd: " + page.messaggio.subject,
|
||||
corpo: page.messaggio.body })
|
||||
}
|
||||
}
|
||||
|
||||
PushUpMenu {
|
||||
MenuItem {
|
||||
text: qsTr("Segna come non letto")
|
||||
onClicked: { avviso.text = qsTr("Segnato non letto"); avvisoTimer.restart() }
|
||||
}
|
||||
MenuItem {
|
||||
text: qsTr("Sposta in Trash")
|
||||
onClicked: { avviso.text = qsTr("Spostato in Trash"); avvisoTimer.restart() }
|
||||
}
|
||||
}
|
||||
|
||||
VerticalScrollDecorator { }
|
||||
}
|
||||
|
||||
// Zone di tap: destra avanti, sinistra indietro.
|
||||
Item {
|
||||
anchors.left: parent.left
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: parent.bottom
|
||||
width: Theme.itemSizeMedium
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: page.vai(-1)
|
||||
}
|
||||
Label {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: Theme.paddingSmall
|
||||
text: "\u2039"
|
||||
font.pixelSize: Theme.fontSizeHuge
|
||||
color: Theme.rgba(Theme.primaryColor, 0.25)
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
anchors.right: parent.right
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: parent.bottom
|
||||
width: Theme.itemSizeMedium
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: page.vai(1)
|
||||
}
|
||||
Label {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: Theme.paddingSmall
|
||||
text: "\u203a"
|
||||
font.pixelSize: Theme.fontSizeHuge
|
||||
color: Theme.rgba(Theme.primaryColor, 0.25)
|
||||
}
|
||||
}
|
||||
|
||||
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: 1200
|
||||
onTriggered: avviso.text = ""
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,165 @@
|
||||
import QtQuick 2.0
|
||||
import Sailfish.Silica 1.0
|
||||
import "../js/dati.js" as Dati
|
||||
|
||||
// Lista messaggi della cartella. La riga non letta e' in grassetto con la
|
||||
// barra a sinistra; data a destra; nessuna colonna, che su un telefono non
|
||||
// ci sta: mittente sopra, oggetto sotto.
|
||||
Page {
|
||||
id: page
|
||||
|
||||
property string cartella: "in"
|
||||
property string titolo: "In"
|
||||
property bool soloNonLetti: false
|
||||
property string ordine: "data"
|
||||
|
||||
ListModel { id: messaggi }
|
||||
|
||||
Component.onCompleted: carica()
|
||||
|
||||
function carica() {
|
||||
messaggi.clear();
|
||||
var lista = Dati.messagesOf(page.cartella).slice();
|
||||
if (page.ordine === "mittente") {
|
||||
lista.sort(function (a, b) {
|
||||
return a.sender.toLowerCase() < b.sender.toLowerCase() ? -1 : 1;
|
||||
});
|
||||
}
|
||||
for (var i = 0; i < lista.length; i++) {
|
||||
var m = lista[i];
|
||||
if (page.soloNonLetti && !m.unread) continue;
|
||||
messaggi.append({
|
||||
mittente: m.sender,
|
||||
oggetto: m.subject,
|
||||
data: m.date,
|
||||
nonLetto: m.unread,
|
||||
junk: m.junk,
|
||||
allegato: m.attachment,
|
||||
indice: i
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// La navigazione sta qui, non nel delegate: nei delegate pageStack non
|
||||
// si risolve su Qt 5.6.
|
||||
function apri(indice) {
|
||||
pageStack.push(Qt.resolvedUrl("MessagePage.qml"), {
|
||||
cartella: page.cartella,
|
||||
indice: indice,
|
||||
titolo: page.titolo
|
||||
});
|
||||
}
|
||||
|
||||
SilicaListView {
|
||||
id: lista
|
||||
anchors.fill: parent
|
||||
model: messaggi
|
||||
|
||||
header: PageHeader {
|
||||
title: page.titolo
|
||||
description: messaggi.count === 1 ? qsTr("1 messaggio")
|
||||
: qsTr("%1 messaggi").arg(messaggi.count)
|
||||
}
|
||||
|
||||
PullDownMenu {
|
||||
MenuItem {
|
||||
text: qsTr("Scarica la posta")
|
||||
onClicked: { page.carica(); avviso.text = qsTr("Aggiornato") ; avvisoTimer.restart() }
|
||||
}
|
||||
MenuItem {
|
||||
text: page.soloNonLetti ? qsTr("Mostra tutti") : qsTr("Solo non letti")
|
||||
onClicked: { page.soloNonLetti = !page.soloNonLetti; page.carica() }
|
||||
}
|
||||
}
|
||||
|
||||
PushUpMenu {
|
||||
MenuItem {
|
||||
text: qsTr("Ordina per data")
|
||||
onClicked: { page.ordine = "data"; page.carica() }
|
||||
}
|
||||
MenuItem {
|
||||
text: qsTr("Ordina per mittente")
|
||||
onClicked: { page.ordine = "mittente"; page.carica() }
|
||||
}
|
||||
}
|
||||
|
||||
delegate: BackgroundItem {
|
||||
id: riga
|
||||
|
||||
height: Math.max(Theme.itemSizeLarge, colonna.implicitHeight + Theme.paddingLarge)
|
||||
onClicked: page.apri(model.indice)
|
||||
|
||||
Rectangle {
|
||||
width: Theme.paddingSmall / 3
|
||||
height: parent.height - Theme.paddingMedium
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.left: parent.left
|
||||
color: Theme.highlightColor
|
||||
visible: model.nonLetto
|
||||
}
|
||||
|
||||
Column {
|
||||
id: colonna
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: Theme.horizontalPageMargin
|
||||
anchors.right: dataLabel.left
|
||||
anchors.rightMargin: Theme.paddingMedium
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
||||
Label {
|
||||
width: parent.width
|
||||
text: model.mittente
|
||||
font.bold: model.nonLetto
|
||||
truncationMode: TruncationMode.Fade
|
||||
color: riga.highlighted ? Theme.highlightColor : Theme.primaryColor
|
||||
}
|
||||
Label {
|
||||
width: parent.width
|
||||
text: model.allegato ? model.oggetto + " \u2022" : model.oggetto
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
truncationMode: TruncationMode.Fade
|
||||
color: Theme.secondaryColor
|
||||
}
|
||||
}
|
||||
|
||||
Label {
|
||||
id: dataLabel
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: Theme.horizontalPageMargin
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: Theme.paddingMedium
|
||||
text: model.data
|
||||
font.pixelSize: Theme.fontSizeExtraSmall
|
||||
color: Theme.secondaryColor
|
||||
}
|
||||
}
|
||||
|
||||
VerticalScrollDecorator { }
|
||||
|
||||
// Messaggio di lista vuota: fratello della lista, non ancorato
|
||||
// all'headerItem (trappola nota).
|
||||
Label {
|
||||
anchors.centerIn: parent
|
||||
width: parent.width - 2 * Theme.horizontalPageMargin
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
visible: messaggi.count === 0
|
||||
text: page.soloNonLetti ? qsTr("Nessun messaggio non letto")
|
||||
: qsTr("Cartella vuota")
|
||||
color: Theme.secondaryColor
|
||||
}
|
||||
}
|
||||
|
||||
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: 1200
|
||||
onTriggered: avviso.text = ""
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user