comunicwatcher/aboutdialog.cpp

46 lines
953 B
C++
Raw Normal View History

2020-06-14 12:44:32 +00:00
#include <QMessageBox>
#include "accounthelper.h"
#include "aboutdialog.h"
#include "ui_aboutdialog.h"
2020-06-13 16:05:06 +00:00
AboutDialog::AboutDialog(QWidget *parent) :
2020-06-13 16:05:06 +00:00
QDialog(parent),
ui(new Ui::AboutDialog)
2020-06-13 16:05:06 +00:00
{
ui->setupUi(this);
2020-06-14 12:44:32 +00:00
AccountHelper::GetUserID([this](int id) {
this->onGotUserId(id);
});
2020-06-14 13:00:45 +00:00
connect(&mUserHelper, &UserHelper::onGotUserInfo, this, &AboutDialog::getUserCallback);
2020-06-13 16:05:06 +00:00
}
AboutDialog::~AboutDialog()
2020-06-13 16:05:06 +00:00
{
delete ui;
}
2020-06-14 12:44:32 +00:00
void AboutDialog::getUserCallback(const User &u)
2020-06-14 13:00:45 +00:00
{
if(!u.isValid()) {
QMessageBox::warning(this, tr("Error"), tr("Could not get user information!"));
return;
}
this->ui->user_name->setText(u.fullName());
}
void AboutDialog::onGotUserId(int userID)
2020-06-14 12:44:32 +00:00
{
if(userID < 1) {
QMessageBox::warning(this, tr("Error"), tr("Could not get your id!"));
return;
}
this->ui->user_id->setText(QString::number(userID));
2020-06-14 13:00:45 +00:00
mUserHelper.getUserInfo(userID);
2020-06-14 12:44:32 +00:00
}