kmail Library API Documentation

csshelper.cpp

00001 /*  -*- mode: C++; c-file-style: "gnu" -*-
00002     csshelper.cpp
00003 
00004     This file is part of KMail, the KDE mail client.
00005     Copyright (c) 2003 Marc Mutz <mutz@kde.org>
00006 
00007     KMail is free software; you can redistribute it and/or modify it
00008     under the terms of the GNU General Public License, version 2, as
00009     published by the Free Software Foundation.
00010 
00011     KMail is distributed in the hope that it will be useful, but
00012     WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014     General Public License for more details.
00015 
00016     You should have received a copy of the GNU General Public License
00017     along with this program; if not, write to the Free Software
00018     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 
00020     In addition, as a special exception, the copyright holders give
00021     permission to link the code of this program with any edition of
00022     the Qt library by Trolltech AS, Norway (or with modified versions
00023     of Qt that use the same license as Qt), and distribute linked
00024     combinations including the two.  You must obey the GNU General
00025     Public License in all respects for all of the code used other than
00026     Qt.  If you modify this file, you may extend this exception to
00027     your version of the file, but you are not obligated to do so.  If
00028     you do not wish to do so, delete this exception statement from
00029     your version.
00030 */
00031 
00032 #include <config.h>
00033 
00034 #include "csshelper.h"
00035 
00036 #include "kmkernel.h"
00037 
00038 #include <kconfig.h>
00039 #include <kglobalsettings.h>
00040 #include <kdebug.h>
00041 #include <kglobal.h>
00042 
00043 #include <qcolor.h>
00044 #include <qfont.h>
00045 #include <qstring.h>
00046 #include <qapplication.h>
00047 
00048 #include <cassert>
00049 
00050 namespace KMail {
00051 
00052   class CSSHelper::Private {
00053     friend class CSSHelper;
00054   public:
00055     Private() {}
00056     ~Private() {}
00057 
00058     bool operator==( const Private & other ) const;
00059     bool operator!=( const Private & other ) const {
00060       return !operator==( other );
00061     }
00062 
00063     void readColorConfig();
00064 
00065     // returns CSS rules specific to the print media type
00066     QString printCssDefinitions() const;
00067 
00068     // returns CSS rules specific to the screen media type
00069     QString screenCssDefinitions( const CSSHelper * helper, bool fixed ) const;
00070 
00071     // returns CSS rules common to both screen and print media types
00072     QString commonCssDefinitions() const;
00073 
00074     QFont bodyFont( bool fixed, bool print=false ) const {
00075       return fixed ? mFixedFont : print ? mPrintFont : mBodyFont ;
00076     }
00077     int fontSize( bool fixed, bool print=false ) const {
00078       return bodyFont( fixed, print ).pointSize();
00079     }
00080 
00081     QString quoteFontTag( int level ) const;
00082 
00083   private:
00084     QFont mBodyFont, mPrintFont, mFixedFont;
00085     QFont mQuoteFont[3];
00086     QColor mQuoteColor[3];
00087     bool mRecycleQuoteColors;
00088     bool mBackingPixmapOn;
00089     QString mBackingPixmapStr;
00090     QColor c1, c2, c3, c4;
00091     // colors for PGP (Frame, Header, Body)
00092     QColor cPgpOk1F, cPgpOk1H, cPgpOk1B,
00093       cPgpOk0F, cPgpOk0H, cPgpOk0B,
00094       cPgpWarnF, cPgpWarnH, cPgpWarnB,
00095       cPgpErrF, cPgpErrH, cPgpErrB,
00096       cPgpEncrF, cPgpEncrH, cPgpEncrB;
00097     // color of frame of warning preceding the source of HTML messages
00098     QColor cHtmlWarning;
00099   };
00100 
00101   bool CSSHelper::Private::operator==( const Private & other ) const {
00102     for ( int i = 0 ; i < 3 ; ++i )
00103       if ( mQuoteFont[i] != other.mQuoteFont[i] ||
00104        mQuoteColor[i] != other.mQuoteColor[i] )
00105     return false;
00106     return // eeek!
00107       mBodyFont == other.mBodyFont &&
00108       mPrintFont == other.mPrintFont &&
00109       mFixedFont == other.mFixedFont &&
00110       mRecycleQuoteColors == other.mRecycleQuoteColors &&
00111       mBackingPixmapOn == other.mBackingPixmapOn &&
00112       mBackingPixmapStr == other.mBackingPixmapStr &&
00113       c1 == other.c1 && c2 == other.c2 && c3 == other.c3 && c4 == other.c4 &&
00114       cHtmlWarning == other.cHtmlWarning &&
00115       cPgpOk1F == other.cPgpOk1F && cPgpOk1H == other.cPgpOk1H && cPgpOk1B == other.cPgpOk1B &&
00116       cPgpOk0F == other.cPgpOk0F && cPgpOk0H == other.cPgpOk0H && cPgpOk0B == other.cPgpOk0B &&
00117       cPgpWarnF == other.cPgpWarnF && cPgpWarnH == other.cPgpWarnH && cPgpWarnB == other.cPgpWarnB &&
00118       cPgpErrF == other.cPgpErrF && cPgpErrH == other.cPgpErrH && cPgpErrB == other.cPgpErrB &&
00119       cPgpEncrF == other.cPgpEncrF && cPgpEncrH == other.cPgpEncrH && cPgpEncrB == other.cPgpEncrB ;
00120     }
00121 
00122   namespace {
00123     // some QColor manipulators that hide the ugly QColor API w.r.t. HSV:
00124     inline QColor darker( const QColor & c ) {
00125       int h, s, v;
00126       c.hsv( &h, &s, &v );
00127       return QColor( h, s, v*4/5, QColor::Hsv );
00128     }
00129 
00130     inline QColor desaturate( const QColor & c ) {
00131       int h, s, v;
00132       c.hsv( &h, &s, &v );
00133       return QColor( h, s/8, v, QColor::Hsv );
00134     }
00135 
00136     inline QColor fixValue( const QColor & c, int newV ) {
00137       int h, s, v;
00138       c.hsv( &h, &s, &v );
00139       return QColor( h, s, newV, QColor::Hsv );
00140     }
00141 
00142     inline int getValueOf( const QColor & c ) {
00143       int h, s, v;
00144       c.hsv( &h, &s, &v );
00145       return v;
00146     }
00147   }
00148 
00149   void CSSHelper::Private::readColorConfig() {
00150     KConfig * config = KMKernel::config();
00151 
00152     KConfigGroup reader( config, "Reader" );
00153     KConfigGroup fonts( config, "Fonts" );
00154     KConfigGroup pixmaps( config, "Pixmaps" );
00155 
00156     c1 = QApplication::palette().active().text();
00157     c2 = KGlobalSettings::linkColor();
00158     c3 = KGlobalSettings::visitedLinkColor();
00159     c4 = QApplication::palette().active().base();
00160     cHtmlWarning = QColor( 0xFF, 0x40, 0x40 ); // warning frame color: light red
00161 
00162     // The default colors are also defined in configuredialog.cpp
00163     cPgpEncrH = QColor( 0x00, 0x80, 0xFF ); // light blue
00164     cPgpOk1H  = QColor( 0x40, 0xFF, 0x40 ); // light green
00165     cPgpOk0H  = QColor( 0xFF, 0xFF, 0x40 ); // light yellow
00166     cPgpWarnH = QColor( 0xFF, 0xFF, 0x40 ); // light yellow
00167     cPgpErrH  = Qt::red;
00168     mQuoteColor[0] = QColor( 0,0,221 ); 
00169     mQuoteColor[1] = QColor( 0,99, 18 );
00170     mQuoteColor[2] = QColor( 84,0,0 );
00171 
00172     mRecycleQuoteColors = reader.readBoolEntry( "RecycleQuoteColors", false );
00173 
00174     if ( !reader.readBoolEntry( "defaultColors", true ) ) {
00175       c1 = reader.readColorEntry("ForegroundColor",&c1);
00176       c2 = reader.readColorEntry("LinkColor",&c2);
00177       c3 = reader.readColorEntry("FollowedColor",&c3);
00178       c4 = reader.readColorEntry("BackgroundColor",&c4);
00179       cPgpEncrH = reader.readColorEntry( "PGPMessageEncr", &cPgpEncrH );
00180       cPgpOk1H  = reader.readColorEntry( "PGPMessageOkKeyOk", &cPgpOk1H );
00181       cPgpOk0H  = reader.readColorEntry( "PGPMessageOkKeyBad", &cPgpOk0H );
00182       cPgpWarnH = reader.readColorEntry( "PGPMessageWarn", &cPgpWarnH );
00183       cPgpErrH  = reader.readColorEntry( "PGPMessageErr", &cPgpErrH );
00184       cHtmlWarning = reader.readColorEntry( "HTMLWarningColor", &cHtmlWarning );
00185       for ( int i = 0 ; i < 3 ; ++i ) {
00186     const QString key = "QuotedText" + QString::number( i+1 );
00187     mQuoteColor[i] = reader.readColorEntry( key, &mQuoteColor[i] );
00188       }
00189     }
00190 
00191     // determine the frame and body color for PGP messages from the header color
00192     // if the header color equals the background color then the other colors are
00193     // also set to the background color (-> old style PGP message viewing)
00194     // else
00195     // the brightness of the frame is set to 4/5 of the brightness of the header
00196     // and in case of a light background color
00197     // the saturation of the body is set to 1/8 of the saturation of the header
00198     // while in case of a dark background color
00199     // the value of the body is set to the value of the background color
00200 
00201     // Check whether the user uses a light color scheme
00202     const int vBG = getValueOf( c4 );
00203     const bool lightBG = vBG >= 128;
00204     if ( cPgpOk1H == c4 ) {
00205       cPgpOk1F = c4;
00206       cPgpOk1B = c4;
00207     } else {
00208       cPgpOk1F= darker( cPgpOk1H );
00209       cPgpOk1B = lightBG ? desaturate( cPgpOk1H ) : fixValue( cPgpOk1H, vBG );
00210     }
00211     if ( cPgpOk0H == c4 ) {
00212       cPgpOk0F = c4;
00213       cPgpOk0B = c4;
00214     } else {
00215       cPgpOk0F = darker( cPgpOk0H );
00216       cPgpOk0B = lightBG ? desaturate( cPgpOk0H ) : fixValue( cPgpOk0H, vBG );
00217     }
00218     if ( cPgpWarnH == c4 ) {
00219       cPgpWarnF = c4;
00220       cPgpWarnB = c4;
00221     } else {
00222       cPgpWarnF = darker( cPgpWarnH );
00223       cPgpWarnB = lightBG ? desaturate( cPgpWarnH ) : fixValue( cPgpWarnH, vBG );
00224     }
00225     if ( cPgpErrH == c4 ) {
00226       cPgpErrF = c4;
00227       cPgpErrB = c4;
00228     } else {
00229       cPgpErrF = darker( cPgpErrH );
00230       cPgpErrB = lightBG ? desaturate( cPgpErrH ) : fixValue( cPgpErrH, vBG );
00231     }
00232     if ( cPgpEncrH == c4 ) {
00233       cPgpEncrF = c4;
00234       cPgpEncrB = c4;
00235     } else {
00236       cPgpEncrF = darker( cPgpEncrH );
00237       cPgpEncrB = lightBG ? desaturate( cPgpEncrH ) : fixValue( cPgpEncrH, vBG );
00238     }
00239 
00240     QFont defaultFont = KGlobalSettings::generalFont();
00241     if ( fonts.readBoolEntry( "defaultFonts", true ) ) {
00242       mBodyFont = mPrintFont = defaultFont;
00243       mFixedFont = KGlobalSettings::fixedFont();
00244       defaultFont.setItalic( true );
00245       for ( int i = 0 ; i < 3 ; ++i )
00246     mQuoteFont[i] = defaultFont;
00247     } else {
00248       mBodyFont = fonts.readFontEntry(  "body-font",  &defaultFont);
00249       mPrintFont = fonts.readFontEntry( "print-font", &defaultFont);
00250       mFixedFont = fonts.readFontEntry( "fixed-font", &defaultFont);
00251       defaultFont.setItalic( true );
00252       for ( int i = 0 ; i < 3 ; ++i ) {
00253     const QString key = QString( "quote%1-font" ).arg( i+1 );
00254     mQuoteFont[i] = fonts.readFontEntry( key, &defaultFont );
00255       }
00256     }
00257 
00258     mBackingPixmapStr = pixmaps.readPathEntry("Readerwin");
00259     mBackingPixmapOn = !mBackingPixmapStr.isEmpty();
00260   }
00261 
00262   CSSHelper::CSSHelper( const QPaintDeviceMetrics & pdm, QObject * parent, const char * name )
00263     : ConfigManager( parent, name ),
00264       d( 0 ), s( 0 ), mMetrics( pdm )
00265   {
00266     d = new Private();
00267     d->readColorConfig();
00268   }
00269 
00270   CSSHelper::~CSSHelper() {
00271     kdWarning( hasPendingChanges(), 5006 )
00272       << "CSSHelper: There were uncommitted changes!" << endl;
00273     delete d; d = 0;
00274     delete s; s = 0;
00275   }
00276 
00277   void CSSHelper::commit() {
00278     // not yet implemented
00279   }
00280 
00281   void CSSHelper::rollback() {
00282     delete s; s = 0;
00283   }
00284 
00285   bool CSSHelper::hasPendingChanges() const {
00286     assert( d );
00287     return s && *s != *d ;
00288   }
00289 
00290   QString CSSHelper::cssDefinitions( bool fixed ) const {
00291     assert( d );
00292     return
00293       d->commonCssDefinitions()
00294       +
00295       "@media screen {\n\n"
00296       +
00297       d->screenCssDefinitions( this, fixed )
00298       +
00299       "}\n"
00300       "@media print {\n\n"
00301       +
00302       d->printCssDefinitions()
00303       +
00304       "}\n";
00305   }
00306 
00307   QString CSSHelper::htmlHead( bool fixed ) const {
00308     return
00309       "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n"
00310       "<html><head><title></title></head>\n"
00311       +
00312       QString( fixed ? "<body class\"fixedfont\">\n" : "<body>\n" );
00313   }
00314 
00315   QString CSSHelper::Private::quoteFontTag( int level ) const {
00316     if ( level < 0 )
00317       level = 0;
00318     static const int numQuoteLevels = sizeof mQuoteFont / sizeof *mQuoteFont ;
00319     const int effectiveLevel = mRecycleQuoteColors
00320       ? level % numQuoteLevels + 1
00321       : kMin( level + 1, numQuoteLevels ) ;
00322     return QString( "<div class=\"quotelevel%1\">" ).arg( effectiveLevel );
00323   }
00324 
00325   QString CSSHelper::quoteFontTag( int level ) const {
00326     assert( d );
00327     return d->quoteFontTag( level );
00328   }
00329 
00330   QString CSSHelper::nonQuotedFontTag() const {
00331     return "<div class=\"noquote\">";
00332   }
00333 
00334   QFont CSSHelper::bodyFont( bool fixed, bool print ) const {
00335     assert( d );
00336     return d->bodyFont( fixed, print );
00337   }
00338 
00339   namespace {
00340     int pointsToPixel( const QPaintDeviceMetrics & metrics, int pointSize ) {
00341       return ( pointSize * metrics.logicalDpiY() + 36 ) / 72 ;
00342     }
00343   }
00344 
00345   QString CSSHelper::Private::printCssDefinitions() const {
00346     const QString headerFont = QString( "  font-family: \"%1\" ! important;\n"
00347                     "  font-size: %2pt ! important;\n" )
00348                            .arg( mPrintFont.family() )
00349                            .arg( mPrintFont.pointSize() );
00350     const QColorGroup & cg = QApplication::palette().active();
00351 
00352     QString quoteCSS;
00353     if ( mPrintFont.italic() )
00354       quoteCSS += "  font-style: italic ! important;\n";
00355     if ( mPrintFont.bold() )
00356       quoteCSS += "  font-weight: bold ! important;\n";
00357     if ( !quoteCSS.isEmpty() )
00358       quoteCSS = "div.noquote {\n" + quoteCSS + "}\n\n";
00359 
00360     return
00361       QString( "body {\n"
00362            "  font-family: \"%1\" ! important;\n"
00363            "  font-size: %2pt ! important;\n"
00364            "  color: #000000 ! important;\n"
00365            "  background-color: #ffffff ! important\n"
00366            "}\n\n" )
00367       .arg( mPrintFont.family(),
00368         QString::number( mPrintFont.pointSize() ) )
00369       +
00370       QString( "tr.textAtmH,\n"
00371            "tr.rfc822H,\n"
00372            "tr.encrH,\n"
00373            "tr.signOkKeyOkH,\n"
00374            "tr.signOkKeyBadH,\n"
00375            "tr.signWarnH,\n"
00376            "tr.signErrH,\n"
00377            "div.header {\n"
00378            "%1"
00379            "}\n\n"
00380 
00381            "div.fancy.header > div {\n"
00382            "  background-color: %2 ! important;\n"
00383            "  color: %3 ! important;\n"
00384            "  padding: 4px ! important;\n"
00385            "  border: solid %3 1px ! important;\n"
00386            "}\n\n"
00387 
00388            "div.fancy.header > div a[href] { color: %3 ! important; }\n\n"
00389 
00390            "div.fancy.header > table.outer{\n"
00391            "  background-color: %2 ! important;\n"
00392            "  color: %3 ! important;\n"
00393            "  border-bottom: solid %3 1px ! important;\n"
00394            "  border-left: solid %3 1px ! important;\n"
00395            "  border-right: solid %3 1px ! important;\n"
00396            "}\n\n"
00397 
00398            "div.fancy.header > div.sender-pic{\n"
00399            "  font-size:0.8em;\n"
00400            "  border:1px solid black;\n"
00401            "  background-color:InfoBackground;\n"
00402            "}\n\n"
00403 
00404            "div.fancy.header > div.sender-status{\n"
00405            "  text-align:center;\n"
00406            "}\n\n"
00407 
00408            "div.htmlWarn {\n"
00409            "  border: 2px solid #ffffff ! important;\n"
00410            "}\n\n"
00411            "div.senderStatus {\n"
00412             
00413             )
00414       .arg( headerFont,
00415         cg.background().name(),
00416         cg.foreground().name() )
00417       + quoteCSS;
00418   }
00419 
00420   QString CSSHelper::Private::screenCssDefinitions( const CSSHelper * helper, bool fixed ) const {
00421     const QString fgColor = c1.name();
00422     const QString bgColor = c4.name();
00423     const QString linkColor = c2.name();
00424     const QString headerFont = QString("  font-family: \"%1\" ! important;\n"
00425                        "  font-size: %2px ! important;\n")
00426       .arg( mBodyFont.family() )
00427       .arg( pointsToPixel( helper->mMetrics, mBodyFont.pointSize() ) );
00428     const QString background = ( mBackingPixmapOn
00429                          ? QString( "  background-image:url(file://%1) ! important;\n" )
00430                            .arg( mBackingPixmapStr )
00431                          : QString( "  background-color: %1 ! important;\n" )
00432                            .arg( bgColor ) );
00433     const QString bodyFontSize = QString::number( pointsToPixel( helper->mMetrics, fontSize( fixed ) ) ) + "px" ;
00434     const QColorGroup & cg = QApplication::palette().active();
00435 
00436     QString quoteCSS;
00437     if ( bodyFont( fixed ).italic() )
00438       quoteCSS += "  font-style: italic ! important;\n";
00439     if ( bodyFont( fixed ).bold() )
00440       quoteCSS += "  font-weight: bold ! important;\n";
00441     if ( !quoteCSS.isEmpty() )
00442       quoteCSS = "div.noquote {\n" + quoteCSS + "}\n\n";
00443 
00444     for ( int i = 0 ; i < 3 ; ++i ) {
00445       quoteCSS += QString( "div.quotelevel%1 {\n"
00446                "  color: %2 ! important;\n" )
00447     .arg( QString::number(i+1), mQuoteColor[i].name() );
00448       if ( mQuoteFont[i].italic() )
00449     quoteCSS += "  font-style: italic ! important;\n";
00450       if ( mQuoteFont[i].bold() )
00451     quoteCSS += "  font-weight: bold ! important;\n";
00452       quoteCSS += "}\n\n";
00453     }
00454 
00455     return
00456       QString( "body {\n"
00457            "  font-family: \"%1\" ! important;\n"
00458            "  font-size: %2 ! important;\n"
00459            "  color: %3 ! important;\n"
00460            "%4"
00461            "}\n\n" )
00462       .arg( bodyFont( fixed ).family(),
00463         bodyFontSize,
00464         fgColor,
00465         background )
00466       +
00467       QString( "a {\n"
00468            "  color: %1 ! important;\n"
00469            "  text-decoration: none ! important;\n"
00470            "}\n\n"
00471 
00472            "table.textAtm { background-color: %2 ! important; }\n\n"
00473 
00474            "tr.textAtmH {\n"
00475            "  background-color: %3 ! important;\n"
00476            "%4"
00477            "}\n\n"
00478 
00479            "tr.textAtmB {\n"
00480            "  background-color: %3 ! important;\n"
00481            "}\n\n"
00482 
00483            "table.rfc822 {\n"
00484            "  background-color: %3 ! important;\n"
00485            "}\n\n"
00486 
00487            "tr.rfc822H {\n"
00488            "%4"
00489            "}\n\n" )
00490       .arg( linkColor, fgColor, bgColor, headerFont )
00491       +
00492       QString( "table.encr {\n"
00493            "  background-color: %1 ! important;\n"
00494            "}\n\n"
00495 
00496            "tr.encrH {\n"
00497            "  background-color: %2 ! important;\n"
00498            "%3"
00499            "}\n\n"
00500 
00501            "tr.encrB { background-color: %4 ! important; }\n\n" )
00502       .arg( cPgpEncrF.name(),
00503         cPgpEncrH.name(),
00504         headerFont,
00505         cPgpEncrB.name() )
00506       +
00507       QString( "table.signOkKeyOk {\n"
00508            "  background-color: %1 ! important;\n"
00509            "}\n\n"
00510 
00511            "tr.signOkKeyOkH {\n"
00512            "  background-color: %2 ! important;\n"
00513            "%3"
00514            "}\n\n"
00515 
00516            "tr.signOkKeyOkB { background-color: %4 ! important; }\n\n" )
00517       .arg( cPgpOk1F.name(),
00518         cPgpOk1H.name(),
00519         headerFont,
00520         cPgpOk1B.name() )
00521       +
00522       QString( "table.signOkKeyBad {\n"
00523            "  background-color: %1 ! important;\n"
00524            "}\n\n"
00525 
00526            "tr.signOkKeyBadH {\n"
00527            "  background-color: %2 ! important;\n"
00528            "%3"
00529            "}\n\n"
00530 
00531            "tr.signOkKeyBadB { background-color: %4 ! important; }\n\n" )
00532       .arg( cPgpOk0F.name(),
00533         cPgpOk0H.name(),
00534         headerFont,
00535         cPgpOk0B.name() )
00536       +
00537       QString( "table.signWarn {\n"
00538            "  background-color: %1 ! important;\n"
00539            "}\n\n"
00540 
00541            "tr.signWarnH {\n"
00542            "  background-color: %2 ! important;\n"
00543            "%3"
00544            "}\n\n"
00545 
00546            "tr.signWarnB { background-color: %4 ! important; }\n\n" )
00547       .arg( cPgpWarnF.name(),
00548         cPgpWarnH.name(),
00549         headerFont,
00550         cPgpWarnB.name() )
00551       +
00552       QString( "table.signErr {\n"
00553            "  background-color: %1 ! important;\n"
00554            "}\n\n"
00555 
00556            "tr.signErrH {\n"
00557            "  background-color: %2 ! important;\n"
00558            "%3"
00559            "}\n\n"
00560 
00561            "tr.signErrB { background-color: %4 ! important; }\n\n" )
00562       .arg( cPgpErrF.name(),
00563         cPgpErrH.name(),
00564         headerFont,
00565         cPgpErrB.name() )
00566       +
00567       QString( "div.htmlWarn {\n"
00568            "  border: 2px solid %1 ! important;\n"
00569            "}\n\n" )
00570       .arg( cHtmlWarning.name() )
00571       +
00572       QString( "div.header {\n"
00573            "%1"
00574            "}\n\n"
00575 
00576            "div.fancy.header > div {\n"
00577            "  background-color: %2 ! important;\n"
00578            "  color: %3 ! important;\n"
00579            "  border: solid %4 1px ! important;\n"
00580            "}\n\n"
00581 
00582            "div.fancy.header > div a[href] { color: %3 ! important; }\n\n"
00583 
00584            "div.fancy.header > div a[href]:hover { text-decoration: underline ! important; }\n\n"
00585 
00586            "div.fancy.header > table.outer {\n"
00587            "  background-color: %5 ! important;\n"
00588            "  color: %4 ! important;\n"
00589            "  border-bottom: solid %4 1px ! important;\n"
00590            "  border-left: solid %4 1px ! important;\n"
00591            "  border-right: solid %4 1px ! important;\n"
00592            "}\n\n"
00593 
00594            "div.senderpic{\n"
00595            "  font-size:0.8em;\n"
00596            "  border:1px solid black;\n"
00597            // FIXME: InfoBackground crashes KHTML
00598            //"  background-color:InfoBackground;\n"
00599            "  background-color:yellow;\n"
00600            "}\n\n"
00601 
00602            "div.senderstatus{\n"
00603            "  text-align:center;\n"
00604            "}\n\n" )
00605 
00606       .arg( headerFont )
00607       .arg( cg.highlight().name(),
00608         cg.highlightedText().name(),
00609         cg.foreground().name(),
00610         cg.background().name() )
00611       + quoteCSS;
00612   }
00613 
00614   QString CSSHelper::Private::commonCssDefinitions() const {
00615     return
00616       "div.header {\n"
00617       "  margin-bottom: 10pt ! important;\n"
00618       "}\n\n"
00619 
00620       "table.textAtm {\n"
00621       "  margin-top: 10pt ! important;\n"
00622       "  margin-bottom: 10pt ! important;\n"
00623       "}\n\n"
00624 
00625       "tr.textAtmH,\n"
00626       "tr.textAtmB,\n"
00627       "tr.rfc822B {\n"
00628       "  font-weight: normal ! important;\n"
00629       "}\n\n"
00630 
00631       "tr.rfc822H,\n"
00632       "tr.encrH,\n"
00633       "tr.signOkKeyOkH,\n"
00634       "tr.signOkKeyBadH,\n"
00635       "tr.signWarnH,\n"
00636       "tr.signErrH {\n"
00637       "  font-weight: bold ! important;\n"
00638       "}\n\n"
00639 
00640       "tr.textAtmH td,\n"
00641       "tr.textAtmB td {\n"
00642       "  padding: 3px ! important;\n"
00643       "}\n\n"
00644 
00645       "table.rfc822 {\n"
00646       "  width: 100% ! important;\n"
00647       "  border: solid 1px black ! important;\n"
00648       "  margin-top: 10pt ! important;\n"
00649       "  margin-bottom: 10pt ! important;\n"
00650       "}\n\n"
00651 
00652       "table.textAtm,\n"
00653       "table.encr,\n"
00654       "table.signWarn,\n"
00655       "table.signErr,\n"
00656       "table.signOkKeyBad,\n"
00657       "table.signOkKeyOk,\n"
00658       "div.fancy.header table {\n"
00659       "  width: 100% ! important;\n"
00660       "  border-width: 0px ! important;\n"
00661       "}\n\n"
00662 
00663       "div.htmlWarn {\n"
00664       "  margin: 0px 5% ! important;\n"
00665       "  padding: 10px ! important;\n"
00666       "  text-align: left ! important;\n"
00667       "}\n\n"
00668 
00669       "div.fancy.header > div {\n"
00670       "  font-weight: bold ! important;\n"
00671       "  padding: 4px ! important;\n"
00672       "}\n\n"
00673 
00674       "div.fancy.header table {\n"
00675       "  padding: 2px ! important;\n" // ### khtml bug: this is ignored
00676       "  text-align: left ! important\n"
00677       "}\n\n"
00678 
00679       "div.fancy.header table th {\n"
00680       "  padding: 0px ! important;\n"
00681       "  white-space: nowrap ! important;\n"
00682       "  border-spacing: 0px ! important;\n"
00683       "  text-align: left ! important;\n"
00684       "  vertical-align: top ! important;\n"
00685       "}\n\n"
00686 
00687       "div.fancy.header table td {\n"
00688       "  padding: 0px ! important;\n"
00689       "  border-spacing: 0px ! important;\n"
00690       "  text-align: left ! important;\n"
00691       "  vertical-align: top ! important;\n"
00692       "  width: 100% ! important;\n"
00693       "}\n\n"
00694       ;
00695   }
00696 
00697 } // namespace KMail
00698 
KDE Logo
This file is part of the documentation for kmail Library Version 3.3.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Mon Apr 4 04:48:23 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003