Better wording
[kdepim.git] / messageviewer / csshelper.cpp
blobbbd5934150c6fdc9340c3ecbab0a17c35f90cf00
1 /* -*- mode: C++; c-file-style: "gnu" -*-
2 csshelper.cpp
4 This file is part of KMail, the KDE mail client.
5 Copyright (c) 2003 Marc Mutz <mutz@kde.org>
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.
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.
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
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.
33 #include "csshelper.h"
34 #include "globalsettings.h"
36 #include "messagecore/globalsettings.h"
38 #include <kconfig.h>
39 #include <kconfiggroup.h>
40 #include <kapplication.h>
41 #include <KColorScheme>
43 #include <QColor>
44 #include <QFont>
45 #include <QPalette>
47 namespace MessageViewer {
49 CSSHelper::CSSHelper( const QPaintDevice *pd ) :
50 CSSHelperBase( pd )
52 KConfig *config = GlobalSettings::self()->config();
54 KConfigGroup reader( config, "Reader" );
55 KConfigGroup fonts( config, "Fonts" );
56 KConfigGroup pixmaps( config, "Pixmaps" );
58 mRecycleQuoteColors = reader.readEntry( "RecycleQuoteColors", false );
60 mForegroundColor = KColorScheme( QPalette::Active ).foreground().color();
61 mBackgroundColor = KColorScheme( QPalette::Active ).background().color();
62 if ( !MessageCore::GlobalSettings::self()->useDefaultColors() ) {
63 mLinkColor =
64 reader.readEntry( "LinkColor", mLinkColor );
65 mVisitedLinkColor =
66 reader.readEntry( "FollowedColor", mVisitedLinkColor );
67 cPgpEncrH =
68 reader.readEntry( "PGPMessageEncr", cPgpEncrH );
69 cPgpOk1H =
70 reader.readEntry( "PGPMessageOkKeyOk", cPgpOk1H );
71 cPgpOk0H =
72 reader.readEntry( "PGPMessageOkKeyBad", cPgpOk0H );
73 cPgpWarnH =
74 reader.readEntry( "PGPMessageWarn", cPgpWarnH );
75 cPgpErrH =
76 reader.readEntry( "PGPMessageErr", cPgpErrH );
77 cHtmlWarning =
78 reader.readEntry( "HTMLWarningColor", cHtmlWarning );
79 for ( int i = 0 ; i < 3 ; ++i ) {
80 const QString key = "QuotedText" + QString::number( i+1 );
81 mQuoteColor[i] = reader.readEntry( key, mQuoteColor[i] );
85 if ( !MessageCore::GlobalSettings::self()->useDefaultFonts() ) {
86 mBodyFont = fonts.readEntry( "body-font", mBodyFont );
87 mPrintFont = fonts.readEntry( "print-font", mPrintFont );
88 mFixedFont = fonts.readEntry( "fixed-font", mFixedFont );
89 mFixedPrintFont = mFixedFont; // FIXME when we have a separate fixed print font
90 QFont defaultFont = mBodyFont;
91 defaultFont.setItalic( true );
92 for ( int i = 0 ; i < 3 ; ++i ) {
93 const QString key = QString( "quote%1-font" ).arg( i+1 );
94 mQuoteFont[i] = fonts.readEntry( key, defaultFont );
98 mShrinkQuotes = GlobalSettings::self()->shrinkQuotes();
100 mBackingPixmapStr = pixmaps.readPathEntry("Readerwin", QString());
101 mBackingPixmapOn = !mBackingPixmapStr.isEmpty();
103 recalculatePGPColors();
106 QString CSSHelper::htmlHead( bool fixed ) const {
107 return
108 "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n"
109 "<html><head><title></title><style>\n"
110 + cssDefinitions( fixed ) +
111 "</style></head>\n"
112 "<body>\n";