diff options
author | Michael Schuster <michael@schuster.ms> | 2019-12-23 17:45:05 +0300 |
---|---|---|
committer | Michael Schuster <48932272+misch7@users.noreply.github.com> | 2019-12-24 09:46:57 +0300 |
commit | bd9652b24c0674be224e1a94bc0bae09364fdc3a (patch) | |
tree | a014debe23d2701dd02978efd66d275bb23047f9 /src/gui/wizard/flow2authwidget.cpp | |
parent | 8b5f09305c82c55aad6908ef4ca0d7bf4970700f (diff) |
Flow2AuthWidget: Minor fixes and improvements
- Improve status messages
- Add a counter to make sure that "Link copied to clipboard." is visible for
three seconds and to not enable the buttons too early
- Add more space between buttons and status
Signed-off-by: Michael Schuster <michael@schuster.ms>
Diffstat (limited to 'src/gui/wizard/flow2authwidget.cpp')
-rw-r--r-- | src/gui/wizard/flow2authwidget.cpp | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/src/gui/wizard/flow2authwidget.cpp b/src/gui/wizard/flow2authwidget.cpp index 1ba91be33..498a9803e 100644 --- a/src/gui/wizard/flow2authwidget.cpp +++ b/src/gui/wizard/flow2authwidget.cpp @@ -30,6 +30,7 @@ Flow2AuthWidget::Flow2AuthWidget(QWidget *parent) , _account(nullptr) , _ui() , _progressIndi(new QProgressIndicator(this)) + , _statusUpdateSkipCount(0) { _ui.setupUi(this); @@ -51,14 +52,16 @@ void Flow2AuthWidget::startAuth(Account *account) if(oldAuth) oldAuth->deleteLater(); + _statusUpdateSkipCount = 0; + if(account) { _account = account; - _asyncAuth.reset(new Flow2Auth(_account, this)); + _asyncAuth.reset(new Flow2Auth(_account, this)); connect(_asyncAuth.data(), &Flow2Auth::result, this, &Flow2AuthWidget::slotAuthResult, Qt::QueuedConnection); - connect(_asyncAuth.data(), &Flow2Auth::statusChanged, this, &Flow2AuthWidget::slotStatusChanged); - connect(this, &Flow2AuthWidget::pollNow, _asyncAuth.data(), &Flow2Auth::slotPollNow); - _asyncAuth->start(); + connect(_asyncAuth.data(), &Flow2Auth::statusChanged, this, &Flow2AuthWidget::slotStatusChanged); + connect(this, &Flow2AuthWidget::pollNow, _asyncAuth.data(), &Flow2Auth::slotPollNow); + _asyncAuth->start(); } } @@ -131,21 +134,28 @@ void Flow2AuthWidget::slotPollNow() void Flow2AuthWidget::slotStatusChanged(Flow2Auth::PollStatus status, int secondsLeft) { switch(status) -{ + { case Flow2Auth::statusPollCountdown: - _ui.statusLabel->setText(tr("Waiting for authorization") + QString(" (%1)").arg(secondsLeft)); + if(_statusUpdateSkipCount > 0) { + _statusUpdateSkipCount--; + break; + } + _ui.statusLabel->setText(tr("Waiting for authorization") + QString("… (%1)").arg(secondsLeft)); stopSpinner(true); break; case Flow2Auth::statusPollNow: - _ui.statusLabel->setText(tr("Polling for authorization") + "..."); + _statusUpdateSkipCount = 0; + _ui.statusLabel->setText(tr("Polling for authorization") + "…"); startSpinner(); break; case Flow2Auth::statusFetchToken: - _ui.statusLabel->setText(tr("Starting authorization") + "..."); + _statusUpdateSkipCount = 0; + _ui.statusLabel->setText(tr("Starting authorization") + "…"); startSpinner(); break; case Flow2Auth::statusCopyLinkToClipboard: _ui.statusLabel->setText(tr("Link copied to clipboard.")); + _statusUpdateSkipCount = 3; stopSpinner(true); break; } @@ -169,8 +179,8 @@ void Flow2AuthWidget::stopSpinner(bool showStatusLabel) _progressIndi->setVisible(false); _progressIndi->stopAnimation(); - _ui.openLinkButton->setEnabled(true); - _ui.copyLinkButton->setEnabled(true); + _ui.openLinkButton->setEnabled(_statusUpdateSkipCount == 0); + _ui.copyLinkButton->setEnabled(_statusUpdateSkipCount == 0); } void Flow2AuthWidget::slotStyleChanged() |