Skip to content

Commit

Permalink
Restyle wizard pages
Browse files Browse the repository at this point in the history
Signed-off-by: Felix Weilbach <[email protected]>
  • Loading branch information
Felix Weilbach committed Feb 25, 2021
1 parent 3e27044 commit 89d0397
Show file tree
Hide file tree
Showing 16 changed files with 1,284 additions and 790 deletions.
2 changes: 1 addition & 1 deletion src/gui/owncloudsetupwizard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 2 additions & 3 deletions src/gui/wizard/flow2authcredspage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -59,6 +56,8 @@ void Flow2AuthCredsPage::initializePage()

// Don't hide the wizard (avoid user confusion)!
//wizard()->hide();

_flow2AuthWidget->slotStyleChanged();
}

void OCC::Flow2AuthCredsPage::cleanupPage()
Expand Down
50 changes: 38 additions & 12 deletions src/gui/wizard/flow2authwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include "common/utility.h"
#include "account.h"
#include "wizard/owncloudwizardcommon.h"
#include "theme.h"
#include "linklabel.h"

#include "QProgressIndicator.h"

Expand All @@ -34,13 +36,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.openLinkLabel, &LinkLabel::clicked, this, &Flow2AuthWidget::slotOpenBrowser);
connect(_ui.copyLinkLabel, &LinkLabel::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)
Expand Down Expand Up @@ -160,24 +170,24 @@ 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();

_ui.openLinkButton->setEnabled(false);
_ui.copyLinkButton->setEnabled(false);
_ui.openLinkLabel->setEnabled(false);
_ui.copyLinkLabel->setEnabled(false);
}

void Flow2AuthWidget::stopSpinner(bool showStatusLabel)
{
_ui.horizontalLayout->setEnabled(false);
_ui.progressLayout->setEnabled(false);
_ui.statusLabel->setVisible(showStatusLabel);
_progressIndi->setVisible(false);
_progressIndi->stopAnimation();

_ui.openLinkButton->setEnabled(_statusUpdateSkipCount == 0);
_ui.copyLinkButton->setEnabled(_statusUpdateSkipCount == 0);
_ui.openLinkLabel->setEnabled(_statusUpdateSkipCount == 0);
_ui.copyLinkLabel->setEnabled(_statusUpdateSkipCount == 0);
}

void Flow2AuthWidget::slotStyleChanged()
Expand All @@ -187,8 +197,24 @@ 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);
}
}

_ui.openLinkLabel->setText(tr("Reopen Browser"));
_ui.openLinkLabel->setAlignment(Qt::AlignCenter);

_ui.copyLinkLabel->setText(tr("Copy Link"));
_ui.copyLinkLabel->setAlignment(Qt::AlignCenter);

WizardCommon::customizeHintLabel(_ui.statusLabel);
}

} // namespace OCC
1 change: 1 addition & 0 deletions src/gui/wizard/flow2authwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ protected slots:
void startSpinner();
void stopSpinner(bool showStatusLabel);
void customizeStyle();
void setLogo();

QProgressIndicator *_progressIndi;
int _statusUpdateSkipCount = 0;
Expand Down
179 changes: 134 additions & 45 deletions src/gui/wizard/flow2authwidget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -27,44 +27,138 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Please switch to your browser to proceed.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="errorLabel">
<property name="text">
<string>An error occurred while connecting. Please try again.</string>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
</widget>
</item>
<item>
<widget class="QCommandLinkButton" name="openLinkButton">
<property name="text">
<string>Re-open Browser</string>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>80</height>
</size>
</property>
</widget>
</spacer>
</item>
<item>
<widget class="QCommandLinkButton" name="copyLinkButton">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="topMargin">
<number>0</number>
</property>
<property name="text">
<string>Copy link</string>
<property name="bottomMargin">
<number>0</number>
</property>
</widget>
<item>
<widget class="QLabel" name="logoLabel">
<property name="text">
<string>Logo</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="font">
<font>
<pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Switch to your browser to connect your account</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="statusLabel">
<property name="text">
<string notr="true">Status</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="margin">
<number>0</number>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="topMargin">
<number>0</number>
</property>
<item>
<widget class="OCC::LinkLabel" name="copyLinkLabel" native="true"/>
</item>
<item>
<widget class="OCC::LinkLabel" name="openLinkLabel" native="true"/>
</item>
</layout>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="errorLabel">
<property name="text">
<string>An error occurred while connecting. Please try again.</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="progressLayout"/>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_2">
Expand All @@ -79,19 +173,6 @@
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="statusLabel">
<property name="text">
<string notr="true">TextLabel</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout"/>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
Expand All @@ -100,13 +181,21 @@
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>107</height>
<height>80</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>OCC::LinkLabel</class>
<extends>QWidget</extends>
<header>wizard/linklabel.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
Loading

0 comments on commit 89d0397

Please sign in to comment.