diff options
author | Fabian Müller <fmueller@owncloud.com> | 2022-06-09 16:46:21 +0300 |
---|---|---|
committer | Hannah von Reth <vonreth@kde.org> | 2022-07-01 18:46:52 +0300 |
commit | 1cbf68636c87b886a1c34f1946932818cadb6cf8 (patch) | |
tree | 5479b7a7d933cb3ce1f0c654b839e276258baa76 /src/gui | |
parent | b4048e5287f4c50c95f24024488638b667f304a5 (diff) |
Simplify setup wizard navigation
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/newwizard/CMakeLists.txt | 4 | ||||
-rw-r--r-- | src/gui/newwizard/navigation.cpp | 80 | ||||
-rw-r--r-- | src/gui/newwizard/navigation.h | 70 | ||||
-rw-r--r-- | src/gui/newwizard/pages/accountconfiguredwizardpage.cpp | 2 | ||||
-rw-r--r-- | src/gui/newwizard/pagination.cpp | 91 | ||||
-rw-r--r-- | src/gui/newwizard/pagination.h | 59 | ||||
-rw-r--r-- | src/gui/newwizard/setupwizardcontroller.cpp | 114 | ||||
-rw-r--r-- | src/gui/newwizard/setupwizardcontroller.h | 2 | ||||
-rw-r--r-- | src/gui/newwizard/setupwizardwindow.cpp | 26 | ||||
-rw-r--r-- | src/gui/newwizard/setupwizardwindow.h | 19 | ||||
-rw-r--r-- | src/gui/newwizard/setupwizardwindow.ui | 6 | ||||
-rw-r--r-- | src/gui/newwizard/states/accountconfiguredsetupwizardstate.cpp | 2 | ||||
-rw-r--r-- | src/gui/newwizard/states/basiccredentialssetupwizardstate.cpp | 2 | ||||
-rw-r--r-- | src/gui/newwizard/states/serverurlsetupwizardstate.cpp | 3 | ||||
-rw-r--r-- | src/gui/newwizard/states/setupwizardstate.h | 17 |
15 files changed, 256 insertions, 241 deletions
diff --git a/src/gui/newwizard/CMakeLists.txt b/src/gui/newwizard/CMakeLists.txt index a4d7309e6..475561c27 100644 --- a/src/gui/newwizard/CMakeLists.txt +++ b/src/gui/newwizard/CMakeLists.txt @@ -28,8 +28,8 @@ add_library(newwizard STATIC setupwizardaccountbuilder.cpp setupwizardaccountbuilder.h - pagination.cpp - pagination.h + navigation.cpp + navigation.h jobs/resolveurljobfactory.cpp jobs/resolveurljobfactory.h diff --git a/src/gui/newwizard/navigation.cpp b/src/gui/newwizard/navigation.cpp new file mode 100644 index 000000000..0c7cdb1c0 --- /dev/null +++ b/src/gui/newwizard/navigation.cpp @@ -0,0 +1,80 @@ +#include "navigation.h" + +#include <QDebug> +#include <QRadioButton> + +namespace OCC::Wizard { + +Navigation::Navigation(QWidget *parent) + : QWidget(parent) +{ + // this class manages its own layout + setLayout(new QHBoxLayout(this)); +} + +void Navigation::setEntries(const QList<SetupWizardState> &newEntries) +{ + // TODO: more advanced implementation (reuse existing buttons within layout) + // current active page is also lost that way + removeAllItems(); + + for (const auto state : newEntries) { + const QString &text = setupWizardStateToText(state); + + auto newButton = new QRadioButton(text, this); + + _entries.insert(state, newButton); + layout()->addWidget(newButton); + + connect(newButton, &QRadioButton::clicked, this, [this, state]() { + emit paginationEntryClicked(state); + }); + } + + enableOrDisableButtons(); +} + +// needed to clean up widgets we added to the layout +Navigation::~Navigation() noexcept +{ + removeAllItems(); +} + +void Navigation::removeAllItems() +{ + qDeleteAll(_entries); +} + +void Navigation::enableOrDisableButtons() +{ + for (const auto state : _entries.keys()) { + auto button = _entries.value(state); + + const auto enabled = [&state, this]() { + if (_enabled) { + return state < _activeState; + } + + return false; + }(); + + // TODO: use custom QRadioButton which doesn't need to be disabled to not be clickable + // can only jump to pages we have visited before + // to avoid resetting the current page, we don't want to enable the active page either + button->setEnabled(enabled); + } +} + +void Navigation::setActiveState(SetupWizardState newState) +{ + _activeState = newState; + + for (const auto key : _entries.keys()) { + auto button = _entries.value(newState); + button->setChecked(key == _activeState); + } + + enableOrDisableButtons(); +} + +} diff --git a/src/gui/newwizard/navigation.h b/src/gui/newwizard/navigation.h new file mode 100644 index 000000000..13b7911b4 --- /dev/null +++ b/src/gui/newwizard/navigation.h @@ -0,0 +1,70 @@ +/* + * Copyright (C) Fabian Müller <fmueller@owncloud.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +#pragma once + +#include "states/setupwizardstate.h" + +#include <QHBoxLayout> +#include <QMap> +#include <QRadioButton> +#include <QString> +#include <QWidget> + +namespace OCC::Wizard { + +/** + * Provides a radio button based quick navigation on the wizard's bottom side. + */ +class Navigation : public QWidget +{ + Q_OBJECT + +public: + explicit Navigation(QWidget *parent = nullptr); + + ~Navigation() noexcept override; + + /** + * Set or replace entries in the navigation. + * This method creates the corresponding buttons. + * @param newEntries ordered list of wizard states to be rendered in the navigation + */ + void setEntries(const QList<SetupWizardState> &newEntries); + +Q_SIGNALS: + /** + * Emitted when a pagination entry is clicked. + * This event is only emitted for previous states. + * @param clickedState state the user wants to switch to + */ + void paginationEntryClicked(SetupWizardState clickedState); + +public Q_SLOTS: + /** + * Change to another state. Applies changes to hosted UI elements (e.g., disables buttons, ) + * @param newState state to activate + */ + void setActiveState(SetupWizardState newState); + +private: + void removeAllItems(); + void enableOrDisableButtons(); + + QMap<SetupWizardState, QRadioButton *> _entries; + SetupWizardState _activeState = SetupWizardState::FirstState; + bool _enabled = true; +}; + +} diff --git a/src/gui/newwizard/pages/accountconfiguredwizardpage.cpp b/src/gui/newwizard/pages/accountconfiguredwizardpage.cpp index e4bb61362..154d743fc 100644 --- a/src/gui/newwizard/pages/accountconfiguredwizardpage.cpp +++ b/src/gui/newwizard/pages/accountconfiguredwizardpage.cpp @@ -86,7 +86,7 @@ AccountConfiguredWizardPage::AccountConfiguredWizardPage(const QString &defaultS }); // this should be handled on application startup, too - OC_ENFORCE(!Theme::instance()->forceVirtualFilesOption() || vfsIsAvailable); + Q_ASSERT(!Theme::instance()->forceVirtualFilesOption() || vfsIsAvailable); if (Theme::instance()->forceVirtualFilesOption()) { // this has no visual effect, but is needed for syncMode() diff --git a/src/gui/newwizard/pagination.cpp b/src/gui/newwizard/pagination.cpp deleted file mode 100644 index 9faa3a27a..000000000 --- a/src/gui/newwizard/pagination.cpp +++ /dev/null @@ -1,91 +0,0 @@ -#include "pagination.h" - -#include <QDebug> -#include <QRadioButton> - -namespace OCC::Wizard { - -Pagination::Pagination(QWidget *parent) - : QWidget(parent) - , _activePageIndex(0) - , _enabled(true) -{ - // this class manages its own layout - setLayout(new QHBoxLayout(this)); -} - -void Pagination::setEntries(const QStringList &newEntries) -{ - // TODO: more advanced implementation (reuse existing buttons within layout) - // current active page is also lost that way - removeAllItems(); - - for (PageIndex i = 0; i < newEntries.count(); ++i) { - auto entry = newEntries[i]; - - auto newButton = new QRadioButton(entry, this); - - _entries.append(newButton); - layout()->addWidget(newButton); - - connect(newButton, &QRadioButton::clicked, this, [this, i]() { - emit paginationEntryClicked(i); - }); - } - - enableOrDisableButtons(); -} - -// needed to clean up widgets we added to the layout -Pagination::~Pagination() noexcept -{ - removeAllItems(); -} - -void Pagination::removeAllItems() -{ - qDeleteAll(_entries); -} - -PageIndex Pagination::entriesCount() const -{ - return _entries.size(); -} - -void Pagination::enableOrDisableButtons() -{ - for (PageIndex i = 0; i < _entries.count(); ++i) { - const auto enabled = [=]() { - if (_enabled) { - return i < _activePageIndex; - } - - return false; - }(); - - // TODO: use custom QRadioButton which doesn't need to be disabled to not be clickable - // can only jump to pages we have visited before - // to avoid resetting the current page, we don't want to enable the active page either - _entries.at(i)->setEnabled(enabled); - } -} - -void Pagination::setActivePageIndex(PageIndex activePageIndex) -{ - _activePageIndex = activePageIndex; - - for (PageIndex i = 0; i < _entries.count(); ++i) { - // we don't want to store those buttons in this object's state - auto button = qobject_cast<QRadioButton *>(layout()->itemAt(i)->widget()); - button->setChecked(i == activePageIndex); - } - - enableOrDisableButtons(); -} - -PageIndex Pagination::activePageIndex() -{ - return _activePageIndex; -} - -} diff --git a/src/gui/newwizard/pagination.h b/src/gui/newwizard/pagination.h deleted file mode 100644 index 2ac2216e4..000000000 --- a/src/gui/newwizard/pagination.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) Fabian Müller <fmueller@owncloud.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - */ - -#pragma once - -#include <QHBoxLayout> -#include <QRadioButton> -#include <QString> -#include <QWidget> - -namespace OCC::Wizard { - -using PageIndex = QStringList::size_type; - -/** - * Renders pagination entries as radio buttons in a horizontal layout. - */ -class Pagination : public QWidget -{ - Q_OBJECT - -public: - explicit Pagination(QWidget *parent = nullptr); - - ~Pagination() noexcept override; - - void setEntries(const QStringList &newEntries); - - [[nodiscard]] PageIndex entriesCount() const; - - PageIndex activePageIndex(); - -Q_SIGNALS: - void paginationEntryClicked(PageIndex clickedPageIndex); - -public Q_SLOTS: - void setActivePageIndex(PageIndex activePageIndex); - -private: - void removeAllItems(); - void enableOrDisableButtons(); - - QList<QRadioButton *> _entries; - PageIndex _activePageIndex; - bool _enabled; -}; - -} diff --git a/src/gui/newwizard/setupwizardcontroller.cpp b/src/gui/newwizard/setupwizardcontroller.cpp index e8aa17ad9..4d66b7570 100644 --- a/src/gui/newwizard/setupwizardcontroller.cpp +++ b/src/gui/newwizard/setupwizardcontroller.cpp @@ -26,10 +26,14 @@ SetupWizardController::SetupWizardController(QWidget *parent) , _context(new SetupWizardContext(parent, this)) { // initialize pagination - const QStringList paginationEntries = { tr("Server URL"), tr("Credentials"), tr("Sync Options") }; - _context->window()->setPaginationEntries(paginationEntries); + _context->window()->setNavigationEntries({ + SetupWizardState::ServerUrlState, + SetupWizardState::CredentialsState, + SetupWizardState::AccountConfiguredState, + }); - nextStep(std::nullopt); + // set up initial state + changeStateTo(SetupWizardState::FirstState); // allow settings dialog to clean up the wizard controller and all the objects it created connect(_context->window(), &SetupWizardWindow::rejected, this, [this]() { @@ -37,24 +41,26 @@ SetupWizardController::SetupWizardController(QWidget *parent) Q_EMIT finished(nullptr, SyncMode::Invalid); }); - connect(_context->window(), &SetupWizardWindow::paginationEntryClicked, this, [this, paginationEntries](PageIndex currentPage, PageIndex clickedPageIndex) { - Q_ASSERT(currentPage < paginationEntries.size()); - qCDebug(lcSetupWizardController) << "pagination entry clicked: current page" << currentPage << "clicked page" << clickedPageIndex; - nextStep(clickedPageIndex); + connect(_context->window(), &SetupWizardWindow::paginationEntryClicked, this, [this](SetupWizardState clickedState) { + qCDebug(lcSetupWizardController) << "pagination entry clicked: current state" << _currentState << "clicked state" << clickedState; + changeStateTo(clickedState); }); - connect(_context->window(), &SetupWizardWindow::nextButtonClicked, this, [this, paginationEntries](PageIndex currentPage) { - Q_ASSERT(currentPage < paginationEntries.size()); - qCDebug(lcSetupWizardController) << "next button clicked on current page" << currentPage; + connect(_context->window(), &SetupWizardWindow::nextButtonClicked, this, [this]() { + qCDebug(lcSetupWizardController) << "next button clicked, current state" << _currentState; _currentState->evaluatePage(); }); // in case the back button is clicked, the current page's data is dismissed, and the previous page should be shown - connect(_context->window(), &SetupWizardWindow::backButtonClicked, this, [this](PageIndex currentPage) { - // back button should be disabled on the first page - Q_ASSERT(currentPage > 0); - qCDebug(lcSetupWizardController) << "back button clicked on current page" << currentPage; - nextStep(currentPage - 1); + connect(_context->window(), &SetupWizardWindow::backButtonClicked, this, [this]() { + // with enum classes, we have to explicitly cast to a numeric value + const auto currentStateIdx = static_cast<int>(_currentState->state()); + Q_ASSERT(currentStateIdx > 0); + + qCDebug(lcSetupWizardController) << "back button clicked, current state" << _currentState; + + const auto previousState = static_cast<SetupWizardState>(currentStateIdx - 1); + changeStateTo(previousState); }); } @@ -63,51 +69,24 @@ SetupWizardWindow *SetupWizardController::window() return _context->window(); } -void SetupWizardController::nextStep(std::optional<PageIndex> desiredPage) +void SetupWizardController::changeStateTo(SetupWizardState nextState) { // should take care of cleaning up the page once the function has finished QScopedPointer<AbstractSetupWizardState> page(_currentState); - // initial state - if (_currentState == nullptr) { - Q_ASSERT(!desiredPage.has_value()); - desiredPage = 0; - } - - // "next button" workflow - if (!desiredPage.has_value()) { - switch (_currentState->state()) { - case SetupWizardState::ServerUrlState: { - desiredPage = 1; - break; - } - case SetupWizardState::CredentialsState: { - desiredPage = 2; - break; - } - case SetupWizardState::AccountConfiguredState: { - const auto *pagePtr = qobject_cast<AccountConfiguredWizardPage *>(_currentState->page()); - - auto account = _context->accountBuilder().build(); - Q_ASSERT(account != nullptr); - Q_EMIT finished(account, pagePtr->syncMode()); - return; - } - default: - Q_UNREACHABLE(); - } - } + // validate initial state + Q_ASSERT(nextState == SetupWizardState::FirstState || _currentState != nullptr); if (_currentState != nullptr) { _currentState->deleteLater(); } - switch (desiredPage.value()) { - case 0: { + switch (nextState) { + case SetupWizardState::ServerUrlState: { _currentState = new ServerUrlSetupWizardState(_context); break; } - case 1: { + case SetupWizardState::CredentialsState: { switch (_context->accountBuilder().authType()) { case DetermineAuthTypeJob::AuthType::Basic: _currentState = new BasicCredentialsSetupWizardState(_context); @@ -121,7 +100,7 @@ void SetupWizardController::nextStep(std::optional<PageIndex> desiredPage) break; } - case 2: { + case SetupWizardState::AccountConfiguredState: { _currentState = new AccountConfiguredSetupWizardState(_context); break; } @@ -129,24 +108,43 @@ void SetupWizardController::nextStep(std::optional<PageIndex> desiredPage) Q_UNREACHABLE(); } - OC_ASSERT(desiredPage.has_value()); - OC_ASSERT(_currentState != nullptr); + Q_ASSERT(_currentState != nullptr); + Q_ASSERT(_currentState->state() == nextState); - qDebug() << "Current wizard state:" << _currentState->state(); + qCDebug(lcSetupWizardController) << "Current wizard state:" << _currentState->state(); - connect(_currentState, &AbstractSetupWizardState::evaluationSuccessful, this, [this, desiredPage]() { + connect(_currentState, &AbstractSetupWizardState::evaluationSuccessful, this, [this]() { _currentState->deleteLater(); - // nextStep(desiredPage.value() + 1); - nextStep(std::nullopt); + + switch (_currentState->state()) { + case SetupWizardState::ServerUrlState: { + changeStateTo(SetupWizardState::CredentialsState); + return; + } + case SetupWizardState::CredentialsState: { + changeStateTo(SetupWizardState::AccountConfiguredState); + return; + } + case SetupWizardState::AccountConfiguredState: { + const auto *pagePtr = qobject_cast<AccountConfiguredWizardPage *>(_currentState->page()); + + auto account = _context->accountBuilder().build(); + Q_ASSERT(account != nullptr); + Q_EMIT finished(account, pagePtr->syncMode()); + return; + } + default: + Q_UNREACHABLE(); + } }); - connect(_currentState, &AbstractSetupWizardState::evaluationFailed, this, [this, desiredPage](const QString &errorMessage) { + connect(_currentState, &AbstractSetupWizardState::evaluationFailed, this, [this](const QString &errorMessage) { _currentState->deleteLater(); _context->window()->showErrorMessage(errorMessage); - nextStep(desiredPage); + changeStateTo(_currentState->state()); }); - _context->window()->displayPage(_currentState->page(), desiredPage.value()); + _context->window()->displayPage(_currentState->page(), _currentState->state()); } SetupWizardController::~SetupWizardController() noexcept diff --git a/src/gui/newwizard/setupwizardcontroller.h b/src/gui/newwizard/setupwizardcontroller.h index a3ef08844..a13ce49ab 100644 --- a/src/gui/newwizard/setupwizardcontroller.h +++ b/src/gui/newwizard/setupwizardcontroller.h @@ -52,7 +52,7 @@ Q_SIGNALS: void finished(AccountPtr newAccount, SyncMode syncMode); private: - void nextStep(std::optional<PageIndex> desiredPage); + void changeStateTo(SetupWizardState nextState); SetupWizardContext *_context = nullptr; diff --git a/src/gui/newwizard/setupwizardwindow.cpp b/src/gui/newwizard/setupwizardwindow.cpp index 7a004ab85..fe40d02ba 100644 --- a/src/gui/newwizard/setupwizardwindow.cpp +++ b/src/gui/newwizard/setupwizardwindow.cpp @@ -48,12 +48,12 @@ SetupWizardWindow::SetupWizardWindow(QWidget *parent) connect(_ui->backButton, &QPushButton::clicked, this, [this]() { slotStartTransition(); - emit backButtonClicked(_ui->pagination->activePageIndex()); + Q_EMIT backButtonClicked(); }); - connect(_ui->pagination, &Pagination::paginationEntryClicked, this, [this](PageIndex clickedPageIndex) { + connect(_ui->navigation, &Navigation::paginationEntryClicked, this, [this](SetupWizardState clickedState) { slotStartTransition(); - emit paginationEntryClicked(_ui->pagination->activePageIndex(), clickedPageIndex); + Q_EMIT paginationEntryClicked(clickedState); }); resize(ocApp()->gui()->settingsDialog()->sizeHintForChild()); @@ -92,19 +92,19 @@ void SetupWizardWindow::loadStylesheet() _ui->contentWidget->setStyleSheet(stylesheet); } -void SetupWizardWindow::displayPage(AbstractSetupWizardPage *page, PageIndex index) +void SetupWizardWindow::displayPage(AbstractSetupWizardPage *page, SetupWizardState state) { _transitioning = false; _ui->backButton->setEnabled(true); _ui->nextButton->setEnabled(true); - if (index == 0) { + if (state == SetupWizardState::FirstState) { _ui->backButton->setEnabled(false); - } else if (index == _ui->pagination->entriesCount()) { + } else if (state == SetupWizardState::FinalState) { _ui->nextButton->setEnabled(false); } - if (index >= (_ui->pagination->entriesCount() - 1)) { + if (state == SetupWizardState::FinalState) { _ui->nextButton->setText(tr("Finish")); } else { _ui->nextButton->setText(tr("Next >")); @@ -116,8 +116,8 @@ void SetupWizardWindow::displayPage(AbstractSetupWizardPage *page, PageIndex ind // initial check whether to enable the next button right away slotUpdateNextButton(); - _ui->pagination->setActivePageIndex(index); - _ui->pagination->setEnabled(true); + _ui->navigation->setActiveState(state); + _ui->navigation->setEnabled(true); connect(_ui->errorMessageDismissButton, &QPushButton::clicked, this, &SetupWizardWindow::slotHideErrorMessageWidget); @@ -141,7 +141,7 @@ void SetupWizardWindow::slotStartTransition() // until a new page is displayed by the controller, we want to prevent the user from initiating another page change _ui->backButton->setEnabled(false); _ui->nextButton->setEnabled(false); - _ui->pagination->setEnabled(false); + _ui->navigation->setEnabled(false); // also, we should assume the user has seen the error message in case one is shown slotHideErrorMessageWidget(); } @@ -171,9 +171,9 @@ void SetupWizardWindow::showErrorMessage(const QString &errorMessage) _ui->errorMessageWidget->show(); } -void SetupWizardWindow::setPaginationEntries(const QStringList &paginationEntries) +void SetupWizardWindow::setNavigationEntries(const QList<SetupWizardState> &entries) { - _ui->pagination->setEntries(paginationEntries); + _ui->navigation->setEntries(entries); } void SetupWizardWindow::slotUpdateNextButton() @@ -228,6 +228,6 @@ SetupWizardWindow::~SetupWizardWindow() noexcept void SetupWizardWindow::slotMoveToNextPage() { slotStartTransition(); - emit nextButtonClicked(_ui->pagination->activePageIndex()); + Q_EMIT nextButtonClicked(); } } diff --git a/src/gui/newwizard/setupwizardwindow.h b/src/gui/newwizard/setupwizardwindow.h index b35134bfd..9142529af 100644 --- a/src/gui/newwizard/setupwizardwindow.h +++ b/src/gui/newwizard/setupwizardwindow.h @@ -15,8 +15,8 @@ #pragma once #include "3rdparty/QProgressIndicator/QProgressIndicator.h" +#include "navigation.h" #include "pages/abstractsetupwizardpage.h" -#include "pagination.h" #include "setupwizardaccountbuilder.h" #include <QDialog> @@ -32,9 +32,10 @@ class SetupWizardWindow; } namespace OCC::Wizard { + /** - * This class contains the UI-specific code. It hides the complexity from the controller, and provides a high-level API. - */ + * This class contains the UI-specific code. It hides the complexity from the controller, and provides a high-level API. + */ class SetupWizardWindow : public QDialog { Q_OBJECT @@ -47,14 +48,14 @@ public: * Set entries in the pagination at the bottom of the wizard UI. * The entries are identified by their position in the list (read: index). */ - void setPaginationEntries(const QStringList &paginationEntries); + void setNavigationEntries(const QList<SetupWizardState> &entries); /** * Render this page within the wizard window. * @param page page to render * @param index index to highlight in pagination (also used to decide which buttons to enable) */ - void displayPage(AbstractSetupWizardPage *page, PageIndex index); + void displayPage(AbstractSetupWizardPage *page, SetupWizardState state); void showErrorMessage(const QString &errorMessage); @@ -64,9 +65,9 @@ protected: bool eventFilter(QObject *obj, QEvent *event) override; Q_SIGNALS: - void paginationEntryClicked(PageIndex currentPage, PageIndex clickedPageIndex); - void nextButtonClicked(PageIndex currentPage); - void backButtonClicked(PageIndex currentPage); + void paginationEntryClicked(SetupWizardState clickedState); + void nextButtonClicked(); + void backButtonClicked(); public Q_SLOTS: /** @@ -92,6 +93,6 @@ private: // need to keep track of the current page for event filtering AbstractSetupWizardPage *_currentPage = nullptr; // during a transition, the event filter must be disabled - bool _transitioning; + bool _transitioning = false; }; } diff --git a/src/gui/newwizard/setupwizardwindow.ui b/src/gui/newwizard/setupwizardwindow.ui index 84d24f03d..83ec84310 100644 --- a/src/gui/newwizard/setupwizardwindow.ui +++ b/src/gui/newwizard/setupwizardwindow.ui @@ -120,7 +120,7 @@ </spacer> </item> <item> - <widget class="OCC::Wizard::Pagination" name="pagination" native="true"/> + <widget class="OCC::Wizard::Navigation" name="navigation" native="true"/> </item> <item> <spacer name="horizontalSpacer_2"> @@ -157,9 +157,9 @@ </widget> <customwidgets> <customwidget> - <class>OCC::Wizard::Pagination</class> + <class>OCC::Wizard::Navigation</class> <extends>QWidget</extends> - <header>pagination.h</header> + <header>navigation.h</header> <container>1</container> </customwidget> <customwidget> diff --git a/src/gui/newwizard/states/accountconfiguredsetupwizardstate.cpp b/src/gui/newwizard/states/accountconfiguredsetupwizardstate.cpp index 9aa7ad2b5..f943969c2 100644 --- a/src/gui/newwizard/states/accountconfiguredsetupwizardstate.cpp +++ b/src/gui/newwizard/states/accountconfiguredsetupwizardstate.cpp @@ -54,7 +54,7 @@ SetupWizardState AccountConfiguredSetupWizardState::state() const void AccountConfiguredSetupWizardState::evaluatePage() { auto accountConfiguredSetupWizardPage = qobject_cast<AccountConfiguredWizardPage *>(_page); - OC_ASSERT(accountConfiguredSetupWizardPage != nullptr); + Q_ASSERT(accountConfiguredSetupWizardPage != nullptr); if (accountConfiguredSetupWizardPage->syncMode() != Wizard::SyncMode::ConfigureUsingFolderWizard) { _context->accountBuilder().setDefaultSyncTargetDir(QDir::fromNativeSeparators(accountConfiguredSetupWizardPage->syncTargetDir())); diff --git a/src/gui/newwizard/states/basiccredentialssetupwizardstate.cpp b/src/gui/newwizard/states/basiccredentialssetupwizardstate.cpp index a35d39bac..7b9f95ac1 100644 --- a/src/gui/newwizard/states/basiccredentialssetupwizardstate.cpp +++ b/src/gui/newwizard/states/basiccredentialssetupwizardstate.cpp @@ -27,7 +27,7 @@ BasicCredentialsSetupWizardState::BasicCredentialsSetupWizardState(SetupWizardCo void BasicCredentialsSetupWizardState::evaluatePage() { auto *basicCredentialsSetupWizardPage = qobject_cast<BasicCredentialsSetupWizardPage *>(_page); - OC_ASSERT(basicCredentialsSetupWizardPage != nullptr); + Q_ASSERT(basicCredentialsSetupWizardPage != nullptr); const QString username = basicCredentialsSetupWizardPage->username(); const QString password = basicCredentialsSetupWizardPage->password(); diff --git a/src/gui/newwizard/states/serverurlsetupwizardstate.cpp b/src/gui/newwizard/states/serverurlsetupwizardstate.cpp index 618781ca3..6280e5a8e 100644 --- a/src/gui/newwizard/states/serverurlsetupwizardstate.cpp +++ b/src/gui/newwizard/states/serverurlsetupwizardstate.cpp @@ -48,7 +48,7 @@ void ServerUrlSetupWizardState::evaluatePage() _context->resetAccountBuilder(); auto serverUrlSetupWizardPage = qobject_cast<ServerUrlSetupWizardPage *>(_page); - OC_ASSERT(serverUrlSetupWizardPage != nullptr); + Q_ASSERT(serverUrlSetupWizardPage != nullptr); const QUrl serverUrl = [serverUrlSetupWizardPage]() { QString userProvidedUrl = serverUrlSetupWizardPage->userProvidedUrl(); @@ -56,7 +56,6 @@ void ServerUrlSetupWizardState::evaluatePage() // fix scheme if necessary // using HTTPS as a default is a real ly good idea nowadays, users can still enter http:// explicitly if they wish to if (!std::any_of(supportedUrlSchemesC.begin(), supportedUrlSchemesC.end(), [userProvidedUrl](const QString &scheme) { - qCDebug(lcSetupWizardServerUrlState) << "no URL scheme provided, prepending default URL scheme" << defaultUrlSchemeC; return userProvidedUrl.startsWith(scheme); })) { qInfo(lcSetupWizardServerUrlState) << "no URL scheme provided, prepending default URL scheme" << defaultUrlSchemeC; diff --git a/src/gui/newwizard/states/setupwizardstate.h b/src/gui/newwizard/states/setupwizardstate.h index 4476d7deb..9d4ae00fd 100644 --- a/src/gui/newwizard/states/setupwizardstate.h +++ b/src/gui/newwizard/states/setupwizardstate.h @@ -31,9 +31,26 @@ Q_NAMESPACE */ enum class SetupWizardState { ServerUrlState, + FirstState = ServerUrlState, + CredentialsState, + AccountConfiguredState, + FinalState = AccountConfiguredState, }; Q_ENUM_NS(SetupWizardState) +static QString setupWizardStateToText(SetupWizardState state) +{ + switch (state) { + case SetupWizardState::ServerUrlState: + return QObject::tr("Server URL"); + case SetupWizardState::CredentialsState: + return QObject::tr("Credentials"); + case SetupWizardState::AccountConfiguredState: + return QObject::tr("Sync Options"); + default: + Q_UNREACHABLE(); + } +} } |