diff --git a/app/qml/DevicePage.qml b/app/qml/DevicePage.qml index 07747592a..7d802f155 100644 --- a/app/qml/DevicePage.qml +++ b/app/qml/DevicePage.qml @@ -127,7 +127,7 @@ Kirigami.ScrollablePage { Kirigami.PlaceholderMessage { // FIXME: not accessible. screen readers won't read this. Idem for the other PlaceholderMessages // https://invent.kde.org/frameworks/kirigami/-/merge_requests/1482 - text: i18nd("kdeconnect-app", "This device is not paired") + text: i18nd("kdeconnect-app", "This device is not paired.\nKey: %1", root.currentDevice.verificationKey) anchors.centerIn: parent visible: root.currentDevice && root.currentDevice.isReachable && !root.currentDevice.isPaired && !root.currentDevice.isPairRequestedByPeer && !root.currentDevice.isPairRequested helpfulAction: Kirigami.Action { @@ -138,7 +138,7 @@ Kirigami.ScrollablePage { } Kirigami.PlaceholderMessage { - text: i18nd("kdeconnect-app", "Pair requested") + text: i18nd("kdeconnect-app", "Pair requested\nKey: " + root.currentDevice.verificationKey) anchors.centerIn: parent visible: root.currentDevice && root.currentDevice.isReachable && root.currentDevice.isPairRequested QQC2.BusyIndicator { @@ -147,7 +147,7 @@ Kirigami.ScrollablePage { } Kirigami.PlaceholderMessage { - text: i18n("Pair requested") + text: i18n("Pair requested\nKey: " + root.currentDevice.verificationKey) visible: root.currentDevice && root.currentDevice.isPairRequestedByPeer anchors.centerIn: parent spacing: Kirigami.Units.largeSpacing diff --git a/core/device.cpp b/core/device.cpp index 6b5edae2a..0288c0e8d 100644 --- a/core/device.cpp +++ b/core/device.cpp @@ -468,7 +468,7 @@ QSslCertificate Device::certificate() const return d->m_deviceInfo.certificate; } -QByteArray Device::verificationKey() const +QString Device::verificationKey() const { auto a = KdeConnectConfig::instance().certificate().publicKey().toDer(); auto b = certificate().publicKey().toDer(); @@ -479,7 +479,7 @@ QByteArray Device::verificationKey() const QCryptographicHash hash(QCryptographicHash::Sha256); hash.addData(a); hash.addData(b); - return hash.result().toHex(); + return QString::fromLatin1(hash.result().toHex().left(8).toUpper()); } QString Device::pluginIconName(const QString &pluginName) diff --git a/core/device.h b/core/device.h index c5fb8e293..e3d420929 100644 --- a/core/device.h +++ b/core/device.h @@ -26,6 +26,7 @@ class KDECONNECTCORE_EXPORT Device : public QObject Q_PROPERTY(QString type READ typeAsString NOTIFY typeChanged) Q_PROPERTY(QString name READ name NOTIFY nameChanged) Q_PROPERTY(QString iconName READ iconName CONSTANT) + Q_PROPERTY(QString verificationKey READ verificationKey CONSTANT) Q_PROPERTY(QString statusIconName READ statusIconName NOTIFY statusIconNameChanged) Q_PROPERTY(bool isReachable READ isReachable NOTIFY reachableChanged) Q_PROPERTY(bool isPaired READ isPaired NOTIFY pairStateChanged) @@ -64,7 +65,7 @@ public: }; QString iconName() const; QString statusIconName() const; - Q_SCRIPTABLE QByteArray verificationKey() const; + Q_SCRIPTABLE QString verificationKey() const; Q_SCRIPTABLE QString encryptionInfo() const; // Add and remove links diff --git a/daemon/kdeconnectd.cpp b/daemon/kdeconnectd.cpp index b887aaa24..718936d47 100644 --- a/daemon/kdeconnectd.cpp +++ b/daemon/kdeconnectd.cpp @@ -53,8 +53,7 @@ public: notification->setIconName(QStringLiteral("dialog-information")); notification->setComponentName(QStringLiteral("kdeconnect")); notification->setTitle(QStringLiteral("KDE Connect")); - notification->setText( - i18n("Pairing request from %1\nKey: %2...", device->name().toHtmlEscaped(), QString::fromUtf8(device->verificationKey().left(8)))); + notification->setText(i18n("Pairing request from %1\nKey: %2", device->name().toHtmlEscaped(), device->verificationKey())); QString deviceId = device->id(); auto openSettings = [deviceId, notification] { OpenConfig oc; diff --git a/kcm/kcm.cpp b/kcm/kcm.cpp index 8698501ca..886c8cac6 100644 --- a/kcm/kcm.cpp +++ b/kcm/kcm.cpp @@ -180,7 +180,7 @@ void KdeConnectKcm::resetCurrentDevice() void KdeConnectKcm::resetDeviceView() { - kcmUi.verificationKey->setText(i18n("Key: %1", QString::fromUtf8(currentDevice->verificationKey()))); + kcmUi.verificationKey->setText(i18n("Key: %1", currentDevice->verificationKey())); kcmUi.name_label->setText(currentDevice->name()); setWhenAvailable(