Merge pull request #4911 from nextcloud/bugfix/account-wizard-size

Make account setup wizard's adjustWizardSize resize to current page size instead of largest wizard page
This commit is contained in:
Claudio Cambra 2022-09-14 02:38:28 +02:00 committed by GitHub
commit 52a6254db0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 10 deletions

View file

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

View file

@ -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
@ -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)

View file

@ -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 @@ protected:
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;