-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainwidget.h
executable file
·99 lines (79 loc) · 2.57 KB
/
mainwidget.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/*
* This file is part of community judge client project developed by Shervin Kh.
* Copyright (C) 2014 Shervin Kh.
* License: GPLv3 Or Later
* Full license could be found in License file shipped with program or at http://www.gnu.org/licenses/
*/
#ifndef MAINWIDGET_H
#define MAINWIDGET_H
#include <QWidget>
#include <QList>
#include <QUrl>
#include "general.h"
class QLabel;
class QVBoxLayout;
class QHBoxLayout;
class QStackedWidget;
class QPushButton;
class Connection;
class LoginWidget;
class UserWidget;
class AdminPanel;
class MainWidget : public QWidget
{
Q_OBJECT
private:
static const QString ver;
static const QString verDate;
Connection *conn;
QLabel *title;
QHBoxLayout *titleLayout;
LoginWidget *loginP;
UserWidget *userP;
AdminPanel *adminP;
QStackedWidget *sw;
QLabel *statusLabel;
QLabel *status;
QPushButton *abortButton;
QHBoxLayout *statusLayout;
QVBoxLayout *totalLayout;
DataTable auth;
bool adminFlag;
QList<QPair<QString, QUrl>> serverList;
QString rememberedUser;
QByteArray rememberedPass;
QUrl rememberedHost;
void saveState();
void loadState();
public:
explicit MainWidget(Connection *con, QWidget *parent = Q_NULLPTR);
~MainWidget();
Connection *connection() {return conn;}
bool handleGeneralStatCodes(StatCode retCode);
void showAboutDialog();
static QByteArray hashPassword(const QByteArray &input);
static QString formatSize(qint64 bytes);
static QString formatTime(qint64 time);
static QString version() {return ver;}
static QString versionDate() {return verDate;}
QList<QPair<QString, QUrl>> &servers() {return serverList;}
void setAuth(const QString &uname, const QByteArray &pass);
void setRememberedUsername(const QString &username) {rememberedUser = username;}
void setRememberedPassword(const QByteArray &password) {rememberedPass = password;}
QString rememberedUsername() const {return rememberedUser;}
QByteArray rememberedPassword() const {return rememberedPass;}
QUrl rememberedHostAddress() const {return rememberedHost;}
QString currentUsername() const {return auth["user"].toString();}
QByteArray currentPassword() const {return auth["pass"].toByteArray();}
bool isAdmin() const {return adminFlag;}
void setAdmin(bool a) {adminFlag = a;}
void setServer(int idx);
void updateServerSelection();
public slots:
void updateStatus();
void switchToLoginPanel();
void switchToUserPanel();
void switchToAdminPanel();
void loginDo();
};
#endif // MAINWIDGET_H