Rename units.dpiScale to units.devicePixelRatio

This commit is contained in:
Sebastian Kügler 2014-01-23 02:18:06 +01:00
parent f305950a80
commit cca8a86f98
2 changed files with 15 additions and 15 deletions

View File

@ -37,7 +37,7 @@ Units::Units (QObject *parent)
//Usual "default" is 96 dpi
//that magic ratio follows the definition of "device independent pixel" by Microsoft
m_dpi = QApplication::desktop()->physicalDpiX();
m_dpiScale = (qreal)m_dpi / (qreal)96;
m_devicePixelRatio = (qreal)m_dpi / (qreal)96;
updateSpacing();
@ -78,18 +78,18 @@ QQmlPropertyMap *Units::iconSizes() const
return m_iconSizes;
}
qreal Units::dpiScale() const
qreal Units::devicePixelRatio() const
{
return m_dpiScale;
return m_devicePixelRatio;
}
void Units::setDpiScale(const qreal scale)
void Units::setDevicePixelRatio(const qreal scale)
{
if (m_dpiScale != scale) {
m_dpiScale = scale;
if (m_devicePixelRatio != scale) {
m_devicePixelRatio = scale;
qDebug() << "Setting dpi scale to " << scale;
emit dpiScaleChanged();
emit devicePixelRatioChanged();
}
}
@ -99,7 +99,7 @@ qreal Units::gridUnit() const
qDebug() << " MRect" << QFontMetrics(QApplication::font()).boundingRect("M").size();
qDebug() << " like spacing" << QFontMetrics(QApplication::font()).boundingRect("M").size().height();
qDebug() << "m_dpi: " << m_dpi;
qDebug() << "m_dpiScale: " << m_dpiScale;
qDebug() << "m_devicePixelRatio: " << m_devicePixelRatio;
const int gridUnit = QFontMetrics(QApplication::font()).boundingRect("M").width();
return m_gridUnit;
}
@ -107,9 +107,9 @@ qreal Units::gridUnit() const
qreal Units::dp(qreal value) const
{
if (value <= 2.0) {
return qRound(value * floor(m_dpiScale));
return qRound(value * floor(m_devicePixelRatio));
} else {
return qRound(value * m_dpiScale);
return qRound(value * m_devicePixelRatio);
}
}

View File

@ -64,7 +64,7 @@ class Units : public QObject
Q_PROPERTY(int smallSpacing READ smallSpacing NOTIFY spacingChanged)
Q_PROPERTY(int largeSpacing READ largeSpacing NOTIFY spacingChanged)
Q_PROPERTY(qreal dpiScale READ dpiScale WRITE setDpiScale NOTIFY dpiScaleChanged)
Q_PROPERTY(qreal devicePixelRatio READ devicePixelRatio WRITE setDevicePixelRatio NOTIFY devicePixelRatioChanged)
public:
Units(QObject *parent = 0);
@ -74,8 +74,8 @@ public:
qreal gridUnit() const;
void setDpiScale(const qreal scale);
qreal dpiScale() const;
void setDevicePixelRatio(const qreal scale);
qreal devicePixelRatio() const;
QQmlPropertyMap *iconSizes() const;
@ -100,7 +100,7 @@ public:
Q_INVOKABLE void printScreenInfo(QQuickItem *item);
Q_SIGNALS:
void dpiScaleChanged();
void devicePixelRatioChanged();
void gridUnitChanged();
void iconSizesChanged();
void spacingChanged();
@ -115,7 +115,7 @@ private:
Plasma::Theme m_theme;
int m_gridUnit;
qreal m_dpiScale;
qreal m_devicePixelRatio;
qreal m_dpi;
QQmlPropertyMap *m_iconSizes;