From f06ea6a328b14201bbfadd430596019085219cbb Mon Sep 17 00:00:00 2001 From: Camila Ayres Date: Mon, 9 Dec 2024 11:06:32 +0100 Subject: [PATCH 1/3] Add bool theme option to display legacy import dialog. Signed-off-by: Camila Ayres --- NEXTCLOUD.cmake | 1 + config.h.in | 1 + src/libsync/theme.cpp | 9 +++++++++ src/libsync/theme.h | 7 +++++++ 4 files changed, 18 insertions(+) diff --git a/NEXTCLOUD.cmake b/NEXTCLOUD.cmake index e2632dbcfb6d6..3cd8a49c09b41 100644 --- a/NEXTCLOUD.cmake +++ b/NEXTCLOUD.cmake @@ -28,6 +28,7 @@ set( APPLICATION_REV_DOMAIN "com.nextcloud.desktopclient" ) set( APPLICATION_VIRTUALFILE_SUFFIX "nextcloud" CACHE STRING "Virtual file suffix (not including the .)") set( APPLICATION_OCSP_STAPLING_ENABLED OFF ) set( APPLICATION_FORBID_BAD_SSL OFF ) +option( APPLICATION_DISPLAY_LEGACY_IMPORT_DIALOG "Display legacy import dialog" ON ) set( LINUX_PACKAGE_SHORTNAME "nextcloud" ) set( LINUX_APPLICATION_ID "${APPLICATION_REV_DOMAIN}.${LINUX_PACKAGE_SHORTNAME}") diff --git a/config.h.in b/config.h.in index be3005502032f..faaec1bea23f6 100644 --- a/config.h.in +++ b/config.h.in @@ -38,6 +38,7 @@ #cmakedefine01 ENFORCE_VIRTUAL_FILES_SYNC_FOLDER #cmakedefine DO_NOT_USE_PROXY "@DO_NOT_USE_PROXY@" #cmakedefine ENFORCE_SINGLE_ACCOUNT "@ENFORCE_SINGLE_ACCOUNT@" +#cmakedefine01 APPLICATION_DISPLAY_LEGACY_IMPORT_DIALOG #cmakedefine ZLIB_FOUND @ZLIB_FOUND@ diff --git a/src/libsync/theme.cpp b/src/libsync/theme.cpp index a77aa4450d7f1..51a42f4ce92bf 100644 --- a/src/libsync/theme.cpp +++ b/src/libsync/theme.cpp @@ -1036,6 +1036,15 @@ bool Theme::darkMode() const return isDarkFromStyle(); } +bool Theme::displayLegacyImportDialog() const +{ +#if defined APPLICATION_DISPLAY_LEGACY_IMPORT_DIALOG && APPLICATION_DISPLAY_LEGACY_IMPORT_DIALOG + return true; +#else + return false; +#endif +} + void Theme::setOverrideServerUrl(const QString &overrideServerUrl) { auto validOverrideServerUrl = overrideServerUrl; diff --git a/src/libsync/theme.h b/src/libsync/theme.h index 9e12ba709f51c..1c1416ef64cdf 100644 --- a/src/libsync/theme.h +++ b/src/libsync/theme.h @@ -604,6 +604,13 @@ class OWNCLOUDSYNC_EXPORT Theme : public QObject [[nodiscard]] QVariantMap systemPalette() const; [[nodiscard]] bool darkMode() const; + /** + * Display legacy import dialog + * + * The user will interact with the dialog to import legacy account when set to true + */ + [[nodiscard]] bool displayLegacyImportDialog() const; + public slots: void setOverrideServerUrl(const QString &overrideServerUrl); void setForceOverrideServerUrl(bool forceOverride); From 2cfe01c162518e73b7023024a8d354752fd80480 Mon Sep 17 00:00:00 2001 From: Camila Ayres Date: Mon, 9 Dec 2024 11:24:16 +0100 Subject: [PATCH 2/3] Check for the option to display legacy import dialog. Signed-off-by: Camila Ayres --- src/gui/accountmanager.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/gui/accountmanager.cpp b/src/gui/accountmanager.cpp index f27d2742703a7..6619e70fee725 100644 --- a/src/gui/accountmanager.cpp +++ b/src/gui/accountmanager.cpp @@ -170,7 +170,8 @@ bool AccountManager::restoreFromLegacySettings() // try to open the correctly themed settings auto settings = ConfigFile::settingsWithGroup(Theme::instance()->appName()); - auto displayMessageBoxWarning = false; + auto wasLegacyImportDialogDisplayed = false; + const auto displayLegacyImportDialog = Theme::instance()->displayLegacyImportDialog(); // if the settings file could not be opened, the childKeys list is empty // then try to load settings from a very old place @@ -206,10 +207,11 @@ bool AccountManager::restoreFromLegacySettings() oCSettings->beginGroup(QLatin1String(accountsC)); const auto accountsListSize = oCSettings->childGroups().size(); oCSettings->endGroup(); - if (const QFileInfo configFileInfo(configFile); configFileInfo.exists() && configFileInfo.isReadable()) { - displayMessageBoxWarning = true; + if (const QFileInfo configFileInfo(configFile); + configFileInfo.exists() && configFileInfo.isReadable()) { qCInfo(lcAccountManager) << "Migrate: checking old config " << configFile; - if (!forceLegacyImport() && accountsListSize > 0) { + if (!forceLegacyImport() && accountsListSize > 0 && displayLegacyImportDialog) { + wasLegacyImportDialogDisplayed = true; const auto importQuestion = accountsListSize > 1 ? tr("%1 accounts were detected from a legacy desktop client.\n" "Should the accounts be imported?").arg(QString::number(accountsListSize)) @@ -282,7 +284,7 @@ bool AccountManager::restoreFromLegacySettings() return true; } - if (displayMessageBoxWarning) { + if (wasLegacyImportDialogDisplayed) { QMessageBox::information(nullptr, tr("Legacy import"), tr("Could not import accounts from legacy client configuration.")); From 5456ed107ac7d3e3369f2c5f9404554ebf1341ed Mon Sep 17 00:00:00 2001 From: Camila Ayres Date: Mon, 9 Dec 2024 15:01:28 +0100 Subject: [PATCH 3/3] Move option APPLICATION_DISPLAY_LEGACY_IMPORT_DIALOG to CMakeLists.txt. Signed-off-by: Camila Ayres --- CMakeLists.txt | 2 ++ NEXTCLOUD.cmake | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 351b3eaa00c41..3c1d91f800855 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,6 +55,8 @@ else() set(APPLICATION_REV_DOMAIN_INSTALLER ${APPLICATION_REV_DOMAIN}) endif() +option( APPLICATION_DISPLAY_LEGACY_IMPORT_DIALOG "Display legacy import dialog" ON ) + # For usage in XML files we preprocess string(REPLACE "&" "&" APPLICATION_NAME_XML_ESCAPED "${APPLICATION_NAME}") string(REPLACE "<" "<" APPLICATION_NAME_XML_ESCAPED "${APPLICATION_NAME_XML_ESCAPED}") diff --git a/NEXTCLOUD.cmake b/NEXTCLOUD.cmake index 3cd8a49c09b41..e2632dbcfb6d6 100644 --- a/NEXTCLOUD.cmake +++ b/NEXTCLOUD.cmake @@ -28,7 +28,6 @@ set( APPLICATION_REV_DOMAIN "com.nextcloud.desktopclient" ) set( APPLICATION_VIRTUALFILE_SUFFIX "nextcloud" CACHE STRING "Virtual file suffix (not including the .)") set( APPLICATION_OCSP_STAPLING_ENABLED OFF ) set( APPLICATION_FORBID_BAD_SSL OFF ) -option( APPLICATION_DISPLAY_LEGACY_IMPORT_DIALOG "Display legacy import dialog" ON ) set( LINUX_PACKAGE_SHORTNAME "nextcloud" ) set( LINUX_APPLICATION_ID "${APPLICATION_REV_DOMAIN}.${LINUX_PACKAGE_SHORTNAME}")