diff options
Diffstat (limited to 'stats_display_window.cpp')
-rw-r--r-- | stats_display_window.cpp | 55 |
1 files changed, 37 insertions, 18 deletions
diff --git a/stats_display_window.cpp b/stats_display_window.cpp index 1dee284..24bbbec 100644 --- a/stats_display_window.cpp +++ b/stats_display_window.cpp @@ -6,7 +6,7 @@ stats_display_window::stats_display_window(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)); + connect(this, SIGNAL(window_loaded()), this, SLOT(window_open()), Qt::ConnectionType(Qt::QueuedConnection | Qt::UniqueConnection)); } stats_display_window::~stats_display_window() @@ -19,25 +19,18 @@ void stats_display_window::showEvent(QShowEvent *ev) emit window_loaded(); } -void stats_display_window::test() +void stats_display_window::window_open() { - 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(); - } + /* + * this slot is called when our stats window is opened + * we will parse our steam account file and edit the UI accordingly + */ + user.username = parse.parse_user_data("\"personaname\":", ": "); + user.realname = parse.parse_user_data("\"realname\":", ": "); + user.avatar_url = parse.parse_user_data("\"avatarfull\":", ": "); + user.status = parse.parse_user_data("\"personastate\":", ": "); download.download_file(user.avatar_url, "avatar.jpg"); + /* now we have to deal with our user account details */ ui->username_label->setText(user.username); if (user.realname == NULL) ui->realname_label->setText("Realname not set"); @@ -46,4 +39,30 @@ void stats_display_window::test() QPixmap image("avatar.jpg"); ui->avatar_label->setPixmap(image); + /* user online status */ + switch(user.status.toInt()) + { + case 0: + ui->status_label->setText("<font color=red>Offline</font>"); + break; + case 1: + ui->status_label->setText("<font color=green>Online</font>"); + break; + case 2: + ui->status_label->setText("<font color=yellow>Busy</font>"); + break; + case 3: + ui->status_label->setText("<font color=orange>Away</font>"); + break; + case 4: + ui->status_label->setText("<font color=black>Snooze</font>"); + break; + default: + ui->status_label->setText("Unknown status"); + break; + } + user.time_ingame = parse.parse_csgo_data("total_time_played"); + QString time_in_game = "Hours in CS:GO: " + QString::number(user.time_ingame.toInt() / 3600); + ui->time_in_label->setText(time_in_game); + qDebug() << user.time_ingame.toInt(); } |