Flow2AuthWidget: Minor fixes and improvements
authorMichael Schuster <michael@schuster.ms>
Mon, 23 Dec 2019 14:45:05 +0000 (15:45 +0100)
committerMichael Schuster <48932272+misch7@users.noreply.github.com>
Tue, 24 Dec 2019 06:46:57 +0000 (07:46 +0100)
- 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>
src/gui/wizard/flow2authwidget.cpp
src/gui/wizard/flow2authwidget.h
src/gui/wizard/flow2authwidget.ui

index 1ba91be3341e85bab1277dd7ad6cf9f2c467986e..498a9803ef63c384110728d8c8bbfc019021858f 100644 (file)
@@ -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()
index c10b847105f6e0a0258f5881fef9c5a4ab6e31c5..609791d9b91a8e8ec50d67ea5abd7e4307046ef0 100644 (file)
@@ -62,6 +62,7 @@ private:
     void customizeStyle();
 
     QProgressIndicator *_progressIndi;
+    int _statusUpdateSkipCount;
 };
 
 } // namespace OCC
index a07e0e1a93f2cf7e22746ae85f8c7bf1cd4dcec0..57f23186d814a87708f99f1f2e240bcfc39037a9 100644 (file)
@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>500</width>
-    <height>280</height>
+    <width>580</width>
+    <height>330</height>
    </rect>
   </property>
   <property name="sizePolicy">
@@ -74,7 +74,7 @@
      <property name="sizeHint" stdset="0">
       <size>
        <width>20</width>
-       <height>10</height>
+       <height>20</height>
       </size>
      </property>
     </spacer>
      <property name="sizeHint" stdset="0">
       <size>
        <width>20</width>
-       <height>127</height>
+       <height>107</height>
       </size>
      </property>
     </spacer>