From faedae547fef99f26d2e4ca10df67d8b7c634ec5 Mon Sep 17 00:00:00 2001 From: Ingo Klcker Date: Tue, 8 Feb 2005 23:14:34 +0000 Subject: [PATCH] - Add a fixed width font for printing. Configurability via GUI will have to wait until after KDE 3.4. - In the custom font case make the fixed width font used for viewing default to KDE's standard fixed width font instead of to KDE's standard non-fixed font. - Use the new fixed width font for printing if the user enabled the Use Fixed Font option. In the custom font case we use the fixed width font the user selected (later the fixed fonts used for viewing and printing will be configurable separately). In the non-custom font case we use KDE's standard fixed width font. BUG:56302 svn path=/trunk/kdepim/; revision=387570 --- csshelper.cpp | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/csshelper.cpp b/csshelper.cpp index 3c3ef978a..2ea79c551 100644 --- a/csshelper.cpp +++ b/csshelper.cpp @@ -63,7 +63,7 @@ namespace KMail { void readColorConfig(); // returns CSS rules specific to the print media type - QString printCssDefinitions() const; + QString printCssDefinitions( bool fixed ) const; // returns CSS rules specific to the screen media type QString screenCssDefinitions( const CSSHelper * helper, bool fixed ) const; @@ -72,7 +72,8 @@ namespace KMail { QString commonCssDefinitions() const; QFont bodyFont( bool fixed, bool print=false ) const { - return fixed ? mFixedFont : print ? mPrintFont : mBodyFont ; + return fixed ? ( print ? mFixedPrintFont : mFixedFont ) + : ( print ? mPrintFont : mBodyFont ); } int fontSize( bool fixed, bool print=false ) const { return bodyFont( fixed, print ).pointSize(); @@ -81,7 +82,7 @@ namespace KMail { QString quoteFontTag( int level ) const; private: - QFont mBodyFont, mPrintFont, mFixedFont; + QFont mBodyFont, mPrintFont, mFixedFont, mFixedPrintFont; QFont mQuoteFont[3]; QColor mQuoteColor[3]; bool mRecycleQuoteColors; @@ -107,6 +108,7 @@ namespace KMail { mBodyFont == other.mBodyFont && mPrintFont == other.mPrintFont && mFixedFont == other.mFixedFont && + mFixedPrintFont == other.mFixedPrintFont && mRecycleQuoteColors == other.mRecycleQuoteColors && mBackingPixmapOn == other.mBackingPixmapOn && mBackingPixmapStr == other.mBackingPixmapStr && @@ -237,16 +239,18 @@ namespace KMail { } QFont defaultFont = KGlobalSettings::generalFont(); + QFont defaultFixedFont = KGlobalSettings::fixedFont(); if ( fonts.readBoolEntry( "defaultFonts", true ) ) { mBodyFont = mPrintFont = defaultFont; - mFixedFont = KGlobalSettings::fixedFont(); + mFixedFont = mFixedPrintFont = defaultFixedFont; defaultFont.setItalic( true ); for ( int i = 0 ; i < 3 ; ++i ) mQuoteFont[i] = defaultFont; } else { mBodyFont = fonts.readFontEntry( "body-font", &defaultFont); mPrintFont = fonts.readFontEntry( "print-font", &defaultFont); - mFixedFont = fonts.readFontEntry( "fixed-font", &defaultFont); + mFixedFont = fonts.readFontEntry( "fixed-font", &defaultFixedFont); + mFixedPrintFont = mFixedFont; // FIXME when we have a separate fixed print font defaultFont.setItalic( true ); for ( int i = 0 ; i < 3 ; ++i ) { const QString key = QString( "quote%1-font" ).arg( i+1 ); @@ -298,7 +302,7 @@ namespace KMail { "}\n" "@media print {\n\n" + - d->printCssDefinitions() + d->printCssDefinitions( fixed ) + "}\n"; } @@ -307,8 +311,7 @@ namespace KMail { return "\n" "\n" - + - QString( fixed ? "\n" : "\n" ); + "\n"; } QString CSSHelper::Private::quoteFontTag( int level ) const { @@ -341,17 +344,18 @@ namespace KMail { } } - QString CSSHelper::Private::printCssDefinitions() const { + QString CSSHelper::Private::printCssDefinitions( bool fixed ) const { const QString headerFont = QString( " font-family: \"%1\" ! important;\n" " font-size: %2pt ! important;\n" ) .arg( mPrintFont.family() ) .arg( mPrintFont.pointSize() ); const QColorGroup & cg = QApplication::palette().active(); + const QFont printFont = bodyFont( fixed, true /* print */ ); QString quoteCSS; - if ( mPrintFont.italic() ) + if ( printFont.italic() ) quoteCSS += " font-style: italic ! important;\n"; - if ( mPrintFont.bold() ) + if ( printFont.bold() ) quoteCSS += " font-weight: bold ! important;\n"; if ( !quoteCSS.isEmpty() ) quoteCSS = "div.noquote {\n" + quoteCSS + "}\n\n"; @@ -363,8 +367,8 @@ namespace KMail { " color: #000000 ! important;\n" " background-color: #ffffff ! important\n" "}\n\n" ) - .arg( mPrintFont.family(), - QString::number( mPrintFont.pointSize() ) ) + .arg( printFont.family(), + QString::number( printFont.pointSize() ) ) + QString( "tr.textAtmH,\n" "tr.rfc822H,\n"