Rename units.dpiScale to units.devicePixelRatio
This commit is contained in:
parent
f305950a80
commit
cca8a86f98
@ -37,7 +37,7 @@ Units::Units (QObject *parent)
|
|||||||
//Usual "default" is 96 dpi
|
//Usual "default" is 96 dpi
|
||||||
//that magic ratio follows the definition of "device independent pixel" by Microsoft
|
//that magic ratio follows the definition of "device independent pixel" by Microsoft
|
||||||
m_dpi = QApplication::desktop()->physicalDpiX();
|
m_dpi = QApplication::desktop()->physicalDpiX();
|
||||||
m_dpiScale = (qreal)m_dpi / (qreal)96;
|
m_devicePixelRatio = (qreal)m_dpi / (qreal)96;
|
||||||
|
|
||||||
updateSpacing();
|
updateSpacing();
|
||||||
|
|
||||||
@ -78,18 +78,18 @@ QQmlPropertyMap *Units::iconSizes() const
|
|||||||
return m_iconSizes;
|
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) {
|
if (m_devicePixelRatio != scale) {
|
||||||
m_dpiScale = scale;
|
m_devicePixelRatio = scale;
|
||||||
qDebug() << "Setting dpi scale to " << 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() << " MRect" << QFontMetrics(QApplication::font()).boundingRect("M").size();
|
||||||
qDebug() << " like spacing" << QFontMetrics(QApplication::font()).boundingRect("M").size().height();
|
qDebug() << " like spacing" << QFontMetrics(QApplication::font()).boundingRect("M").size().height();
|
||||||
qDebug() << "m_dpi: " << m_dpi;
|
qDebug() << "m_dpi: " << m_dpi;
|
||||||
qDebug() << "m_dpiScale: " << m_dpiScale;
|
qDebug() << "m_devicePixelRatio: " << m_devicePixelRatio;
|
||||||
const int gridUnit = QFontMetrics(QApplication::font()).boundingRect("M").width();
|
const int gridUnit = QFontMetrics(QApplication::font()).boundingRect("M").width();
|
||||||
return m_gridUnit;
|
return m_gridUnit;
|
||||||
}
|
}
|
||||||
@ -107,9 +107,9 @@ qreal Units::gridUnit() const
|
|||||||
qreal Units::dp(qreal value) const
|
qreal Units::dp(qreal value) const
|
||||||
{
|
{
|
||||||
if (value <= 2.0) {
|
if (value <= 2.0) {
|
||||||
return qRound(value * floor(m_dpiScale));
|
return qRound(value * floor(m_devicePixelRatio));
|
||||||
} else {
|
} else {
|
||||||
return qRound(value * m_dpiScale);
|
return qRound(value * m_devicePixelRatio);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ class Units : public QObject
|
|||||||
Q_PROPERTY(int smallSpacing READ smallSpacing NOTIFY spacingChanged)
|
Q_PROPERTY(int smallSpacing READ smallSpacing NOTIFY spacingChanged)
|
||||||
Q_PROPERTY(int largeSpacing READ largeSpacing 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:
|
public:
|
||||||
Units(QObject *parent = 0);
|
Units(QObject *parent = 0);
|
||||||
@ -74,8 +74,8 @@ public:
|
|||||||
|
|
||||||
qreal gridUnit() const;
|
qreal gridUnit() const;
|
||||||
|
|
||||||
void setDpiScale(const qreal scale);
|
void setDevicePixelRatio(const qreal scale);
|
||||||
qreal dpiScale() const;
|
qreal devicePixelRatio() const;
|
||||||
|
|
||||||
QQmlPropertyMap *iconSizes() const;
|
QQmlPropertyMap *iconSizes() const;
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ public:
|
|||||||
Q_INVOKABLE void printScreenInfo(QQuickItem *item);
|
Q_INVOKABLE void printScreenInfo(QQuickItem *item);
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void dpiScaleChanged();
|
void devicePixelRatioChanged();
|
||||||
void gridUnitChanged();
|
void gridUnitChanged();
|
||||||
void iconSizesChanged();
|
void iconSizesChanged();
|
||||||
void spacingChanged();
|
void spacingChanged();
|
||||||
@ -115,7 +115,7 @@ private:
|
|||||||
Plasma::Theme m_theme;
|
Plasma::Theme m_theme;
|
||||||
|
|
||||||
int m_gridUnit;
|
int m_gridUnit;
|
||||||
qreal m_dpiScale;
|
qreal m_devicePixelRatio;
|
||||||
qreal m_dpi;
|
qreal m_dpi;
|
||||||
|
|
||||||
QQmlPropertyMap *m_iconSizes;
|
QQmlPropertyMap *m_iconSizes;
|
||||||
|
Loading…
Reference in New Issue
Block a user