diff --git a/src/gui/owncloudsetupwizard.cpp b/src/gui/owncloudsetupwizard.cpp index 86c4524a86034..0ce78f58e3d58 100644 --- a/src/gui/owncloudsetupwizard.cpp +++ b/src/gui/owncloudsetupwizard.cpp @@ -126,9 +126,8 @@ void OwncloudSetupWizard::startWizard() const auto startPage = WizardCommon::Page_ServerSetup; #endif // WITH_PROVIDERS _ocWizard->setStartId(startPage); - _ocWizard->restart(); - + _ocWizard->adjustWizardSize(); _ocWizard->open(); _ocWizard->raise(); } diff --git a/src/gui/wizard/owncloudwizard.cpp b/src/gui/wizard/owncloudwizard.cpp index 4a9c4d11e4859..afc19c40986f0 100644 --- a/src/gui/wizard/owncloudwizard.cpp +++ b/src/gui/wizard/owncloudwizard.cpp @@ -134,9 +134,16 @@ void OwncloudWizard::centerWindow() void OwncloudWizard::adjustWizardSize() { const auto pageSizes = calculateWizardPageSizes(); - const auto longestSide = calculateLongestSideOfWizardPages(pageSizes); + const auto currentPageIndex = currentId(); - resize(QSize(longestSide, longestSide)); + // If we can, just use the size of the current page + if(currentPageIndex > -1 && currentPageIndex < pageSizes.count()) { + resize(pageSizes.at(currentPageIndex)); + return; + } + + // As a backup, resize to largest page + resize(calculateLargestSizeOfWizardPages(pageSizes)); } QList OwncloudWizard::calculateWizardPageSizes() const @@ -153,11 +160,17 @@ QList OwncloudWizard::calculateWizardPageSizes() const return pageSizes; } -int OwncloudWizard::calculateLongestSideOfWizardPages(const QList &pageSizes) const +QSize OwncloudWizard::calculateLargestSizeOfWizardPages(const QList &pageSizes) const { - return std::accumulate(std::cbegin(pageSizes), std::cend(pageSizes), 0, [](int current, const QSize &size) { - return std::max({ current, size.width(), size.height() }); - }); + QSize largestSize; + for(const auto size : pageSizes) { + const auto largerWidth = qMax(largestSize.width(), size.width()); + const auto largerHeight = qMax(largestSize.height(), size.height()); + + largestSize = QSize(largerWidth, largerHeight); + } + + return largestSize; } void OwncloudWizard::setAccount(AccountPtr account) diff --git a/src/gui/wizard/owncloudwizard.h b/src/gui/wizard/owncloudwizard.h index 14fcbc507063c..a23aed748becb 100644 --- a/src/gui/wizard/owncloudwizard.h +++ b/src/gui/wizard/owncloudwizard.h @@ -96,6 +96,7 @@ public slots: void slotCurrentPageChanged(int); void successfulStep(); void slotCustomButtonClicked(const int which); + void adjustWizardSize(); signals: void clearPendingRequests(); @@ -114,8 +115,7 @@ public slots: private: void customizeStyle(); - void adjustWizardSize(); - int calculateLongestSideOfWizardPages(const QList &pageSizes) const; + QSize calculateLargestSizeOfWizardPages(const QList &pageSizes) const; QList calculateWizardPageSizes() const; AccountPtr _account;