diff --git a/src/gui/owncloudsetupwizard.cpp b/src/gui/owncloudsetupwizard.cpp index 2c964d5ced07..51c727208a14 100644 --- a/src/gui/owncloudsetupwizard.cpp +++ b/src/gui/owncloudsetupwizard.cpp @@ -116,7 +116,7 @@ void OwncloudSetupWizard::startWizard() // if its a relative path, prepend with users home dir, otherwise use as absolute path if (!QDir(localFolder).isAbsolute()) { - localFolder = QDir::homePath() + QDir::separator() + localFolder; + localFolder = QDir::homePath() + QLatin1Char('/') + localFolder; } _ocWizard->setProperty("localFolder", localFolder); diff --git a/src/gui/wizard/flow2authcredspage.cpp b/src/gui/wizard/flow2authcredspage.cpp index 33bced5837b8..e03b9a50faba 100644 --- a/src/gui/wizard/flow2authcredspage.cpp +++ b/src/gui/wizard/flow2authcredspage.cpp @@ -33,9 +33,6 @@ Flow2AuthCredsPage::Flow2AuthCredsPage() { _layout = new QVBoxLayout(this); - setTitle(WizardCommon::titleTemplate().arg(tr("Connect to %1").arg(Theme::instance()->appNameGUI()))); - setSubTitle(WizardCommon::subTitleTemplate().arg(tr("Login in your browser (Login Flow v2)"))); - _flow2AuthWidget = new Flow2AuthWidget(); _layout->addWidget(_flow2AuthWidget); @@ -59,6 +56,8 @@ void Flow2AuthCredsPage::initializePage() // Don't hide the wizard (avoid user confusion)! //wizard()->hide(); + + _flow2AuthWidget->slotStyleChanged(); } void OCC::Flow2AuthCredsPage::cleanupPage() diff --git a/src/gui/wizard/flow2authwidget.cpp b/src/gui/wizard/flow2authwidget.cpp index 86a6ebb4ad9b..ea83034f1958 100644 --- a/src/gui/wizard/flow2authwidget.cpp +++ b/src/gui/wizard/flow2authwidget.cpp @@ -17,6 +17,7 @@ #include "common/utility.h" #include "account.h" #include "wizard/owncloudwizardcommon.h" +#include "theme.h" #include "QProgressIndicator.h" @@ -34,13 +35,21 @@ Flow2AuthWidget::Flow2AuthWidget(QWidget *parent) WizardCommon::initErrorLabel(_ui.errorLabel); _ui.errorLabel->setTextFormat(Qt::RichText); - connect(_ui.openLinkButton, &QCommandLinkButton::clicked, this, &Flow2AuthWidget::slotOpenBrowser); - connect(_ui.copyLinkButton, &QCommandLinkButton::clicked, this, &Flow2AuthWidget::slotCopyLinkToClipboard); + connect(_ui.openLinkButton, &QPushButton::clicked, this, &Flow2AuthWidget::slotOpenBrowser); + connect(_ui.copyLinkButton, &QPushButton::clicked, this, &Flow2AuthWidget::slotCopyLinkToClipboard); - _ui.horizontalLayout->addWidget(_progressIndi); + auto sizePolicy = _progressIndi->sizePolicy(); + sizePolicy.setRetainSizeWhenHidden(true); + _progressIndi->setSizePolicy(sizePolicy); + + _ui.progressLayout->addWidget(_progressIndi); stopSpinner(false); +} - customizeStyle(); +void Flow2AuthWidget::setLogo() +{ + const auto backgroundColor = palette().window().color(); + _ui.logoLabel->setPixmap(Theme::hidpiFileName("external.png", backgroundColor)); } void Flow2AuthWidget::startAuth(Account *account) @@ -160,7 +169,7 @@ void Flow2AuthWidget::slotStatusChanged(Flow2Auth::PollStatus status, int second void Flow2AuthWidget::startSpinner() { - _ui.horizontalLayout->setEnabled(true); + _ui.progressLayout->setEnabled(true); _ui.statusLabel->setVisible(true); _progressIndi->setVisible(true); _progressIndi->startAnimation(); @@ -171,7 +180,7 @@ void Flow2AuthWidget::startSpinner() void Flow2AuthWidget::stopSpinner(bool showStatusLabel) { - _ui.horizontalLayout->setEnabled(false); + _ui.progressLayout->setEnabled(false); _ui.statusLabel->setVisible(showStatusLabel); _progressIndi->setVisible(false); _progressIndi->stopAnimation(); @@ -187,8 +196,21 @@ void Flow2AuthWidget::slotStyleChanged() void Flow2AuthWidget::customizeStyle() { - if(_progressIndi) - _progressIndi->setColor(QGuiApplication::palette().color(QPalette::Text)); + setLogo(); + + if (_progressIndi) { + const auto isDarkBackground = Theme::isDarkColor(palette().window().color()); + if (isDarkBackground) { + _progressIndi->setColor(Qt::white); + } else { + _progressIndi->setColor(Qt::black); + } + } + + WizardCommon::customizeLinkButtonStyle(_ui.openLinkButton); + WizardCommon::customizeLinkButtonStyle(_ui.copyLinkButton); + + WizardCommon::customizeHintLabel(_ui.statusLabel); } } // namespace OCC diff --git a/src/gui/wizard/flow2authwidget.h b/src/gui/wizard/flow2authwidget.h index 8c13806b1258..90095c79c14c 100644 --- a/src/gui/wizard/flow2authwidget.h +++ b/src/gui/wizard/flow2authwidget.h @@ -60,6 +60,7 @@ protected slots: void startSpinner(); void stopSpinner(bool showStatusLabel); void customizeStyle(); + void setLogo(); QProgressIndicator *_progressIndi; int _statusUpdateSkipCount = 0; diff --git a/src/gui/wizard/flow2authwidget.ui b/src/gui/wizard/flow2authwidget.ui index 57f23186d814..fdf9d3319858 100644 --- a/src/gui/wizard/flow2authwidget.ui +++ b/src/gui/wizard/flow2authwidget.ui @@ -27,44 +27,152 @@ - - - Please switch to your browser to proceed. - - - true - - - - - - - An error occurred while connecting. Please try again. + + + Qt::Vertical - - Qt::PlainText + + QSizePolicy::Expanding - - - - - - Re-open Browser + + + 20 + 80 + - + - - - - 50 - false - + + + 0 - - Copy link + + 0 - + + + + Logo + + + Qt::AlignCenter + + + + + + + + 12 + 75 + true + + + + Switch to your browser to connect your account + + + Qt::AlignCenter + + + true + + + + + + + Status + + + Qt::AlignCenter + + + 0 + + + + + + + 0 + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + 0 + + + + + Reopen browser + + + true + + + + + + + Copy link + + + false + + + true + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + An error occurred while connecting. Please try again. + + + Qt::PlainText + + + Qt::AlignCenter + + + + + + + @@ -79,19 +187,6 @@ - - - - TextLabel - - - Qt::AlignCenter - - - - - - @@ -100,7 +195,7 @@ 20 - 107 + 80 diff --git a/src/gui/wizard/owncloudadvancedsetuppage.cpp b/src/gui/wizard/owncloudadvancedsetuppage.cpp index b3d45bb6152f..2f0eff14c170 100644 --- a/src/gui/wizard/owncloudadvancedsetuppage.cpp +++ b/src/gui/wizard/owncloudadvancedsetuppage.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include "QProgressIndicator.h" @@ -32,21 +33,26 @@ #include #include "creds/abstractcredentials.h" #include "networkjobs.h" +#include "wizard/owncloudwizard.h" namespace OCC { -OwncloudAdvancedSetupPage::OwncloudAdvancedSetupPage() +OwncloudAdvancedSetupPage::OwncloudAdvancedSetupPage(OwncloudWizard *wizard) : QWizardPage() , _progressIndi(new QProgressIndicator(this)) + , _ocWizard(wizard) { _ui.setupUi(this); - - Theme *theme = Theme::instance(); - setTitle(WizardCommon::titleTemplate().arg(tr("Connect to %1").arg(theme->appNameGUI()))); - setSubTitle(WizardCommon::subTitleTemplate().arg(tr("Setup local folder options"))); + setupSyncModeLabel(); + setupRKeepLocal(); + setupCbSyncFromScratch(); registerField(QLatin1String("OCSyncFromScratch"), _ui.cbSyncFromScratch); + auto sizePolicy = _progressIndi->sizePolicy(); + sizePolicy.setRetainSizeWhenHidden(true); + _progressIndi->setSizePolicy(sizePolicy); + _ui.resultLayout->addWidget(_progressIndi); stopSpinner(); setupCustomization(); @@ -65,13 +71,11 @@ OwncloudAdvancedSetupPage::OwncloudAdvancedSetupPage() }); connect(_ui.bSelectiveSync, &QAbstractButton::clicked, this, &OwncloudAdvancedSetupPage::slotSelectiveSyncClicked); - QIcon appIcon = theme->applicationIcon(); - _ui.lServerIcon->setText(QString()); - _ui.lServerIcon->setPixmap(appIcon.pixmap(48)); - _ui.lLocalIcon->setText(QString()); - - // TO DO: File doesn't exist anymore - unneccessary or replacement needed? - _ui.lLocalIcon->setPixmap(QPixmap(Theme::hidpiFileName(":/client/theme/folder-sync.png"))); + const auto theme = Theme::instance(); + const auto appIcon = theme->applicationIcon(); + const auto appIconSize = Theme::isHidpi() ? 128 : 64; + + _ui.lServerIcon->setPixmap(appIcon.pixmap(appIconSize)); if (theme->wizardHideExternalStorageConfirmationCheckbox()) { _ui.confCheckBoxExternal->hide(); @@ -106,6 +110,16 @@ void OwncloudAdvancedSetupPage::setupCustomization() variant = theme->customMedia(Theme::oCSetupBottom); WizardCommon::setupCustomMedia(variant, _ui.bottomLabel); + + WizardCommon::customizeSpinBoxStyle(_ui.confSpinBox); + + WizardCommon::customizeSecondaryButtonStyle(_ui.bSelectiveSync); + WizardCommon::customizeSecondaryButtonStyle(_ui.pbSelectLocalFolder); + + WizardCommon::customizeHintLabel(_ui.lFreeSpace); + WizardCommon::customizeHintLabel(_ui.lSyncEverythingSizeLabel); + WizardCommon::customizeHintLabel(_ui.lSelectiveSyncSizeLabel); + WizardCommon::customizeHintLabel(_ui.serverAddressLabel); } bool OwncloudAdvancedSetupPage::isComplete() const @@ -158,6 +172,64 @@ void OwncloudAdvancedSetupPage::initializePage() _ui.confCheckBoxSize->setChecked(newFolderLimit.first); _ui.confSpinBox->setValue(newFolderLimit.second); _ui.confCheckBoxExternal->setChecked(cfgFile.confirmExternalStorage()); + + fetchUserAvatar(); + fetchUserData(); + + customizeStyle(); +} + +void OwncloudAdvancedSetupPage::fetchUserAvatar() +{ + // Reset user avatar + const auto appIcon = Theme::instance()->applicationIcon(); + _ui.lServerIcon->setPixmap(appIcon.pixmap(48)); + // Fetch user avatar + const auto account = _ocWizard->account(); + auto avatarSize = 64; + if (Theme::isHidpi()) { + avatarSize *= 2; + } + const auto avatarJob = new AvatarJob(account, account->davUser(), avatarSize, this); + avatarJob->setTimeout(20 * 1000); + QObject::connect(avatarJob, &AvatarJob::avatarPixmap, this, [this](const QImage &avatarImage) { + if (avatarImage.isNull()) { + return; + } + const auto avatarPixmap = QPixmap::fromImage(AvatarJob::makeCircularAvatar(avatarImage)); + _ui.lServerIcon->setPixmap(avatarPixmap); + }); + avatarJob->start(); +} + +void OwncloudAdvancedSetupPage::fetchUserData() +{ + const auto account = _ocWizard->account(); + + // Fetch user data + const auto userJob = new JsonApiJob(account, QLatin1String("ocs/v1.php/cloud/user"), this); + userJob->setTimeout(20 * 1000); + connect(userJob, &JsonApiJob::jsonReceived, this, [this](const QJsonDocument &json) { + const auto objData = json.object().value("ocs").toObject().value("data").toObject(); + const auto displayName = objData.value("display-name").toString(); + _ui.userNameLabel->setText(displayName); + }); + userJob->start(); + + const auto serverUrl = account->url().toString(); + setServerAddressLabelUrl(serverUrl); + const auto userName = account->davDisplayName(); + _ui.userNameLabel->setText(userName); +} + +void OwncloudAdvancedSetupPage::setServerAddressLabelUrl(const QUrl &url) +{ + if (!url.isValid()) { + return; + } + + const auto prettyUrl = url.toString().mid(url.scheme().size() + 3); // + 3 because we need to remove :// + _ui.serverAddressLabel->setText(prettyUrl); } // Called if the user changes the user- or url field. Adjust the texts and @@ -172,7 +244,8 @@ void OwncloudAdvancedSetupPage::updateStatus() QString t; - _ui.pbSelectLocalFolder->setText(QDir::toNativeSeparators(locFolder)); + setLocalFolderPushButtonPath(locFolder); + if (dataChanged()) { if (_remoteFolder.isEmpty() || _remoteFolder == QLatin1String("/")) { t = ""; @@ -185,20 +258,18 @@ void OwncloudAdvancedSetupPage::updateStatus() const bool dirNotEmpty(QDir(locFolder).entryList(QDir::AllEntries | QDir::NoDotAndDotDot).count() > 0); if (dirNotEmpty) { - t += tr("

