2011-08-27 23:01:28 +02:00
|
|
|
/* This file is part of Clementine.
|
|
|
|
Copyright 2010, David Sansome <me@davidsansome.com>
|
|
|
|
|
|
|
|
Clementine is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Clementine is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef LOGINSTATEWIDGET_H
|
|
|
|
#define LOGINSTATEWIDGET_H
|
|
|
|
|
2011-11-05 22:46:34 +01:00
|
|
|
#include <QDate>
|
2011-08-27 23:01:28 +02:00
|
|
|
#include <QWidget>
|
|
|
|
|
|
|
|
class Ui_LoginStateWidget;
|
|
|
|
|
|
|
|
class LoginStateWidget : public QWidget {
|
|
|
|
Q_OBJECT
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
public:
|
2014-02-10 16:03:54 +01:00
|
|
|
LoginStateWidget(QWidget* parent = nullptr);
|
2011-08-27 23:01:28 +02:00
|
|
|
~LoginStateWidget();
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
enum State { LoggedIn, LoginInProgress, LoggedOut };
|
2011-08-27 23:01:28 +02:00
|
|
|
|
|
|
|
// Installs an event handler on the field so that pressing enter will emit
|
|
|
|
// LoginClicked() instead of doing the default action (closing the dialog).
|
|
|
|
void AddCredentialField(QWidget* widget);
|
|
|
|
|
|
|
|
// This widget (usually a QGroupBox) will be hidden when SetLoggedIn(true)
|
|
|
|
// is called.
|
|
|
|
void AddCredentialGroup(QWidget* widget);
|
|
|
|
|
|
|
|
// QObject
|
|
|
|
bool eventFilter(QObject* object, QEvent* event);
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
public slots:
|
2011-08-27 23:01:28 +02:00
|
|
|
// Changes the "You are logged in/out" label, shows/hides any QGroupBoxes
|
|
|
|
// added with AddCredentialGroup.
|
2019-11-09 23:45:28 +01:00
|
|
|
void SetLoggedIn(State state, const QString& account_name = QString());
|
2011-08-27 23:01:28 +02:00
|
|
|
|
|
|
|
// Hides the "You are logged in/out" label completely.
|
|
|
|
void HideLoggedInState();
|
|
|
|
|
|
|
|
void SetAccountTypeText(const QString& text);
|
|
|
|
void SetAccountTypeVisible(bool visible);
|
|
|
|
|
2011-11-05 22:46:34 +01:00
|
|
|
void SetExpires(const QDate& expires);
|
|
|
|
|
2020-09-18 16:15:19 +02:00
|
|
|
signals:
|
2011-08-27 23:01:28 +02:00
|
|
|
void LogoutClicked();
|
|
|
|
void LoginClicked();
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
private slots:
|
2011-08-27 23:01:28 +02:00
|
|
|
void Logout();
|
2011-11-27 18:54:36 +01:00
|
|
|
void FocusLastCredentialField();
|
2011-08-27 23:01:28 +02:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
private:
|
2011-08-27 23:01:28 +02:00
|
|
|
Ui_LoginStateWidget* ui_;
|
|
|
|
|
2011-11-27 18:54:36 +01:00
|
|
|
State state_;
|
|
|
|
|
2011-08-27 23:01:28 +02:00
|
|
|
QList<QObject*> credential_fields_;
|
|
|
|
QList<QWidget*> credential_groups_;
|
|
|
|
};
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
#endif // LOGINSTATEWIDGET_H
|