Il ramo SUBSCRIBE parlava col server ma lasciava il file .grumpydove-unsubscribed nella cartella: la nota restava. Patch al motore per crearlo/toglierlo subito. Aggiunto UNSUBSCRIBE.
144 lines
4.7 KiB
QML
144 lines
4.7 KiB
QML
import QtQuick 2.0
|
|
import Sailfish.Silica 1.0
|
|
|
|
// Creare, rinominare o eliminare una cartella.
|
|
// Creare: il motore crea una Maildir vera (tmp, new, cur), non un contenitore.
|
|
// Eliminare porta via anche i messaggi che contiene: due tocchi, come per il
|
|
// cestino.
|
|
Page {
|
|
id: page
|
|
|
|
// Non chiamarla `parent`: in QML è già la proprietà dell'Item, e
|
|
// ridichiararla impedisce il caricamento della pagina.
|
|
property int cartellaPadre: 0
|
|
// In un account la cartella va creata sul server: il motore la
|
|
// accoda e la crea al controllo successivo.
|
|
property bool remota: false
|
|
property int rinomina: -1 // >= 0: si sta rinominando quella cartella
|
|
property string nomeIniziale: ""
|
|
property string errore: ""
|
|
property bool confermaElimina: false
|
|
|
|
allowedOrientations: Orientation.All
|
|
|
|
SilicaFlickable {
|
|
anchors.fill: parent
|
|
contentHeight: colonna.height + Theme.paddingLarge
|
|
|
|
Column {
|
|
id: colonna
|
|
anchors.top: parent.top
|
|
anchors.topMargin: Theme.itemSizeLarge
|
|
width: parent.width
|
|
spacing: Theme.paddingLarge
|
|
|
|
PageHeader {
|
|
title: page.rinomina >= 0 ? qsTr("Rinomina la cartella")
|
|
: qsTr("Nuova cartella")
|
|
description: page.rinomina >= 0 ? qsTr("Nell'albero delle cartelle")
|
|
: page.remota ? qsTr("Sul server, al prossimo controllo")
|
|
: qsTr("Dentro Local")
|
|
}
|
|
|
|
TextField {
|
|
id: nome
|
|
width: parent.width - 2 * Theme.horizontalPageMargin
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
label: qsTr("Nome")
|
|
placeholderText: qsTr("per esempio: Progetti")
|
|
text: page.nomeIniziale
|
|
inputMethodHints: Qt.ImhNoAutoUppercase
|
|
EnterKey.enabled: true
|
|
EnterKey.text: qsTr("Conferma")
|
|
EnterKey.onClicked: page.conferma()
|
|
}
|
|
|
|
Button {
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
text: page.rinomina >= 0 ? qsTr("Rinomina") : qsTr("Crea")
|
|
preferredWidth: Theme.buttonWidthSmall
|
|
onClicked: page.conferma()
|
|
}
|
|
|
|
Button {
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
visible: page.rinomina >= 0
|
|
text: qsTr("Sottoscrivi questa cartella")
|
|
preferredWidth: Theme.buttonWidthMedium
|
|
onClicked: page.sottoscrivi()
|
|
}
|
|
|
|
Button {
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
visible: page.rinomina >= 0
|
|
text: qsTr("Annulla la sottoscrizione")
|
|
preferredWidth: Theme.buttonWidthMedium
|
|
onClicked: page.annullaSottoscrizione()
|
|
}
|
|
|
|
Button {
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
visible: page.rinomina >= 0
|
|
text: page.confermaElimina ? qsTr("Tocca di nuovo per eliminare")
|
|
: qsTr("Elimina la cartella")
|
|
preferredWidth: Theme.buttonWidthMedium
|
|
onClicked: page.elimina()
|
|
}
|
|
|
|
Label {
|
|
width: parent.width - 2 * Theme.horizontalPageMargin
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
horizontalAlignment: Text.AlignHCenter
|
|
text: page.errore
|
|
visible: page.errore.length > 0
|
|
wrapMode: Text.Wrap
|
|
font.pixelSize: Theme.fontSizeExtraSmall
|
|
color: Theme.highlightColor
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
Timer {
|
|
id: timerConferma
|
|
interval: 5000
|
|
onTriggered: page.confermaElimina = false
|
|
}
|
|
|
|
function conferma() {
|
|
if (page.rinomina >= 0)
|
|
page.errore = engine.rinominaCartella(page.rinomina, nome.text);
|
|
else if (page.remota)
|
|
page.errore = engine.creaCartellaSulServer(page.cartellaPadre, nome.text);
|
|
else
|
|
page.errore = engine.creaCartella(page.cartellaPadre, nome.text);
|
|
if (page.errore.length === 0)
|
|
pageStack.pop();
|
|
}
|
|
|
|
function sottoscrivi() {
|
|
page.errore = engine.sottoscrivi(page.rinomina);
|
|
if (page.errore.length === 0)
|
|
pageStack.pop();
|
|
}
|
|
|
|
function annullaSottoscrizione() {
|
|
page.errore = engine.annullaSottoscrizione(page.rinomina);
|
|
if (page.errore.length === 0)
|
|
pageStack.pop();
|
|
}
|
|
|
|
function elimina() {
|
|
if (!page.confermaElimina) {
|
|
page.confermaElimina = true;
|
|
timerConferma.restart();
|
|
return;
|
|
}
|
|
page.confermaElimina = false;
|
|
timerConferma.stop();
|
|
page.errore = engine.eliminaCartella(page.rinomina);
|
|
if (page.errore.length === 0)
|
|
pageStack.pop();
|
|
}
|
|
}
|