Commit 399f64be authored by Pino Toscano's avatar Pino Toscano

Introduce realDpi{X,Y}(), that (on X11) can return the ral DPI values w/o any Xrdb setting.

Otherwise, they return the same as dpi{X,Y}().

svn path=/trunk/KDE/kdegraphics/okular/; revision=979128
parent b84d4a34
......@@ -12,6 +12,8 @@
#include "utils_p.h"
#include <QtCore/QRect>
#include <QApplication>
#include <QDesktopWidget>
#include <QImage>
#include <QIODevice>
......@@ -67,6 +69,18 @@ double Utils::dpiY()
return QX11Info::appDpiY();
}
double Utils::realDpiX()
{
const QDesktopWidget* w = QApplication::desktop();
return (double(w->width()) * 25.4) / double(w->widthMM());
}
double Utils::realDpiY()
{
const QDesktopWidget* w = QApplication::desktop();
return (double(w->height()) * 25.4) / double(w->heightMM());
}
#elif defined(Q_WS_MAC)
/*
* Code copied from http://developer.apple.com/qa/qa2001/qa1217.html
......@@ -140,8 +154,17 @@ double Utils::dpiY()
return err == CGDisplayNoErr ? y : 72.0;
}
double Utils::realDpiX()
{
return dpiX();
}
double Utils::realDpiY()
{
return dpiY();
}
#else
#include <QDesktopWidget>
double Utils::dpiX()
{
......@@ -152,6 +175,16 @@ double Utils::dpiY()
{
return QDesktopWidget().physicalDpiY();
}
double Utils::realDpiX()
{
return dpiX();
}
double Utils::realDpiY()
{
return dpiY();
}
#endif
inline static bool isWhite( QRgb argb ) {
......
......@@ -43,6 +43,26 @@ class OKULAR_EXPORT Utils
*/
static double dpiY();
/**
* Return the real horizontal DPI of the main display.
*
* On X11, it can indicate the real horizontal DPI value without any Xrdb
* setting. Otherwise, returns the same as dpiX(),
*
* since 0.9 (KDE 4.3)
*/
static double realDpiX();
/**
* Return the real vertical DPI of the main display
*
* On X11, it can indicate the real horizontal DPI value without any Xrdb
* setting. Otherwise, returns the same as dpiX(),
*
* since 0.9 (KDE 4.3)
*/
static double realDpiY();
/**
* Compute the smallest rectangle that contains all non-white pixels in image),
* in normalized [0,1] coordinates.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment