diff --git a/src/output.h b/src/output.h --- a/src/output.h +++ b/src/output.h @@ -106,9 +106,22 @@ * * @return identifying hash of this output * @since 5.15 + * @deprecated + * @see hashMd5 */ QString hash() const; + /** + * Returns an identifying hex encoded MD5-hash for this output. + * + * The hash is calculated either via the edid hash or if no + * edid is available by the output name, which is hashed as well. + * + * @return identifying hash of this output + * @since 5.17 + */ + QString hashMd5() const; + Type type() const; void setType(Type type); diff --git a/src/output.cpp b/src/output.cpp --- a/src/output.cpp +++ b/src/output.cpp @@ -27,6 +27,7 @@ #include #include #include +#include using namespace KScreen; @@ -218,6 +219,16 @@ return name(); } +QString Output::hashMd5() const +{ + if (edid() && edid()->isValid()) { + return edid()->hash(); + } + const auto hash = QCryptographicHash::hash(name().toLatin1(), + QCryptographicHash::Md5); + return QString::fromLatin1(hash.toHex()); +} + Output::Type Output::type() const { return d->type;