diff --git a/cockatrice/src/userinfobox.cpp b/cockatrice/src/userinfobox.cpp index 369e08fb..65290c6d 100644 --- a/cockatrice/src/userinfobox.cpp +++ b/cockatrice/src/userinfobox.cpp @@ -26,29 +26,33 @@ UserInfoBox::UserInfoBox(AbstractClient *_client, bool _editable, QWidget *paren nameFont.setPointSizeF(nameFont.pointSizeF() * 1.5); nameLabel.setFont(nameFont); - avatarLabel.setMinimumSize(200, 200); - avatarLabel.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - avatarLabel.setAlignment(Qt::AlignCenter); + auto *userIconAndNameLayout = new QHBoxLayout; + userIconAndNameLayout->addWidget(&userLevelIcon, 0, 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; avatarLayout->setContentsMargins(0, 0, 0, 0); avatarLayout->addStretch(1); - avatarLayout->addWidget(&avatarLabel, 3); + avatarLayout->addWidget(&avatarPic, 3); avatarLayout->addStretch(1); auto *mainLayout = new QGridLayout; 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(&realNameLabel2, 2, 1, 1, 2); - mainLayout->addWidget(&countryLabel1, 4, 0, 1, 1); - mainLayout->addWidget(&countryLabel2, 4, 1, 1, 1, Qt::AlignCenter); - mainLayout->addWidget(&countryLabel3, 4, 2, 1, 1); - mainLayout->addWidget(&userLevelLabel1, 5, 0, 1, 1); - mainLayout->addWidget(&userLevelLabel2, 5, 1, 1, 1, Qt::AlignCenter); - mainLayout->addWidget(&userLevelLabel3, 5, 2, 1, 1); - mainLayout->addWidget(&accountAgeLabel1, 6, 0, 1, 1); - mainLayout->addWidget(&accountAgeLabel2, 6, 2, 1, 1); + mainLayout->addWidget(&countryLabel1, 3, 0, 1, 1); + mainLayout->addWidget(&countryLabel2, 3, 1, 1, 1, Qt::AlignCenter); + mainLayout->addWidget(&countryLabel3, 3, 2, 1, 1); + mainLayout->addWidget(&userLevelLabel1, 4, 0, 1, 1); + mainLayout->addWidget(&userLevelLabel2, 4, 1, 1, 2); + mainLayout->addWidget(&accountAgeLabel1, 5, 0, 1, 1); + mainLayout->addWidget(&accountAgeLabel2, 5, 1, 1, 2); mainLayout->setColumnStretch(2, 10); if (editable) { @@ -95,14 +99,14 @@ void UserInfoBox::updateInfo(const ServerInfo_User &user) QString country = QString::fromStdString(user.country()); if (country.length() != 0) { - countryLabel2.setPixmap(CountryPixmapGenerator::generatePixmap(15, country)); + countryLabel2.setPixmap(CountryPixmapGenerator::generatePixmap(13, country)); countryLabel3.setText(QString("%1").arg(country.toUpper())); } else { countryLabel2.setText(""); countryLabel3.setText(""); } - userLevelLabel2.setPixmap( + userLevelIcon.setPixmap( UserLevelPixmapGenerator::generatePixmap(15, userLevel, false, QString::fromStdString(user.privlevel()))); QString userLevelText; 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()); } - userLevelLabel3.setText(userLevelText); + userLevelLabel2.setText(userLevelText); QString accountAgeString = tr("Unregistered user"); 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) { - QPixmap resizedPixmap = avatarPixmap.scaled(avatarLabel.size(), Qt::KeepAspectRatio, Qt::SmoothTransformation); - avatarLabel.setPixmap(resizedPixmap); + QPixmap resizedPixmap = avatarPixmap.scaled(avatarPic.size(), Qt::KeepAspectRatio, Qt::SmoothTransformation); + avatarPic.setPixmap(resizedPixmap); QWidget::resizeEvent(event); } diff --git a/cockatrice/src/userinfobox.h b/cockatrice/src/userinfobox.h index 937f1dda..1fa5bb30 100644 --- a/cockatrice/src/userinfobox.h +++ b/cockatrice/src/userinfobox.h @@ -16,8 +16,8 @@ class UserInfoBox : public QWidget private: AbstractClient *client; bool editable; - QLabel avatarLabel, nameLabel, realNameLabel1, realNameLabel2, countryLabel1, countryLabel2, countryLabel3, - userLevelLabel1, userLevelLabel2, userLevelLabel3, accountAgeLabel1, accountAgeLabel2; + QLabel avatarPic, userLevelIcon, nameLabel, realNameLabel1, realNameLabel2, countryLabel1, countryLabel2, + countryLabel3, userLevelLabel1, userLevelLabel2, accountAgeLabel1, accountAgeLabel2; QPushButton editButton, passwordButton, avatarButton; QPixmap avatarPixmap;