32 #include <messagecore/settings/globalsettings.h>
35 #include <KColorScheme>
38 #include <KGlobalSettings>
40 #include <QApplication>
41 #include <QPaintDevice>
43 namespace MessageViewer {
65 inline int getValueOf(
const QColor & c ) {
73 mShrinkQuotes( false ),
78 mLinkColor = KColorScheme( QPalette::Active, KColorScheme::View ).foreground( KColorScheme::LinkText ).color();
79 mVisitedLinkColor = KColorScheme( QPalette::Active, KColorScheme::View ).foreground( KColorScheme::VisitedText ).color();
89 if(MessageCore::GlobalSettings::self()->useDefaultColors()) {
90 for (
int i = 0 ; i < 3 ; ++i ) {
94 mQuoteColor[0] = MessageCore::GlobalSettings::self()->quotedText1();
95 mQuoteColor[1] = MessageCore::GlobalSettings::self()->quotedText2();
96 mQuoteColor[2] = MessageCore::GlobalSettings::self()->quotedText3();
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();
106 for (
int i = 0 ; i < 3 ; ++i )
127 const bool lightBG = vBG >= 128;
167 commonCssDefinitions()
171 screenCssDefinitions(
this, fixed )
174 "@media print {\n\n")
176 printCssDefinitions( fixed )
183 QLatin1String(
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n"
184 "<html><head><title></title></head>\n"
193 ? level % numQuoteLevels + 1
194 : qMin( level + 1, numQuoteLevels ) ;
195 if ( level >= numQuoteLevels )
210 int CSSHelperBase::fontSize(
bool fixed,
bool print )
const {
216 int pointsToPixel(
const QPaintDevice *pd,
int pointSize ) {
217 return ( pointSize * pd->
logicalDpiY() + 36 ) / 72 ;
223 QString CSSHelperBase::printCssDefinitions(
bool fixed )
const {
225 " font-size: %2pt ! important;\n" )
233 quoteCSS +=
QLatin1String(
" font-style: italic ! important;\n");
234 if ( printFont.
bold() )
235 quoteCSS +=
QLatin1String(
" font-weight: bold ! important;\n");
241 " font-family: \"%1\" ! important;\n"
242 " font-size: %2pt ! important;\n"
243 " color: #000000 ! important;\n"
244 " background-color: #ffffff ! important\n"
250 "tr.signInProgressH,\n"
254 "tr.signOkKeyBadH,\n"
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"
269 "div.fancy.header > div a[href] { color: %3 ! important; }\n\n"
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"
280 " display:none ! important;\n"
284 " border: 2px solid #ffffff ! important;\n"
285 " line-height: normal;\n"
289 " font-size:0.8em ! important;\n"
290 " border:1px solid black ! important;\n"
291 " background-color:%2 ! important;\n"
294 "div.senderstatus{\n"
295 " text-align:center ! important;\n"
299 " display:none ! important;\n"
303 pal.
color( QPalette::Background ).
name(),
304 pal.
color( QPalette::Foreground ).
name() )
308 QString CSSHelperBase::screenCssDefinitions(
const CSSHelperBase * helper,
bool fixed )
const {
313 " font-size: %2px ! important;\n")
326 quoteCSS +=
QLatin1String(
" font-style: italic ! important;\n");
328 quoteCSS +=
QLatin1String(
" font-weight: bold ! important;\n");
333 for (
int i = 0 ; i < 3 ; ++i ) {
335 " color: %2 ! important;\n" )
338 quoteCSS +=
QLatin1String(
" font-style: italic ! important;\n");
340 quoteCSS +=
QLatin1String(
" font-weight: bold ! important;\n");
348 for (
int i = 0 ; i < 3 ; ++i ) {
350 " color: %2 ! important;\n" )
353 quoteCSS +=
QLatin1String(
" font-style: italic ! important;\n");
355 quoteCSS +=
QLatin1String(
" font-weight: bold ! important;\n");
363 " font-family: \"%1\" ! important;\n"
364 " font-size: %2 ! important;\n"
365 " color: %3 ! important;\n"
384 " color: %1 ! important;\n"
385 " text-decoration: none ! important;\n"
389 " color: white ! important;\n"
393 " color: black ! important;\n"
396 "table.textAtm { background-color: %2 ! important; }\n\n"
399 " background-color: %3 ! important;\n"
404 " background-color: %3 ! important;\n"
407 "table.signInProgress,\n"
409 " background-color: %3 ! important;\n"
412 "tr.signInProgressH,\n"
416 .
arg( linkColor, fgColor, bgColor, headerFont )
419 " background-color: %1 ! important;\n"
423 " background-color: %2 ! important;\n"
427 "tr.encrB { background-color: %4 ! important; }\n\n" )
434 " background-color: %1 ! important;\n"
437 "tr.signOkKeyOkH {\n"
438 " background-color: %2 ! important;\n"
442 "tr.signOkKeyOkB { background-color: %4 ! important; }\n\n" )
449 " background-color: %1 ! important;\n"
452 "tr.signOkKeyBadH {\n"
453 " background-color: %2 ! important;\n"
457 "tr.signOkKeyBadB { background-color: %4 ! important; }\n\n" )
464 " background-color: %1 ! important;\n"
468 " background-color: %2 ! important;\n"
472 "tr.signWarnB { background-color: %4 ! important; }\n\n" )
479 " background-color: %1 ! important;\n"
483 " background-color: %2 ! important;\n"
487 "tr.signErrB { background-color: %4 ! important; }\n\n" )
494 " border: 2px solid %1 ! important;\n"
495 " line-height: normal;\n"
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"
510 "div.fancy.header > div a[href] { color: %3 ! important; }\n\n"
512 "div.fancy.header > div a[href]:hover { text-decoration: underline ! important; }\n\n"
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"
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"
532 " padding: 0px ! important;\n"
533 " font-size:0.8em ! important;\n"
534 " border:1px solid %6 ! important;\n"
537 " background-color:%5 ! important;\n"
540 "div.senderstatus{\n"
541 " text-align:center ! important;\n"
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() )
554 QString CSSHelperBase::commonCssDefinitions()
const {
557 " font-size: %2px ! important;\n")
563 " margin-bottom: 10pt ! important;\n"
567 " margin-top: 10pt ! important;\n"
568 " margin-bottom: 10pt ! important;\n"
574 " font-weight: normal ! important;\n"
577 "tr.signInProgressH,\n"
581 "tr.signOkKeyBadH,\n"
584 " font-weight: bold ! important;\n"
589 " padding: 3px ! important;\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"
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"
613 " margin: 0px 5% ! important;\n"
614 " padding: 10px ! important;\n"
615 " text-align: left ! important;\n"
616 " line-height: normal;\n"
619 "div.fancy.header > div {\n"
620 " font-weight: bold ! important;\n"
621 " padding: 4px ! important;\n"
622 " line-height: normal;\n"
625 "div.fancy.header table {\n"
626 " padding: 2px ! important;\n"
627 " text-align: left ! important;\n"
628 " border-collapse: separate ! important;\n"
631 "div.fancy.header table th {\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"
644 "div.fancy.header table td {\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"
657 "div.fancy.header table a:hover {\n"
658 " background-color: transparent ! important;\n"
661 "span.pimsmileytext {\n"
662 " position: absolute;\n"
665 " visibility: hidden;\n"
668 "img.pimsmileyimg {\n"
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)
691 const int actualLevel = qMin( qMax( level, 0 ), 2 );
QString nonQuotedFontTag() const
void recalculatePGPColors()
Recalculate PGP frame and body colors (should be called after changing color settings) ...
void setPrintFont(const QFont &font)
const QColor & color(ColorGroup group, ColorRole role) const
void getHsv(int *h, int *s, int *v, int *a) const
QColor fromHsv(int h, int s, int v, int a)
QString number(int n, int base)
QFont bodyFont(bool fixedFont=false, bool printing=false) const
void setBodyFont(const QFont &font)
QString cssDefinitions(bool fixedFont=false) const
QString quoteFontTag(int level) const
void setItalic(bool enable)
QString mBackingPixmapStr
QColor pgpWarnColor() const
QColor quoteColor(int level)
QString htmlHead(bool fixedFont=false) const
QString fromLatin1(const char *str, int size)
CSSHelperBase(const QPaintDevice *pd)
Construct a CSSHelper object and set its font and color settings to default values.
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
static const char *const quoteFontSizes[]