diff --git a/src/gui/application.cpp b/src/gui/application.cpp index 2813ae45fe70..d23be5c145f2 100644 --- a/src/gui/application.cpp +++ b/src/gui/application.cpp @@ -338,9 +338,6 @@ Application::Application(int &argc, char **argv) FolderMan::instance()->setupFolders(); _proxy.setupQtProxyFromConfig(); // folders have to be defined first, than we set up the Qt proxy. - // Enable word wrapping of QInputDialog (#4197) - setStyleSheet("QInputDialog QLabel { qproperty-wordWrap:1; }"); - connect(AccountManager::instance(), &AccountManager::accountAdded, this, &Application::slotAccountStateAdded); connect(AccountManager::instance(), &AccountManager::accountRemoved, diff --git a/src/gui/wizard/owncloudwizard.cpp b/src/gui/wizard/owncloudwizard.cpp index 4c57e96c1c67..32bd1318276a 100644 --- a/src/gui/wizard/owncloudwizard.cpp +++ b/src/gui/wizard/owncloudwizard.cpp @@ -47,9 +47,7 @@ Q_LOGGING_CATEGORY(lcWizard, "nextcloud.gui.wizard", QtInfoMsg) OwncloudWizard::OwncloudWizard(QWidget *parent) : QWizard(parent) , _account(nullptr) -#ifdef WITH_PROVIDERS , _welcomePage(new WelcomePage(this)) -#endif // WITH_PROVIDERS , _setupPage(new OwncloudSetupPage(this)) , _httpCredsPage(new OwncloudHttpCredsPage(this)) , _browserCredsPage(new OwncloudOAuthCredsPage) @@ -61,9 +59,7 @@ OwncloudWizard::OwncloudWizard(QWidget *parent) setObjectName("owncloudWizard"); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); -#ifdef WITH_PROVIDERS setPage(WizardCommon::Page_Welcome, _welcomePage); -#endif // WITH_PROVIDERS setPage(WizardCommon::Page_ServerSetup, _setupPage); setPage(WizardCommon::Page_HttpCreds, _httpCredsPage); setPage(WizardCommon::Page_OAuthCreds, _browserCredsPage); @@ -76,7 +72,6 @@ OwncloudWizard::OwncloudWizard(QWidget *parent) // note: start Id is set by the calling class depending on if the // welcome text is to be shown or not. - setWizardStyle(QWizard::ModernStyle); connect(this, &QWizard::currentIdChanged, this, &OwncloudWizard::slotCurrentPageChanged); connect(_setupPage, &OwncloudSetupPage::determineAuthType, this, &OwncloudWizard::determineAuthType); @@ -90,15 +85,11 @@ OwncloudWizard::OwncloudWizard(QWidget *parent) Theme *theme = Theme::instance(); - setWindowTitle(tr("%1 Connection Wizard").arg(theme->appNameGUI())); + setWindowTitle(tr("Add %1 account").arg(theme->appNameGUI())); setWizardStyle(QWizard::ModernStyle); - setPixmap(QWizard::BannerPixmap, theme->wizardHeaderBanner()); - setPixmap(QWizard::LogoPixmap, theme->wizardHeaderLogo()); setOption(QWizard::NoBackButtonOnStartPage); setOption(QWizard::NoBackButtonOnLastPage); setOption(QWizard::NoCancelButton); - setTitleFormat(Qt::RichText); - setSubTitleFormat(Qt::RichText); setButtonText(QWizard::CustomButton1, tr("Skip folders configuration")); // Change the next buttons size policy since we hide it on the @@ -117,6 +108,55 @@ OwncloudWizard::OwncloudWizard(QWidget *parent) // allow Flow2 page to poll on window activation connect(this, &OwncloudWizard::onActivate, _flow2CredsPage, &Flow2AuthCredsPage::slotPollNow); + + adjustWizardSize(); +} + +void OwncloudWizard::adjustWizardSize() +{ + const auto pageSizes = calculateWizardPageSizes(); + const auto longestSide = calculateLongestSideOfWizardPages(pageSizes); + + resize(QSize(longestSide, longestSide)); +} + +QList OwncloudWizard::calculateWizardPageSizes() const +{ + QList pageSizes; + const auto pIds = pageIds(); + + std::transform(pIds.begin(), pIds.end(), std::back_inserter(pageSizes), [this](int pageId) { + auto p = page(pageId); + + p->adjustSize(); + + return p->sizeHint(); + }); + + return pageSizes; +} + +int OwncloudWizard::calculateLongestSideOfWizardPages(const QList &pageSizes) const +{ + const auto calculateLongestSide = [](const QSize &size) { + return size.height() < size.width() ? size.width() : size.height(); + }; + + return std::accumulate( + std::next(pageSizes.begin()), + pageSizes.end(), + [&pageSizes, &calculateLongestSide]() { + const auto longestSideOfSize = calculateLongestSide(pageSizes.first()); + + return longestSideOfSize; + }(), + [&calculateLongestSide](int currentLongestSide, const QSize &size) { + const auto longestSideOfSize = calculateLongestSide(size); + if (longestSideOfSize > currentLongestSide) { + return longestSideOfSize; + } + return currentLongestSide; + }); } void OwncloudWizard::setAccount(AccountPtr account) @@ -337,6 +377,37 @@ void OwncloudWizard::changeEvent(QEvent *e) void OwncloudWizard::customizeStyle() { // HINT: Customize wizard's own style here, if necessary in the future (Dark-/Light-Mode switching) + auto theme = Theme::instance(); + auto wizardPalette = palette(); + + wizardPalette.setColor(QPalette::Window, theme->wizardHeaderBackgroundColor()); + QColor colorWindowDisabled(wizardPalette.color(QPalette::Window)); + colorWindowDisabled.setAlpha(128); + wizardPalette.setColor(QPalette::Disabled, QPalette::Window, colorWindowDisabled); + + wizardPalette.setColor(QPalette::Base, theme->wizardHeaderBackgroundColor()); + QColor colorBaseDisabled(wizardPalette.color(QPalette::Base)); + colorBaseDisabled.setAlpha(128); + wizardPalette.setColor(QPalette::Disabled, QPalette::Base, colorBaseDisabled); + + wizardPalette.setColor(QPalette::WindowText, theme->wizardHeaderTitleColor()); + QColor colorWindowTextDisabled(wizardPalette.color(QPalette::WindowText)); + colorWindowTextDisabled.setAlpha(128); + wizardPalette.setColor(QPalette::Disabled, QPalette::WindowText, colorWindowTextDisabled); + + wizardPalette.setColor(QPalette::Text, theme->wizardHeaderTitleColor()); + QColor colorTextDisabled(wizardPalette.color(QPalette::Text)); + colorTextDisabled.setAlpha(128); + wizardPalette.setColor(QPalette::Disabled, QPalette::Text, colorWindowTextDisabled); + + // Set separator color + wizardPalette.setColor(QPalette::Mid, theme->wizardHeaderBackgroundColor()); + + setPalette(wizardPalette); + + WizardCommon::customizePrimaryButtonStyle(button(QWizard::NextButton)); + WizardCommon::customizeSecondaryButtonStyle(button(QWizard::CustomButton1)); + WizardCommon::customizeSecondaryButtonStyle(button(QWizard::BackButton)); } void OwncloudWizard::bringToTop() diff --git a/src/gui/wizard/owncloudwizard.h b/src/gui/wizard/owncloudwizard.h index 3c6fb5c6e1f8..1cee087585af 100644 --- a/src/gui/wizard/owncloudwizard.h +++ b/src/gui/wizard/owncloudwizard.h @@ -114,6 +114,9 @@ public slots: private: void customizeStyle(); + void adjustWizardSize(); + int calculateLongestSideOfWizardPages(const QList &pageSizes) const; + QList calculateWizardPageSizes() const; AccountPtr _account; WelcomePage *_welcomePage;