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
|
#include "stats_display_window.h"
#include "ui_stats_display_window.h"
stats_display_window::stats_display_window(QWidget *parent) :
QWidget(parent),
ui(new Ui::stats_display_window)
{
ui->setupUi(this);
connect(this, SIGNAL(window_loaded()), this, SLOT(test()), Qt::ConnectionType(Qt::QueuedConnection | Qt::UniqueConnection));
}
stats_display_window::~stats_display_window()
{
delete ui;
}
void stats_display_window::showEvent(QShowEvent *ev)
{
emit window_loaded();
}
void stats_display_window::test()
{
QFile file("userdata.dat");
if (file.open(QIODevice::ReadOnly))
{
QTextStream in(&file);
while (!in.atEnd())
{
QString line = in.readLine();
if (line.contains("\"personaname\":"))
user.username = line.split(": ")[1].replace("\"", "").replace(",", "");
if (line.contains("\"realname\":"))
user.realname = line.split(": ")[1].replace("\"", "").replace(",", "");
if (line.contains("\"avatarfull\":"))
user.avatar_url = line.split(": ")[1].replace("\"", "").replace(",", "");
}
file.close();
}
download.download_file(user.avatar_url, "avatar.jpg");
ui->username_label->setText(user.username);
if (user.realname == NULL)
ui->realname_label->setText("Realname not set");
else
ui->realname_label->setText(user.realname);
QPixmap image("avatar.jpg");
ui->avatar_label->setPixmap(image);
}
|