summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoman Gilg <[email protected]>2018-11-12 18:49:21 +0100
committerRoman Gilg <[email protected]>2018-11-13 11:56:51 +0100
commit740a86695df4ecac670ce892974fbc4afeaf32d1 (patch)
treec1f17ec11076fa5541f56d6dcdde17e2b463a853
parent3a0303fce1891717298101d18b811eb8995547bb (diff)
Make use of libkscreen hash API
Summary: Replace kscreen's own calculations with libkscreen API. Test Plan: Compiles, serializertest passes. Reviewers: #plasma, davidedmundson Reviewed By: #plasma, davidedmundson Subscribers: plasma-devel Tags: #plasma Differential Revision: https://phabricator.kde.org/D16845
-rw-r--r--kded/serializer.cpp35
-rw-r--r--kded/serializer.h1
-rw-r--r--tests/kded/serializertest.cpp2
3 files changed, 5 insertions, 33 deletions
diff --git a/kded/serializer.cpp b/kded/serializer.cpp
index a2823ea..010c1aa 100644
--- a/kded/serializer.cpp
+++ b/kded/serializer.cpp
@@ -57,25 +57,7 @@ QString Serializer::configId(const KScreen::ConfigPtr &config)
if (!config) {
return QString();
}
- KScreen::OutputList outputs = config->outputs();
-
- QStringList hashList;
- //qCDebug(KSCREEN_KDED) << "Calculating config ID for" << currentConfig.data();
- Q_FOREACH(const KScreen::OutputPtr &output, outputs) {
- if (!output->isConnected()) {
- continue;
- }
-
- //qCDebug(KSCREEN_KDED) << "\tPart of the Id: " << Serializer::outputId(output);
- hashList.insert(0, Serializer::outputId(output));
- }
-
- qSort(hashList.begin(), hashList.end());
-
- const QByteArray hash = QCryptographicHash::hash(hashList.join(QString()).toLatin1(),
- QCryptographicHash::Md5).toHex();
- //qCDebug(KSCREEN_KDED) << "\tConfig ID:" << hash;
- return QString::fromLatin1(hash);
+ return config->connectedOutputsHash();
}
bool Serializer::configExists(const KScreen::ConfigPtr &config)
@@ -155,7 +137,7 @@ bool Serializer::saveConfig(const KScreen::ConfigPtr &config, const QString &con
QVariantMap info;
- info[QStringLiteral("id")] = Serializer::outputId(output);
+ info[QStringLiteral("id")] = output->hash();
info[QStringLiteral("primary")] = output->isPrimary();
info[QStringLiteral("enabled")] = output->isEnabled();
info[QStringLiteral("rotation")] = output->rotation();
@@ -228,7 +210,7 @@ KScreen::OutputPtr Serializer::findOutput(const KScreen::ConfigPtr &config, cons
QStringList allIds;
allIds.reserve(outputs.count());
Q_FOREACH (const KScreen::OutputPtr &output, outputs) {
- const auto outputId = Serializer::outputId(output);
+ const auto outputId = output->hash();
if (allIds.contains(outputId) && !duplicateIds.contains(outputId)) {
duplicateIds << outputId;
}
@@ -240,7 +222,7 @@ KScreen::OutputPtr Serializer::findOutput(const KScreen::ConfigPtr &config, cons
if (!output->isConnected()) {
continue;
}
- const auto outputId = Serializer::outputId(output);
+ const auto outputId = output->hash();
if (outputId != info[QStringLiteral("id")].toString()) {
continue;
}
@@ -311,15 +293,6 @@ KScreen::OutputPtr Serializer::findOutput(const KScreen::ConfigPtr &config, cons
return KScreen::OutputPtr();
}
-QString Serializer::outputId(const KScreen::OutputPtr &output)
-{
- if (output->edid() && output->edid()->isValid()) {
- return output->edid()->hash();
- }
-
- return output->name();
-}
-
QVariantMap Serializer::metadata(const KScreen::OutputPtr &output)
{
QVariantMap metadata;
diff --git a/kded/serializer.h b/kded/serializer.h
index f8586be..7e262eb 100644
--- a/kded/serializer.h
+++ b/kded/serializer.h
@@ -36,7 +36,6 @@ public:
static bool moveConfig(const QString &srcId, const QString &destId);
static KScreen::OutputPtr findOutput(const KScreen::ConfigPtr &config, const QVariantMap &info);
- static QString outputId(const KScreen::OutputPtr &output);
static QVariantMap metadata(const KScreen::OutputPtr &output);
static void setConfigPath(const QString &path);
diff --git a/tests/kded/serializertest.cpp b/tests/kded/serializertest.cpp
index 0366774..891dea8 100644
--- a/tests/kded/serializertest.cpp
+++ b/tests/kded/serializertest.cpp
@@ -365,7 +365,7 @@ void TestSerializer::testIdenticalOutputs()
QCOMPARE(config->connectedOutputs().count(), 6);
Q_FOREACH (auto output, config->connectedOutputs()) {
QVERIFY(positions.keys().contains(output->name()));
- QVERIFY(output->name() != Serializer::outputId(output));
+ QVERIFY(output->name() != output->hash());
QCOMPARE(positions[output->name()], output->pos());
QCOMPARE(output->currentMode()->size(), QSize(1920, 1080));
QCOMPARE(output->currentMode()->refreshRate(), 60.0);