Hi Dan,

On Sunday, 2014-06-01, 14:46:44, Dan Chapman wrote:

> As a quick simple example from the qml side say only for Smtp
> submission, in ComposePage.qml it would look something like this
> 
> property Submission submission
> property MSAFactory msaFactory
> 
> Component {
>     id: submissionComponent
>         Submission {}
> }
> Component {
>     id: smtpFactoryComponent
>     SMTPFactory {}
> }
> 
> Component.onCompleted: setupConnection()
> 
> function setupConnection() {
>     // here we now setup the connection in the same kind of way as the
> desktop
>     var subMethod = smtpAccountSettings.msaSubmissionMethod
> switch (subMethod) {
>     case MSAAccount.SMTP:
>     case MSAAccount.SSMTP:
>     case MSAAccount.SMTP_STARTTLS:
>         // create a new SMTPFactory object initialized with our settings
>         msaFactory =
> smtpFactoryComponent.createObject(smtpAccountSettings.server,
> 
>                              smtpAccountSettings.port,
> 
>                              subMethod == MSAAccount.SSMTP,
> 
>                              subMethod == MSAAccount.SMTP_STARTTLS,
> 
>                              smtpAccountSettings.authenticateEnabled,
> 
>                              smtpAccountSettings.username
> 
>                             )
>         break
>     case MSAAccount.SENDAMAIL:
>     case MSAAccount.IMAP_SENDMAIL:
>          break
>        // now create our submission object
>     submission = submissionComponent.createObject(0,
> imapAccess.imapModel, msaFactory)
> }
> 
> function buildMessage() {
>     // generate message from UI here
> }
> 
> function sendMessage() {
>     buildMessage()
>     // set options stored in smtpAccountSettings
>     submission.setImapOptions()
>     submission.setSmtpOptions()
>     submission.send()
> }

That doesn't look very declarative to me.
Any specific reason all that imperative code and logic has to be done in the 
UI?

Looks like buildMessage() is, if at all, the only part that the 
ComposePage.qml would be concerned with, all sending being internal to the 
application core, no?

I would imagine a QML facing API to look more like this:

class Composer : public QObject
{
    Q_OBJECT
    Q_PROPERTY(QString identity ....)
    Q_PROPERTY(ReceiverModel toModel .... CONSTANT)
    Q_PROPERTY(ReceiverModel ccModel .... CONSTANT)
    Q_PROPERTY(ReceiverModel bccModel ... CONSTANT)
    Q_PROPERTY(QString subject ....)
    Q_PROPERTY(QString body ....)
    Q_PROPERTY(AttachmentModel attachmentModel .... CONSTANT)

public Q_SLOTS:
    void send();
    void sendLater();
    void saveAsDraft();
};

In simple QtQuick that would then be used similar to this:

Composer {
    id: composer

    subject: subjectInput.text
    body: bodyInput.text
}

TexInput {
   id: subjectInput
}

TextArea {
    id: bodyInput
}

Image {
    source: "sendAction.png"
        MouseArea {
            onClicked: composer.send()
        }
}

Cheers,
Kevin

-- 
Kevin Krammer, KDE developer, xdg-utils developer
KDE user support, developer mentoring

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to