diff --git a/src/app/qml/AccountMenu.qml b/src/app/qml/AccountMenu.qml index 3d1cd0b93..2f7a0bd0b 100644 --- a/src/app/qml/AccountMenu.qml +++ b/src/app/qml/AccountMenu.qml @@ -88,7 +88,7 @@ KirigamiComponents.ConvergentContextMenu { Kirigami.Action { text: i18nc("@action:inmenu", "Verify This Device") icon.name: "security-low" - visible: !root.connection.isVerifiedSession() + visible: !root.connection.isVerifiedSession onTriggered: { root.connection.startSelfVerification(); const dialog = Qt.createComponent("org.kde.kirigami", "PromptDialog").createObject(QQC2.Overlay.overlay, { diff --git a/src/app/qml/KeyVerificationDialog.qml b/src/app/qml/KeyVerificationDialog.qml index e108de7d1..6f17b2d04 100644 --- a/src/app/qml/KeyVerificationDialog.qml +++ b/src/app/qml/KeyVerificationDialog.qml @@ -4,6 +4,7 @@ import QtQuick import QtQuick.Controls as QQC2 import QtQuick.Layouts +import QtQuick.Window import QtQml import org.kde.kirigami as Kirigami @@ -170,6 +171,7 @@ Kirigami.Page { return ""; } } + onDone: root.QQC2.Window.window.close() } } diff --git a/src/libneochat/neochatconnection.cpp b/src/libneochat/neochatconnection.cpp index ec303f6af..8ff5f591d 100644 --- a/src/libneochat/neochatconnection.cpp +++ b/src/libneochat/neochatconnection.cpp @@ -141,6 +141,12 @@ void NeoChatConnection::connectSignals() }); }, Qt::SingleShotConnection); + + connect(this, &Connection::sessionVerified, this, [this](const QString &userId, const QString &deviceId) { + if (userId == this->userId() && deviceId == this->deviceId()) { + Q_EMIT ownSessionVerified(); + } + }); } int NeoChatConnection::badgeNotificationCount() const diff --git a/src/libneochat/neochatconnection.h b/src/libneochat/neochatconnection.h index fac28411f..8389481df 100644 --- a/src/libneochat/neochatconnection.h +++ b/src/libneochat/neochatconnection.h @@ -90,6 +90,11 @@ class NeoChatConnection : public Quotient::Connection */ Q_PROPERTY(bool enablePushNotifications READ enablePushNotifications NOTIFY enablePushNotificationsChanged) + /** + * @brief True if this connection is a verified session. + */ + Q_PROPERTY(bool isVerifiedSession READ isVerifiedSession NOTIFY ownSessionVerified) + public: /** * @brief Defines the status after an attempt to change the password on an account. @@ -209,7 +214,7 @@ public: /** * @return True if this connection is a verified session. */ - Q_INVOKABLE bool isVerifiedSession() const; + bool isVerifiedSession() const; Q_SIGNALS: void globalUrlPreviewEnabledChanged(); @@ -242,6 +247,11 @@ Q_SIGNALS: */ void roomAboutToBeLeft(const QString &id); + /** + * @brief When the connection's own verification state changes. + */ + void ownSessionVerified(); + private: static bool m_globalUrlPreviewDefault; static PushRuleAction::Action m_defaultAction; diff --git a/src/settings/DevicesPage.qml b/src/settings/DevicesPage.qml index c3fdb2b2a..ac41ac50e 100644 --- a/src/settings/DevicesPage.qml +++ b/src/settings/DevicesPage.qml @@ -38,7 +38,7 @@ FormCard.FormCardPage { 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() + visible: !root.connection.isVerifiedSession onClicked: { root.connection.startSelfVerification(); const dialog = Qt.createComponent("org.kde.kirigami", "PromptDialog").createObject(QQC2.Overlay.overlay, { @@ -94,6 +94,9 @@ FormCard.FormCardPage { title: i18n("Remove device") standardButtons: QQC2.Dialog.Cancel + + Component.onCompleted: passwordField.forceActiveFocus() + FormCard.FormCard { FormCard.FormTextFieldDelegate { id: passwordField