From d8a9e472c9e6973d16a3e4b46246c013fde9eec1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20Knau=C3=9F?= Date: Tue, 2 Feb 2016 10:34:33 +0100 Subject: create & load css for mails --- framework/mail/CMakeLists.txt | 2 + framework/mail/csshelper.cpp | 64 +++++++++ framework/mail/csshelper.h | 44 ++++++ framework/mail/data/mail.css | 298 +++++++++++++++++++++++++++++++++++++++ framework/mail/maillistmodel.cpp | 7 +- 5 files changed, 412 insertions(+), 3 deletions(-) create mode 100644 framework/mail/csshelper.cpp create mode 100644 framework/mail/csshelper.h create mode 100644 framework/mail/data/mail.css (limited to 'framework') 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 actions/sinkactions.cpp objecttreesource.cpp stringhtmlwriter.cpp + csshelper.cpp ) +add_definitions(-DMAIL_DATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/data") add_library(mailplugin SHARED ${mailplugin_SRCS}) 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 @@ +/* + csshelper.cpp + + This file is part of KMail, the KDE mail client. + Copyright (c) 2003 Marc Mutz + + KMail is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License, version 2, as + published by the Free Software Foundation. + + KMail is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + + In addition, as a special exception, the copyright holders give + permission to link the code of this program with any edition of + the Qt library by Trolltech AS, Norway (or with modified versions + of Qt that use the same license as Qt), and distribute linked + combinations including the two. You must obey the GNU General + Public License in all respects for all of the code used other than + Qt. If you modify this file, you may extend this exception to + your version of the file, but you are not obligated to do so. If + you do not wish to do so, delete this exception statement from + your version. +*/ + +#include "csshelper.h" + +#include +#include +#include +#include +#include +#include + +CSSHelper::CSSHelper(const QPaintDevice *pd) : + MessageViewer::CSSHelperBase(pd) +{ + +} + +QString cssDefinitions() +{ + QFile file(QLatin1String(MAIL_DATA_DIR) + QLatin1Char('/') + "mail.css"); + if (file.open(QFile::ReadOnly)) { + return file.readAll(); + } + return QString(); +} + +QString CSSHelper::htmlHead(bool fixed) const +{ + return + QLatin1String("\n" + "\n" + "\n"); +} \ 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 @@ +/* -*- c++ -*- + csshelper.h + + This file is part of KMail, the KDE mail client. + Copyright (c) 2003 Marc Mutz + + KMail is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License, version 2, as + published by the Free Software Foundation. + + KMail is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + + In addition, as a special exception, the copyright holders give + permission to link the code of this program with any edition of + the Qt library by Trolltech AS, Norway (or with modified versions + of Qt that use the same license as Qt), and distribute linked + combinations including the two. You must obey the GNU General + Public License in all respects for all of the code used other than + Qt. If you modify this file, you may extend this exception to + your version of the file, but you are not obligated to do so. If + you do not wish to do so, delete this exception statement from + your version. +*/ + +#pragma once + +#include + +class CSSHelper : public MessageViewer::CSSHelperBase +{ +public: + explicit CSSHelper(const QPaintDevice *pd); + + /** @return HTML head including style sheet definitions and the + >body< tag */ + QString htmlHead(bool fixedFont = false) const Q_DECL_OVERRIDE; +}; \ 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 @@ +div.header { + margin-bottom: 10pt ! important; +} + +table.textAtm { + margin-top: 10pt ! important; + margin-bottom: 10pt ! important; +} + +tr.textAtmH, +tr.textAtmB, +tr.rfc822B { + font-weight: normal ! important; +} + +tr.signInProgressH, +tr.rfc822H, +tr.encrH, +tr.signOkKeyOkH, +tr.signOkKeyBadH, +tr.signWarnH, +tr.sign +ErrH { + font-weight: bold ! important; +} + +tr.textAtmH td, +tr.textAtmB td { + padding: 3px ! important; +} + +table.rfc822 { + width: 100% ! important; + border: solid 1px black ! important; + margin-top: 10pt ! important; + margin-bottom: 10pt ! important; +} + +table.textAtm, +table.encr, +table.signWarn, +table.signErr, +table.signOkKeyBad, +table.signOkKeyOk, +table.signInProgress, +div.fancy.header table { + width: 100% ! important; + border-width: 0px ! important; + line-height: normal; +} + +div.htmlWarn { + margin: 0px 5% ! important; + padding: 10px ! important; + text-align: left ! important; + line-height: normal; +} + +div.fancy.header > div { + font-weight: bold ! important; + padding: 4px ! important; + line-height: normal; +} + +div.fancy.header table { + padding: 2px ! important; + text-align: left ! important; + border-collapse: separate ! important; +} + +div.fancy.header table th { + font-family: "Helvetica" ! important; + font-size: 12pt; + padding: 0px ! important; + white-space: nowrap ! important; + border-spacing: 0px ! important; + text-align: left ! important; + vertical-align: top ! important; + background-color: #efebe7 ! important; + color: #000000 ! important; + border: 1px ! important; +} + +div.fancy.header table td { + font-family: "Helvetica" ! important; + font-size: 12pt; + padding: 0px ! important; + border-spacing: 0px ! important; + text-align: left ! important; + vertical-align: top ! important; + width: 100% ! important; + background-color: #efebe7 ! important; + color: #000000 ! important; + border: 1px ! important; +} + +div.fancy.header table a:hover { + background-color: transparent ! important; +} + +span.pimsmileytext { + position: absolute; + top: 0px; + left: 0px; + visibility: hidden; +} + +img.pimsmileyimg { +} + +div.quotelevelmark { + position: absolute; + margin-left:-10px; +} + +body { + font-family: "Helvetica" ! important; + font-size: 12pt; + color: #000000 ! important; + background-color: #ffffff ! important; +} + +a { + color: #0000cc ! important; + text-decoration: none ! important; +} + +a.white { + color: white ! important; +} + +a.black { + color: black ! important; +} + +table.textAtm { background-color: #000000 ! important; } + +tr.textAtmH { + background-color: #ffffff ! important; + font-family: "Helvetica" ! important; + font-size: 12pt; +} + +tr.textAtmB { + background-color: #ffffff ! important; +} + +table.signInProgress, +table.rfc822 { + background-color: #ffffff ! important +; +} + +tr.signInProgressH, +tr.rfc822H { + font-family: "Helvetica" ! important; + font-size: 12pt; +} + +table.encr { + background-color: #cc0000 ! important; +} + +tr.encrH { + background-color: #ff0000 ! important; + color: #000000 ! important; + font-family: "Helvetica" ! important; + font-size: 12pt; +} + +tr.encrB { background-color: #ffe0e0 ! important; } + +table.signOkKeyOk { + background-color: #00cc00 ! important; +} + +tr.signOkKeyOkH { + background-color: #00ff00 ! important; + color: #000000 ! important; + font-family: "Helvetica" ! important; + font-size: 12pt; +} + +tr.signOkKeyOkB { background-color: #e0ffe0 ! important; } + +table.signOkKeyBad { + background-color: #00cc00 ! important; +} + +tr.signOkKeyBadH { + background-color: #00ff00 ! important; + color: #000000 ! important; + font-family: "Helvetica" ! important; + font-size: 12pt; +} + +tr.signOkKeyBadB { background-color: #e0ffe0 ! important; } + +table.signWarn { + background-color: #cc0 ! important; +} + +tr.signWarnH { + background-color: #fc0 ! important; + color: #000000 ! important; + font-family: "Helvetica" ! imp +ortant; + font-size: 12pt; +} + +tr.signWarnB { background-color: #e0e0ff ! important; } + +table.signErr { + background-color: #c00 ! important; +} + +tr.signErrH { + background-color: #0f00 ! important; + color: #0000 +00 ! important; + font-family: "Helvetica" ! important; + font-size: 12pt; +} + +tr.signErrB { background-color: #d3d3f0 ! important; } + +div.htmlWarn { + border: 2px solid #00001a ! important; + line-height: normal; +} + +div.header { + font-family: "Helvetica" ! important; + font-size: 12pt; +} + +div.fancy.header > div { + background-color: #308cc6 ! important; + color: #ffffff ! important; + border: solid #000000 1px ! important; + line-height: normal; +} + +div.fancy.header > div a[href] { color: #ffffff ! important; } + +div.fancy.header > div a[href]:hover { text-decoration: underline ! important; } + +div.fancy.header > div.spamheader { + background-color: #cdcdcd ! important; + border-top: 0px ! important; + padding: 3px ! important; + color: black ! important; + font-weight: bold ! important; + font-size: 12pt; +} + +div.fancy.header > table.outer { + background-color: #efebe7 ! important; + color: #000000 ! important; + border-bottom: solid #000000 1px ! important; + border-left: solid #000000 1px ! important; + border-right: solid #000000 1px ! important; +} + +div.senderpic{ + padding: 0px ! important; + font-size:0.8em ! important; + border:1px solid #b8b5b2 ! important; + background-color:#efebe7 ! important; +} + +div.senderstatus{ + text-align:center ! important; +} + +div.quotelevel1 { + color: #100000 ! important; +} + +div.quotelevel2 { + color: #200000 ! important; +} + +div.quotelevel3 { + color: #300000 ! important; +} + +div.deepquotelevel1 { + color: #100000 ! important; +} + +div.deepquotelevel2 { + color: #200000 ! important; +} + +div.deepquotelevel3 { + color: #300000 ! important; +} \ 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 @@ #include "stringhtmlwriter.h" #include "objecttreesource.h" +#include "csshelper.h" #include #include -#include -#include +#include + MailListModel::MailListModel(QObject *parent) : QIdentityProxyModel() @@ -100,7 +101,7 @@ QVariant MailListModel::data(const QModelIndex &idx, int role) const // render the mail StringHtmlWriter htmlWriter; QImage paintDevice; - MessageViewer::CSSHelperBase cssHelper(&paintDevice); + CSSHelper cssHelper(&paintDevice); MessageViewer::NodeHelper nodeHelper; ObjectTreeSource source(&htmlWriter, &cssHelper); MessageViewer::ObjectTreeParser otp(&source, &nodeHelper); -- cgit v1.2.3