Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make account setup wizard's adjustWizardSize resize to current page size instead of largest wizard page #4911

Merged
merged 1 commit into from
Sep 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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