1 /*
2     Copyright © 2015-2019 by The qTox Project Contributors
3 
4     This file is part of qTox, a Qt-based graphical interface for Tox.
5 
6     qTox is libre software: you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation, either version 3 of the License, or
9     (at your option) any later version.
10 
11     qTox is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15 
16     You should have received a copy of the GNU General Public License
17     along with qTox.  If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 
21 #ifndef LOGINSCREEN_H
22 #define LOGINSCREEN_H
23 
24 #include <QDialog>
25 #include <QShortcut>
26 #include <QToolButton>
27 
28 class Profile;
29 
30 namespace Ui {
31 class LoginScreen;
32 }
33 
34 class LoginScreen : public QDialog
35 {
36     Q_OBJECT
37 
38 public:
39     LoginScreen(const QString& initialProfileName = QString(), QWidget* parent = nullptr);
40     ~LoginScreen();
41     bool event(QEvent* event) final override;
42 
43 signals:
44 
45     void windowStateChanged(Qt::WindowStates states);
46     void autoLoginChanged(bool state);
47     void createNewProfile(QString name, const QString& pass);
48     void loadProfile(QString name, const QString& pass);
49 
50 public slots:
51     void onProfileLoaded();
52     void onProfileLoadFailed();
53     void onAutoLoginChanged(bool state);
54 
55 private slots:
56     void onAutoLoginCheckboxChanged(int state);
57     void onLoginUsernameSelected(const QString& name);
58     void onPasswordEdited();
59     // Buttons to change page
60     void onNewProfilePageClicked();
61     void onLoginPageClicked();
62     // Buttons to submit form
63     void onCreateNewProfile();
64     void onLogin();
65     void onImportProfile();
66 
67 private:
68     void reset(const QString& initialProfileName = QString());
69     void retranslateUi();
70     void showCapsIndicator();
71     void hideCapsIndicator();
72     void checkCapsLock();
73 
74 private:
75     Ui::LoginScreen* ui;
76     QShortcut quitShortcut;
77 };
78 
79 #endif // LOGINSCREEN_H
80