diff options
author | Sandro Knauß <sknauss@kde.org> | 2016-02-02 10:34:33 +0100 |
---|---|---|
committer | Sandro Knauß <sknauss@kde.org> | 2016-02-02 10:34:33 +0100 |
commit | d8a9e472c9e6973d16a3e4b46246c013fde9eec1 (patch) | |
tree | d9188a56f3a2ebc6055b5b57722493d5ec0d7deb | |
parent | 8b2871ec42807268aee352af16cf0cf300898017 (diff) | |
download | kube-d8a9e472c9e6973d16a3e4b46246c013fde9eec1.tar.gz kube-d8a9e472c9e6973d16a3e4b46246c013fde9eec1.zip |
create & load css for mails
-rw-r--r-- | framework/mail/CMakeLists.txt | 2 | ||||
-rw-r--r-- | framework/mail/csshelper.cpp | 64 | ||||
-rw-r--r-- | framework/mail/csshelper.h | 44 | ||||
-rw-r--r-- | framework/mail/data/mail.css | 298 | ||||
-rw-r--r-- | framework/mail/maillistmodel.cpp | 7 |
5 files changed, 412 insertions, 3 deletions
diff --git a/framework/mail/CMakeLists.txt b/framework/mail/CMakeLists.txt index 64e3856f..9957adc3 100644 --- a/framework/mail/CMakeLists.txt +++ b/framework/mail/CMakeLists.txt | |||
@@ -8,7 +8,9 @@ set(mailplugin_SRCS | |||
8 | actions/sinkactions.cpp | 8 | actions/sinkactions.cpp |
9 | objecttreesource.cpp | 9 | objecttreesource.cpp |
10 | stringhtmlwriter.cpp | 10 | stringhtmlwriter.cpp |
11 | csshelper.cpp | ||
11 | ) | 12 | ) |
13 | add_definitions(-DMAIL_DATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/data") | ||
12 | 14 | ||
13 | add_library(mailplugin SHARED ${mailplugin_SRCS}) | 15 | add_library(mailplugin SHARED ${mailplugin_SRCS}) |
14 | 16 | ||
diff --git a/framework/mail/csshelper.cpp b/framework/mail/csshelper.cpp new file mode 100644 index 00000000..a6355c57 --- /dev/null +++ b/framework/mail/csshelper.cpp | |||
@@ -0,0 +1,64 @@ | |||
1 | /* | ||
2 | csshelper.cpp | ||
3 | |||
4 | This file is part of KMail, the KDE mail client. | ||
5 | Copyright (c) 2003 Marc Mutz <mutz@kde.org> | ||
6 | |||
7 | KMail is free software; you can redistribute it and/or modify it | ||
8 | under the terms of the GNU General Public License, version 2, as | ||
9 | published by the Free Software Foundation. | ||
10 | |||
11 | KMail is distributed in the hope that it will be useful, but | ||
12 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
14 | General Public License for more details. | ||
15 | |||
16 | You should have received a copy of the GNU General Public License | ||
17 | along with this program; if not, write to the Free Software | ||
18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
19 | |||
20 | In addition, as a special exception, the copyright holders give | ||
21 | permission to link the code of this program with any edition of | ||
22 | the Qt library by Trolltech AS, Norway (or with modified versions | ||
23 | of Qt that use the same license as Qt), and distribute linked | ||
24 | combinations including the two. You must obey the GNU General | ||
25 | Public License in all respects for all of the code used other than | ||
26 | Qt. If you modify this file, you may extend this exception to | ||
27 | your version of the file, but you are not obligated to do so. If | ||
28 | you do not wish to do so, delete this exception statement from | ||
29 | your version. | ||
30 | */ | ||
31 | |||
32 | #include "csshelper.h" | ||
33 | |||
34 | #include <QColor> | ||
35 | #include <QDebug> | ||
36 | #include <QFile> | ||
37 | #include <QFont> | ||
38 | #include <QFont> | ||
39 | #include <QPalette> | ||
40 | |||
41 | CSSHelper::CSSHelper(const QPaintDevice *pd) : | ||
42 | MessageViewer::CSSHelperBase(pd) | ||
43 | { | ||
44 | |||
45 | } | ||
46 | |||
47 | QString cssDefinitions() | ||
48 | { | ||
49 | QFile file(QLatin1String(MAIL_DATA_DIR) + QLatin1Char('/') + "mail.css"); | ||
50 | if (file.open(QFile::ReadOnly)) { | ||
51 | return file.readAll(); | ||
52 | } | ||
53 | return QString(); | ||
54 | } | ||
55 | |||
56 | QString CSSHelper::htmlHead(bool fixed) const | ||
57 | { | ||
58 | return | ||
59 | QLatin1String("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n" | ||
60 | "<html><head><title></title><style>\n") | ||
61 | + ::cssDefinitions() + | ||
62 | QLatin1String("</style></head>\n" | ||
63 | "<body>\n"); | ||
64 | } \ No newline at end of file | ||
diff --git a/framework/mail/csshelper.h b/framework/mail/csshelper.h new file mode 100644 index 00000000..775014e3 --- /dev/null +++ b/framework/mail/csshelper.h | |||
@@ -0,0 +1,44 @@ | |||
1 | /* -*- c++ -*- | ||
2 | csshelper.h | ||
3 | |||
4 | This file is part of KMail, the KDE mail client. | ||
5 | Copyright (c) 2003 Marc Mutz <mutz@kde.org> | ||
6 | |||
7 | KMail is free software; you can redistribute it and/or modify it | ||
8 | under the terms of the GNU General Public License, version 2, as | ||
9 | published by the Free Software Foundation. | ||
10 | |||
11 | KMail is distributed in the hope that it will be useful, but | ||
12 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
14 | General Public License for more details. | ||
15 | |||
16 | You should have received a copy of the GNU General Public License | ||
17 | along with this program; if not, write to the Free Software | ||
18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
19 | |||
20 | In addition, as a special exception, the copyright holders give | ||
21 | permission to link the code of this program with any edition of | ||
22 | the Qt library by Trolltech AS, Norway (or with modified versions | ||
23 | of Qt that use the same license as Qt), and distribute linked | ||
24 | combinations including the two. You must obey the GNU General | ||
25 | Public License in all respects for all of the code used other than | ||
26 | Qt. If you modify this file, you may extend this exception to | ||
27 | your version of the file, but you are not obligated to do so. If | ||
28 | you do not wish to do so, delete this exception statement from | ||
29 | your version. | ||
30 | */ | ||
31 | |||
32 | #pragma once | ||
33 | |||
34 | #include <MessageViewer/CSSHelperBase> | ||
35 | |||
36 | class CSSHelper : public MessageViewer::CSSHelperBase | ||
37 | { | ||
38 | public: | ||
39 | explicit CSSHelper(const QPaintDevice *pd); | ||
40 | |||
41 | /** @return HTML head including style sheet definitions and the | ||
42 | >body< tag */ | ||
43 | QString htmlHead(bool fixedFont = false) const Q_DECL_OVERRIDE; | ||
44 | }; \ No newline at end of file | ||
diff --git a/framework/mail/data/mail.css b/framework/mail/data/mail.css new file mode 100644 index 00000000..a0d7d0d1 --- /dev/null +++ b/framework/mail/data/mail.css | |||
@@ -0,0 +1,298 @@ | |||
1 | div.header { | ||
2 | margin-bottom: 10pt ! important; | ||
3 | } | ||
4 | |||
5 | table.textAtm { | ||
6 | margin-top: 10pt ! important; | ||
7 | margin-bottom: 10pt ! important; | ||
8 | } | ||
9 | |||
10 | tr.textAtmH, | ||
11 | tr.textAtmB, | ||
12 | tr.rfc822B { | ||
13 | font-weight: normal ! important; | ||
14 | } | ||
15 | |||
16 | tr.signInProgressH, | ||
17 | tr.rfc822H, | ||
18 | tr.encrH, | ||
19 | tr.signOkKeyOkH, | ||
20 | tr.signOkKeyBadH, | ||
21 | tr.signWarnH, | ||
22 | tr.sign | ||
23 | ErrH { | ||
24 | font-weight: bold ! important; | ||
25 | } | ||
26 | |||
27 | tr.textAtmH td, | ||
28 | tr.textAtmB td { | ||
29 | padding: 3px ! important; | ||
30 | } | ||
31 | |||
32 | table.rfc822 { | ||
33 | width: 100% ! important; | ||
34 | border: solid 1px black ! important; | ||
35 | margin-top: 10pt ! important; | ||
36 | margin-bottom: 10pt ! important; | ||
37 | } | ||
38 | |||
39 | table.textAtm, | ||
40 | table.encr, | ||
41 | table.signWarn, | ||
42 | table.signErr, | ||
43 | table.signOkKeyBad, | ||
44 | table.signOkKeyOk, | ||
45 | table.signInProgress, | ||
46 | div.fancy.header table { | ||
47 | width: 100% ! important; | ||
48 | border-width: 0px ! important; | ||
49 | line-height: normal; | ||
50 | } | ||
51 | |||
52 | div.htmlWarn { | ||
53 | margin: 0px 5% ! important; | ||
54 | padding: 10px ! important; | ||
55 | text-align: left ! important; | ||
56 | line-height: normal; | ||
57 | } | ||
58 | |||
59 | div.fancy.header > div { | ||
60 | font-weight: bold ! important; | ||
61 | padding: 4px ! important; | ||
62 | line-height: normal; | ||
63 | } | ||
64 | |||
65 | div.fancy.header table { | ||
66 | padding: 2px ! important; | ||
67 | text-align: left ! important; | ||
68 | border-collapse: separate ! important; | ||
69 | } | ||
70 | |||
71 | div.fancy.header table th { | ||
72 | font-family: "Helvetica" ! important; | ||
73 | font-size: 12pt; | ||
74 | padding: 0px ! important; | ||
75 | white-space: nowrap ! important; | ||
76 | border-spacing: 0px ! important; | ||
77 | text-align: left ! important; | ||
78 | vertical-align: top ! important; | ||
79 | background-color: #efebe7 ! important; | ||
80 | color: #000000 ! important; | ||
81 | border: 1px ! important; | ||
82 | } | ||
83 | |||
84 | div.fancy.header table td { | ||
85 | font-family: "Helvetica" ! important; | ||
86 | font-size: 12pt; | ||
87 | padding: 0px ! important; | ||
88 | border-spacing: 0px ! important; | ||
89 | text-align: left ! important; | ||
90 | vertical-align: top ! important; | ||
91 | width: 100% ! important; | ||
92 | background-color: #efebe7 ! important; | ||
93 | color: #000000 ! important; | ||
94 | border: 1px ! important; | ||
95 | } | ||
96 | |||
97 | div.fancy.header table a:hover { | ||
98 | background-color: transparent ! important; | ||
99 | } | ||
100 | |||
101 | span.pimsmileytext { | ||
102 | position: absolute; | ||
103 | top: 0px; | ||
104 | left: 0px; | ||
105 | visibility: hidden; | ||
106 | } | ||
107 | |||
108 | img.pimsmileyimg { | ||
109 | } | ||
110 | |||
111 | div.quotelevelmark { | ||
112 | position: absolute; | ||
113 | margin-left:-10px; | ||
114 | } | ||
115 | |||
116 | body { | ||
117 | font-family: "Helvetica" ! important; | ||
118 | font-size: 12pt; | ||
119 | color: #000000 ! important; | ||
120 | background-color: #ffffff ! important; | ||
121 | } | ||
122 | |||
123 | a { | ||
124 | color: #0000cc ! important; | ||
125 | text-decoration: none ! important; | ||
126 | } | ||
127 | |||
128 | a.white { | ||
129 | color: white ! important; | ||
130 | } | ||
131 | |||
132 | a.black { | ||
133 | color: black ! important; | ||
134 | } | ||
135 | |||
136 | table.textAtm { background-color: #000000 ! important; } | ||
137 | |||
138 | tr.textAtmH { | ||
139 | background-color: #ffffff ! important; | ||
140 | font-family: "Helvetica" ! important; | ||
141 | font-size: 12pt; | ||
142 | } | ||
143 | |||
144 | tr.textAtmB { | ||
145 | background-color: #ffffff ! important; | ||
146 | } | ||
147 | |||
148 | table.signInProgress, | ||
149 | table.rfc822 { | ||
150 | background-color: #ffffff ! important | ||
151 | ; | ||
152 | } | ||
153 | |||
154 | tr.signInProgressH, | ||
155 | tr.rfc822H { | ||
156 | font-family: "Helvetica" ! important; | ||
157 | font-size: 12pt; | ||
158 | } | ||
159 | |||
160 | table.encr { | ||
161 | background-color: #cc0000 ! important; | ||
162 | } | ||
163 | |||
164 | tr.encrH { | ||
165 | background-color: #ff0000 ! important; | ||
166 | color: #000000 ! important; | ||
167 | font-family: "Helvetica" ! important; | ||
168 | font-size: 12pt; | ||
169 | } | ||
170 | |||
171 | tr.encrB { background-color: #ffe0e0 ! important; } | ||
172 | |||
173 | table.signOkKeyOk { | ||
174 | background-color: #00cc00 ! important; | ||
175 | } | ||
176 | |||
177 | tr.signOkKeyOkH { | ||
178 | background-color: #00ff00 ! important; | ||
179 | color: #000000 ! important; | ||
180 | font-family: "Helvetica" ! important; | ||
181 | font-size: 12pt; | ||
182 | } | ||
183 | |||
184 | tr.signOkKeyOkB { background-color: #e0ffe0 ! important; } | ||
185 | |||
186 | table.signOkKeyBad { | ||
187 | background-color: #00cc00 ! important; | ||
188 | } | ||
189 | |||
190 | tr.signOkKeyBadH { | ||
191 | background-color: #00ff00 ! important; | ||
192 | color: #000000 ! important; | ||
193 | font-family: "Helvetica" ! important; | ||
194 | font-size: 12pt; | ||
195 | } | ||
196 | |||
197 | tr.signOkKeyBadB { background-color: #e0ffe0 ! important; } | ||
198 | |||
199 | table.signWarn { | ||
200 | background-color: #cc0 ! important; | ||
201 | } | ||
202 | |||
203 | tr.signWarnH { | ||
204 | background-color: #fc0 ! important; | ||
205 | color: #000000 ! important; | ||
206 | font-family: "Helvetica" ! imp | ||
207 | ortant; | ||
208 | font-size: 12pt; | ||
209 | } | ||
210 | |||
211 | tr.signWarnB { background-color: #e0e0ff ! important; } | ||
212 | |||
213 | table.signErr { | ||
214 | background-color: #c00 ! important; | ||
215 | } | ||
216 | |||
217 | tr.signErrH { | ||
218 | background-color: #0f00 ! important; | ||
219 | color: #0000 | ||
220 | 00 ! important; | ||
221 | font-family: "Helvetica" ! important; | ||
222 | font-size: 12pt; | ||
223 | } | ||
224 | |||
225 | tr.signErrB { background-color: #d3d3f0 ! important; } | ||
226 | |||
227 | div.htmlWarn { | ||
228 | border: 2px solid #00001a ! important; | ||
229 | line-height: normal; | ||
230 | } | ||
231 | |||
232 | div.header { | ||
233 | font-family: "Helvetica" ! important; | ||
234 | font-size: 12pt; | ||
235 | } | ||
236 | |||
237 | div.fancy.header > div { | ||
238 | background-color: #308cc6 ! important; | ||
239 | color: #ffffff ! important; | ||
240 | border: solid #000000 1px ! important; | ||
241 | line-height: normal; | ||
242 | } | ||
243 | |||
244 | div.fancy.header > div a[href] { color: #ffffff ! important; } | ||
245 | |||
246 | div.fancy.header > div a[href]:hover { text-decoration: underline ! important; } | ||
247 | |||
248 | div.fancy.header > div.spamheader { | ||
249 | background-color: #cdcdcd ! important; | ||
250 | border-top: 0px ! important; | ||
251 | padding: 3px ! important; | ||
252 | color: black ! important; | ||
253 | font-weight: bold ! important; | ||
254 | font-size: 12pt; | ||
255 | } | ||
256 | |||
257 | div.fancy.header > table.outer { | ||
258 | background-color: #efebe7 ! important; | ||
259 | color: #000000 ! important; | ||
260 | border-bottom: solid #000000 1px ! important; | ||
261 | border-left: solid #000000 1px ! important; | ||
262 | border-right: solid #000000 1px ! important; | ||
263 | } | ||
264 | |||
265 | div.senderpic{ | ||
266 | padding: 0px ! important; | ||
267 | font-size:0.8em ! important; | ||
268 | border:1px solid #b8b5b2 ! important; | ||
269 | background-color:#efebe7 ! important; | ||
270 | } | ||
271 | |||
272 | div.senderstatus{ | ||
273 | text-align:center ! important; | ||
274 | } | ||
275 | |||
276 | div.quotelevel1 { | ||
277 | color: #100000 ! important; | ||
278 | } | ||
279 | |||
280 | div.quotelevel2 { | ||
281 | color: #200000 ! important; | ||
282 | } | ||
283 | |||
284 | div.quotelevel3 { | ||
285 | color: #300000 ! important; | ||
286 | } | ||
287 | |||
288 | div.deepquotelevel1 { | ||
289 | color: #100000 ! important; | ||
290 | } | ||
291 | |||
292 | div.deepquotelevel2 { | ||
293 | color: #200000 ! important; | ||
294 | } | ||
295 | |||
296 | div.deepquotelevel3 { | ||
297 | color: #300000 ! important; | ||
298 | } \ No newline at end of file | ||
diff --git a/framework/mail/maillistmodel.cpp b/framework/mail/maillistmodel.cpp index e43351b0..95534cec 100644 --- a/framework/mail/maillistmodel.cpp +++ b/framework/mail/maillistmodel.cpp | |||
@@ -22,11 +22,12 @@ | |||
22 | 22 | ||
23 | #include "stringhtmlwriter.h" | 23 | #include "stringhtmlwriter.h" |
24 | #include "objecttreesource.h" | 24 | #include "objecttreesource.h" |
25 | #include "csshelper.h" | ||
25 | 26 | ||
26 | #include <QFile> | 27 | #include <QFile> |
27 | #include <QImage> | 28 | #include <QImage> |
28 | #include <KF5/MessageViewer/ObjectTreeParser> | 29 | #include <MessageViewer/ObjectTreeParser> |
29 | #include <KF5/MessageViewer/CSSHelperBase> | 30 | |
30 | 31 | ||
31 | MailListModel::MailListModel(QObject *parent) | 32 | MailListModel::MailListModel(QObject *parent) |
32 | : QIdentityProxyModel() | 33 | : QIdentityProxyModel() |
@@ -100,7 +101,7 @@ QVariant MailListModel::data(const QModelIndex &idx, int role) const | |||
100 | // render the mail | 101 | // render the mail |
101 | StringHtmlWriter htmlWriter; | 102 | StringHtmlWriter htmlWriter; |
102 | QImage paintDevice; | 103 | QImage paintDevice; |
103 | MessageViewer::CSSHelperBase cssHelper(&paintDevice); | 104 | CSSHelper cssHelper(&paintDevice); |
104 | MessageViewer::NodeHelper nodeHelper; | 105 | MessageViewer::NodeHelper nodeHelper; |
105 | ObjectTreeSource source(&htmlWriter, &cssHelper); | 106 | ObjectTreeSource source(&htmlWriter, &cssHelper); |
106 | MessageViewer::ObjectTreeParser otp(&source, &nodeHelper); | 107 | MessageViewer::ObjectTreeParser otp(&source, &nodeHelper); |