From 2623f4b811a720056b9ff82b5eed8dc7b3cbbd8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20M=C3=BCller?= Date: Wed, 12 Jul 2023 11:28:53 +0200 Subject: [PATCH 1/3] Show advanced group box's contents upon problems --- .../pages/accountconfiguredwizardpage.cpp | 5 +++++ .../pages/accountconfiguredwizardpage.h | 2 ++ src/gui/newwizard/setupwizardcontroller.cpp | 18 ++++++++++++++++-- src/gui/newwizard/setupwizardcontroller.h | 3 ++- src/gui/newwizard/setupwizardcontroller_p.h | 15 +++++++++++++++ 5 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 src/gui/newwizard/setupwizardcontroller_p.h diff --git a/src/gui/newwizard/pages/accountconfiguredwizardpage.cpp b/src/gui/newwizard/pages/accountconfiguredwizardpage.cpp index baba68562d1..ca6b165a7ac 100644 --- a/src/gui/newwizard/pages/accountconfiguredwizardpage.cpp +++ b/src/gui/newwizard/pages/accountconfiguredwizardpage.cpp @@ -187,4 +187,9 @@ bool AccountConfiguredWizardPage::validateInput() // nothing to validate here return true; } + +void AccountConfiguredWizardPage::setShowAdvancedSettings(bool showAdvancedSettings) +{ + _ui->advancedConfigGroupBox->setChecked(showAdvancedSettings); +} } diff --git a/src/gui/newwizard/pages/accountconfiguredwizardpage.h b/src/gui/newwizard/pages/accountconfiguredwizardpage.h index 3a58f3e76a3..af95a742572 100644 --- a/src/gui/newwizard/pages/accountconfiguredwizardpage.h +++ b/src/gui/newwizard/pages/accountconfiguredwizardpage.h @@ -39,6 +39,8 @@ class AccountConfiguredWizardPage : public AbstractSetupWizardPage bool validateInput() override; + void setShowAdvancedSettings(bool showAdvancedSettings); + private: ::Ui::AccountConfiguredWizardPage *_ui; }; diff --git a/src/gui/newwizard/setupwizardcontroller.cpp b/src/gui/newwizard/setupwizardcontroller.cpp index 808c0e89000..981926043fa 100644 --- a/src/gui/newwizard/setupwizardcontroller.cpp +++ b/src/gui/newwizard/setupwizardcontroller.cpp @@ -24,6 +24,8 @@ namespace { using namespace OCC; using namespace OCC::Wizard; +using namespace SetupWizardControllerPrivate; + /** * Generate list of wizard states to put in the navigation. * The actual wizard may be in states not within this list to perform tasks in the background without user interaction @@ -103,7 +105,7 @@ SetupWizardWindow *SetupWizardController::window() return _context->window(); } -void SetupWizardController::changeStateTo(SetupWizardState nextState) +void SetupWizardController::changeStateTo(SetupWizardState nextState, ChangeReason reason) { // validate initial state Q_ASSERT(nextState == SetupWizardState::ServerUrlState || _currentState != nullptr); @@ -137,6 +139,18 @@ void SetupWizardController::changeStateTo(SetupWizardState nextState) } case SetupWizardState::AccountConfiguredState: { _currentState = new AccountConfiguredSetupWizardState(_context); + + switch (reason) { + case ChangeReason::Default: + break; + case ChangeReason::EvaluationFailed: + // whenever the evaluation of the last page fails, it's safe to assume it's due to some issue with the advanced + // therefore, we want to show them in that case + auto *page = dynamic_cast(_currentState->page()); + if (OC_ENSURE(page != nullptr)) { + page->setShowAdvancedSettings(true); + } + } break; } default: @@ -207,7 +221,7 @@ void SetupWizardController::changeStateTo(SetupWizardState nextState) connect(_currentState, &AbstractSetupWizardState::evaluationFailed, this, [this](const QString &errorMessage) { _currentState->deleteLater(); _context->window()->showErrorMessage(errorMessage); - changeStateTo(_currentState->state()); + changeStateTo(_currentState->state(), ChangeReason::EvaluationFailed); }); _context->window()->displayPage(_currentState->page(), _currentState->state()); diff --git a/src/gui/newwizard/setupwizardcontroller.h b/src/gui/newwizard/setupwizardcontroller.h index 4037ef6e46b..413939e84e3 100644 --- a/src/gui/newwizard/setupwizardcontroller.h +++ b/src/gui/newwizard/setupwizardcontroller.h @@ -20,6 +20,7 @@ #include "pages/abstractsetupwizardpage.h" #include "setupwizardaccountbuilder.h" #include "setupwizardcontext.h" +#include "setupwizardcontroller_p.h" #include "setupwizardwindow.h" #include "states/abstractsetupwizardstate.h" @@ -53,7 +54,7 @@ class SetupWizardController : public QObject void finished(AccountPtr newAccount, SyncMode syncMode, const QVariantMap &dynamicRegistrationData); private: - void changeStateTo(SetupWizardState nextState); + void changeStateTo(SetupWizardState nextState, SetupWizardControllerPrivate::ChangeReason reason = SetupWizardControllerPrivate::ChangeReason::Default); SetupWizardContext *_context = nullptr; diff --git a/src/gui/newwizard/setupwizardcontroller_p.h b/src/gui/newwizard/setupwizardcontroller_p.h new file mode 100644 index 00000000000..4713e59a571 --- /dev/null +++ b/src/gui/newwizard/setupwizardcontroller_p.h @@ -0,0 +1,15 @@ +#pragma once + +#include + +namespace OCC::Wizard::SetupWizardControllerPrivate { + +Q_NAMESPACE + +enum class ChangeReason { + Default, + EvaluationFailed, +}; +Q_ENUM_NS(ChangeReason) + +} From dd9461f54eab769065f327033d673e8b4f45626e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20M=C3=BCller?= Date: Wed, 12 Jul 2023 11:29:06 +0200 Subject: [PATCH 2/3] Remember last sync target directory --- src/gui/newwizard/setupwizardaccountbuilder.cpp | 5 +++++ src/gui/newwizard/setupwizardaccountbuilder.h | 1 + .../states/accountconfiguredsetupwizardstate.cpp | 14 ++++++++++---- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/gui/newwizard/setupwizardaccountbuilder.cpp b/src/gui/newwizard/setupwizardaccountbuilder.cpp index c0f98a7ee87..fb3821e17ba 100644 --- a/src/gui/newwizard/setupwizardaccountbuilder.cpp +++ b/src/gui/newwizard/setupwizardaccountbuilder.cpp @@ -184,6 +184,11 @@ void SetupWizardAccountBuilder::setDefaultSyncTargetDir(const QString &syncTarge _defaultSyncTargetDir = syncTargetDir; } +QString SetupWizardAccountBuilder::defaultSyncTargetDir() const +{ + return _defaultSyncTargetDir; +} + QString SetupWizardAccountBuilder::legacyWebFingerUsername() const { return _legacyWebFingerUsername; diff --git a/src/gui/newwizard/setupwizardaccountbuilder.h b/src/gui/newwizard/setupwizardaccountbuilder.h index 44a4db95afa..e9ba094970e 100644 --- a/src/gui/newwizard/setupwizardaccountbuilder.h +++ b/src/gui/newwizard/setupwizardaccountbuilder.h @@ -145,6 +145,7 @@ class SetupWizardAccountBuilder // getter is not needed at the moment void setDefaultSyncTargetDir(const QString &syncTargetDir); + QString defaultSyncTargetDir() const; /** * Store custom CA certificate for the newly built account. diff --git a/src/gui/newwizard/states/accountconfiguredsetupwizardstate.cpp b/src/gui/newwizard/states/accountconfiguredsetupwizardstate.cpp index b125811cdd8..0960f5c483e 100644 --- a/src/gui/newwizard/states/accountconfiguredsetupwizardstate.cpp +++ b/src/gui/newwizard/states/accountconfiguredsetupwizardstate.cpp @@ -55,8 +55,13 @@ AccountConfiguredSetupWizardState::AccountConfiguredSetupWizardState(SetupWizard return _context->accountBuilder().serverUrl(); }(); - _page = new AccountConfiguredWizardPage(FolderMan::suggestSyncFolder(urlToSuggestSyncFolderFor, _context->accountBuilder().displayName()), vfsIsAvailable, - enableVfsByDefault, vfsModeIsExperimental); + QString defaultSyncTargetDir = _context->accountBuilder().defaultSyncTargetDir(); + + if (defaultSyncTargetDir.isEmpty()) { + defaultSyncTargetDir = FolderMan::suggestSyncFolder(urlToSuggestSyncFolderFor, _context->accountBuilder().displayName()); + } + + _page = new AccountConfiguredWizardPage(defaultSyncTargetDir, vfsIsAvailable, enableVfsByDefault, vfsModeIsExperimental); } SetupWizardState AccountConfiguredSetupWizardState::state() const @@ -72,6 +77,9 @@ void AccountConfiguredSetupWizardState::evaluatePage() if (accountConfiguredSetupWizardPage->syncMode() != Wizard::SyncMode::ConfigureUsingFolderWizard) { QString syncTargetDir = QDir::fromNativeSeparators(accountConfiguredSetupWizardPage->syncTargetDir()); + // make sure we remember it now so we can show it to the user again upon failures + _context->accountBuilder().setDefaultSyncTargetDir(syncTargetDir); + const QString errorMessageTemplate = tr("Invalid local download directory: %1"); if (!QDir::isAbsolutePath(syncTargetDir)) { @@ -84,8 +92,6 @@ void AccountConfiguredSetupWizardState::evaluatePage() Q_EMIT evaluationFailed(errorMessageTemplate.arg(invalidPathErrorMessage)); return; } - - _context->accountBuilder().setDefaultSyncTargetDir(syncTargetDir); } Q_EMIT evaluationSuccessful(); From 461a326cc004b2fbb93316ffc9042cc2f3ec25b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20M=C3=BCller?= Date: Fri, 21 Jul 2023 16:56:49 +0200 Subject: [PATCH 3/3] Remove recursive include --- src/gui/newwizard/enums.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gui/newwizard/enums.h b/src/gui/newwizard/enums.h index 4e45fdf8197..9f5604bd170 100644 --- a/src/gui/newwizard/enums.h +++ b/src/gui/newwizard/enums.h @@ -15,7 +15,6 @@ #pragma once #include "common/utility.h" -#include "enums.h" #include