-
Notifications
You must be signed in to change notification settings - Fork 1
/
sguclient.cpp
96 lines (79 loc) · 2.08 KB
/
sguclient.cpp
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
#include "sguclient.h"
#include "friendactivity.h"
#include "accountmanager.h"
#include "filedownloader.h"
#include "onlinestatus.h"
#include "competition.h"
#include <QtGui>
SGUClient::SGUClient(QWidget *parent) :
QMainWindow(parent)
{
friendAct = new QPushButton(tr("Friends activity"));
competit = new QPushButton(tr("Competitions"));
stat = new QPushButton(tr("Status"));
accs = new QPushButton(tr("Accounts"));
butts = new QVBoxLayout;
butts->addWidget(friendAct);
butts->addWidget(competit);
butts->addWidget(stat);
butts->addWidget(accs);
sw = new QStackedWidget;
layou = new QHBoxLayout;
layou->addLayout(butts);
layou->addWidget(sw);
wid = new QWidget;
wid->setLayout(layou);
fd = new FileDownloader(this);
am = new AccountManager(this, fd);
fa = new FriendActivity(this, am);
so = new OnlineStatus(this, am, fd);
com = new Competition(this, am);
sw->addWidget(fa);
sw->addWidget(so);
sw->addWidget(am);
sw->addWidget(com);
sw->setCurrentWidget(fa);
connect(accs, SIGNAL(clicked()), this, SLOT(accPage()));
connect(friendAct, SIGNAL(clicked()), this, SLOT(faPage()));
connect(stat, SIGNAL(clicked()), this, SLOT(statPage()));
connect(competit, SIGNAL(clicked()), this, SLOT(comPage()));
setCentralWidget(wid);
setWindowTitle("SGU Client By Leo145");
QTimer::singleShot(0, this, SLOT(loadCache()));
}
SGUClient::~SGUClient()
{
QFile file(".SGU_Client_Cached_Data");
if (file.open(QIODevice::WriteOnly))
{
QDataStream ds(&file);
ds << *am << *fa << *so << *com;
}
file.close();
}
void SGUClient::loadCache()
{
QFile file(".SGU_Client_Cached_Data");
if (file.open(QIODevice::ReadOnly))
{
QDataStream ds(&file);
ds >> *am >> *fa >> *so >> *com;
}
file.close();
}
void SGUClient::accPage()
{
sw->setCurrentWidget(am);
}
void SGUClient::faPage()
{
sw->setCurrentWidget(fa);
}
void SGUClient::statPage()
{
sw->setCurrentWidget(so);
}
void SGUClient::comPage()
{
sw->setCurrentWidget(com);
}