Added the units.displayAspectRatio property
This commit is contained in:
parent
fc6938887b
commit
6008c889f5
@ -46,6 +46,7 @@ Units::Units (QObject *parent)
|
||||
{
|
||||
m_iconSizes = new QQmlPropertyMap(this);
|
||||
updateDevicePixelRatio();
|
||||
updateDisplayAspectRatio();
|
||||
updateSpacing();
|
||||
|
||||
//iconLoaderSettingsChanged();
|
||||
@ -142,11 +143,25 @@ int Units::devicePixelIconSize(const int size) const
|
||||
return out;
|
||||
}
|
||||
|
||||
qreal Units::displayAspectRatio() const
|
||||
{
|
||||
return m_displayAspectRatio;
|
||||
}
|
||||
|
||||
qreal Units::devicePixelRatio() const
|
||||
{
|
||||
return m_devicePixelRatio;
|
||||
}
|
||||
|
||||
void Units::updateDisplayAspectRatio()
|
||||
{
|
||||
QWidget *screen = QApplication::desktop()->screen();
|
||||
|
||||
m_displayAspectRatio = screen->width() / (qreal)screen->height();
|
||||
|
||||
emit displayAspectRatioChanged();
|
||||
}
|
||||
|
||||
void Units::updateDevicePixelRatio()
|
||||
{
|
||||
// Going through QDesktopWidget seems to be the most reliable way no
|
||||
|
@ -83,6 +83,11 @@ class Units : public QObject
|
||||
*/
|
||||
Q_PROPERTY(qreal devicePixelRatio READ devicePixelRatio NOTIFY devicePixelRatioChanged)
|
||||
|
||||
/**
|
||||
* The ratio between the screen width and height of the main screen.
|
||||
*/
|
||||
Q_PROPERTY(qreal displayAspectRatio READ displayAspectRatio NOTIFY displayAspectRatioChanged)
|
||||
|
||||
/**
|
||||
* units.longDuration should be used for longer, screen-covering animations, for opening and
|
||||
* closing of dialogs and other "not too small" animations
|
||||
@ -111,6 +116,11 @@ public:
|
||||
*/
|
||||
qreal devicePixelRatio() const;
|
||||
|
||||
/**
|
||||
* @return The ratio between physical and device-independent pixels.
|
||||
*/
|
||||
qreal displayAspectRatio() const;
|
||||
|
||||
/**
|
||||
* @return map with iconsizes, indexed by name
|
||||
*/
|
||||
@ -142,6 +152,7 @@ public:
|
||||
|
||||
Q_SIGNALS:
|
||||
void devicePixelRatioChanged();
|
||||
void displayAspectRatioChanged();
|
||||
void gridUnitChanged();
|
||||
void iconSizesChanged();
|
||||
void spacingChanged();
|
||||
@ -154,6 +165,7 @@ private Q_SLOTS:
|
||||
|
||||
private:
|
||||
void updateDevicePixelRatio();
|
||||
void updateDisplayAspectRatio();
|
||||
void updateSpacing();
|
||||
/**
|
||||
* @return The dpi-adjusted size for a given icon size
|
||||
@ -164,6 +176,7 @@ private:
|
||||
|
||||
int m_gridUnit;
|
||||
qreal m_devicePixelRatio;
|
||||
qreal m_displayAspectRatio;
|
||||
qreal m_dpi;
|
||||
|
||||
QQmlPropertyMap *m_iconSizes;
|
||||
|
Loading…
Reference in New Issue
Block a user