compose -> claim -> send_start -> send_poll, poi queue_sent per la copia in Sent. Il foglio e' To/Cc/Bcc/Subject, riga vuota, corpo (Mail_Compose.Parse); la riga SMTP viene da AccountSettings::smtpLine. ComposePage ha Cc, il pulsante Invia e gli esiti.
148 lines
5.0 KiB
QML
148 lines
5.0 KiB
QML
import QtQuick 2.0
|
|
import Sailfish.Silica 1.0
|
|
|
|
// Composizione e invio. Il motore mette il messaggio nella coda (Out), lo
|
|
// manda con SMTP e lascia la copia in Sent; qui si segue l'esito.
|
|
Page {
|
|
id: page
|
|
|
|
property string destinatario: ""
|
|
property string copia: ""
|
|
property string oggetto: ""
|
|
property string corpo: ""
|
|
|
|
property bool inviando: false
|
|
property string errore: ""
|
|
|
|
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, anche piu' di uno")
|
|
text: page.destinatario
|
|
inputMethodHints: Qt.ImhEmailCharactersOnly | Qt.ImhNoAutoUppercase
|
|
EnterKey.enabled: true
|
|
EnterKey.iconSource: "image://theme/icon-m-enter-next"
|
|
EnterKey.onClicked: campoCc.forceActiveFocus()
|
|
}
|
|
|
|
TextField {
|
|
id: campoCc
|
|
width: parent.width - 2 * Theme.horizontalPageMargin
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
label: qsTr("Cc")
|
|
placeholderText: qsTr("facoltativo")
|
|
text: page.copia
|
|
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 {
|
|
id: pulsanteInvia
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
text: page.inviando ? qsTr("Invio in corso…") : qsTr("Invia")
|
|
preferredWidth: Theme.buttonWidthSmall
|
|
enabled: !page.inviando
|
|
onClicked: page.invia()
|
|
}
|
|
|
|
Label {
|
|
width: parent.width - 2 * Theme.horizontalPageMargin
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
horizontalAlignment: Text.AlignHCenter
|
|
text: page.errore
|
|
visible: page.errore.length > 0
|
|
font.pixelSize: Theme.fontSizeExtraSmall
|
|
color: Theme.highlightColor
|
|
wrapMode: Text.Wrap
|
|
}
|
|
}
|
|
|
|
VerticalScrollDecorator { }
|
|
}
|
|
|
|
Connections {
|
|
target: engine
|
|
onSendFinished: {
|
|
page.inviando = false;
|
|
if (falliti === 0) {
|
|
avviso.text = inviati === 1 ? qsTr("Messaggio inviato")
|
|
: qsTr("%1 messaggi inviati").arg(inviati);
|
|
avvisoTimer.restart();
|
|
timerPop.restart();
|
|
} else {
|
|
page.errore = esito.length > 0 ? esito
|
|
: qsTr("Invio non riuscito");
|
|
}
|
|
}
|
|
}
|
|
|
|
function invia() {
|
|
page.errore = "";
|
|
const motivo = engine.sendMessage(campoA.text, campoCc.text, "",
|
|
campoOggetto.text, campoCorpo.text);
|
|
if (motivo.length > 0) {
|
|
page.errore = motivo;
|
|
return;
|
|
}
|
|
page.inviando = true;
|
|
}
|
|
|
|
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()
|
|
}
|
|
}
|