forked from shervinkh/sgu-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sguclient.cpp
112 lines (93 loc) · 2.65 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#include "sguclient.h"
#include "friendactivity.h"
#include "accountmanager.h"
#include "filedownloader.h"
#include "onlinestatus.h"
#include "competition.h"
#include "suggestion.h"
#include <QtGui>
SGUClient::SGUClient(QWidget *parent) :
QMainWindow(parent)
{
friendAct = new QPushButton(tr("Friends activity"));
competit = new QPushButton(tr("Competitions"));
sugg = new QPushButton(tr("Suggestions"));
stat = new QPushButton(tr("Status"));
accs = new QPushButton(tr("Accounts"));
friendAct->setMinimumHeight( friendAct->sizeHint().height() * 1.3 );
competit->setMinimumHeight( competit->sizeHint().height() * 1.3 );
sugg->setMinimumHeight( sugg->sizeHint().height() * 1.3 );
stat->setMinimumHeight( stat->sizeHint().height() * 1.3 );
accs->setMinimumHeight( accs->sizeHint().height() * 1.3 );
butts = new QVBoxLayout;
butts->addWidget(friendAct);
butts->addWidget(competit);
butts->addWidget(sugg);
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);
sug = new Suggestion(this, am);
sw->addWidget(fa);
sw->addWidget(so);
sw->addWidget(am);
sw->addWidget(com);
sw->addWidget(sug);
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()));
connect(sugg, SIGNAL(clicked()) , this, SLOT(sugPage()) );
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 << *sug;
}
file.close();
}
void SGUClient::loadCache()
{
QFile file(".SGU_Client_Cached_Data");
if (file.open(QIODevice::ReadOnly))
{
QDataStream ds(&file);
ds >> *am >> *fa >> *so >> *com >> *sug;
}
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);
}
void SGUClient::sugPage(){
sw->setCurrentWidget(sug);
}