From e65a9a9dd17df168e68a0089ea7553897d851fbe Mon Sep 17 00:00:00 2001 From: Michael Haeckel Date: Sun, 10 Mar 2002 20:14:26 +0000 Subject: [PATCH] Specify the font size for khtml again in pixel to get also the same size as in the font dialog, if the X-Server doesn't know the screen size. svn path=/trunk/kdenetwork/kmail/; revision=142245 --- about/main.html | 2 +- kmreaderwin.cpp | 17 +++++++++++++---- kmreaderwin.h | 3 +++ 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/about/main.html b/about/main.html index 665483e9b..3a83709a8 100644 --- a/about/main.html +++ b/about/main.html @@ -4,7 +4,7 @@ Conquer your Desktop! diff --git a/kmreaderwin.cpp b/kmreaderwin.cpp index e5f5d2ad7..70e7cf00b 100644 --- a/kmreaderwin.cpp +++ b/kmreaderwin.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -589,7 +590,7 @@ void KMReaderWin::displayAboutPage() } else { info = info.arg( QString::null ); } - mViewer->write(content.arg(fntSize).arg(info)); + mViewer->write(content.arg(pointsToPixel(fntSize), 0, 'f', 5).arg(info)); mViewer->end(); } @@ -683,6 +684,14 @@ void KMReaderWin::sendNextHtmlChunk() mHtmlTimer.start(0, TRUE); } +//----------------------------------------------------------------------------- +double KMReaderWin::pointsToPixel(int pointSize) +{ + QPaintDeviceMetrics pdm(mViewer->view()); + double pixelSize = pointSize; + return pixelSize * pdm.logicalDpiY() / 72; +} + //----------------------------------------------------------------------------- void KMReaderWin::parseMsg(void) { @@ -725,10 +734,10 @@ void KMReaderWin::parseMsg(void) ((mPrinting) ? QString("body { font-family: \"%1\"; font-size: %2pt; " "color: #000000; background-color: #FFFFFF; }\n") .arg( mBodyFamily ).arg( fntSize ) - : QString("body { font-family: \"%1\"; font-size: %2pt; " + : QString("body { font-family: \"%1\"; font-size: %2px; " "color: %3; background-color: %4; }\n") - .arg( mBodyFamily ).arg( fntSize ).arg(c1.name()) - .arg(c4.name())) + + .arg( mBodyFamily ).arg( pointsToPixel(fntSize), 0, 'f', 5 ) + .arg(c1.name()) .arg(c4.name())) + ((mPrinting) ? QString("a { color: #000000; text-decoration: none; }") : QString("a { color: %1; ").arg(c2.name()) + "text-decoration: none; }" + // just playing diff --git a/kmreaderwin.h b/kmreaderwin.h index f9030f1a4..dbfb151cb 100644 --- a/kmreaderwin.h +++ b/kmreaderwin.h @@ -191,6 +191,9 @@ protected: /** Watch for palette changes */ virtual bool event(QEvent *e); + /** Calculate the pixel size */ + double pointsToPixel(int pointSize); + /** Feeds the HTML viewer with the contents of the given message. HTML begin/end parts are written around the message. */ virtual void parseMsg(void);