mirror of
https://gitlab.com/comunic/comunicwatcher
synced 2024-10-22 22:53:24 +00:00
46 lines
963 B
C++
46 lines
963 B
C++
#include <QMessageBox>
|
|
|
|
#include "accounthelper.h"
|
|
#include "whoamidialog.h"
|
|
#include "ui_whoamidialog.h"
|
|
|
|
WhoAmIDialog::WhoAmIDialog(QWidget *parent) :
|
|
QDialog(parent),
|
|
ui(new Ui::WhoAmIDialog)
|
|
{
|
|
ui->setupUi(this);
|
|
|
|
AccountHelper::GetUserID([this](int id) {
|
|
this->onGotUserId(id);
|
|
});
|
|
|
|
connect(&mUserHelper, &UserHelper::onGotUserInfo, this, &WhoAmIDialog::getUserCallback);
|
|
}
|
|
|
|
WhoAmIDialog::~WhoAmIDialog()
|
|
{
|
|
delete ui;
|
|
}
|
|
|
|
void WhoAmIDialog::getUserCallback(const User &u)
|
|
{
|
|
if(!u.isValid()) {
|
|
QMessageBox::warning(this, tr("Error"), tr("Could not get user information!"));
|
|
return;
|
|
}
|
|
|
|
this->ui->user_name->setText(u.fullName());
|
|
}
|
|
|
|
void WhoAmIDialog::onGotUserId(int userID)
|
|
{
|
|
if(userID < 1) {
|
|
QMessageBox::warning(this, tr("Error"), tr("Could not get your id!"));
|
|
return;
|
|
}
|
|
|
|
this->ui->user_id->setText(QString::number(userID));
|
|
|
|
mUserHelper.getUserInfo(userID);
|
|
}
|