• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

messageviewer

  • sources
  • kde-4.12
  • kdepim
  • messageviewer
  • viewer
csshelperbase.cpp
Go to the documentation of this file.
1 /* -*- mode: C++; c-file-style: "gnu" -*-
2  csshelper.cpp
3 
4  This file is part of KMail, the KDE mail client.
5  Copyright (c) 2003 Marc Mutz <mutz@kde.org>
6 
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.
10 
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.
15 
16  You should have received a copy of the GNU General Public License along
17  with this program; if not, write to the Free Software Foundation, Inc.,
18  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 
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.
30 */
31 
32 #include <messagecore/settings/globalsettings.h>
33 #include "csshelperbase.h"
34 
35 #include <KColorScheme>
36 #include <KDebug>
37 #include <KGlobal>
38 #include <KGlobalSettings>
39 
40 #include <QApplication>
41 #include <QPaintDevice>
42 
43 namespace MessageViewer {
44 
45  namespace {
46  // some QColor manipulators that hide the ugly QColor API w.r.t. HSV:
47  inline QColor darker( const QColor & c ) {
48  int h, s, v;
49  c.getHsv( &h, &s, &v );
50  return QColor::fromHsv( h, s, v*4/5 );
51  }
52 
53  inline QColor desaturate( const QColor & c ) {
54  int h, s, v;
55  c.getHsv( &h, &s, &v );
56  return QColor::fromHsv( h, s/8, v );
57  }
58 
59  inline QColor fixValue( const QColor & c, int newV ) {
60  int h, s, v;
61  c.getHsv( &h, &s, &v );
62  return QColor::fromHsv( h, s, newV );
63  }
64 
65  inline int getValueOf( const QColor & c ) {
66  int h, s, v;
67  c.getHsv( &h, &s, &v );
68  return v;
69  }
70  }
71 
72  CSSHelperBase::CSSHelperBase( const QPaintDevice *pd ) :
73  mShrinkQuotes( false ),
74  mPaintDevice( pd )
75  {
76  // initialize with defaults - should match the corresponding application defaults
77  mForegroundColor = QApplication::palette().color( QPalette::Text );
78  mLinkColor = KColorScheme( QPalette::Active, KColorScheme::View ).foreground( KColorScheme::LinkText ).color();
79  mVisitedLinkColor = KColorScheme( QPalette::Active, KColorScheme::View ).foreground( KColorScheme::VisitedText ).color();
80  mBackgroundColor = QApplication::palette().color( QPalette::Base );
81  cHtmlWarning = QColor( 0xFF, 0x40, 0x40 ); // warning frame color: light red
82 
83  cPgpEncrH = QColor( 0x00, 0x80, 0xFF ); // light blue
84  cPgpOk1H = QColor( 0x40, 0xFF, 0x40 ); // light green
85  cPgpOk0H = QColor( 0xFF, 0xFF, 0x40 ); // light yellow
86  cPgpWarnH = QColor( 0xFF, 0xFF, 0x40 ); // light yellow
87  cPgpErrH = Qt::red;
88 
89  if(MessageCore::GlobalSettings::self()->useDefaultColors()) {
90  for ( int i = 0 ; i < 3 ; ++i ) {
91  mQuoteColor[i] = QColor( 0x00, 0x80 - i * 0x10, 0x00 ); // shades of green
92  }
93  } else {
94  mQuoteColor[0] = MessageCore::GlobalSettings::self()->quotedText1();
95  mQuoteColor[1] = MessageCore::GlobalSettings::self()->quotedText2();
96  mQuoteColor[2] = MessageCore::GlobalSettings::self()->quotedText3();
97  }
98  mRecycleQuoteColors = false;
99 
100  QFont defaultFont = KGlobalSettings::generalFont();
101  QFont defaultFixedFont = KGlobalSettings::fixedFont();
102  mBodyFont = MessageCore::GlobalSettings::self()->useDefaultFonts() ? defaultFont: MessageCore::GlobalSettings::self()->bodyFont();
103  mPrintFont = MessageCore::GlobalSettings::self()->useDefaultFonts() ? defaultFont : MessageCore::GlobalSettings::self()->printFont();
104  mFixedFont = mFixedPrintFont = defaultFixedFont;
105  defaultFont.setItalic( true );
106  for ( int i = 0 ; i < 3 ; ++i )
107  mQuoteFont[i] = defaultFont;
108 
109  mBackingPixmapOn = false;
110 
111  recalculatePGPColors();
112  }
113 
114  void CSSHelperBase::recalculatePGPColors() {
115  // determine the frame and body color for PGP messages from the header color
116  // if the header color equals the background color then the other colors are
117  // also set to the background color (-> old style PGP message viewing)
118  // else
119  // the brightness of the frame is set to 4/5 of the brightness of the header
120  // and in case of a light background color
121  // the saturation of the body is set to 1/8 of the saturation of the header
122  // while in case of a dark background color
123  // the value of the body is set to the value of the background color
124 
125  // Check whether the user uses a light color scheme
126  const int vBG = getValueOf( mBackgroundColor );
127  const bool lightBG = vBG >= 128;
128  if ( cPgpOk1H == mBackgroundColor ) {
129  cPgpOk1F = mBackgroundColor;
130  cPgpOk1B = mBackgroundColor;
131  } else {
132  cPgpOk1F= darker( cPgpOk1H );
133  cPgpOk1B = lightBG ? desaturate( cPgpOk1H ) : fixValue( cPgpOk1H, vBG );
134  }
135  if ( cPgpOk0H == mBackgroundColor ) {
136  cPgpOk0F = mBackgroundColor;
137  cPgpOk0B = mBackgroundColor;
138  } else {
139  cPgpOk0F = darker( cPgpOk0H );
140  cPgpOk0B = lightBG ? desaturate( cPgpOk0H ) : fixValue( cPgpOk0H, vBG );
141  }
142  if ( cPgpWarnH == mBackgroundColor ) {
143  cPgpWarnF = mBackgroundColor;
144  cPgpWarnB = mBackgroundColor;
145  } else {
146  cPgpWarnF = darker( cPgpWarnH );
147  cPgpWarnB = lightBG ? desaturate( cPgpWarnH ) : fixValue( cPgpWarnH, vBG );
148  }
149  if ( cPgpErrH == mBackgroundColor ) {
150  cPgpErrF = mBackgroundColor;
151  cPgpErrB = mBackgroundColor;
152  } else {
153  cPgpErrF = darker( cPgpErrH );
154  cPgpErrB = lightBG ? desaturate( cPgpErrH ) : fixValue( cPgpErrH, vBG );
155  }
156  if ( cPgpEncrH == mBackgroundColor ) {
157  cPgpEncrF = mBackgroundColor;
158  cPgpEncrB = mBackgroundColor;
159  } else {
160  cPgpEncrF = darker( cPgpEncrH );
161  cPgpEncrB = lightBG ? desaturate( cPgpEncrH ) : fixValue( cPgpEncrH, vBG );
162  }
163  }
164 
165  QString CSSHelperBase::cssDefinitions( bool fixed ) const {
166  return
167  commonCssDefinitions()
168  +
169  QLatin1String("@media screen {\n\n")
170  +
171  screenCssDefinitions( this, fixed )
172  +
173  QLatin1String("}\n"
174  "@media print {\n\n")
175  +
176  printCssDefinitions( fixed )
177  +
178  QLatin1String("\n");
179  }
180 
181  QString CSSHelperBase::htmlHead( bool /*fixed*/ ) const {
182  return
183  QLatin1String("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n"
184  "<html><head><title></title></head>\n"
185  "<body>\n");
186  }
187 
188  QString CSSHelperBase::quoteFontTag( int level ) const {
189  if ( level < 0 )
190  level = 0;
191  static const int numQuoteLevels = sizeof mQuoteFont / sizeof *mQuoteFont;
192  const int effectiveLevel = mRecycleQuoteColors
193  ? level % numQuoteLevels + 1
194  : qMin( level + 1, numQuoteLevels ) ;
195  if ( level >= numQuoteLevels )
196  return QString::fromLatin1( "<div class=\"deepquotelevel%1\">" ).arg( effectiveLevel );
197  else
198  return QString::fromLatin1( "<div class=\"quotelevel%1\">" ).arg( effectiveLevel );
199  }
200 
201  QString CSSHelperBase::nonQuotedFontTag() const {
202  return QLatin1String("<div class=\"noquote\">");
203  }
204 
205  QFont CSSHelperBase::bodyFont( bool fixed, bool print ) const {
206  return fixed ? ( print ? mFixedPrintFont : mFixedFont )
207  : ( print ? mPrintFont : mBodyFont );
208  }
209 
210  int CSSHelperBase::fontSize( bool fixed, bool print ) const {
211  return bodyFont( fixed, print ).pointSize();
212  }
213 
214 
215  namespace {
216  int pointsToPixel( const QPaintDevice *pd, int pointSize ) {
217  return ( pointSize * pd->logicalDpiY() + 36 ) / 72 ;
218  }
219  }
220 
221  static const char * const quoteFontSizes[] = { "85", "80", "75" };
222 
223  QString CSSHelperBase::printCssDefinitions( bool fixed ) const {
224  const QString headerFont = QString::fromLatin1( " font-family: \"%1\" ! important;\n"
225  " font-size: %2pt ! important;\n" )
226  .arg( mPrintFont.family() )
227  .arg( mPrintFont.pointSize() );
228  const QPalette &pal = QApplication::palette();
229 
230  const QFont printFont = bodyFont( fixed, true /* print */ );
231  QString quoteCSS;
232  if ( printFont.italic() )
233  quoteCSS += QLatin1String(" font-style: italic ! important;\n");
234  if ( printFont.bold() )
235  quoteCSS += QLatin1String(" font-weight: bold ! important;\n");
236  if ( !quoteCSS.isEmpty() )
237  quoteCSS = QLatin1String("div.noquote {\n") + quoteCSS + QLatin1String("}\n\n");
238 
239  return
240  QString::fromLatin1( "body {\n"
241  " font-family: \"%1\" ! important;\n"
242  " font-size: %2pt ! important;\n"
243  " color: #000000 ! important;\n"
244  " background-color: #ffffff ! important\n"
245  "}\n\n" )
246  .arg( printFont.family(),
247  QString::number( printFont.pointSize() ) )
248  +
249  QString::fromLatin1( "tr.textAtmH,\n"
250  "tr.signInProgressH,\n"
251  "tr.rfc822H,\n"
252  "tr.encrH,\n"
253  "tr.signOkKeyOkH,\n"
254  "tr.signOkKeyBadH,\n"
255  "tr.signWarnH,\n"
256  "tr.signErrH,\n"
257  "div.header {\n"
258  "%1"
259  "}\n\n"
260 
261  "div.fancy.header > div {\n"
262  " background-color: %2 ! important;\n"
263  " color: %3 ! important;\n"
264  " padding: 4px ! important;\n"
265  " border: solid %3 1px ! important;\n"
266  " line-height: normal;\n"
267  "}\n\n"
268 
269  "div.fancy.header > div a[href] { color: %3 ! important; }\n\n"
270 
271  "div.fancy.header > table.outer{\n"
272  " background-color: %2 ! important;\n"
273  " color: %3 ! important;\n"
274  " border-bottom: solid %3 1px ! important;\n"
275  " border-left: solid %3 1px ! important;\n"
276  " border-right: solid %3 1px ! important;\n"
277  "}\n\n"
278 
279  "div.spamheader {\n"
280  " display:none ! important;\n"
281  "}\n\n"
282 
283  "div.htmlWarn {\n"
284  " border: 2px solid #ffffff ! important;\n"
285  " line-height: normal;\n"
286  "}\n\n"
287 
288  "div.senderpic{\n"
289  " font-size:0.8em ! important;\n"
290  " border:1px solid black ! important;\n"
291  " background-color:%2 ! important;\n"
292  "}\n\n"
293 
294  "div.senderstatus{\n"
295  " text-align:center ! important;\n"
296  "}\n\n"
297 
298  "div.noprint {\n"
299  " display:none ! important;\n"
300  "}\n\n"
301  )
302  .arg( headerFont,
303  pal.color( QPalette::Background ).name(),
304  pal.color( QPalette::Foreground ).name() )
305  + quoteCSS;
306  }
307 
308  QString CSSHelperBase::screenCssDefinitions( const CSSHelperBase * helper, bool fixed ) const {
309  const QString fgColor = mForegroundColor.name();
310  const QString bgColor = mBackgroundColor.name();
311  const QString linkColor = mLinkColor.name();
312  const QString headerFont = QString::fromLatin1(" font-family: \"%1\" ! important;\n"
313  " font-size: %2px ! important;\n")
314  .arg( mBodyFont.family() )
315  .arg( pointsToPixel( helper->mPaintDevice, mBodyFont.pointSize() ) );
316  const QString background = ( mBackingPixmapOn
317  ? QString::fromLatin1( " background-image:url(file:///%1) ! important;\n" )
318  .arg( mBackingPixmapStr )
319  : QString::fromLatin1( " background-color: %1 ! important;\n" )
320  .arg( bgColor ) );
321  const QString bodyFontSize = QString::number( pointsToPixel( helper->mPaintDevice, fontSize( fixed ) ) ) + QLatin1String("px");
322  const QPalette & pal = QApplication::palette();
323 
324  QString quoteCSS;
325  if ( bodyFont( fixed ).italic() )
326  quoteCSS += QLatin1String(" font-style: italic ! important;\n");
327  if ( bodyFont( fixed ).bold() )
328  quoteCSS += QLatin1String(" font-weight: bold ! important;\n");
329  if ( !quoteCSS.isEmpty() )
330  quoteCSS = QLatin1String("div.noquote {\n") + quoteCSS + QLatin1String("}\n\n");
331 
332  // CSS definitions for quote levels 1-3
333  for ( int i = 0 ; i < 3 ; ++i ) {
334  quoteCSS += QString::fromLatin1( "div.quotelevel%1 {\n"
335  " color: %2 ! important;\n" )
336  .arg( QString::number(i+1), mQuoteColor[i].name() );
337  if ( mQuoteFont[i].italic() )
338  quoteCSS += QLatin1String(" font-style: italic ! important;\n");
339  if ( mQuoteFont[i].bold() )
340  quoteCSS += QLatin1String(" font-weight: bold ! important;\n");
341  if ( mShrinkQuotes )
342  quoteCSS += QLatin1String(" font-size: ") + QString::fromLatin1( quoteFontSizes[i] )
343  + QLatin1String("% ! important;\n");
344  quoteCSS += QLatin1String("}\n\n");
345  }
346 
347  // CSS definitions for quote levels 4+
348  for ( int i = 0 ; i < 3 ; ++i ) {
349  quoteCSS += QString::fromLatin1( "div.deepquotelevel%1 {\n"
350  " color: %2 ! important;\n" )
351  .arg( QString::number(i+1), mQuoteColor[i].name() );
352  if ( mQuoteFont[i].italic() )
353  quoteCSS += QLatin1String(" font-style: italic ! important;\n");
354  if ( mQuoteFont[i].bold() )
355  quoteCSS += QLatin1String(" font-weight: bold ! important;\n");
356  if ( mShrinkQuotes )
357  quoteCSS += QLatin1String(" font-size: 70% ! important;\n");
358  quoteCSS += QLatin1String("}\n\n");
359  }
360 
361  return
362  QString::fromLatin1( "body {\n"
363  " font-family: \"%1\" ! important;\n"
364  " font-size: %2 ! important;\n"
365  " color: %3 ! important;\n"
366  "%4"
367  "}\n\n" )
368  .arg( bodyFont( fixed ).family(),
369  bodyFontSize,
370  fgColor,
371  background )
372  +
373 /* This shouldn't be necessary because font properties are inherited
374  automatically and causes wrong font settings with QTextBrowser
375  because it doesn't understand the inherit statement
376  QString::fromLatin1( "table {\n"
377  " font-family: inherit ! important;\n"
378  " font-size: inherit ! important;\n"
379  " font-weight: inherit ! important;\n"
380  "}\n\n" )
381  +
382  */
383  QString::fromLatin1( "a {\n"
384  " color: %1 ! important;\n"
385  " text-decoration: none ! important;\n"
386  "}\n\n"
387 
388  "a.white {\n"
389  " color: white ! important;\n"
390  "}\n\n"
391 
392  "a.black {\n"
393  " color: black ! important;\n"
394  "}\n\n"
395 
396  "table.textAtm { background-color: %2 ! important; }\n\n"
397 
398  "tr.textAtmH {\n"
399  " background-color: %3 ! important;\n"
400  "%4"
401  "}\n\n"
402 
403  "tr.textAtmB {\n"
404  " background-color: %3 ! important;\n"
405  "}\n\n"
406 
407  "table.signInProgress,\n"
408  "table.rfc822 {\n"
409  " background-color: %3 ! important;\n"
410  "}\n\n"
411 
412  "tr.signInProgressH,\n"
413  "tr.rfc822H {\n"
414  "%4"
415  "}\n\n" )
416  .arg( linkColor, fgColor, bgColor, headerFont )
417  +
418  QString::fromLatin1( "table.encr {\n"
419  " background-color: %1 ! important;\n"
420  "}\n\n"
421 
422  "tr.encrH {\n"
423  " background-color: %2 ! important;\n"
424  "%3"
425  "}\n\n"
426 
427  "tr.encrB { background-color: %4 ! important; }\n\n" )
428  .arg( cPgpEncrF.name(),
429  cPgpEncrH.name(),
430  headerFont,
431  cPgpEncrB.name() )
432  +
433  QString::fromLatin1( "table.signOkKeyOk {\n"
434  " background-color: %1 ! important;\n"
435  "}\n\n"
436 
437  "tr.signOkKeyOkH {\n"
438  " background-color: %2 ! important;\n"
439  "%3"
440  "}\n\n"
441 
442  "tr.signOkKeyOkB { background-color: %4 ! important; }\n\n" )
443  .arg( cPgpOk1F.name(),
444  cPgpOk1H.name(),
445  headerFont,
446  cPgpOk1B.name() )
447  +
448  QString::fromLatin1( "table.signOkKeyBad {\n"
449  " background-color: %1 ! important;\n"
450  "}\n\n"
451 
452  "tr.signOkKeyBadH {\n"
453  " background-color: %2 ! important;\n"
454  "%3"
455  "}\n\n"
456 
457  "tr.signOkKeyBadB { background-color: %4 ! important; }\n\n" )
458  .arg( cPgpOk0F.name(),
459  cPgpOk0H.name(),
460  headerFont,
461  cPgpOk0B.name() )
462  +
463  QString::fromLatin1( "table.signWarn {\n"
464  " background-color: %1 ! important;\n"
465  "}\n\n"
466 
467  "tr.signWarnH {\n"
468  " background-color: %2 ! important;\n"
469  "%3"
470  "}\n\n"
471 
472  "tr.signWarnB { background-color: %4 ! important; }\n\n" )
473  .arg( cPgpWarnF.name(),
474  cPgpWarnH.name(),
475  headerFont,
476  cPgpWarnB.name() )
477  +
478  QString::fromLatin1( "table.signErr {\n"
479  " background-color: %1 ! important;\n"
480  "}\n\n"
481 
482  "tr.signErrH {\n"
483  " background-color: %2 ! important;\n"
484  "%3"
485  "}\n\n"
486 
487  "tr.signErrB { background-color: %4 ! important; }\n\n" )
488  .arg( cPgpErrF.name(),
489  cPgpErrH.name(),
490  headerFont,
491  cPgpErrB.name() )
492  +
493  QString::fromLatin1( "div.htmlWarn {\n"
494  " border: 2px solid %1 ! important;\n"
495  " line-height: normal;\n"
496  "}\n\n" )
497  .arg( cHtmlWarning.name() )
498  +
499  QString::fromLatin1( "div.header {\n"
500  "%1"
501  "}\n\n"
502 
503  "div.fancy.header > div {\n"
504  " background-color: %2 ! important;\n"
505  " color: %3 ! important;\n"
506  " border: solid %4 1px ! important;\n"
507  " line-height: normal;\n"
508  "}\n\n"
509 
510  "div.fancy.header > div a[href] { color: %3 ! important; }\n\n"
511 
512  "div.fancy.header > div a[href]:hover { text-decoration: underline ! important; }\n\n"
513 
514  "div.fancy.header > div.spamheader {\n"
515  " background-color: #cdcdcd ! important;\n"
516  " border-top: 0px ! important;\n"
517  " padding: 3px ! important;\n"
518  " color: black ! important;\n"
519  " font-weight: bold ! important;\n"
520  " font-size: smaller ! important;\n"
521  "}\n\n"
522 
523  "div.fancy.header > table.outer {\n"
524  " background-color: %5 ! important;\n"
525  " color: %4 ! important;\n"
526  " border-bottom: solid %4 1px ! important;\n"
527  " border-left: solid %4 1px ! important;\n"
528  " border-right: solid %4 1px ! important;\n"
529  "}\n\n"
530 
531  "div.senderpic{\n"
532  " padding: 0px ! important;\n"
533  " font-size:0.8em ! important;\n"
534  " border:1px solid %6 ! important;\n"
535  // FIXME: InfoBackground crashes KHTML
536  //" background-color:InfoBackground ! important;\n"
537  " background-color:%5 ! important;\n"
538  "}\n\n"
539 
540  "div.senderstatus{\n"
541  " text-align:center ! important;\n"
542  "}\n\n"
543  )
544 
545  .arg( headerFont )
546  .arg( pal.color( QPalette::Highlight ).name(),
547  pal.color( QPalette::HighlightedText ).name(),
548  pal.color( QPalette::Foreground ).name(),
549  pal.color( QPalette::Background ).name() )
550  .arg( pal.color( QPalette::Mid ).name() )
551  + quoteCSS;
552  }
553 
554  QString CSSHelperBase::commonCssDefinitions() const {
555  const QPalette & pal = QApplication::palette();
556  const QString headerFont = QString::fromLatin1("font-family: \"%1\" ! important;\n"
557  " font-size: %2px ! important;\n")
558  .arg( mBodyFont.family() )
559  .arg( pointsToPixel( this->mPaintDevice, mBodyFont.pointSize() ) );
560 
561  return
562  QString::fromLatin1("div.header {\n"
563  " margin-bottom: 10pt ! important;\n"
564  "}\n\n"
565 
566  "table.textAtm {\n"
567  " margin-top: 10pt ! important;\n"
568  " margin-bottom: 10pt ! important;\n"
569  "}\n\n"
570 
571  "tr.textAtmH,\n"
572  "tr.textAtmB,\n"
573  "tr.rfc822B {\n"
574  " font-weight: normal ! important;\n"
575  "}\n\n"
576 
577  "tr.signInProgressH,\n"
578  "tr.rfc822H,\n"
579  "tr.encrH,\n"
580  "tr.signOkKeyOkH,\n"
581  "tr.signOkKeyBadH,\n"
582  "tr.signWarnH,\n"
583  "tr.signErrH {\n"
584  " font-weight: bold ! important;\n"
585  "}\n\n"
586 
587  "tr.textAtmH td,\n"
588  "tr.textAtmB td {\n"
589  " padding: 3px ! important;\n"
590  "}\n\n"
591 
592  "table.rfc822 {\n"
593  " width: 100% ! important;\n"
594  " border: solid 1px black ! important;\n"
595  " margin-top: 10pt ! important;\n"
596  " margin-bottom: 10pt ! important;\n"
597  "}\n\n"
598 
599  "table.textAtm,\n"
600  "table.encr,\n"
601  "table.signWarn,\n"
602  "table.signErr,\n"
603  "table.signOkKeyBad,\n"
604  "table.signOkKeyOk,\n"
605  "table.signInProgress,\n"
606  "div.fancy.header table {\n"
607  " width: 100% ! important;\n"
608  " border-width: 0px ! important;\n"
609  " line-height: normal;\n"
610  "}\n\n"
611 
612  "div.htmlWarn {\n"
613  " margin: 0px 5% ! important;\n"
614  " padding: 10px ! important;\n"
615  " text-align: left ! important;\n"
616  " line-height: normal;\n"
617  "}\n\n"
618 
619  "div.fancy.header > div {\n"
620  " font-weight: bold ! important;\n"
621  " padding: 4px ! important;\n"
622  " line-height: normal;\n"
623  "}\n\n"
624 
625  "div.fancy.header table {\n"
626  " padding: 2px ! important;\n" // ### khtml bug: this is ignored
627  " text-align: left ! important;\n"
628  " border-collapse: separate ! important;\n"
629  "}\n\n"
630 
631  "div.fancy.header table th {\n"
632  " %3\n"
633  " padding: 0px ! important;\n"
634  " white-space: nowrap ! important;\n"
635  " border-spacing: 0px ! important;\n"
636  " text-align: left ! important;\n"
637  " vertical-align: top ! important;\n"
638  " background-color: %1 ! important;\n"
639  " color: %2 ! important;\n"
640  " border: 1px ! important;\n"
641 
642  "}\n\n"
643 
644  "div.fancy.header table td {\n"
645  " %3\n"
646  " padding: 0px ! important;\n"
647  " border-spacing: 0px ! important;\n"
648  " text-align: left ! important;\n"
649  " vertical-align: top ! important;\n"
650  " width: 100% ! important;\n"
651  " background-color: %1 ! important;\n"
652  " color: %2 ! important;\n"
653  " border: 1px ! important;\n"
654  "}\n\n"
655 
656 
657  "div.fancy.header table a:hover {\n"
658  " background-color: transparent ! important;\n"
659  "}\n\n"
660 
661  "span.pimsmileytext {\n"
662  " position: absolute;\n"
663  " top: 0px;\n"
664  " left: 0px;\n"
665  " visibility: hidden;\n"
666  "}\n\n"
667 
668  "img.pimsmileyimg {\n"
669  "}\n\n"
670 
671  "div.quotelevelmark {\n"
672  " position: absolute;\n"
673  " margin-left:-10px;\n"
674  "}\n\n").arg( pal.color( QPalette::Background ).name() ).arg(pal.color( QPalette::Foreground ).name()).arg(headerFont)
675  ;
676  }
677 
678 
679  void CSSHelperBase::setBodyFont( const QFont& font )
680  {
681  mBodyFont = font;
682  }
683 
684  void CSSHelperBase::setPrintFont( const QFont& font )
685  {
686  mPrintFont = font;
687  }
688 
689  QColor CSSHelperBase::quoteColor( int level )
690  {
691  const int actualLevel = qMin( qMax( level, 0 ), 2 );
692  return mQuoteColor[actualLevel];
693  }
694 
695  QColor CSSHelperBase::pgpWarnColor() const
696  {
697  return cPgpWarnH;
698  }
699 
700 }
MessageViewer::CSSHelperBase::mShrinkQuotes
bool mShrinkQuotes
Definition: csshelperbase.h:87
MessageViewer::CSSHelperBase::mQuoteFont
QFont mQuoteFont[3]
Definition: csshelperbase.h:83
MessageViewer::CSSHelperBase::nonQuotedFontTag
QString nonQuotedFontTag() const
Definition: csshelperbase.cpp:201
MessageViewer::CSSHelperBase::cPgpErrH
QColor cPgpErrH
Definition: csshelperbase.h:91
MessageViewer::CSSHelperBase::cPgpEncrF
QColor cPgpEncrF
Definition: csshelperbase.h:91
MessageViewer::CSSHelperBase::recalculatePGPColors
void recalculatePGPColors()
Recalculate PGP frame and body colors (should be called after changing color settings) ...
Definition: csshelperbase.cpp:114
MessageViewer::CSSHelperBase::setPrintFont
void setPrintFont(const QFont &font)
Definition: csshelperbase.cpp:684
MessageViewer::CSSHelperBase::mBackingPixmapOn
bool mBackingPixmapOn
Definition: csshelperbase.h:86
MessageViewer::CSSHelperBase::cPgpErrF
QColor cPgpErrF
Definition: csshelperbase.h:91
MessageViewer::CSSHelperBase::mBackgroundColor
QColor mBackgroundColor
Definition: csshelperbase.h:89
MessageViewer::CSSHelperBase::cPgpWarnF
QColor cPgpWarnF
Definition: csshelperbase.h:91
MessageViewer::CSSHelperBase::mFixedFont
QFont mFixedFont
Definition: csshelperbase.h:82
MessageViewer::CSSHelperBase::cPgpWarnH
QColor cPgpWarnH
Definition: csshelperbase.h:91
MessageViewer::CSSHelperBase::bodyFont
QFont bodyFont(bool fixedFont=false, bool printing=false) const
Definition: csshelperbase.cpp:205
MessageViewer::CSSHelperBase::mFixedPrintFont
QFont mFixedPrintFont
Definition: csshelperbase.h:82
MessageViewer::CSSHelperBase::cPgpOk1H
QColor cPgpOk1H
Definition: csshelperbase.h:91
MessageViewer::CSSHelperBase::setBodyFont
void setBodyFont(const QFont &font)
Definition: csshelperbase.cpp:679
MessageViewer::CSSHelperBase::cssDefinitions
QString cssDefinitions(bool fixedFont=false) const
Definition: csshelperbase.cpp:165
MessageViewer::CSSHelperBase::mVisitedLinkColor
QColor mVisitedLinkColor
Definition: csshelperbase.h:89
MessageViewer::CSSHelperBase::mRecycleQuoteColors
bool mRecycleQuoteColors
Definition: csshelperbase.h:85
MessageViewer::CSSHelperBase::mLinkColor
QColor mLinkColor
Definition: csshelperbase.h:89
MessageViewer::CSSHelperBase::quoteFontTag
QString quoteFontTag(int level) const
Definition: csshelperbase.cpp:188
MessageViewer::CSSHelperBase::cPgpOk0H
QColor cPgpOk0H
Definition: csshelperbase.h:91
MessageViewer::CSSHelperBase::mBackingPixmapStr
QString mBackingPixmapStr
Definition: csshelperbase.h:88
MessageViewer::CSSHelperBase::cPgpOk1F
QColor cPgpOk1F
Definition: csshelperbase.h:91
MessageViewer::CSSHelperBase::cPgpWarnB
QColor cPgpWarnB
Definition: csshelperbase.h:91
MessageViewer::CSSHelperBase::pgpWarnColor
QColor pgpWarnColor() const
Definition: csshelperbase.cpp:695
MessageViewer::CSSHelperBase::mForegroundColor
QColor mForegroundColor
Definition: csshelperbase.h:89
MessageViewer::CSSHelperBase::quoteColor
QColor quoteColor(int level)
Definition: csshelperbase.cpp:689
MessageViewer::CSSHelperBase::cHtmlWarning
QColor cHtmlWarning
Definition: csshelperbase.h:97
MessageViewer::CSSHelperBase::htmlHead
QString htmlHead(bool fixedFont=false) const
Definition: csshelperbase.cpp:181
MessageViewer::CSSHelperBase::mPrintFont
QFont mPrintFont
Definition: csshelperbase.h:82
MessageViewer::CSSHelperBase::cPgpOk0F
QColor cPgpOk0F
Definition: csshelperbase.h:91
csshelperbase.h
MessageViewer::CSSHelperBase::cPgpEncrB
QColor cPgpEncrB
Definition: csshelperbase.h:91
MessageViewer::CSSHelperBase::cPgpOk0B
QColor cPgpOk0B
Definition: csshelperbase.h:91
MessageViewer::CSSHelperBase::cPgpOk1B
QColor cPgpOk1B
Definition: csshelperbase.h:91
MessageViewer::CSSHelperBase::cPgpEncrH
QColor cPgpEncrH
Definition: csshelperbase.h:91
MessageViewer::CSSHelperBase::CSSHelperBase
CSSHelperBase(const QPaintDevice *pd)
Construct a CSSHelper object and set its font and color settings to default values.
Definition: csshelperbase.cpp:72
MessageViewer::CSSHelperBase::mBodyFont
QFont mBodyFont
Definition: csshelperbase.h:82
MessageViewer::quoteFontSizes
static const char *const quoteFontSizes[]
Definition: csshelperbase.cpp:221
MessageViewer::CSSHelperBase::mQuoteColor
QColor mQuoteColor[3]
Definition: csshelperbase.h:84
MessageViewer::CSSHelperBase::cPgpErrB
QColor cPgpErrB
Definition: csshelperbase.h:91
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:55:57 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

messageviewer

Skip menu "messageviewer"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal