mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-22 04:55:48 +03:00
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:
commit
52a6254db0
3 changed files with 22 additions and 10 deletions
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue