From 928911e33c285776a67a8d59d473b1018e19b745 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Mon, 2 Sep 2024 11:13:24 -0400 Subject: [PATCH] Settings: Overhaul the Security page This improves the organization of this page, which is starting to become a bit of a mess. The "Hide images and video events" option is moved here, and the page is rebranded accordingly for "Security & Safety". Unnecessary headings are removed, and the ignored users button is moved to the top of the page. Explanations for the import/keys buttons are added. The key display is removed as it's not useful for the user (because they don't know what to do with it) nor developers (because you can't copy it.) We can add it back somewhere else. This has the added benefit of making the whole page fit in the default settings window size too. --- src/settings/NeoChatGeneralPage.qml | 17 ------ src/settings/NeoChatSecurityPage.qml | 80 +++++++++++++++------------- src/settings/NeoChatSettingsView.qml | 2 +- 3 files changed, 44 insertions(+), 55 deletions(-) diff --git a/src/settings/NeoChatGeneralPage.qml b/src/settings/NeoChatGeneralPage.qml index 604772b5f..d58ad9ffd 100644 --- a/src/settings/NeoChatGeneralPage.qml +++ b/src/settings/NeoChatGeneralPage.qml @@ -194,23 +194,6 @@ FormCard.FormCardPage { NeoChatConfig.save(); } } - - FormCard.FormDelegateSeparator { - above: showAvatarChangeDelegate - below: hideImagesDelegate - } - - FormCard.FormCheckDelegate { - id: hideImagesDelegate - text: i18nc("@label:checkbox", "Hide image and video events by default") - description: i18nc("@info", "When this option is enabled, images and videos are only shown after a button is clicked.") - checked: NeoChatConfig.hideImages - enabled: !NeoChatConfig.isHideImagesImmutable - onToggled: { - NeoChatConfig.hideImages = checked; - NeoChatConfig.save(); - } - } } FormCard.FormHeader { title: i18nc("Chat Editor", "Editor") diff --git a/src/settings/NeoChatSecurityPage.qml b/src/settings/NeoChatSecurityPage.qml index dc5c9baad..dc756166e 100644 --- a/src/settings/NeoChatSecurityPage.qml +++ b/src/settings/NeoChatSecurityPage.qml @@ -3,6 +3,7 @@ import QtQuick import QtQuick.Controls as QQC2 +import QtQuick.Layouts import org.kde.kirigami as Kirigami import org.kde.kirigamiaddons.formcard as FormCard @@ -15,7 +16,7 @@ FormCard.FormCardPage { required property NeoChatConnection connection - title: i18nc("@title", "Security") + title: i18nc("@title", "Security & Safety") header: KirigamiComponents.Banner { id: banner @@ -24,13 +25,39 @@ FormCard.FormCardPage { type: Kirigami.MessageType.Error } - FormCard.FormHeader { - title: i18nc("@title:group", "Invitations") - } FormCard.FormCard { + Layout.topMargin: Kirigami.Units.largeSpacing + FormCard.FormButtonDelegate { + id: ignoredUsersDelegate + text: i18nc("@action:button", "Ignored Users") + icon.name: "im-invisible-user" + onClicked: root.QQC2.ApplicationWindow.window.pageStack.pushDialogLayer(ignoredUsersDialogComponent, {}, { + title: i18nc("@title:window", "Ignored Users") + }); + } + FormCard.FormDelegateSeparator { + above: ignoredUsersDelegate + below: hideImagesDelegate + } FormCard.FormCheckDelegate { + id: hideImagesDelegate + text: i18nc("@label:checkbox", "Hide images and videos by default") + description: i18nc("@info", "When this option is enabled, images and videos are only shown after a button is clicked.") + checked: NeoChatConfig.hideImages + enabled: !NeoChatConfig.isHideImagesImmutable + onToggled: { + NeoChatConfig.hideImages = checked; + NeoChatConfig.save(); + } + } + FormCard.FormDelegateSeparator { + above: hideImagesDelegate + below: rejectInvitationsDelegate + } + FormCard.FormCheckDelegate { + id: rejectInvitationsDelegate text: i18nc("@option:check", "Reject invitations from unknown users") - description: connection.canCheckMutualRooms ? i18n("If enabled, NeoChat will reject invitations from users you don't share a room with.") : i18n("Your server does not support this setting.") + description: connection.canCheckMutualRooms ? i18nc("@info", "If enabled, NeoChat will reject invitations from users you don't share a room with.") : i18nc("@info", "Your server does not support this setting.") checked: NeoChatConfig.rejectUnknownInvites enabled: !NeoChatConfig.isRejectUnknownInvitesImmutable && connection.canCheckMutualRooms onToggled: { @@ -40,42 +67,15 @@ FormCard.FormCardPage { } } FormCard.FormHeader { - title: i18nc("@title:group", "Ignored Users") - } - FormCard.FormCard { - FormCard.FormButtonDelegate { - text: i18nc("@action:button", "Manage ignored users") - onClicked: root.QQC2.ApplicationWindow.window.pageStack.pushDialogLayer(ignoredUsersDialogComponent, {}, { - title: i18nc("@title:window", "Ignored Users") - }); - } - } - FormCard.FormHeader { - title: i18nc("@title", "Keys") - } - FormCard.FormCard { - FormCard.FormTextDelegate { - text: connection.deviceKey - description: i18n("Device key") - } - FormCard.FormTextDelegate { - text: connection.encryptionKey - description: i18n("Encryption key") - } - FormCard.FormTextDelegate { - text: connection.deviceId - description: i18n("Device id") - } - } - - FormCard.FormHeader { + title: i18nc("@title", "Encryption") visible: Controller.csSupported - title: i18nc("@title", "Encryption Keys") } FormCard.FormCard { visible: Controller.csSupported FormCard.FormButtonDelegate { - text: i18nc("@action:button", "Import Encryption Keys") + id: importKeysDelegate + text: i18nc("@action:button", "Import Keys") + description: i18nc("@info", "Import encryption keys from a backup.") icon.name: "document-import" onClicked: { let dialog = root.QQC2.ApplicationWindow.window.pageStack.pushDialogLayer(Qt.createComponent("org.kde.neochat.settings", "ImportKeysDialog"), { @@ -91,8 +91,14 @@ FormCard.FormCardPage { banner.visible = false; } } + FormCard.FormDelegateSeparator { + above: importKeysDelegate + below: exportKeysDelegate + } FormCard.FormButtonDelegate { - text: i18nc("@action:button", "Export Encryption Keys") + id: exportKeysDelegate + text: i18nc("@action:button", "Export Keys") + description: i18nc("@info", "Export this device's encryption keys.") icon.name: "document-export" onClicked: { root.QQC2.ApplicationWindow.window.pageStack.pushDialogLayer(Qt.createComponent("org.kde.neochat.settings", "ExportKeysDialog"), { diff --git a/src/settings/NeoChatSettingsView.qml b/src/settings/NeoChatSettingsView.qml index ca54f693f..744491c6f 100644 --- a/src/settings/NeoChatSettingsView.qml +++ b/src/settings/NeoChatSettingsView.qml @@ -48,7 +48,7 @@ KirigamiSettings.ConfigurationView { }, KirigamiSettings.ConfigurationModule { moduleId: "security" - text: i18n("Security") + text: i18nc("@title", "Security & Safety") icon.name: "preferences-security" page: () => Qt.createComponent("org.kde.neochat.settings", "NeoChatSecurityPage") initialProperties: () => {