mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-12 00:54:53 -07:00
Clang-format (#3028)
* 1/3 Add .clang-format file and travis compilation check * 2/3 Run clang-format * 3/3 Fix compilation problems due to include reordering * 3bis/3 AfterControlStatement: false
This commit is contained in:
parent
8dbdd24c8e
commit
b29bd9e070
272 changed files with 13378 additions and 9535 deletions
|
|
@ -1,19 +1,19 @@
|
|||
#include "userinfobox.h"
|
||||
#include "pixmapgenerator.h"
|
||||
#include "abstractclient.h"
|
||||
#include "dlg_edit_user.h"
|
||||
#include "dlg_edit_password.h"
|
||||
#include "dlg_edit_avatar.h"
|
||||
#include "dlg_edit_password.h"
|
||||
#include "dlg_edit_user.h"
|
||||
#include "pixmapgenerator.h"
|
||||
|
||||
#include <QLabel>
|
||||
#include <QDateTime>
|
||||
#include <QGridLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "pending_command.h"
|
||||
#include "pb/session_commands.pb.h"
|
||||
#include "pb/response_get_user_info.pb.h"
|
||||
#include "pb/session_commands.pb.h"
|
||||
#include "pending_command.h"
|
||||
|
||||
const qint64 SIXTY = 60;
|
||||
const qint64 HOURS_IN_A_DAY = 24;
|
||||
|
|
@ -45,9 +45,8 @@ UserInfoBox::UserInfoBox(AbstractClient *_client, bool _editable, QWidget *paren
|
|||
mainLayout->addWidget(&accountAgeLabel2, 6, 2, 1, 1);
|
||||
mainLayout->setColumnStretch(2, 10);
|
||||
|
||||
if(editable)
|
||||
{
|
||||
QHBoxLayout * buttonsLayout = new QHBoxLayout;
|
||||
if (editable) {
|
||||
QHBoxLayout *buttonsLayout = new QHBoxLayout;
|
||||
buttonsLayout->addWidget(&editButton);
|
||||
buttonsLayout->addWidget(&passwordButton);
|
||||
buttonsLayout->addWidget(&avatarButton);
|
||||
|
|
@ -81,26 +80,25 @@ void UserInfoBox::updateInfo(const ServerInfo_User &user)
|
|||
|
||||
QPixmap avatarPixmap;
|
||||
const std::string bmp = user.avatar_bmp();
|
||||
if (!avatarPixmap.loadFromData((const uchar *) bmp.data(), bmp.size()))
|
||||
avatarPixmap = UserLevelPixmapGenerator::generatePixmap(64, userLevel, false, QString::fromStdString(user.privlevel()));
|
||||
if (!avatarPixmap.loadFromData((const uchar *)bmp.data(), bmp.size()))
|
||||
avatarPixmap =
|
||||
UserLevelPixmapGenerator::generatePixmap(64, userLevel, false, QString::fromStdString(user.privlevel()));
|
||||
avatarLabel.setPixmap(avatarPixmap.scaled(avatarLabel.size(), Qt::KeepAspectRatio, Qt::SmoothTransformation));
|
||||
|
||||
nameLabel.setText(QString::fromStdString(user.name()));
|
||||
realNameLabel2.setText(QString::fromStdString(user.real_name()));
|
||||
QString country = QString::fromStdString(user.country());
|
||||
|
||||
if (country.length() != 0)
|
||||
{
|
||||
if (country.length() != 0) {
|
||||
countryLabel2.setPixmap(CountryPixmapGenerator::generatePixmap(15, country));
|
||||
countryLabel3.setText(QString("(%1)").arg(country.toUpper()));
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
countryLabel2.setText("");
|
||||
countryLabel3.setText("");
|
||||
}
|
||||
|
||||
userLevelLabel2.setPixmap(UserLevelPixmapGenerator::generatePixmap(15, userLevel, false, QString::fromStdString(user.privlevel())));
|
||||
userLevelLabel2.setPixmap(
|
||||
UserLevelPixmapGenerator::generatePixmap(15, userLevel, false, QString::fromStdString(user.privlevel())));
|
||||
QString userLevelText;
|
||||
if (userLevel.testFlag(ServerInfo_User::IsAdmin))
|
||||
userLevelText = tr("Administrator");
|
||||
|
|
@ -118,12 +116,13 @@ void UserInfoBox::updateInfo(const ServerInfo_User &user)
|
|||
userLevelLabel3.setText(userLevelText);
|
||||
|
||||
QString accountAgeString = tr("Unregistered user");
|
||||
if (userLevel.testFlag(ServerInfo_User::IsAdmin) || userLevel.testFlag(ServerInfo_User::IsModerator) || userLevel.testFlag(ServerInfo_User::IsRegistered)) {
|
||||
if (userLevel.testFlag(ServerInfo_User::IsAdmin) || userLevel.testFlag(ServerInfo_User::IsModerator) ||
|
||||
userLevel.testFlag(ServerInfo_User::IsRegistered)) {
|
||||
if (user.accountage_secs() == 0)
|
||||
accountAgeString = tr("Unknown");
|
||||
else {
|
||||
qint64 seconds = user.accountage_secs();
|
||||
qint64 minutes = seconds / SIXTY;
|
||||
qint64 minutes = seconds / SIXTY;
|
||||
qint64 hours = minutes / SIXTY;
|
||||
qint64 days = hours / HOURS_IN_A_DAY;
|
||||
qint64 years = days / DAYS_IN_A_YEAR;
|
||||
|
|
@ -151,7 +150,8 @@ void UserInfoBox::updateInfo(const QString &userName)
|
|||
cmd.set_user_name(userName.toStdString());
|
||||
|
||||
PendingCommand *pend = client->prepareSessionCommand(cmd);
|
||||
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(processResponse(const Response &)));
|
||||
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this,
|
||||
SLOT(processResponse(const Response &)));
|
||||
|
||||
client->sendCommand(pend);
|
||||
}
|
||||
|
|
@ -169,7 +169,8 @@ void UserInfoBox::actEdit()
|
|||
Command_GetUserInfo cmd;
|
||||
|
||||
PendingCommand *pend = client->prepareSessionCommand(cmd);
|
||||
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(actEditInternal(const Response &)));
|
||||
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this,
|
||||
SLOT(actEditInternal(const Response &)));
|
||||
|
||||
client->sendCommand(pend);
|
||||
}
|
||||
|
|
@ -184,17 +185,18 @@ void UserInfoBox::actEditInternal(const Response &r)
|
|||
QString realName = QString::fromStdString(user.real_name());
|
||||
|
||||
DlgEditUser dlg(this, email, country, realName);
|
||||
if(!dlg.exec())
|
||||
if (!dlg.exec())
|
||||
return;
|
||||
|
||||
Command_AccountEdit cmd;
|
||||
cmd.set_real_name(dlg.getRealName().toStdString());
|
||||
cmd.set_email(dlg.getEmail().toStdString());
|
||||
cmd.set_gender((ServerInfo_User_Gender) dlg.getGender());
|
||||
cmd.set_gender((ServerInfo_User_Gender)dlg.getGender());
|
||||
cmd.set_country(dlg.getCountry().toStdString());
|
||||
|
||||
PendingCommand *pend = client->prepareSessionCommand(cmd);
|
||||
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(processEditResponse(const Response &)));
|
||||
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this,
|
||||
SLOT(processEditResponse(const Response &)));
|
||||
|
||||
client->sendCommand(pend);
|
||||
}
|
||||
|
|
@ -202,7 +204,7 @@ void UserInfoBox::actEditInternal(const Response &r)
|
|||
void UserInfoBox::actPassword()
|
||||
{
|
||||
DlgEditPassword dlg(this);
|
||||
if(!dlg.exec())
|
||||
if (!dlg.exec())
|
||||
return;
|
||||
|
||||
Command_AccountPassword cmd;
|
||||
|
|
@ -210,7 +212,8 @@ void UserInfoBox::actPassword()
|
|||
cmd.set_new_password(dlg.getNewPassword().toStdString());
|
||||
|
||||
PendingCommand *pend = client->prepareSessionCommand(cmd);
|
||||
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(processPasswordResponse(const Response &)));
|
||||
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this,
|
||||
SLOT(processPasswordResponse(const Response &)));
|
||||
|
||||
client->sendCommand(pend);
|
||||
}
|
||||
|
|
@ -218,14 +221,15 @@ void UserInfoBox::actPassword()
|
|||
void UserInfoBox::actAvatar()
|
||||
{
|
||||
DlgEditAvatar dlg(this);
|
||||
if(!dlg.exec())
|
||||
if (!dlg.exec())
|
||||
return;
|
||||
|
||||
Command_AccountImage cmd;
|
||||
cmd.set_image(dlg.getImage().data(), dlg.getImage().size());
|
||||
|
||||
PendingCommand *pend = client->prepareSessionCommand(cmd);
|
||||
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(processAvatarResponse(const Response &)));
|
||||
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this,
|
||||
SLOT(processAvatarResponse(const Response &)));
|
||||
|
||||
client->sendCommand(pend);
|
||||
}
|
||||
|
|
@ -238,11 +242,13 @@ void UserInfoBox::processEditResponse(const Response &r)
|
|||
QMessageBox::information(this, tr("Information"), tr("User information updated."));
|
||||
break;
|
||||
case Response::RespFunctionNotAllowed:
|
||||
QMessageBox::critical(this, tr("Error"), tr("This server does not permit you to update your user informations."));
|
||||
QMessageBox::critical(this, tr("Error"),
|
||||
tr("This server does not permit you to update your user informations."));
|
||||
break;
|
||||
case Response::RespInternalError:
|
||||
default:
|
||||
QMessageBox::critical(this, tr("Error"), tr("An error occured while trying to update your user informations."));
|
||||
QMessageBox::critical(this, tr("Error"),
|
||||
tr("An error occured while trying to update your user informations."));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -264,7 +270,8 @@ void UserInfoBox::processPasswordResponse(const Response &r)
|
|||
break;
|
||||
case Response::RespInternalError:
|
||||
default:
|
||||
QMessageBox::critical(this, tr("Error"), tr("An error occured while trying to update your user informations."));
|
||||
QMessageBox::critical(this, tr("Error"),
|
||||
tr("An error occured while trying to update your user informations."));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue