Make setDevicePixelRatio(qreal) a simple slot
This commit is contained in:
parent
831357d98f
commit
6dfb4f240b
@ -36,7 +36,7 @@ Units::Units (QObject *parent)
|
||||
m_devicePixelRatio(-1)
|
||||
{
|
||||
m_iconSizes = new QQmlPropertyMap(this);
|
||||
setDevicePixelRatio(0);
|
||||
updateDevicePixelRatio();
|
||||
updateSpacing();
|
||||
|
||||
//iconLoaderSettingsChanged();
|
||||
@ -113,10 +113,8 @@ qreal Units::devicePixelRatio() const
|
||||
return m_devicePixelRatio;
|
||||
}
|
||||
|
||||
void Units::setDevicePixelRatio(const qreal scale)
|
||||
void Units::updateDevicePixelRatio()
|
||||
{
|
||||
if (m_devicePixelRatio != scale) {
|
||||
if (scale <= 0) {
|
||||
// Going through QDesktopWidget seems to be the most reliable way no
|
||||
// to get the DPI, and thus devicePixelRatio
|
||||
// Using QGuiApplication::devicePixelRatio() gives too coarse values,
|
||||
@ -126,13 +124,8 @@ void Units::setDevicePixelRatio(const qreal scale)
|
||||
// Usual "default" is 96 dpi
|
||||
// that magic ratio follows the definition of "device independent pixel" by Microsoft
|
||||
m_devicePixelRatio = (qreal)dpi / (qreal)96;
|
||||
} else {
|
||||
m_devicePixelRatio = scale;
|
||||
}
|
||||
qDebug() << "XX Setting dpi scale to " << scale;
|
||||
iconLoaderSettingsChanged();
|
||||
emit devicePixelRatioChanged();
|
||||
}
|
||||
}
|
||||
|
||||
int Units::gridUnit() const
|
||||
|
@ -127,15 +127,7 @@ private Q_SLOTS:
|
||||
void iconLoaderSettingsChanged();
|
||||
|
||||
private:
|
||||
/**
|
||||
* Overrides the devicePixelRatio
|
||||
*
|
||||
* Set the device pixel ratio to a custom value.
|
||||
*
|
||||
* @arg ratio, 0 resets to detected value
|
||||
*/
|
||||
void setDevicePixelRatio(const qreal ratio);
|
||||
|
||||
void updateDevicePixelRatio();
|
||||
void updateSpacing();
|
||||
/**
|
||||
* @return The dpi-adjusted size for a given icon size
|
||||
|
Loading…
Reference in New Issue
Block a user