diff options
Diffstat (limited to 'stats_display_window.cpp')
-rw-r--r-- | stats_display_window.cpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/stats_display_window.cpp b/stats_display_window.cpp new file mode 100644 index 0000000..1dee284 --- /dev/null +++ b/stats_display_window.cpp @@ -0,0 +1,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); + +} |