Temporarily add an invokable to read dpi value

This commit is contained in:
Sebastian Kügler 2014-01-20 02:44:35 +01:00
parent ff1d062b47
commit 22c12b8424
2 changed files with 27 additions and 0 deletions

View File

@ -24,6 +24,8 @@
#include <QFontMetrics> #include <QFontMetrics>
#include <kiconloader.h> #include <kiconloader.h>
#include <QApplication> #include <QApplication>
#include <QScreen>
#include <QQuickWindow>
#include <QDebug> #include <QDebug>
@ -64,4 +66,26 @@ QQmlPropertyMap *ThemeProxy::iconSizes() const
return m_iconSizes; return m_iconSizes;
} }
int ThemeProxy::dpi(QQuickItem* item)
{
int _dpi = 1337;
qDebug() << " ----- dpi() ---- ";
if (item) {
QScreen* screen = item->window()->screen();
if (screen) {
qDebug() << "screen geo: " << screen->availableGeometry();
_dpi = screen->physicalDotsPerInch();
qDebug() << " refreshRate : " << screen->refreshRate();
qDebug() << " devicePixelRatio: " << screen->devicePixelRatio();
qDebug() << " depth : " << screen->depth();
qDebug() << " dpi X: " << screen->physicalDotsPerInchX();
qDebug() << " dpi Y: " << screen->physicalDotsPerInchY();
qDebug() << " ->> dpi: " << _dpi;
}
}
return _dpi;
}
#include "moc_theme.cpp" #include "moc_theme.cpp"

View File

@ -26,6 +26,7 @@
#include <QColor> #include <QColor>
#include <QJSValue> #include <QJSValue>
#include <QQmlEngine> #include <QQmlEngine>
#include <QQuickItem>
#include <Plasma/Theme> #include <Plasma/Theme>
@ -57,6 +58,8 @@ public:
QQmlPropertyMap *iconSizes() const; QQmlPropertyMap *iconSizes() const;
Q_INVOKABLE int dpi(QQuickItem *item);
private Q_SLOTS: private Q_SLOTS:
void iconLoaderSettingsChanged(); void iconLoaderSettingsChanged();