Flow2: Make ProgressIndicator's background-aware (Dark-/Light-Mode switching)

Signed-off-by: Michael Schuster <michael@schuster.ms>
This commit is contained in:
Michael Schuster 2019-12-21 04:31:45 +01:00 committed by Michael Schuster
parent e81f972270
commit a69aed80e6
7 changed files with 52 additions and 0 deletions

View file

@ -33,6 +33,9 @@ WebFlowCredentialsDialog::WebFlowCredentialsDialog(Account *account, bool useFlo
connect(_flow2AuthWidget, &Flow2AuthWidget::urlCatched, this, &WebFlowCredentialsDialog::urlCatched);
// Connect styleChanged events to our widgets, so they can adapt (Dark-/Light-Mode switching)
connect(this, &WebFlowCredentialsDialog::styleChanged, _flow2AuthWidget, &Flow2AuthWidget::slotStyleChanged);
// allow Flow2 page to poll on window activation
connect(this, &WebFlowCredentialsDialog::onActivate, _flow2AuthWidget, &Flow2AuthWidget::slotPollNow);
} else {
@ -52,6 +55,8 @@ WebFlowCredentialsDialog::WebFlowCredentialsDialog(Account *account, bool useFlo
WizardCommon::initErrorLabel(_errorLabel);
setLayout(_layout);
customizeStyle();
}
void WebFlowCredentialsDialog::closeEvent(QCloseEvent* e) {
@ -93,6 +98,14 @@ void WebFlowCredentialsDialog::setError(const QString &error) {
void WebFlowCredentialsDialog::changeEvent(QEvent *e)
{
switch (e->type()) {
case QEvent::StyleChange:
case QEvent::PaletteChange:
case QEvent::ThemeChange:
customizeStyle();
// Notify the other widgets (Dark-/Light-Mode switching)
emit styleChanged();
break;
case QEvent::ActivationChange:
if(isActiveWindow())
emit onActivate();
@ -104,6 +117,11 @@ void WebFlowCredentialsDialog::changeEvent(QEvent *e)
QDialog::changeEvent(e);
}
void WebFlowCredentialsDialog::customizeStyle()
{
// HINT: Customize dialog's own style here, if necessary in the future (Dark-/Light-Mode switching)
}
void WebFlowCredentialsDialog::slotShowSettingsDialog()
{
// bring window to top but slightly delay, to avoid being hidden behind the SettingsDialog

View file

@ -37,9 +37,12 @@ public slots:
signals:
void urlCatched(const QString user, const QString pass, const QString host);
void styleChanged();
void onActivate();
private:
void customizeStyle();
bool _useFlow2;
Flow2AuthWidget *_flow2AuthWidget;

View file

@ -55,6 +55,8 @@ Flow2AuthCredsPage::Flow2AuthCredsPage()
_ui.horizontalLayout->addWidget(_progressIndi);
stopSpinner(false);
customizeStyle();
}
void Flow2AuthCredsPage::initializePage()
@ -203,4 +205,15 @@ void Flow2AuthCredsPage::stopSpinner(bool showStatusLabel)
_ui.copyLinkButton->setEnabled(true);
}
void Flow2AuthCredsPage::slotStyleChanged()
{
customizeStyle();
}
void Flow2AuthCredsPage::customizeStyle()
{
if(_progressIndi)
_progressIndi->setColor(QGuiApplication::palette().color(QPalette::Text));
}
} // namespace OCC

View file

@ -49,6 +49,7 @@ public Q_SLOTS:
void asyncAuthResult(Flow2Auth::Result, const QString &user, const QString &appPassword);
void slotPollNow();
void slotStatusChanged(int secondsLeft);
void slotStyleChanged();
signals:
void connectToOCUrl(const QString &);
@ -67,6 +68,7 @@ protected slots:
private:
void startSpinner();
void stopSpinner(bool showStatusLabel);
void customizeStyle();
QProgressIndicator *_progressIndi;
};

View file

@ -64,6 +64,8 @@ Flow2AuthWidget::Flow2AuthWidget(Account *account, QWidget *parent)
connect(_asyncAuth.data(), &Flow2Auth::statusChanged, this, &Flow2AuthWidget::slotStatusChanged);
connect(this, &Flow2AuthWidget::pollNow, _asyncAuth.data(), &Flow2Auth::slotPollNow);
_asyncAuth->start();
customizeStyle();
}
void Flow2AuthWidget::asyncAuthResult(Flow2Auth::Result r, const QString &user,
@ -161,4 +163,15 @@ void Flow2AuthWidget::stopSpinner(bool showStatusLabel)
_ui.copyLinkButton->setEnabled(true);
}
void Flow2AuthWidget::slotStyleChanged()
{
customizeStyle();
}
void Flow2AuthWidget::customizeStyle()
{
if(_progressIndi)
_progressIndi->setColor(QGuiApplication::palette().color(QPalette::Text));
}
} // namespace OCC

View file

@ -39,6 +39,7 @@ public Q_SLOTS:
void asyncAuthResult(Flow2Auth::Result, const QString &user, const QString &appPassword);
void slotPollNow();
void slotStatusChanged(int secondsLeft);
void slotStyleChanged();
signals:
void urlCatched(const QString user, const QString pass, const QString host);
@ -58,6 +59,7 @@ protected slots:
private:
void startSpinner();
void stopSpinner(bool showStatusLabel);
void customizeStyle();
QProgressIndicator *_progressIndi;
};

View file

@ -106,6 +106,7 @@ OwncloudWizard::OwncloudWizard(QWidget *parent)
// Connect styleChanged events to our widgets, so they can adapt (Dark-/Light-Mode switching)
connect(this, &OwncloudWizard::styleChanged, _setupPage, &OwncloudSetupPage::slotStyleChanged);
connect(this, &OwncloudWizard::styleChanged, _advancedSetupPage, &OwncloudAdvancedSetupPage::slotStyleChanged);
connect(this, &OwncloudWizard::styleChanged, _flow2CredsPage, &Flow2AuthCredsPage::slotStyleChanged);
customizeStyle();