From 5fe28cb183abaf6a0d8bcc974579c45eb6c356f9 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Wed, 16 Jul 2025 19:27:23 -0400 Subject: [PATCH] Suggest verifying your own device in Devices settings This button is currently hidden under the user menu, but it should be shown more prominently - especially under the Devices settings. The button under the user menu and this new one is now hidden when your device is already verified. --- src/app/qml/AccountMenu.qml | 3 ++- src/libneochat/neochatconnection.cpp | 5 +++++ src/libneochat/neochatconnection.h | 5 +++++ src/settings/DevicesCard.qml | 1 + src/settings/DevicesPage.qml | 19 +++++++++++++++++++ 5 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/app/qml/AccountMenu.qml b/src/app/qml/AccountMenu.qml index 04b4e01d5..bdc557dfa 100644 --- a/src/app/qml/AccountMenu.qml +++ b/src/app/qml/AccountMenu.qml @@ -88,9 +88,10 @@ KirigamiComponents.ConvergentContextMenu { }) } - QQC2.Action { + Kirigami.Action { text: i18nc("@action:inmenu", "Verify This Device") icon.name: "security-low" + visible: !root.connection.isVerifiedSession() onTriggered: { root.connection.startSelfVerification(); const dialog = Qt.createComponent("org.kde.kirigami", "PromptDialog").createObject(QQC2.Overlay.overlay, { diff --git a/src/libneochat/neochatconnection.cpp b/src/libneochat/neochatconnection.cpp index b4ed79d55..0db72a33f 100644 --- a/src/libneochat/neochatconnection.cpp +++ b/src/libneochat/neochatconnection.cpp @@ -558,4 +558,9 @@ bool NeoChatConnection::enablePushNotifications() const return m_pushNotificationsEnabled; } +bool NeoChatConnection::isVerifiedSession() const +{ + return isVerifiedDevice(userId(), deviceId()); +} + #include "moc_neochatconnection.cpp" diff --git a/src/libneochat/neochatconnection.h b/src/libneochat/neochatconnection.h index 84b22bbf5..fac28411f 100644 --- a/src/libneochat/neochatconnection.h +++ b/src/libneochat/neochatconnection.h @@ -206,6 +206,11 @@ public: LinkPreviewer *previewerForLink(const QUrl &link); + /** + * @return True if this connection is a verified session. + */ + Q_INVOKABLE bool isVerifiedSession() const; + Q_SIGNALS: void globalUrlPreviewEnabledChanged(); void labelChanged(); diff --git a/src/settings/DevicesCard.qml b/src/settings/DevicesCard.qml index 119f86a52..1e14de1d2 100644 --- a/src/settings/DevicesCard.qml +++ b/src/settings/DevicesCard.qml @@ -13,6 +13,7 @@ import org.kde.neochat ColumnLayout { id: root + default property alias delegates: devicesCard.delegates required property string title required property var type required property bool showVerifyButton diff --git a/src/settings/DevicesPage.qml b/src/settings/DevicesPage.qml index 4f417b8be..c3fdb2b2a 100644 --- a/src/settings/DevicesPage.qml +++ b/src/settings/DevicesPage.qml @@ -33,6 +33,25 @@ FormCard.FormCardPage { title: i18nc("@info:group", "This Device") type: DevicesModel.This showVerifyButton: false + + FormCard.FormButtonDelegate { + icon.name: "security-low" + text: i18nc("@action:button", "Verify This Device") + description: i18nc("@info:description", "This device is marked as insecure until it's verified by another device. It's recommended to verify as soon as possible.") + visible: !root.connection.isVerifiedSession() + onClicked: { + root.connection.startSelfVerification(); + const dialog = Qt.createComponent("org.kde.kirigami", "PromptDialog").createObject(QQC2.Overlay.overlay, { + title: i18nc("@title", "Verification Request Sent"), + subtitle: i18nc("@info:label", "To proceed, accept the verification request on another device."), + standardButtons: Kirigami.Dialog.Ok + }) + dialog.open(); + root.connection.onNewKeyVerificationSession.connect(() => { + dialog.close(); + }); + } + } } DevicesCard { title: i18nc("@info:group", "Verified Devices")