summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSandro Knauß <sknauss@kde.org>2016-02-02 10:34:33 +0100
committerSandro Knauß <sknauss@kde.org>2016-02-02 10:34:33 +0100
commitd8a9e472c9e6973d16a3e4b46246c013fde9eec1 (patch)
treed9188a56f3a2ebc6055b5b57722493d5ec0d7deb
parent8b2871ec42807268aee352af16cf0cf300898017 (diff)
downloadkube-d8a9e472c9e6973d16a3e4b46246c013fde9eec1.tar.gz
kube-d8a9e472c9e6973d16a3e4b46246c013fde9eec1.zip
create & load css for mails
-rw-r--r--framework/mail/CMakeLists.txt2
-rw-r--r--framework/mail/csshelper.cpp64
-rw-r--r--framework/mail/csshelper.h44
-rw-r--r--framework/mail/data/mail.css298
-rw-r--r--framework/mail/maillistmodel.cpp7
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)
13add_definitions(-DMAIL_DATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/data")
12 14
13add_library(mailplugin SHARED ${mailplugin_SRCS}) 15add_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
41CSSHelper::CSSHelper(const QPaintDevice *pd) :
42 MessageViewer::CSSHelperBase(pd)
43{
44
45}
46
47QString 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
56QString 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
36class CSSHelper : public MessageViewer::CSSHelperBase
37{
38public:
39 explicit CSSHelper(const QPaintDevice *pd);
40
41 /** @return HTML head including style sheet definitions and the
42 &gt;body&lt; 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 @@
1div.header {
2 margin-bottom: 10pt ! important;
3}
4
5table.textAtm {
6 margin-top: 10pt ! important;
7 margin-bottom: 10pt ! important;
8}
9
10tr.textAtmH,
11tr.textAtmB,
12tr.rfc822B {
13 font-weight: normal ! important;
14}
15
16tr.signInProgressH,
17tr.rfc822H,
18tr.encrH,
19tr.signOkKeyOkH,
20tr.signOkKeyBadH,
21tr.signWarnH,
22tr.sign
23ErrH {
24 font-weight: bold ! important;
25}
26
27tr.textAtmH td,
28tr.textAtmB td {
29 padding: 3px ! important;
30}
31
32table.rfc822 {
33 width: 100% ! important;
34 border: solid 1px black ! important;
35 margin-top: 10pt ! important;
36 margin-bottom: 10pt ! important;
37}
38
39table.textAtm,
40table.encr,
41table.signWarn,
42table.signErr,
43table.signOkKeyBad,
44table.signOkKeyOk,
45table.signInProgress,
46div.fancy.header table {
47 width: 100% ! important;
48 border-width: 0px ! important;
49 line-height: normal;
50}
51
52div.htmlWarn {
53 margin: 0px 5% ! important;
54 padding: 10px ! important;
55 text-align: left ! important;
56 line-height: normal;
57}
58
59div.fancy.header > div {
60 font-weight: bold ! important;
61 padding: 4px ! important;
62 line-height: normal;
63}
64
65div.fancy.header table {
66 padding: 2px ! important;
67 text-align: left ! important;
68 border-collapse: separate ! important;
69}
70
71div.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
84div.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
97div.fancy.header table a:hover {
98 background-color: transparent ! important;
99}
100
101span.pimsmileytext {
102 position: absolute;
103 top: 0px;
104 left: 0px;
105 visibility: hidden;
106}
107
108img.pimsmileyimg {
109}
110
111div.quotelevelmark {
112 position: absolute;
113 margin-left:-10px;
114}
115
116body {
117 font-family: "Helvetica" ! important;
118 font-size: 12pt;
119 color: #000000 ! important;
120 background-color: #ffffff ! important;
121}
122
123a {
124 color: #0000cc ! important;
125 text-decoration: none ! important;
126}
127
128a.white {
129 color: white ! important;
130}
131
132a.black {
133 color: black ! important;
134}
135
136table.textAtm { background-color: #000000 ! important; }
137
138tr.textAtmH {
139 background-color: #ffffff ! important;
140 font-family: "Helvetica" ! important;
141 font-size: 12pt;
142}
143
144tr.textAtmB {
145 background-color: #ffffff ! important;
146}
147
148table.signInProgress,
149table.rfc822 {
150 background-color: #ffffff ! important
151;
152}
153
154tr.signInProgressH,
155tr.rfc822H {
156 font-family: "Helvetica" ! important;
157 font-size: 12pt;
158}
159
160table.encr {
161 background-color: #cc0000 ! important;
162}
163
164tr.encrH {
165 background-color: #ff0000 ! important;
166 color: #000000 ! important;
167 font-family: "Helvetica" ! important;
168 font-size: 12pt;
169}
170
171tr.encrB { background-color: #ffe0e0 ! important; }
172
173table.signOkKeyOk {
174 background-color: #00cc00 ! important;
175}
176
177tr.signOkKeyOkH {
178 background-color: #00ff00 ! important;
179 color: #000000 ! important;
180 font-family: "Helvetica" ! important;
181 font-size: 12pt;
182}
183
184tr.signOkKeyOkB { background-color: #e0ffe0 ! important; }
185
186table.signOkKeyBad {
187 background-color: #00cc00 ! important;
188}
189
190tr.signOkKeyBadH {
191 background-color: #00ff00 ! important;
192 color: #000000 ! important;
193 font-family: "Helvetica" ! important;
194 font-size: 12pt;
195}
196
197tr.signOkKeyBadB { background-color: #e0ffe0 ! important; }
198
199table.signWarn {
200 background-color: #cc0 ! important;
201}
202
203tr.signWarnH {
204 background-color: #fc0 ! important;
205 color: #000000 ! important;
206 font-family: "Helvetica" ! imp
207ortant;
208 font-size: 12pt;
209}
210
211tr.signWarnB { background-color: #e0e0ff ! important; }
212
213table.signErr {
214 background-color: #c00 ! important;
215}
216
217tr.signErrH {
218 background-color: #0f00 ! important;
219 color: #0000
22000 ! important;
221 font-family: "Helvetica" ! important;
222 font-size: 12pt;
223}
224
225tr.signErrB { background-color: #d3d3f0 ! important; }
226
227div.htmlWarn {
228 border: 2px solid #00001a ! important;
229 line-height: normal;
230}
231
232div.header {
233 font-family: "Helvetica" ! important;
234 font-size: 12pt;
235}
236
237div.fancy.header > div {
238 background-color: #308cc6 ! important;
239 color: #ffffff ! important;
240 border: solid #000000 1px ! important;
241 line-height: normal;
242}
243
244div.fancy.header > div a[href] { color: #ffffff ! important; }
245
246div.fancy.header > div a[href]:hover { text-decoration: underline ! important; }
247
248div.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
257div.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
265div.senderpic{
266 padding: 0px ! important;
267 font-size:0.8em ! important;
268 border:1px solid #b8b5b2 ! important;
269 background-color:#efebe7 ! important;
270}
271
272div.senderstatus{
273 text-align:center ! important;
274}
275
276div.quotelevel1 {
277 color: #100000 ! important;
278}
279
280div.quotelevel2 {
281 color: #200000 ! important;
282}
283
284div.quotelevel3 {
285 color: #300000 ! important;
286}
287
288div.deepquotelevel1 {
289 color: #100000 ! important;
290}
291
292div.deepquotelevel2 {
293 color: #200000 ! important;
294}
295
296div.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
31MailListModel::MailListModel(QObject *parent) 32MailListModel::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);