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