From fba06a745c9b0e5837d53a109b119454fc3a62a6 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Fri, 11 Aug 2023 15:05:42 +0800 Subject: [PATCH] Add warning prior to folder encryption to prevent unknowing users from creating unrecoverable encrypted folders Signed-off-by: Claudio Cambra --- src/gui/accountsettings.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/gui/accountsettings.cpp b/src/gui/accountsettings.cpp index 7613595cd..994fbe3c3 100644 --- a/src/gui/accountsettings.cpp +++ b/src/gui/accountsettings.cpp @@ -109,6 +109,27 @@ void showEnableE2eeWithVirtualFilesWarningDialog(std::function onAcc messageBox->open(); } +void showEnableE2eeWarningDialog(std::function onAccept) +{ + const auto messageBox = new QMessageBox; + messageBox->setAttribute(Qt::WA_DeleteOnClose); + messageBox->setText(AccountSettings::tr("End-to-end Encryption")); + messageBox->setInformativeText( + AccountSettings::tr("This will encrypt your folder and all files within it. " + "These files will no longer be accessible without your encryption mnemonic key. " + "\nThis process is not reversible. Are you sure you want to proceed?")); + messageBox->setIcon(QMessageBox::Warning); + const auto dontEncryptButton = messageBox->addButton(QMessageBox::StandardButton::Cancel); + Q_ASSERT(dontEncryptButton); + dontEncryptButton->setText(AccountSettings::tr("Do not encrypt folder")); + const auto encryptButton = messageBox->addButton(QMessageBox::StandardButton::Ok); + Q_ASSERT(encryptButton); + encryptButton->setText(AccountSettings::tr("Encrypt folder")); + QObject::connect(messageBox, &QMessageBox::accepted, onAccept); + + messageBox->open(); +} + /** * Adjusts the mouse cursor based on the region it is on over the folder tree view. * @@ -415,7 +436,8 @@ void AccountSettings::slotMarkSubfolderEncrypted(FolderStatusModel::SubFolderInf showEnableE2eeWithVirtualFilesWarningDialog(encryptFolder); return; } - encryptFolder(); + + showEnableE2eeWarningDialog(encryptFolder); } void AccountSettings::slotEditCurrentIgnoredFiles()