From c315e817b2c64e22bfce8dbc40a40e355e2b6bd1 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Wed, 8 Jan 2025 16:38:39 -0500 Subject: [PATCH] Add an option to disable encryption in new chats Right now NeoChat (or more technically, libQuotient) decides to use encryption by default in new chats. Some users may not prefer or need this, so a new option is added under Security to change this behavior. BUG: 498375 --- src/neochatconfig.kcfg | 4 ++++ src/neochatconnection.cpp | 4 ++++ src/settings/NeoChatSecurityPage.qml | 15 +++++++++++++++ 3 files changed, 23 insertions(+) diff --git a/src/neochatconfig.kcfg b/src/neochatconfig.kcfg index b0f45eb45..e706d0f7e 100644 --- a/src/neochatconfig.kcfg +++ b/src/neochatconfig.kcfg @@ -223,6 +223,10 @@ false + + + true + diff --git a/src/neochatconnection.cpp b/src/neochatconnection.cpp index 0d5977c56..21a9a6650 100644 --- a/src/neochatconnection.cpp +++ b/src/neochatconnection.cpp @@ -145,6 +145,10 @@ void NeoChatConnection::connectSignals() }); }, Qt::SingleShotConnection); + setDirectChatEncryptionDefault(NeoChatConfig::preferUsingEncryption()); + connect(NeoChatConfig::self(), &NeoChatConfig::PreferUsingEncryptionChanged, this, [] { + setDirectChatEncryptionDefault(NeoChatConfig::preferUsingEncryption()); + }); } int NeoChatConnection::badgeNotificationCount() const diff --git a/src/settings/NeoChatSecurityPage.qml b/src/settings/NeoChatSecurityPage.qml index ae21a4fd8..1861193ac 100644 --- a/src/settings/NeoChatSecurityPage.qml +++ b/src/settings/NeoChatSecurityPage.qml @@ -65,6 +65,21 @@ FormCard.FormCardPage { NeoChatConfig.save(); } } + FormCard.FormDelegateSeparator { + above: rejectInvitationsDelegate + below: preferEncryptionDelegate + } + FormCard.FormCheckDelegate { + id: preferEncryptionDelegate + text: i18nc("@option:check", "Turn on encryption in new chats") + description: i18nc("@info", "If enabled, NeoChat will use encryption when starting new direct messages.") + checked: NeoChatConfig.preferUsingEncryption + enabled: !NeoChatConfig.preferUsingEncryptionImmutable + onToggled: { + NeoChatConfig.preferUsingEncryption = checked; + NeoChatConfig.save(); + } + } } FormCard.FormHeader { title: i18nc("@title:group", "Encryption")