UI: User info dialog updates (#4533)
This commit is contained in:
parent
07248692ce
commit
304ed3cd60
2 changed files with 24 additions and 20 deletions
|
@ -26,29 +26,33 @@ UserInfoBox::UserInfoBox(AbstractClient *_client, bool _editable, QWidget *paren
|
||||||
nameFont.setPointSizeF(nameFont.pointSizeF() * 1.5);
|
nameFont.setPointSizeF(nameFont.pointSizeF() * 1.5);
|
||||||
nameLabel.setFont(nameFont);
|
nameLabel.setFont(nameFont);
|
||||||
|
|
||||||
avatarLabel.setMinimumSize(200, 200);
|
auto *userIconAndNameLayout = new QHBoxLayout;
|
||||||
avatarLabel.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
userIconAndNameLayout->addWidget(&userLevelIcon, 0, Qt::AlignCenter);
|
||||||
avatarLabel.setAlignment(Qt::AlignCenter);
|
userIconAndNameLayout->addWidget(&nameLabel, 1);
|
||||||
|
userIconAndNameLayout->addStretch();
|
||||||
|
|
||||||
|
avatarPic.setMinimumSize(200, 200);
|
||||||
|
avatarPic.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||||
|
avatarPic.setAlignment(Qt::AlignCenter);
|
||||||
|
|
||||||
auto *avatarLayout = new QHBoxLayout;
|
auto *avatarLayout = new QHBoxLayout;
|
||||||
avatarLayout->setContentsMargins(0, 0, 0, 0);
|
avatarLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
avatarLayout->addStretch(1);
|
avatarLayout->addStretch(1);
|
||||||
avatarLayout->addWidget(&avatarLabel, 3);
|
avatarLayout->addWidget(&avatarPic, 3);
|
||||||
avatarLayout->addStretch(1);
|
avatarLayout->addStretch(1);
|
||||||
|
|
||||||
auto *mainLayout = new QGridLayout;
|
auto *mainLayout = new QGridLayout;
|
||||||
mainLayout->addLayout(avatarLayout, 0, 0, 1, 3);
|
mainLayout->addLayout(avatarLayout, 0, 0, 1, 3);
|
||||||
mainLayout->addWidget(&nameLabel, 1, 0, 1, 3);
|
mainLayout->addLayout(userIconAndNameLayout, 1, 0, 1, 3);
|
||||||
mainLayout->addWidget(&realNameLabel1, 2, 0, 1, 1);
|
mainLayout->addWidget(&realNameLabel1, 2, 0, 1, 1);
|
||||||
mainLayout->addWidget(&realNameLabel2, 2, 1, 1, 2);
|
mainLayout->addWidget(&realNameLabel2, 2, 1, 1, 2);
|
||||||
mainLayout->addWidget(&countryLabel1, 4, 0, 1, 1);
|
mainLayout->addWidget(&countryLabel1, 3, 0, 1, 1);
|
||||||
mainLayout->addWidget(&countryLabel2, 4, 1, 1, 1, Qt::AlignCenter);
|
mainLayout->addWidget(&countryLabel2, 3, 1, 1, 1, Qt::AlignCenter);
|
||||||
mainLayout->addWidget(&countryLabel3, 4, 2, 1, 1);
|
mainLayout->addWidget(&countryLabel3, 3, 2, 1, 1);
|
||||||
mainLayout->addWidget(&userLevelLabel1, 5, 0, 1, 1);
|
mainLayout->addWidget(&userLevelLabel1, 4, 0, 1, 1);
|
||||||
mainLayout->addWidget(&userLevelLabel2, 5, 1, 1, 1, Qt::AlignCenter);
|
mainLayout->addWidget(&userLevelLabel2, 4, 1, 1, 2);
|
||||||
mainLayout->addWidget(&userLevelLabel3, 5, 2, 1, 1);
|
mainLayout->addWidget(&accountAgeLabel1, 5, 0, 1, 1);
|
||||||
mainLayout->addWidget(&accountAgeLabel1, 6, 0, 1, 1);
|
mainLayout->addWidget(&accountAgeLabel2, 5, 1, 1, 2);
|
||||||
mainLayout->addWidget(&accountAgeLabel2, 6, 2, 1, 1);
|
|
||||||
mainLayout->setColumnStretch(2, 10);
|
mainLayout->setColumnStretch(2, 10);
|
||||||
|
|
||||||
if (editable) {
|
if (editable) {
|
||||||
|
@ -95,14 +99,14 @@ void UserInfoBox::updateInfo(const ServerInfo_User &user)
|
||||||
QString country = QString::fromStdString(user.country());
|
QString country = QString::fromStdString(user.country());
|
||||||
|
|
||||||
if (country.length() != 0) {
|
if (country.length() != 0) {
|
||||||
countryLabel2.setPixmap(CountryPixmapGenerator::generatePixmap(15, country));
|
countryLabel2.setPixmap(CountryPixmapGenerator::generatePixmap(13, country));
|
||||||
countryLabel3.setText(QString("%1").arg(country.toUpper()));
|
countryLabel3.setText(QString("%1").arg(country.toUpper()));
|
||||||
} else {
|
} else {
|
||||||
countryLabel2.setText("");
|
countryLabel2.setText("");
|
||||||
countryLabel3.setText("");
|
countryLabel3.setText("");
|
||||||
}
|
}
|
||||||
|
|
||||||
userLevelLabel2.setPixmap(
|
userLevelIcon.setPixmap(
|
||||||
UserLevelPixmapGenerator::generatePixmap(15, userLevel, false, QString::fromStdString(user.privlevel())));
|
UserLevelPixmapGenerator::generatePixmap(15, userLevel, false, QString::fromStdString(user.privlevel())));
|
||||||
QString userLevelText;
|
QString userLevelText;
|
||||||
if (userLevel.testFlag(ServerInfo_User::IsAdmin))
|
if (userLevel.testFlag(ServerInfo_User::IsAdmin))
|
||||||
|
@ -121,7 +125,7 @@ void UserInfoBox::updateInfo(const ServerInfo_User &user)
|
||||||
userLevelText += " | " + QString("%1").arg(user.privlevel().c_str());
|
userLevelText += " | " + QString("%1").arg(user.privlevel().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
userLevelLabel3.setText(userLevelText);
|
userLevelLabel2.setText(userLevelText);
|
||||||
|
|
||||||
QString accountAgeString = tr("Unregistered user");
|
QString accountAgeString = tr("Unregistered user");
|
||||||
if (userLevel.testFlag(ServerInfo_User::IsAdmin) || userLevel.testFlag(ServerInfo_User::IsModerator) ||
|
if (userLevel.testFlag(ServerInfo_User::IsAdmin) || userLevel.testFlag(ServerInfo_User::IsModerator) ||
|
||||||
|
@ -358,7 +362,7 @@ void UserInfoBox::processAvatarResponse(const Response &r)
|
||||||
|
|
||||||
void UserInfoBox::resizeEvent(QResizeEvent *event)
|
void UserInfoBox::resizeEvent(QResizeEvent *event)
|
||||||
{
|
{
|
||||||
QPixmap resizedPixmap = avatarPixmap.scaled(avatarLabel.size(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
QPixmap resizedPixmap = avatarPixmap.scaled(avatarPic.size(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||||
avatarLabel.setPixmap(resizedPixmap);
|
avatarPic.setPixmap(resizedPixmap);
|
||||||
QWidget::resizeEvent(event);
|
QWidget::resizeEvent(event);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,8 +16,8 @@ class UserInfoBox : public QWidget
|
||||||
private:
|
private:
|
||||||
AbstractClient *client;
|
AbstractClient *client;
|
||||||
bool editable;
|
bool editable;
|
||||||
QLabel avatarLabel, nameLabel, realNameLabel1, realNameLabel2, countryLabel1, countryLabel2, countryLabel3,
|
QLabel avatarPic, userLevelIcon, nameLabel, realNameLabel1, realNameLabel2, countryLabel1, countryLabel2,
|
||||||
userLevelLabel1, userLevelLabel2, userLevelLabel3, accountAgeLabel1, accountAgeLabel2;
|
countryLabel3, userLevelLabel1, userLevelLabel2, accountAgeLabel1, accountAgeLabel2;
|
||||||
QPushButton editButton, passwordButton, avatarButton;
|
QPushButton editButton, passwordButton, avatarButton;
|
||||||
QPixmap avatarPixmap;
|
QPixmap avatarPixmap;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue