Scale identity combobox and send/cancel buttons according to screen DPI.
[kdepim.git] / messageviewer / csshelper.cpp
blob3db2f4c2c639bf129de7c635830a24ff30304d7d
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 <config-messageviewer.h>
35 #include "csshelper.h"
36 #include "globalsettings.h"
38 #include "messagecore/globalsettings.h"
40 #include <kconfig.h>
41 #include <kconfiggroup.h>
42 #include <kapplication.h>
43 #include <KColorScheme>
45 #include <QColor>
46 #include <QFont>
47 #include <QPalette>
49 namespace MessageViewer {
51 CSSHelper::CSSHelper( const QPaintDevice *pd ) :
52 CSSHelperBase( pd )
54 KConfig *config = GlobalSettings::self()->config();
56 KConfigGroup reader( config, "Reader" );
57 KConfigGroup fonts( config, "Fonts" );
58 KConfigGroup pixmaps( config, "Pixmaps" );
60 mRecycleQuoteColors = reader.readEntry( "RecycleQuoteColors", false );
62 mForegroundColor = KColorScheme( QPalette::Active ).foreground().color();
63 mBackgroundColor = KColorScheme( QPalette::Active ).background().color();
64 if ( !MessageCore::GlobalSettings::self()->useDefaultColors() ) {
65 mLinkColor =
66 reader.readEntry( "LinkColor", mLinkColor );
67 mVisitedLinkColor =
68 reader.readEntry( "FollowedColor", mVisitedLinkColor );
69 cPgpEncrH =
70 reader.readEntry( "PGPMessageEncr", cPgpEncrH );
71 cPgpOk1H =
72 reader.readEntry( "PGPMessageOkKeyOk", cPgpOk1H );
73 cPgpOk0H =
74 reader.readEntry( "PGPMessageOkKeyBad", cPgpOk0H );
75 cPgpWarnH =
76 reader.readEntry( "PGPMessageWarn", cPgpWarnH );
77 cPgpErrH =
78 reader.readEntry( "PGPMessageErr", cPgpErrH );
79 cHtmlWarning =
80 reader.readEntry( "HTMLWarningColor", cHtmlWarning );
81 for ( int i = 0 ; i < 3 ; ++i ) {
82 const QString key = "QuotedText" + QString::number( i+1 );
83 mQuoteColor[i] = reader.readEntry( key, mQuoteColor[i] );
87 if ( !MessageCore::GlobalSettings::self()->useDefaultFonts() ) {
88 mBodyFont = fonts.readEntry( "body-font", mBodyFont );
89 mPrintFont = fonts.readEntry( "print-font", mPrintFont );
90 mFixedFont = fonts.readEntry( "fixed-font", mFixedFont );
91 mFixedPrintFont = mFixedFont; // FIXME when we have a separate fixed print font
92 QFont defaultFont = mBodyFont;
93 defaultFont.setItalic( true );
94 for ( int i = 0 ; i < 3 ; ++i ) {
95 const QString key = QString( "quote%1-font" ).arg( i+1 );
96 mQuoteFont[i] = fonts.readEntry( key, defaultFont );
100 mShrinkQuotes = GlobalSettings::self()->shrinkQuotes();
102 mBackingPixmapStr = pixmaps.readPathEntry("Readerwin", QString());
103 mBackingPixmapOn = !mBackingPixmapStr.isEmpty();
105 recalculatePGPColors();
108 QString CSSHelper::htmlHead( bool fixed ) const {
109 return
110 "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n"
111 "<html><head><title></title><style>\n"
112 + cssDefinitions( fixed ) +
113 "</style></head>\n"
114 "<body>\n";