Skip to content

Commit

Permalink
Merge pull request #4911 from nextcloud/bugfix/account-wizard-size
Browse files Browse the repository at this point in the history
Make account setup wizard's adjustWizardSize resize to current page size instead of largest wizard page
  • Loading branch information
claucambra authored Sep 14, 2022
2 parents b91dad9 + 14303d0 commit 52a6254
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
3 changes: 1 addition & 2 deletions src/gui/owncloudsetupwizard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
25 changes: 19 additions & 6 deletions src/gui/wizard/owncloudwizard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<QSize> OwncloudWizard::calculateWizardPageSizes() const
Expand All @@ -153,11 +160,17 @@ QList<QSize> OwncloudWizard::calculateWizardPageSizes() const
return pageSizes;
}

int OwncloudWizard::calculateLongestSideOfWizardPages(const QList<QSize> &pageSizes) const
QSize OwncloudWizard::calculateLargestSizeOfWizardPages(const QList<QSize> &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)
Expand Down
4 changes: 2 additions & 2 deletions src/gui/wizard/owncloudwizard.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public slots:
void slotCurrentPageChanged(int);
void successfulStep();
void slotCustomButtonClicked(const int which);
void adjustWizardSize();

signals:
void clearPendingRequests();
Expand All @@ -114,8 +115,7 @@ public slots:

private:
void customizeStyle();
void adjustWizardSize();
int calculateLongestSideOfWizardPages(const QList<QSize> &pageSizes) const;
QSize calculateLargestSizeOfWizardPages(const QList<QSize> &pageSizes) const;
QList<QSize> calculateWizardPageSizes() const;

AccountPtr _account;
Expand Down

0 comments on commit 52a6254

Please sign in to comment.