diff options
-rw-r--r-- | applications/kube-mail/package/contents/ui/Composer.qml | 42 | ||||
-rw-r--r-- | framework/mail/CMakeLists.txt | 1 | ||||
-rw-r--r-- | framework/mail/composer.cpp | 109 | ||||
-rw-r--r-- | framework/mail/composer.h | 71 | ||||
-rw-r--r-- | framework/mail/mailplugin.cpp | 2 |
5 files changed, 222 insertions, 3 deletions
diff --git a/applications/kube-mail/package/contents/ui/Composer.qml b/applications/kube-mail/package/contents/ui/Composer.qml index 66305254..52cb2f6c 100644 --- a/applications/kube-mail/package/contents/ui/Composer.qml +++ b/applications/kube-mail/package/contents/ui/Composer.qml | |||
@@ -20,19 +20,25 @@ import QtQuick 2.4 | |||
20 | import QtQuick.Controls 1.4 | 20 | import QtQuick.Controls 1.4 |
21 | import QtQuick.Layouts 1.1 | 21 | import QtQuick.Layouts 1.1 |
22 | 22 | ||
23 | import org.kde.kube.mail 1.0 as Mail | ||
24 | |||
23 | Item { | 25 | Item { |
24 | id: root | 26 | id: root |
25 | 27 | ||
26 | function send() { | 28 | function send() { |
27 | 29 | composer.send() | |
28 | } | 30 | } |
29 | 31 | ||
30 | function saveAsDraft() { | 32 | function saveAsDraft() { |
31 | 33 | composer.saveAsDraft() | |
32 | } | 34 | } |
33 | 35 | ||
34 | function clear() { | 36 | function clear() { |
37 | composer.clear(); | ||
38 | } | ||
35 | 39 | ||
40 | Mail.Composer { | ||
41 | id: composer | ||
36 | } | 42 | } |
37 | 43 | ||
38 | ColumnLayout { | 44 | ColumnLayout { |
@@ -61,6 +67,12 @@ Item { | |||
61 | id: to | 67 | id: to |
62 | 68 | ||
63 | Layout.fillWidth: true | 69 | Layout.fillWidth: true |
70 | |||
71 | text: composer.to | ||
72 | |||
73 | onTextChanged: { | ||
74 | composer.to = text; | ||
75 | } | ||
64 | } | 76 | } |
65 | 77 | ||
66 | Label { | 78 | Label { |
@@ -71,6 +83,12 @@ Item { | |||
71 | id: cc | 83 | id: cc |
72 | 84 | ||
73 | Layout.fillWidth: true | 85 | Layout.fillWidth: true |
86 | |||
87 | text: composer.cc | ||
88 | |||
89 | onTextChanged: { | ||
90 | composer.cc = text; | ||
91 | } | ||
74 | } | 92 | } |
75 | 93 | ||
76 | Label { | 94 | Label { |
@@ -81,6 +99,12 @@ Item { | |||
81 | id: bcc | 99 | id: bcc |
82 | 100 | ||
83 | Layout.fillWidth: true | 101 | Layout.fillWidth: true |
102 | |||
103 | text: composer.bcc | ||
104 | |||
105 | onTextChanged: { | ||
106 | composer.bcc = text; | ||
107 | } | ||
84 | } | 108 | } |
85 | } | 109 | } |
86 | 110 | ||
@@ -89,12 +113,24 @@ Item { | |||
89 | 113 | ||
90 | Layout.fillWidth: true | 114 | Layout.fillWidth: true |
91 | 115 | ||
92 | placeholderText: "Subject" | 116 | placeholderText: "Enter Subject" |
117 | |||
118 | text: composer.subject | ||
119 | |||
120 | onTextChanged: { | ||
121 | composer.subject = text; | ||
122 | } | ||
93 | } | 123 | } |
94 | 124 | ||
95 | TextArea { | 125 | TextArea { |
96 | id: content | 126 | id: content |
97 | 127 | ||
128 | text: composer.body | ||
129 | |||
130 | onTextChanged: { | ||
131 | composer.body = text; | ||
132 | } | ||
133 | |||
98 | Layout.fillWidth: true | 134 | Layout.fillWidth: true |
99 | Layout.fillHeight: true | 135 | Layout.fillHeight: true |
100 | 136 | ||
diff --git a/framework/mail/CMakeLists.txt b/framework/mail/CMakeLists.txt index 9957adc3..6616e492 100644 --- a/framework/mail/CMakeLists.txt +++ b/framework/mail/CMakeLists.txt | |||
@@ -9,6 +9,7 @@ set(mailplugin_SRCS | |||
9 | objecttreesource.cpp | 9 | objecttreesource.cpp |
10 | stringhtmlwriter.cpp | 10 | stringhtmlwriter.cpp |
11 | csshelper.cpp | 11 | csshelper.cpp |
12 | composer.cpp | ||
12 | ) | 13 | ) |
13 | add_definitions(-DMAIL_DATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/data") | 14 | add_definitions(-DMAIL_DATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/data") |
14 | 15 | ||
diff --git a/framework/mail/composer.cpp b/framework/mail/composer.cpp new file mode 100644 index 00000000..aa1ec7fc --- /dev/null +++ b/framework/mail/composer.cpp | |||
@@ -0,0 +1,109 @@ | |||
1 | /* | ||
2 | Copyright (c) 2016 Michael Bohlender <michael.bohlender@kdemail.net> | ||
3 | |||
4 | This library is free software; you can redistribute it and/or modify it | ||
5 | under the terms of the GNU Library General Public License as published by | ||
6 | the Free Software Foundation; either version 2 of the License, or (at your | ||
7 | option) any later version. | ||
8 | |||
9 | This library is distributed in the hope that it will be useful, but WITHOUT | ||
10 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
11 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public | ||
12 | License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Library General Public License | ||
15 | along with this library; see the file COPYING.LIB. If not, write to the | ||
16 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
17 | 02110-1301, USA. | ||
18 | */ | ||
19 | |||
20 | |||
21 | #include "composer.h" | ||
22 | |||
23 | Composer::Composer(QObject *parent) : QObject(parent) | ||
24 | { | ||
25 | |||
26 | } | ||
27 | |||
28 | QString Composer::to() const | ||
29 | { | ||
30 | return m_to; | ||
31 | } | ||
32 | |||
33 | void Composer::setTo(const QString &to) | ||
34 | { | ||
35 | if(m_to != to) { | ||
36 | m_to = to; | ||
37 | emit toChanged(); | ||
38 | } | ||
39 | } | ||
40 | |||
41 | QString Composer::cc() const | ||
42 | { | ||
43 | return m_cc; | ||
44 | } | ||
45 | |||
46 | void Composer::setCc(const QString &cc) | ||
47 | { | ||
48 | if(m_cc != cc) { | ||
49 | m_cc = cc; | ||
50 | emit ccChanged(); | ||
51 | } | ||
52 | } | ||
53 | |||
54 | QString Composer::bcc() const | ||
55 | { | ||
56 | return m_bcc; | ||
57 | } | ||
58 | |||
59 | void Composer::setBcc(const QString &bcc) | ||
60 | { | ||
61 | if(m_bcc != bcc) { | ||
62 | m_bcc = bcc; | ||
63 | emit bccChanged(); | ||
64 | } | ||
65 | } | ||
66 | |||
67 | QString Composer::subject() const | ||
68 | { | ||
69 | return m_subject; | ||
70 | } | ||
71 | |||
72 | void Composer::setSubject(const QString &subject) | ||
73 | { | ||
74 | if(m_subject != subject) { | ||
75 | m_subject = subject; | ||
76 | emit subjectChanged(); | ||
77 | } | ||
78 | } | ||
79 | |||
80 | QString Composer::body() const | ||
81 | { | ||
82 | return m_body; | ||
83 | } | ||
84 | |||
85 | void Composer::setBody(const QString &body) | ||
86 | { | ||
87 | if(m_body != body) { | ||
88 | m_body = body; | ||
89 | emit bodyChanged(); | ||
90 | } | ||
91 | } | ||
92 | |||
93 | void Composer::send() | ||
94 | { | ||
95 | //TODO | ||
96 | clear(); | ||
97 | } | ||
98 | |||
99 | void Composer::saveAsDraft() | ||
100 | { | ||
101 | //TODO | ||
102 | clear(); | ||
103 | } | ||
104 | |||
105 | void Composer::clear() | ||
106 | { | ||
107 | setSubject(""); | ||
108 | setBody(""); | ||
109 | } \ No newline at end of file | ||
diff --git a/framework/mail/composer.h b/framework/mail/composer.h new file mode 100644 index 00000000..a9741f6b --- /dev/null +++ b/framework/mail/composer.h | |||
@@ -0,0 +1,71 @@ | |||
1 | /* | ||
2 | Copyright (c) 2016 Michael Bohlender <michael.bohlender@kdemail.net> | ||
3 | |||
4 | This library is free software; you can redistribute it and/or modify it | ||
5 | under the terms of the GNU Library General Public License as published by | ||
6 | the Free Software Foundation; either version 2 of the License, or (at your | ||
7 | option) any later version. | ||
8 | |||
9 | This library is distributed in the hope that it will be useful, but WITHOUT | ||
10 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
11 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public | ||
12 | License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Library General Public License | ||
15 | along with this library; see the file COPYING.LIB. If not, write to the | ||
16 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
17 | 02110-1301, USA. | ||
18 | */ | ||
19 | |||
20 | #pragma once | ||
21 | |||
22 | #include <QObject> | ||
23 | #include <QString> | ||
24 | |||
25 | |||
26 | class Composer : public QObject | ||
27 | { | ||
28 | Q_OBJECT | ||
29 | Q_PROPERTY (QString to READ to WRITE setTo NOTIFY toChanged) | ||
30 | Q_PROPERTY (QString cc READ cc WRITE setCc NOTIFY ccChanged) | ||
31 | Q_PROPERTY (QString bcc READ bcc WRITE setBcc NOTIFY bccChanged) | ||
32 | Q_PROPERTY (QString subject READ subject WRITE setSubject NOTIFY subjectChanged) | ||
33 | Q_PROPERTY (QString body READ body WRITE setBody NOTIFY bodyChanged) | ||
34 | |||
35 | public: | ||
36 | explicit Composer(QObject *parent = Q_NULLPTR); | ||
37 | |||
38 | QString to() const; | ||
39 | void setTo(const QString &to); | ||
40 | |||
41 | QString cc() const; | ||
42 | void setCc(const QString &cc); | ||
43 | |||
44 | QString bcc() const; | ||
45 | void setBcc(const QString &bcc); | ||
46 | |||
47 | QString subject() const; | ||
48 | void setSubject(const QString &subject); | ||
49 | |||
50 | QString body() const; | ||
51 | void setBody(const QString &body); | ||
52 | |||
53 | signals: | ||
54 | void subjectChanged(); | ||
55 | void bodyChanged(); | ||
56 | void toChanged(); | ||
57 | void ccChanged(); | ||
58 | void bccChanged(); | ||
59 | |||
60 | public slots: | ||
61 | void send(); | ||
62 | void saveAsDraft(); | ||
63 | void clear(); | ||
64 | |||
65 | private: | ||
66 | QString m_to; | ||
67 | QString m_cc; | ||
68 | QString m_bcc; | ||
69 | QString m_subject; | ||
70 | QString m_body; | ||
71 | }; | ||
diff --git a/framework/mail/mailplugin.cpp b/framework/mail/mailplugin.cpp index 8b35dfb7..691d4a15 100644 --- a/framework/mail/mailplugin.cpp +++ b/framework/mail/mailplugin.cpp | |||
@@ -22,6 +22,7 @@ | |||
22 | 22 | ||
23 | #include "maillistmodel.h" | 23 | #include "maillistmodel.h" |
24 | #include "folderlistmodel.h" | 24 | #include "folderlistmodel.h" |
25 | #include "composer.h" | ||
25 | 26 | ||
26 | #include <QtQml> | 27 | #include <QtQml> |
27 | 28 | ||
@@ -31,4 +32,5 @@ void MailPlugin::registerTypes (const char *uri) | |||
31 | 32 | ||
32 | qmlRegisterType<FolderListModel>(uri, 1, 0, "FolderListModel"); | 33 | qmlRegisterType<FolderListModel>(uri, 1, 0, "FolderListModel"); |
33 | qmlRegisterType<MailListModel>(uri, 1, 0, "MailListModel"); | 34 | qmlRegisterType<MailListModel>(uri, 1, 0, "MailListModel"); |
35 | qmlRegisterType<Composer>(uri, 1, 0, "Composer"); | ||
34 | } | 36 | } |