summaryrefslogtreecommitdiffstats
path: root/src/displaysettings
diff options
context:
space:
mode:
authorJuho Annunen <juho.annunen@qt.io>2017-10-11 13:30:52 +0300
committerSami Nurmenniemi <sami.nurmenniemi@qt.io>2017-11-22 10:40:45 +0000
commit3895b8504f65346a1de19aa1ceb9570175337283 (patch)
tree3c97b2b57874bc1d3932350b4db7a779ddd80840 /src/displaysettings
parent61e9e8c83e817b3692beae03bd8e683d247207b0 (diff)
Update API and settings UI
Implemented new UI design for Settings and minor changes to API Task-number: QTBUG-63091 Change-Id: Id72e20b53bc33ca0a3068d1e9b664fc5836a1cda Reviewed-by: Kari Oikarinen <kari.oikarinen@qt.io> Reviewed-by: Teemu Holappa <teemu.holappa@qt.io>
Diffstat (limited to 'src/displaysettings')
-rw-r--r--src/displaysettings/displaysettings.cpp24
-rw-r--r--src/displaysettings/displaysettings.h8
-rw-r--r--src/displaysettings/displaysettings_p.cpp50
-rw-r--r--src/displaysettings/displaysettings_p.h11
4 files changed, 85 insertions, 8 deletions
diff --git a/src/displaysettings/displaysettings.cpp b/src/displaysettings/displaysettings.cpp
index 0ab5177..128c8df 100644
--- a/src/displaysettings/displaysettings.cpp
+++ b/src/displaysettings/displaysettings.cpp
@@ -71,12 +71,36 @@ int DisplaySettings::physicalScreenSizeInch() const
return d->physicalScreenSizeInch();
}
+int DisplaySettings::physicalScreenWidthMm() const
+{
+ Q_D(const DisplaySettings);
+ return d->physicalScreenWidthMm();
+}
+
+int DisplaySettings::physicalScreenHeightMm() const
+{
+ Q_D(const DisplaySettings);
+ return d->physicalScreenHeightMm();
+}
+
void DisplaySettings::setPhysicalScreenSizeInch(int inches)
{
Q_D(DisplaySettings);
d->setPhysicalScreenSizeInch(inches);
}
+void DisplaySettings::setPhysicalScreenWidthMm(int newWidth)
+{
+ Q_D(DisplaySettings);
+ d->setPhysicalScreenWidthMm(newWidth);
+}
+
+void DisplaySettings::setPhysicalScreenHeightMm(int newHeight)
+{
+ Q_D(DisplaySettings);
+ d->setPhysicalScreenHeightMm(newHeight);
+}
+
bool DisplaySettings::physicalScreenSizeOverride() const
{
Q_D(const DisplaySettings);
diff --git a/src/displaysettings/displaysettings.h b/src/displaysettings/displaysettings.h
index fc8782f..835da3f 100644
--- a/src/displaysettings/displaysettings.h
+++ b/src/displaysettings/displaysettings.h
@@ -41,6 +41,8 @@ class Q_DECL_EXPORT DisplaySettings : public QObject
Q_PROPERTY(int displayBrightness READ displayBrightness WRITE setDisplayBrightness NOTIFY displayBrightnessChanged)
Q_PROPERTY(int physicalScreenSizeInch READ physicalScreenSizeInch WRITE setPhysicalScreenSizeInch NOTIFY physicalScreenSizeInchChanged)
+ Q_PROPERTY(int physicalScreenWidthMm READ physicalScreenWidthMm WRITE setPhysicalScreenWidthMm NOTIFY physicalScreenWidthMmChanged)
+ Q_PROPERTY(int physicalScreenHeightMm READ physicalScreenHeightMm WRITE setPhysicalScreenHeightMm NOTIFY physicalScreenHeightMmChanged)
Q_PROPERTY(bool physicalScreenSizeOverride READ physicalScreenSizeOverride WRITE setPhysicalScreenSizeOverride NOTIFY physicalScreenSizeOverrideChanged)
public:
@@ -49,17 +51,23 @@ public:
int displayBrightness();
int physicalScreenSizeInch() const;
+ int physicalScreenWidthMm() const;
+ int physicalScreenHeightMm() const;
bool physicalScreenSizeOverride() const;
public Q_SLOTS:
bool setDisplayBrightness(int value);
void setPhysicalScreenSizeInch(int inches);
void setPhysicalScreenSizeOverride(bool enable);
+ void setPhysicalScreenWidthMm(int newWidth);
+ void setPhysicalScreenHeightMm(int newHeight);
Q_SIGNALS:
void displayBrightnessChanged(int newValue);
void physicalScreenSizeInchChanged(int newInches);
void physicalScreenSizeOverrideChanged(bool newValue);
+ void physicalScreenWidthMmChanged(int newValue);
+ void physicalScreenHeightMmChanged(int newValue);
protected:
DisplaySettingsPrivate *d_ptr;
diff --git a/src/displaysettings/displaysettings_p.cpp b/src/displaysettings/displaysettings_p.cpp
index c7bbc9a..c0a512d 100644
--- a/src/displaysettings/displaysettings_p.cpp
+++ b/src/displaysettings/displaysettings_p.cpp
@@ -101,6 +101,16 @@ int DisplaySettingsPrivate::physicalScreenSizeInch() const
return m_physScreenSize->size();
}
+int DisplaySettingsPrivate::physicalScreenWidthMm() const
+{
+ return m_physScreenSize->widthMm();
+}
+
+int DisplaySettingsPrivate::physicalScreenHeightMm() const
+{
+ return m_physScreenSize->heightMm();
+}
+
void DisplaySettingsPrivate::setPhysicalScreenSizeInch(int inches)
{
Q_Q(DisplaySettings);
@@ -110,6 +120,24 @@ void DisplaySettingsPrivate::setPhysicalScreenSizeInch(int inches)
}
}
+void DisplaySettingsPrivate::setPhysicalScreenWidthMm(int newWidth)
+{
+ Q_Q(DisplaySettings);
+ if (m_physScreenSize->widthMm() != newWidth) {
+ m_physScreenSize->setSizeMm(newWidth, m_physScreenSize->heightMm());
+ emit q->physicalScreenWidthMmChanged(newWidth);
+ }
+}
+
+void DisplaySettingsPrivate::setPhysicalScreenHeightMm(int newHeight)
+{
+ Q_Q(DisplaySettings);
+ if (m_physScreenSize->heightMm() != newHeight) {
+ m_physScreenSize->setSizeMm(m_physScreenSize->widthMm(), newHeight);
+ emit q->physicalScreenHeightMmChanged(newHeight);
+ }
+}
+
bool DisplaySettingsPrivate::physicalScreenSizeOverride() const
{
return m_physScreenSize->enabled();
@@ -147,7 +175,8 @@ void PhysicalScreenSize::read(const QString &filename)
if (!f.open(QIODevice::ReadOnly | QIODevice::Text))
return;
- int physScreenWidth = 154, physScreenHeight = 90;
+ physScreenWidthMm = 154;
+ physScreenHeightMm = 90;
int found = 0;
while (!f.atEnd()) {
QByteArray line = f.readLine().trimmed();
@@ -159,13 +188,13 @@ void PhysicalScreenSize::read(const QString &filename)
int val = values[2].toInt(&ok);
if (ok) {
++found;
- physScreenWidth = val;
+ physScreenWidthMm = val;
}
} else if (values[1] == QByteArrayLiteral("QT_QPA_EGLFS_PHYSICAL_HEIGHT")) {
int val = values[2].toInt(&ok);
if (ok) {
++found;
- physScreenHeight = val;
+ physScreenHeightMm = val;
}
}
}
@@ -174,7 +203,7 @@ void PhysicalScreenSize::read(const QString &filename)
if (found == 2)
physScreenSizeEnabled = true;
- const qreal diagMM = qSqrt(physScreenWidth * physScreenWidth + physScreenHeight * physScreenHeight);
+ const qreal diagMM = qSqrt(physScreenWidthMm * physScreenWidthMm + physScreenHeightMm * physScreenHeightMm);
physScreenSizeInch = qRound(diagMM / 25.4);
}
@@ -207,10 +236,8 @@ void PhysicalScreenSize::write(const QString &filename, bool includePhysSize)
if (!f.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text))
return;
- const qreal diagMM = physScreenSizeInch * 25.4;
- // Assume 16:9 aspect ratio
- const int physScreenHeight = qRound(diagMM / 1.975);
- const int physScreenWidth = qRound(physScreenHeight * 1.777);
+ const int physScreenHeight = physScreenHeightMm;
+ const int physScreenWidth = physScreenWidthMm;
foreach (const QByteArray &line, lines)
f.write(line + QByteArrayLiteral("\n"));
@@ -227,6 +254,13 @@ void PhysicalScreenSize::setSize(int inches)
physWriteTimer.start();
}
+void PhysicalScreenSize::setSizeMm(int width, int height)
+{
+ physScreenWidthMm = width;
+ physScreenHeightMm = height;
+ physWriteTimer.start();
+}
+
bool PhysicalScreenSize::enabled() const
{
return physScreenSizeEnabled;
diff --git a/src/displaysettings/displaysettings_p.h b/src/displaysettings/displaysettings_p.h
index 329ed81..089777c 100644
--- a/src/displaysettings/displaysettings_p.h
+++ b/src/displaysettings/displaysettings_p.h
@@ -52,7 +52,10 @@ public:
virtual ~PhysicalScreenSize();
void setSize(int inches);
+ void setSizeMm(int widthMm, int heightMm);
int size() const { return physScreenSizeInch; }
+ int widthMm() const { return physScreenWidthMm; }
+ int heightMm() const { return physScreenHeightMm; }
bool enabled() const;
void setEnabled(bool enable);
@@ -66,6 +69,8 @@ private:
bool physScreenSizeEnabled;
int physScreenSizeInch;
+ int physScreenWidthMm;
+ int physScreenHeightMm;
QTimer physWriteTimer;
};
@@ -85,16 +90,22 @@ public:
DisplaySettingsPrivate(DisplaySettings* qq);
int displayBrightness();
int physicalScreenSizeInch() const;
+ int physicalScreenWidthMm() const;
+ int physicalScreenHeightMm() const;
bool physicalScreenSizeOverride() const;
bool setDisplayBrightness(int value);
void setPhysicalScreenSizeInch(int inches);
+ void setPhysicalScreenWidthMm(int newWidth);
+ void setPhysicalScreenHeightMm(int newHeight);
void setPhysicalScreenSizeOverride(bool enable);
private:
void initLightDevices();
DisplaySettings *q_ptr;
int m_brightness;
int m_screenSizeInch;
+ int m_screenWidthMm;
+ int m_screenHeightMm;
bool m_sizeOverride;
QList<LightDevice> m_lightDevices;
bool m_lightDevicesInitialized;