1 /* 2 * Copyright (C) by Michael Schuster <michael@schuster.ms> 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, but 10 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 11 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * for more details. 13 */ 14 15 #ifndef FLOW2AUTHWIDGET_H 16 #define FLOW2AUTHWIDGET_H 17 18 #include <QUrl> 19 #include <QWidget> 20 21 #include "creds/flow2auth.h" 22 23 #include "ui_flow2authwidget.h" 24 25 class QProgressIndicator; 26 27 namespace OCC { 28 29 class Flow2AuthWidget : public QWidget 30 { 31 Q_OBJECT 32 public: 33 Flow2AuthWidget(QWidget *parent = nullptr); 34 ~Flow2AuthWidget() override; 35 36 void startAuth(Account *account); 37 void resetAuth(Account *account = nullptr); 38 void setError(const QString &error); 39 40 public Q_SLOTS: 41 void slotAuthResult(Flow2Auth::Result, const QString &errorString, const QString &user, const QString &appPassword); 42 void slotPollNow(); 43 void slotStatusChanged(Flow2Auth::PollStatus status, int secondsLeft); 44 void slotStyleChanged(); 45 46 signals: 47 void authResult(Flow2Auth::Result, const QString &errorString, const QString &user, const QString &appPassword); 48 void pollNow(); 49 50 private: 51 Account *_account = nullptr; 52 QScopedPointer<Flow2Auth> _asyncAuth; 53 Ui_Flow2AuthWidget _ui; 54 55 protected slots: 56 void slotOpenBrowser(); 57 void slotCopyLinkToClipboard(); 58 59 private: 60 void startSpinner(); 61 void stopSpinner(bool showStatusLabel); 62 void customizeStyle(); 63 void setLogo(); 64 65 QProgressIndicator *_progressIndi; 66 int _statusUpdateSkipCount = 0; 67 }; 68 69 } // namespace OCC 70 71 #endif // FLOW2AUTHWIDGET_H 72