Warning: The local folder is not empty. " - "Pick a resolution!

"); + t += tr("Warning: The local folder is not empty. Pick a resolution!"); } - _ui.resolutionWidget->setVisible(dirNotEmpty); + setResolutionGuiVisible(dirNotEmpty); } else { - _ui.resolutionWidget->setVisible(false); + setResolutionGuiVisible(false); } QString lfreeSpaceStr = Utility::octetsToString(availableLocalSpace()); - _ui.lFreeSpace->setText(QString(tr("Free space: %1")).arg(lfreeSpaceStr)); + _ui.lFreeSpace->setText(QString(tr("%1 free space")).arg(lfreeSpaceStr)); _ui.syncModeLabel->setText(t); _ui.syncModeLabel->setFixedHeight(_ui.syncModeLabel->sizeHint().height()); - wizard()->resize(wizard()->sizeHint()); qint64 rSpace = _ui.rSyncEverything->isChecked() ? _rSize : _rSelectedSize; @@ -211,6 +282,13 @@ void OwncloudAdvancedSetupPage::updateStatus() emit completeChanged(); } +void OwncloudAdvancedSetupPage::setResolutionGuiVisible(bool value) +{ + _ui.syncModeLabel->setVisible(value); + _ui.rKeepLocal->setVisible(value); + _ui.cbSyncFromScratch->setVisible(value); +} + /* obsolete */ bool OwncloudAdvancedSetupPage::dataChanged() { @@ -334,7 +412,7 @@ void OwncloudAdvancedSetupPage::slotSelectFolder() { QString dir = QFileDialog::getExistingDirectory(nullptr, tr("Local Sync Folder"), QDir::homePath()); if (!dir.isEmpty()) { - _ui.pbSelectLocalFolder->setText(dir); + setLocalFolderPushButtonPath(dir); wizard()->setProperty("localFolder", dir); updateStatus(); } @@ -344,6 +422,22 @@ void OwncloudAdvancedSetupPage::slotSelectFolder() setErrorString(errorStr); } + +void OwncloudAdvancedSetupPage::setLocalFolderPushButtonPath(const QString &path) +{ + const auto homeDir = QDir::homePath().endsWith('/') ? QDir::homePath() : QDir::homePath() + QLatin1Char('/'); + + if (!path.startsWith(homeDir)) { + _ui.pbSelectLocalFolder->setText(QDir::toNativeSeparators(path)); + return; + } + + auto prettyPath = path; + prettyPath.remove(0, homeDir.size()); + + _ui.pbSelectLocalFolder->setText(QDir::toNativeSeparators(prettyPath)); +} + void OwncloudAdvancedSetupPage::slotSelectiveSyncClicked() { AccountPtr acc = static_cast(wizard())->account(); @@ -439,8 +533,23 @@ void OwncloudAdvancedSetupPage::slotStyleChanged() void OwncloudAdvancedSetupPage::customizeStyle() { - if(_progressIndi) - _progressIndi->setColor(QGuiApplication::palette().color(QPalette::Text)); + if (_progressIndi) { + const auto isDarkBackground = Theme::isDarkColor(palette().window().color()); + if (isDarkBackground) { + _progressIndi->setColor(Qt::white); + } else { + _progressIndi->setColor(Qt::black); + } + } + + styleSyncLogo(); + styleLocalFolderLabel(); +} + +void OwncloudAdvancedSetupPage::styleLocalFolderLabel() +{ + const auto backgroundColor = palette().window().color(); + _ui.lLocal->setPixmap(QPixmap(Theme::hidpiFileName("folder.png", backgroundColor))); } void OwncloudAdvancedSetupPage::setRadioChecked(QRadioButton *radio) @@ -457,4 +566,31 @@ void OwncloudAdvancedSetupPage::setRadioChecked(QRadioButton *radio) _ui.rVirtualFileSync->setCheckable(false); } +void OwncloudAdvancedSetupPage::styleSyncLogo() +{ + const auto backgroundColor = palette().window().color(); + _ui.syncLogoLabel->setPixmap(Theme::hidpiFileName("sync-arrows.png", backgroundColor)); +} + +void OwncloudAdvancedSetupPage::setupSyncModeLabel() +{ + auto sizePolicy = _ui.syncModeLabel->sizePolicy(); + sizePolicy.setRetainSizeWhenHidden(true); + _ui.syncModeLabel->setSizePolicy(sizePolicy); +} + +void OwncloudAdvancedSetupPage::setupRKeepLocal() +{ + auto sizePolicy = _ui.rKeepLocal->sizePolicy(); + sizePolicy.setRetainSizeWhenHidden(true); + _ui.rKeepLocal->setSizePolicy(sizePolicy); +} + +void OwncloudAdvancedSetupPage::setupCbSyncFromScratch() +{ + auto sizePolicy = _ui.cbSyncFromScratch->sizePolicy(); + sizePolicy.setRetainSizeWhenHidden(true); + _ui.cbSyncFromScratch->setSizePolicy(sizePolicy); +} + } // namespace OCC diff --git a/src/gui/wizard/owncloudadvancedsetuppage.h b/src/gui/wizard/owncloudadvancedsetuppage.h index 7fcde225a716..069f385d9fa8 100644 --- a/src/gui/wizard/owncloudadvancedsetuppage.h +++ b/src/gui/wizard/owncloudadvancedsetuppage.h @@ -25,6 +25,8 @@ class QProgressIndicator; namespace OCC { +class OwncloudWizard; + /** * @brief The OwncloudAdvancedSetupPage class * @ingroup gui @@ -33,7 +35,7 @@ class OwncloudAdvancedSetupPage : public QWizardPage { Q_OBJECT public: - OwncloudAdvancedSetupPage(); + OwncloudAdvancedSetupPage(OwncloudWizard *wizard); bool isComplete() const override; void initializePage() override; @@ -73,6 +75,16 @@ private slots: qint64 availableLocalSpace() const; QString checkLocalSpace(qint64 remoteSize) const; void customizeStyle(); + void setServerAddressLabelUrl(const QUrl &url); + void setLocalFolderPushButtonPath(const QString &path); + void styleSyncLogo(); + void styleLocalFolderLabel(); + void setResolutionGuiVisible(bool value); + void setupSyncModeLabel(); + void setupRKeepLocal(); + void setupCbSyncFromScratch(); + void fetchUserAvatar(); + void fetchUserData(); Ui_OwncloudAdvancedSetupPage _ui; bool _checking = false; @@ -83,6 +95,7 @@ private slots: QStringList _selectiveSyncBlacklist; qint64 _rSize = -1; qint64 _rSelectedSize = -1; + OwncloudWizard *_ocWizard; }; } // namespace OCC diff --git a/src/gui/wizard/owncloudadvancedsetuppage.ui b/src/gui/wizard/owncloudadvancedsetuppage.ui index 3b3b688dd80f..008d81742131 100644 --- a/src/gui/wizard/owncloudadvancedsetuppage.ui +++ b/src/gui/wizard/owncloudadvancedsetuppage.ui @@ -11,7 +11,7 @@ - + 0 0 @@ -48,7 +48,7 @@ Qt::Vertical - QSizePolicy::Fixed + QSizePolicy::Expanding @@ -59,9 +59,291 @@
- - - + + + 0 + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + 0 + + + + + + + Qt::Vertical + + + QSizePolicy::Expanding + + + + 20 + 40 + + + + + + + + Avatar + + + Qt::AlignCenter + + + + + + + + 75 + true + + + + User name + + + Qt::AlignCenter + + + + + + + Server address + + + Qt::AlignCenter + + + + + + + Qt::Vertical + + + QSizePolicy::Expanding + + + + 20 + 40 + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Minimum + + + + 40 + 20 + + + + + + + + Sync Logo + + + Qt::AlignCenter + + + + + + + Qt::Horizontal + + + QSizePolicy::Minimum + + + + 40 + 20 + + + + + + + + + + Qt::Vertical + + + QSizePolicy::Expanding + + + + 20 + 40 + + + + + + + + + 0 + 0 + + + + &Local Folder + + + Qt::AlignCenter + + + pbSelectLocalFolder + + + + + + + + 75 + true + + + + Local Folder + + + Qt::AlignCenter + + + + + + + 0 + + + + + Qt::Horizontal + + + QSizePolicy::Minimum + + + + 0 + 20 + + + + + + + + + 0 + 0 + + + + pbSelectLocalFolder + + + true + + + false + + + + + + + Qt::Horizontal + + + QSizePolicy::Minimum + + + + 0 + 20 + + + + + + + + + + + 0 + 0 + + + + Free space + + + Qt::AlignCenter + + + + + + + Qt::Vertical + + + QSizePolicy::Expanding + + + + 20 + 40 + + + + + + + + + + Qt::Horizontal @@ -73,378 +355,425 @@ - - - - - 0 - - - 0 - - - + + + + + + QLayout::SetMinimumSize + + + 0 + + + 0 + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + 0 + + + 0 + + + + + 0 + + + 0 + + + + + 0 + + + + + Synchronize everything from server + + + true + + + + + + + Size + + + Qt::PlainText + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + 0 + + + + + Qt::Horizontal + + + QSizePolicy::Minimum + + + + 20 + 20 + + + + + + + + Ask before syncing folders larger than + + + + + + + + 0 + 0 + + + + 999999 + + + 99 + + + + + + + MB + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + 0 + + + + + Qt::Horizontal + + + QSizePolicy::Minimum + + + + 20 + 20 + + + + + + + + Ask before syncing external storages + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + 0 + + + + + + 0 + 0 + + + + + + + false + + + + + + + Choose what to sync + + + true + + + false + + + + + + + TextLabel + + + Qt::PlainText + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + 0 + 0 + + + + Use virtual files !PLACEHOLDER! + + + false + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + 0 + 0 + + + + + 6 + + + QLayout::SetMinimumSize + + + 0 + + + 2 + + + 0 + + + 0 + - - - S&ynchronize everything from server + + + + 0 + 0 + - - true + + + 9 + 75 + true + + + + 1 - - - - - TextLabel + Status message - Qt::PlainText + Qt::AutoText - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - 0 - - - - - Qt::Horizontal + + Qt::AlignCenter - - QSizePolicy::Minimum - - - - 10 - 20 - - - - - - - - - - Ask for confirmation before synchroni&zing folders larger than - - - - - - - 999999 - - - 99 - - - - - - - MB - - - - - - - - - Ask for confirmation before synchronizing e&xternal storages + + false - - - - - + - + 0 0 - - - - false - - - - - - - Choose what to sync - - - - - - - TextLabel + Keep local data - - Qt::PlainText + + true - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - + - + 0 0 + + <html><head/><body><p>If this box is checked, existing content in the local folder will be erased to start a clean sync from the server.</p><p>Do not check this if the local content should be uploaded to the servers folder.</p></body></html> + - Use &virtual files !PLACEHOLDER! + Erase local folder and start a clean sync - false + true - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - - TextLabel - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - &Local Folder - - - Qt::AlignCenter - - - pbSelectLocalFolder - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - 0 - 0 - - - - pbSelectLocalFolder - - - - - - - - - TextLabel - - - Qt::AlignCenter - - - - - - - Server - - - Qt::AlignCenter - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - 0 - 0 - - - - - QLayout::SetMinimumSize - - - QFormLayout::ExpandingFieldsGrow - - - - - &Keep local data - - - true - - - - - - - <html><head/><body><p>If this box is checked, existing content in the local folder will be erased to start a clean sync from the server.</p><p>Do not check this if the local content should be uploaded to the servers folder.</p></body></html> - - - Start a &clean sync (Erases the local folder!) - - - true - - - - - - - - + + - Qt::Vertical - - - QSizePolicy::MinimumExpanding + Qt::Horizontal - 20 - 40 + 40 + 20 - - - - TextLabel - - - - - - TextLabel + + + Qt::Vertical - + + QSizePolicy::Expanding + + + + 20 + 40 + + + - + - Status message - - - Qt::RichText - - - Qt::AlignCenter - - - true + TextLabel diff --git a/src/gui/wizard/owncloudsetupnocredspage.ui b/src/gui/wizard/owncloudsetupnocredspage.ui index d3e62595e06d..d67873450da9 100644 --- a/src/gui/wizard/owncloudsetupnocredspage.ui +++ b/src/gui/wizard/owncloudsetupnocredspage.ui @@ -6,12 +6,12 @@ 0 0 - 802 - 629 + 556 + 489 - + 0 0 @@ -27,102 +27,84 @@ - + + + TextLabel + + + + + Qt::Vertical - QSizePolicy::MinimumExpanding + QSizePolicy::Expanding 20 - 20 + 80 - - - - 0 - 0 - - - - TextLabel - - - Qt::RichText - - - Qt::AlignCenter - - - true + + + 0 - - - - - - - - 40 - 0 - + + + Qt::Horizontal - + - 40 - 16777215 + 0 + 0 - - - - - true - - + - - - - 12 - 75 - true - + + + Logo - - - - 40 - 0 - + + + Qt::Horizontal - + - 40 - 16777215 + 0 + 0 - - - - - true - - + + + + + Qt::Vertical + + + QSizePolicy::Minimum + + + + 0 + 0 + + + + @@ -143,38 +125,28 @@ + + 0 + QLayout::SetDefaultConstraint - - - - Qt::Horizontal - - - QSizePolicy::Preferred - - - - 40 - 0 - - - - + + 6 + Qt::Vertical - QSizePolicy::MinimumExpanding + QSizePolicy::Minimum - 20 + 0 0 @@ -182,73 +154,138 @@ + + 0 + - - - - 0 - 0 - + + + Qt::Horizontal - - Server Address + + + 0 + 0 + - - leUrl + + + + + + + 12 + 75 + true + + + + Server address - - - - 0 - 0 - + + + Qt::Horizontal - - + + + 0 + 0 + - + + + + + + + + 0 + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 80 + 0 + + + - - + + + 8 + + 0 + + + + + 0 + 0 + + + + + 200 + 0 + + + + https://try.nextcloud.com + + + + + + + + 0 + 0 + + + + This is the link to your %1 web interface when you open it in the browser. + + + Qt::AlignCenter + + + true + + + - - - - 0 - 0 - + + + Qt::Horizontal + + + QSizePolicy::Expanding - + - 24 - 24 + 80 + 0 - - - - + - - - - This is the link to your %1 web interface when you open it in the browser.<br/>It looks like https://cloud.example.com or https://example.com/cloud - - - true - - - @@ -268,6 +305,9 @@ + + + @@ -278,7 +318,7 @@ - 20 + 0 0 @@ -286,22 +326,6 @@ - - - - Qt::Horizontal - - - QSizePolicy::Preferred - - - - 40 - 0 - - - - @@ -317,163 +341,26 @@ - 20 - 20 + 0 + 0 - - - 6 - - - 20 + + + TextLabel - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 150 - 0 - - - - false - - - Sign up with a provider - - - false - - - - - - - - 0 - 0 - - - - - 150 - 0 - - - - Log in to your %1 - - - false - - - true - - - false - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - + 0 - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - <a href="https://docs.nextcloud.com/server/latest/admin_manual/installation/#installation"><span style=" text-decoration: underline; color:#7a7a7a;">Host your own server</span></a> - - - true - - - Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - TextLabel - - - Qt::RichText - - - @@ -482,11 +369,6 @@ QLineEdit
wizard/postfixlineedit.h
- - OCC::SlideShow - QWidget -
wizard/slideshow.h
-
diff --git a/src/gui/wizard/owncloudsetuppage.cpp b/src/gui/wizard/owncloudsetuppage.cpp index eff655e000c3..b6042cb0481e 100644 --- a/src/gui/wizard/owncloudsetuppage.cpp +++ b/src/gui/wizard/owncloudsetuppage.cpp @@ -45,10 +45,9 @@ OwncloudSetupPage::OwncloudSetupPage(QWidget *parent) { _ui.setupUi(this); - Theme *theme = Theme::instance(); - setTitle(WizardCommon::titleTemplate().arg(tr("Connect to %1").arg(theme->appNameGUI()))); - setSubTitle(WizardCommon::subTitleTemplate().arg(tr("Setup %1 server").arg(theme->appNameGUI()))); + setupServerAddressDescriptionLabel(); + Theme *theme = Theme::instance(); if (theme->overrideServerUrl().isEmpty()) { _ui.leUrl->setPostfix(theme->wizardUrlPostfix()); _ui.leUrl->setPlaceholderText(theme->wizardUrlHint()); @@ -59,7 +58,11 @@ OwncloudSetupPage::OwncloudSetupPage(QWidget *parent) registerField(QLatin1String("OCUrl*"), _ui.leUrl); - _ui.resultLayout->addWidget(_progressIndi); + auto sizePolicy = _progressIndi->sizePolicy(); + sizePolicy.setRetainSizeWhenHidden(true); + _progressIndi->setSizePolicy(sizePolicy); + + _ui.progressLayout->addWidget(_progressIndi); stopSpinner(); setupCustomization(); @@ -70,35 +73,18 @@ OwncloudSetupPage::OwncloudSetupPage(QWidget *parent) addCertDial = new AddCertificateDialog(this); connect(addCertDial, &QDialog::accepted, this, &OwncloudSetupPage::slotCertificateAccepted); +} -#ifdef WITH_PROVIDERS - connect(_ui.loginButton, &QPushButton::clicked, this, &OwncloudSetupPage::slotLogin); - connect(_ui.createAccountButton, &QPushButton::clicked, this, &OwncloudSetupPage::slotGotoProviderList); - - _ui.login->hide(); - _ui.slideShow->addSlide(Theme::hidpiFileName(":/client/theme/colored/wizard-nextcloud.png"), tr("Keep your data secure and under your control")); - _ui.slideShow->addSlide(Theme::hidpiFileName(":/client/theme/colored/wizard-files.png"), tr("Secure collaboration & file exchange")); - _ui.slideShow->addSlide(Theme::hidpiFileName(":/client/theme/colored/wizard-groupware.png"), tr("Easy-to-use web mail, calendaring & contacts")); - _ui.slideShow->addSlide(Theme::hidpiFileName(":/client/theme/colored/wizard-talk.png"), tr("Screensharing, online meetings & web conferences")); - - connect(_ui.slideShow, &SlideShow::clicked, _ui.slideShow, &SlideShow::stopShow); - connect(_ui.nextButton, &QPushButton::clicked, _ui.slideShow, &SlideShow::nextSlide); - connect(_ui.prevButton, &QPushButton::clicked, _ui.slideShow, &SlideShow::prevSlide); - - _ui.slideShow->startShow(); -#else - _ui.createAccountButton->hide(); - _ui.loginButton->hide(); - _ui.installLink->hide(); - _ui.slideShow->hide(); -#endif +void OwncloudSetupPage::setLogo() +{ + const auto backgroundColor = palette().window().color(); + _ui.logoLabel->setPixmap(Theme::instance()->wizardApplicationLogo(backgroundColor)); +} +void OwncloudSetupPage::setupServerAddressDescriptionLabel() +{ const auto appName = Theme::instance()->appNameGUI(); - _ui.loginButton->setText(tr("Log in to your %1").arg(appName)); - _ui.addressDescriptionLabel->setText(tr("This is the link to your %1 web interface when you open it in the browser.
" - "It looks like https://cloud.example.com or https://example.com/cloud").arg(appName)); - - customizeStyle(); + _ui.serverAddressDescriptionLabel->setText(tr("The link to your %1 web interface when you open it in the browser.").arg(appName)); } void OwncloudSetupPage::setServerUrl(const QString &newUrl) @@ -127,25 +113,17 @@ void OwncloudSetupPage::setupCustomization() variant = theme->customMedia(Theme::oCSetupBottom); WizardCommon::setupCustomMedia(variant, _ui.bottomLabel); + + auto leUrlPalette = _ui.leUrl->palette(); + leUrlPalette.setColor(QPalette::Text, Qt::black); + leUrlPalette.setColor(QPalette::Base, Qt::white); + _ui.leUrl->setPalette(leUrlPalette); } #ifdef WITH_PROVIDERS void OwncloudSetupPage::slotLogin() { - _ui.slideShow->hide(); - _ui.nextButton->hide(); - _ui.prevButton->hide(); - _ocWizard->setRegistration(false); - _ui.login->setMaximumHeight(0); - auto *animation = new QPropertyAnimation(_ui.login, "maximumHeight"); - animation->setDuration(0); - animation->setStartValue(500); - animation->setEndValue(500); - _ui.login->show(); - _ui.loginButton->hide(); - wizard()->resize(wizard()->sizeHint()); - animation->start(); } void OwncloudSetupPage::slotGotoProviderList() { @@ -181,16 +159,6 @@ void OwncloudSetupPage::slotUrlChanged(const QString &url) if (newUrl != url) { _ui.leUrl->setText(newUrl); } - - const auto isSecure = url.startsWith(QLatin1String("https://")); - const auto toolTip = isSecure ? tr("This URL is secure. You can use it.") - : tr("This URL is NOT secure as it is not encrypted.\n" - "It is not advisable to use it."); - const auto pixmap = isSecure ? QPixmap(Theme::hidpiFileName(":/client/theme/lock-https.svg")) - : QPixmap(Theme::hidpiFileName(":/client/theme/lock-http.svg")); - - _ui.urlLabel->setToolTip(toolTip); - _ui.urlLabel->setPixmap(pixmap.scaled(_ui.urlLabel->size(), Qt::KeepAspectRatio)); } void OwncloudSetupPage::slotUrlEditFinished() @@ -210,6 +178,8 @@ bool OwncloudSetupPage::isComplete() const void OwncloudSetupPage::initializePage() { + customizeStyle(); + WizardCommon::initErrorLabel(_ui.errorLabel); _authTypeKnown = false; @@ -217,26 +187,27 @@ void OwncloudSetupPage::initializePage() QAbstractButton *nextButton = wizard()->button(QWizard::NextButton); auto *pushButton = qobject_cast(nextButton); - if (pushButton) + if (pushButton) { pushButton->setDefault(true); + nextButton->setFocus(); + } - // If url is overriden by theme, it's already set and - // we just check the server type and switch to second page - // immediately. - if (Theme::instance()->overrideServerUrl().isEmpty()) { - _ui.leUrl->setFocus(); - } else if (!Theme::instance()->forceOverrideServerUrl()) { + if (!Theme::instance()->overrideServerUrl().isEmpty() && !Theme::instance()->forceOverrideServerUrl()) { + // If the url is overwritten but we don't force to use that url + // Just focus the next button to let the user navigate quicker if (nextButton) { nextButton->setFocus(); } - } else { + } else if (!Theme::instance()->overrideServerUrl().isEmpty()) { + // If the overwritten url is not empty and we force this overwritten url + // we just check the server type and switch to next page + // immediately. setCommitPage(true); // Hack: setCommitPage() changes caption, but after an error this page could still be visible setButtonText(QWizard::CommitButton, tr("&Next >")); validatePage(); setVisible(false); } - wizard()->resize(wizard()->sizeHint()); } int OwncloudSetupPage::nextId() const @@ -269,7 +240,7 @@ bool OwncloudSetupPage::validatePage() QString u = url(); QUrl qurl(u); if (!qurl.isValid() || qurl.host().isEmpty()) { - setErrorString(tr("Invalid URL"), false); + setErrorString(tr("Server address does not seem to be valid"), false); return false; } @@ -338,21 +309,18 @@ void OwncloudSetupPage::setErrorString(const QString &err, bool retryHTTPonly) _checking = false; emit completeChanged(); stopSpinner(); - wizard()->resize(wizard()->sizeHint()); } void OwncloudSetupPage::startSpinner() { - _ui.resultLayout->setEnabled(true); - _ui.urlLabel->setVisible(false); + _ui.progressLayout->setEnabled(true); _progressIndi->setVisible(true); _progressIndi->startAnimation(); } void OwncloudSetupPage::stopSpinner() { - _ui.resultLayout->setEnabled(false); - _ui.urlLabel->setVisible(true); + _ui.progressLayout->setEnabled(false); _progressIndi->setVisible(false); _progressIndi->stopAnimation(); } @@ -397,24 +365,19 @@ void OwncloudSetupPage::slotStyleChanged() void OwncloudSetupPage::customizeStyle() { -#ifdef WITH_PROVIDERS - Theme *theme = Theme::instance(); - - bool widgetHasDarkBg = Theme::isDarkColor(QGuiApplication::palette().base().color()); - _ui.nextButton->setIcon(theme->uiThemeIcon(QString("control-next.svg"), widgetHasDarkBg)); - _ui.prevButton->setIcon(theme->uiThemeIcon(QString("control-prev.svg"), widgetHasDarkBg)); - - // QPushButtons are a mess when it comes to consistent background coloring without stylesheets, - // so we do it here even though this is an exceptional styling method here - _ui.createAccountButton->setStyleSheet("QPushButton {background-color: #0082C9; color: white}"); + setLogo(); + + if (_progressIndi) { + const auto isDarkBackground = Theme::isDarkColor(palette().window().color()); + if (isDarkBackground) { + _progressIndi->setColor(Qt::white); + } else { + _progressIndi->setColor(Qt::black); + } + } - QPalette pal = _ui.slideShow->palette(); - pal.setColor(QPalette::WindowText, theme->wizardHeaderBackgroundColor()); - _ui.slideShow->setPalette(pal); -#endif - if(_progressIndi) - _progressIndi->setColor(QGuiApplication::palette().color(QPalette::Text)); + WizardCommon::customizeHintLabel(_ui.serverAddressDescriptionLabel); } } // namespace OCC diff --git a/src/gui/wizard/owncloudsetuppage.h b/src/gui/wizard/owncloudsetuppage.h index 18b9c0135dc0..485a2bd62203 100644 --- a/src/gui/wizard/owncloudsetuppage.h +++ b/src/gui/wizard/owncloudsetuppage.h @@ -78,7 +78,9 @@ protected slots: void determineAuthType(const QString &); private: + void setLogo(); void customizeStyle(); + void setupServerAddressDescriptionLabel(); Ui_OwncloudSetupPage _ui; diff --git a/src/gui/wizard/owncloudwizard.cpp b/src/gui/wizard/owncloudwizard.cpp index be9bd855e0ab..69af6d97e366 100644 --- a/src/gui/wizard/owncloudwizard.cpp +++ b/src/gui/wizard/owncloudwizard.cpp @@ -54,7 +54,7 @@ OwncloudWizard::OwncloudWizard(QWidget *parent) , _httpCredsPage(new OwncloudHttpCredsPage(this)) , _browserCredsPage(new OwncloudOAuthCredsPage) , _flow2CredsPage(new Flow2AuthCredsPage) - , _advancedSetupPage(new OwncloudAdvancedSetupPage) + , _advancedSetupPage(new OwncloudAdvancedSetupPage(this)) , _resultPage(new OwncloudWizardResultPage) , _webViewPage(new WebViewPage(this)) { @@ -112,6 +112,37 @@ OwncloudWizard::OwncloudWizard(QWidget *parent) // allow Flow2 page to poll on window activation connect(this, &OwncloudWizard::onActivate, _flow2CredsPage, &Flow2AuthCredsPage::slotPollNow); + + adjustWizardSize(); +} + +void OwncloudWizard::adjustWizardSize() +{ + 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(); + }); + + const auto maxPageSizeIter = std::max_element(pageSizes.begin(), pageSizes.end(), [](const QSize &size1, const QSize &size2) { + const auto size1Widest = size1.width() > size1.height() ? size1.width() : size1.height(); + const auto size2Widest = size2.width() > size2.height() ? size2.width() : size2.height(); + + if (size1Widest < size2Widest) { + return true; + } + + return false; + }); + + Q_ASSERT(maxPageSizeIter != pageSizes.end()); + const auto maxPageSizeWidest = maxPageSizeIter->width() > maxPageSizeIter->height() ? maxPageSizeIter->width() : maxPageSizeIter->height(); + const QSize newWizardSize(maxPageSizeWidest, maxPageSizeWidest); + resize(newWizardSize); } void OwncloudWizard::setAccount(AccountPtr account) diff --git a/src/gui/wizard/webview.ui b/src/gui/wizard/webview.ui index ba3588ca8776..8ab0665b7871 100644 --- a/src/gui/wizard/webview.ui +++ b/src/gui/wizard/webview.ui @@ -11,15 +11,15 @@ - + 0 0 - 800 - 650 + 0 + 0 diff --git a/src/gui/wizard/webviewpage.cpp b/src/gui/wizard/webviewpage.cpp index 01311e839bf6..c8eff02e50f1 100644 --- a/src/gui/wizard/webviewpage.cpp +++ b/src/gui/wizard/webviewpage.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include "owncloudwizard.h" #include "creds/webflowcredentials.h" @@ -24,6 +25,7 @@ WebViewPage::WebViewPage(QWidget *parent) _webView = new WebView(this); auto *layout = new QVBoxLayout(this); + layout->setMargin(0); layout->addWidget(_webView); setLayout(layout); @@ -52,6 +54,39 @@ void WebViewPage::initializePage() { } qCInfo(lcWizardWebiewPage()) << "Url to auth at: " << url; _webView->setUrl(QUrl(url)); + + _originalWizardSize = _ocWizard->size(); + resizeWizard(); +} + +void WebViewPage::resizeWizard() +{ + // The webview needs a little bit more space + const auto windowGeometry = QGuiApplication::primaryScreen()->geometry(); + const auto windowWidth = windowGeometry.width(); + const auto windowHeight = windowGeometry.height(); + const auto newWizardWidth = _originalWizardSize.width() * 2; + const auto newWizardHeight = _originalWizardSize.height() * 2; + + if (newWizardWidth < windowWidth && newWizardHeight < windowHeight) { + _ocWizard->resize(newWizardWidth, newWizardHeight); + centerWindow(); + } +} + +void WebViewPage::centerWindow() +{ + auto window = _ocWizard->window(); + const auto screenGeometry = QGuiApplication::primaryScreen()->geometry(); + const auto windowGeometry = window->geometry(); + const auto newWindowPosition = screenGeometry.center() - QPoint(windowGeometry.width() / 2, windowGeometry.height() / 2); + window->move(newWindowPosition); +} + +void WebViewPage::cleanupPage() +{ + _ocWizard->resize(_originalWizardSize); + centerWindow(); } int WebViewPage::nextId() const { diff --git a/src/gui/wizard/webviewpage.h b/src/gui/wizard/webviewpage.h index 65f00c33bb96..423c19336f74 100644 --- a/src/gui/wizard/webviewpage.h +++ b/src/gui/wizard/webviewpage.h @@ -17,6 +17,7 @@ class WebViewPage : public AbstractCredentialsWizardPage ~WebViewPage(); void initializePage() override; + void cleanupPage() override; int nextId() const override; bool isComplete() const override; @@ -30,6 +31,9 @@ private slots: void urlCatched(QString user, QString pass, QString host); private: + void centerWindow(); + void resizeWizard(); + OwncloudWizard *_ocWizard; WebView *_webView; @@ -37,6 +41,8 @@ private slots: QString _pass; bool _useSystemProxy; + + QSize _originalWizardSize; }; } diff --git a/src/libsync/nextcloudtheme.cpp b/src/libsync/nextcloudtheme.cpp index 0ec3f2d27398..2a709564c6e4 100644 --- a/src/libsync/nextcloudtheme.cpp +++ b/src/libsync/nextcloudtheme.cpp @@ -35,7 +35,7 @@ NextcloudTheme::NextcloudTheme() QString NextcloudTheme::wizardUrlHint() const { - return QString("https://host:port"); + return QString("https://try.nextcloud.com"); } }