Since the default remote poll interval has been re-raised recently to 30 seconds,
the delay between clicking "Grant access" in the browser and fetch and showing success
in the dialog may seem erroneous to the users and tempt them to click "Re-open browser"
again, causing the whole login process to restart.
This commit implements an event handler to pass the dialog's window activation
event down to the Login Flow v2 widget, in order to allow it to poll earlier.
See previous commits for dependent implementation details.
Signed-off-by: Michael Schuster <michael@schuster.ms>
_layout->addWidget(_flow2AuthWidget);
connect(_flow2AuthWidget, &Flow2AuthWidget::urlCatched, this, &WebFlowCredentialsDialog::urlCatched);
+
+ // allow Flow2 page to poll on window activation
+ connect(this, &WebFlowCredentialsDialog::onActivate, _flow2AuthWidget, &Flow2AuthWidget::slotPollNow);
} else {
_webView = new WebView();
_layout->addWidget(_webView);
}
}
+void WebFlowCredentialsDialog::changeEvent(QEvent *e)
+{
+ switch (e->type()) {
+ case QEvent::ActivationChange:
+ if(isActiveWindow())
+ emit onActivate();
+ break;
+ default:
+ break;
+ }
+
+ QDialog::changeEvent(e);
+}
+
void WebFlowCredentialsDialog::slotShowSettingsDialog()
{
// bring window to top but slightly delay, to avoid being hidden behind the SettingsDialog
protected:
void closeEvent(QCloseEvent * e) override;
+ void changeEvent(QEvent *) override;
public slots:
void slotShowSettingsDialog();
signals:
void urlCatched(const QString user, const QString pass, const QString host);
+ void onActivate();
private:
bool _useFlow2;
_asyncAuth.reset(new Flow2Auth(_account, this));
connect(_asyncAuth.data(), &Flow2Auth::result, this, &Flow2AuthWidget::asyncAuthResult, Qt::QueuedConnection);
+ connect(this, &Flow2AuthWidget::pollNow, _asyncAuth.data(), &Flow2Auth::slotPollNow);
_asyncAuth->start();
}
QApplication::clipboard()->setText(_asyncAuth->authorisationLink().toString(QUrl::FullyEncoded));
}
+void Flow2AuthWidget::slotPollNow()
+{
+ emit pollNow();
+}
+
} // namespace OCC
public Q_SLOTS:
void asyncAuthResult(Flow2Auth::Result, const QString &user, const QString &appPassword);
+ void slotPollNow();
signals:
void urlCatched(const QString user, const QString pass, const QString host);
+ void pollNow();
private:
Account *_account;