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 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/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/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) + +} 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();