summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Kügler <[email protected]>2016-11-08 18:13:19 +0100
committerSebastian Kügler <[email protected]>2016-11-10 01:20:34 +0100
commit2875e5d3cfb10d705de79b5fd0daaf1db6d7dcdd (patch)
treeecf7c28afb2bf0c891c0eba23c56deafb1962606
parent6cc05cae8143bf2a1f50389f39cc7976ac7030b7 (diff)
scale property for KScreen::Output
Summary: This adds a scale property to KScreen::Output. By default, it's 1.0, which means no scaling. The value is a qreal, and the conversion to int for the backends that only understand int is made in the underlying backend code. RFC. :) Test Plan: autotests included Reviewers: graesslin, davidedmundson Reviewed By: davidedmundson Subscribers: plasma-devel, davidedmundson Tags: #plasma Differential Revision: https://phabricator.kde.org/D3312
-rw-r--r--autotests/configs/multipleoutput.json1
-rw-r--r--autotests/testscreenconfig.cpp2
-rw-r--r--backends/fake/parser.cpp6
-rw-r--r--src/output.cpp17
-rw-r--r--src/output.h20
5 files changed, 46 insertions, 0 deletions
diff --git a/autotests/configs/multipleoutput.json b/autotests/configs/multipleoutput.json
index d168f27..6df3529 100644
--- a/autotests/configs/multipleoutput.json
+++ b/autotests/configs/multipleoutput.json
@@ -119,6 +119,7 @@
"width" : 1920,
"height" : 1080
},
+ "scale" : 1.4,
"currentModeId" : 4,
"preferredModes" : [4],
"rotation" : 1,
diff --git a/autotests/testscreenconfig.cpp b/autotests/testscreenconfig.cpp
index ef91dc2..968cf30 100644
--- a/autotests/testscreenconfig.cpp
+++ b/autotests/testscreenconfig.cpp
@@ -109,6 +109,7 @@ void testScreenConfig::singleOutput()
QCOMPARE(output->currentModeId(), QLatin1String("3"));
QCOMPARE(output->preferredModeId(), QLatin1String("3"));
QCOMPARE(output->rotation(), Output::None);
+ QCOMPARE(output->scale(), 1.0);
QCOMPARE(output->isConnected(), true);
QCOMPARE(output->isEnabled(), true);
QCOMPARE(output->isPrimary(), true);
@@ -159,6 +160,7 @@ void testScreenConfig::multiOutput()
QCOMPARE(output->currentModeId(), QLatin1String("4"));
QCOMPARE(output->preferredModeId(), QLatin1String("4"));
QCOMPARE(output->rotation(), Output::None);
+ QCOMPARE(output->scale(), 1.4);
QCOMPARE(output->isConnected(), true);
QCOMPARE(output->isEnabled(), true);
QCOMPARE(output->isPrimary(), false);
diff --git a/backends/fake/parser.cpp b/backends/fake/parser.cpp
index 48f2303..ccf00ad 100644
--- a/backends/fake/parser.cpp
+++ b/backends/fake/parser.cpp
@@ -189,6 +189,12 @@ OutputPtr Parser::outputFromJson(QMap< QString, QVariant > map)
map.remove(QLatin1Literal("size"));
}
+ if (map.contains("scale")) {
+ qDebug() << "Scale found:" << map["scale"].toReal();
+ output->setScale(map["scale"].toReal());
+ map.remove(QLatin1Literal("size"));
+ }
+
//Remove some extra properties that we do not want or need special treatment
map.remove(QLatin1Literal("edid"));
diff --git a/src/output.cpp b/src/output.cpp
index 1fcf30b..8f35605 100644
--- a/src/output.cpp
+++ b/src/output.cpp
@@ -37,6 +37,7 @@ class Output::Private
id(0),
type(Unknown),
rotation(None),
+ scale(1.0),
connected(false),
enabled(false),
primary(false),
@@ -56,6 +57,7 @@ class Output::Private
pos(other.pos),
size(other.size),
rotation(other.rotation),
+ scale(other.scale),
connected(other.connected),
enabled(other.enabled),
primary(other.primary)
@@ -84,6 +86,7 @@ class Output::Private
QPoint pos;
QSize size;
Rotation rotation;
+ qreal scale;
bool connected;
bool enabled;
bool primary;
@@ -377,6 +380,20 @@ void Output::setRotation(Output::Rotation rotation)
Q_EMIT rotationChanged();
}
+qreal Output::scale() const
+{
+ return d->scale;
+}
+
+void Output::setScale(qreal factor)
+{
+ if (d->scale == factor) {
+ return;
+ }
+ d->scale = factor;
+ emit scaleChanged();
+}
+
bool Output::isConnected() const
{
return d->connected;
diff --git a/src/output.h b/src/output.h
index 13b4a72..f126dc2 100644
--- a/src/output.h
+++ b/src/output.h
@@ -58,6 +58,8 @@ class KSCREEN_EXPORT Output : public QObject
Q_PROPERTY(QList<int> clones READ clones WRITE setClones NOTIFY clonesChanged)
Q_PROPERTY(KScreen::Edid* edid READ edid CONSTANT)
Q_PROPERTY(QSize sizeMm READ sizeMm CONSTANT)
+ Q_PROPERTY(qreal scale READ scale WRITE setScale NOTIFY scaleChanged)
+
enum Type {
Unknown,
@@ -192,6 +194,23 @@ class KSCREEN_EXPORT Output : public QObject
*/
QRect geometry() const;
+ /**
+ * returns the scaling factor to use for this output
+ *
+ * @since 5.9
+ */
+ qreal scale() const;
+
+ /**
+ * Set the scaling factor for this output.
+ *
+ * @arg factor Scale factor to use for this output, the backend may or may not
+ * be able to deal with non-integer values, in that case, the factor gets rounded.
+ *
+ * @since 5.9
+ */
+ void setScale(qreal factor);
+
void apply(const OutputPtr &other);
Q_SIGNALS:
void outputChanged();
@@ -203,6 +222,7 @@ class KSCREEN_EXPORT Output : public QObject
void isEnabledChanged();
void isPrimaryChanged();
void clonesChanged();
+ void scaleChanged();
/** The mode list changed.
*