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:
ctrlaltca 2018-01-27 10:41:32 +01:00 committed by GitHub
parent 8dbdd24c8e
commit b29bd9e070
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
272 changed files with 13378 additions and 9535 deletions

View file

@ -1,23 +1,27 @@
#include <QLineEdit>
#include <QVBoxLayout>
#include <QMenu>
#include <QSystemTrayIcon>
#include <QApplication>
#include <QDebug>
#include "tab_message.h"
#include "abstractclient.h"
#include "chatview/chatview.h"
#include "main.h"
#include "settingscache.h"
#include "soundengine.h"
#include <QApplication>
#include <QDebug>
#include <QLineEdit>
#include <QMenu>
#include <QSystemTrayIcon>
#include <QVBoxLayout>
#include "pending_command.h"
#include "pb/session_commands.pb.h"
#include "pb/event_user_message.pb.h"
#include "pb/serverinfo_user.pb.h"
#include "pb/session_commands.pb.h"
#include "pending_command.h"
TabMessage::TabMessage(TabSupervisor *_tabSupervisor, AbstractClient *_client, const ServerInfo_User &_ownUserInfo, const ServerInfo_User &_otherUserInfo)
: Tab(_tabSupervisor), client(_client), ownUserInfo(new ServerInfo_User(_ownUserInfo)), otherUserInfo(new ServerInfo_User(_otherUserInfo)), userOnline(true)
TabMessage::TabMessage(TabSupervisor *_tabSupervisor,
AbstractClient *_client,
const ServerInfo_User &_ownUserInfo,
const ServerInfo_User &_otherUserInfo)
: Tab(_tabSupervisor), client(_client), ownUserInfo(new ServerInfo_User(_ownUserInfo)),
otherUserInfo(new ServerInfo_User(_otherUserInfo)), userOnline(true)
{
chatView = new ChatView(tabSupervisor, tabSupervisor, 0, true);
connect(chatView, SIGNAL(showCardInfoPopup(QPoint, QString)), this, SLOT(showCardInfoPopup(QPoint, QString)));
@ -25,11 +29,11 @@ TabMessage::TabMessage(TabSupervisor *_tabSupervisor, AbstractClient *_client, c
connect(chatView, SIGNAL(addMentionTag(QString)), this, SLOT(addMentionTag(QString)));
sayEdit = new QLineEdit;
connect(sayEdit, SIGNAL(returnPressed()), this, SLOT(sendMessage()));
QVBoxLayout *vbox = new QVBoxLayout;
vbox->addWidget(chatView);
vbox->addWidget(sayEdit);
aLeave = new QAction(this);
connect(aLeave, SIGNAL(triggered()), this, SLOT(actLeave()));
@ -39,7 +43,7 @@ TabMessage::TabMessage(TabSupervisor *_tabSupervisor, AbstractClient *_client, c
retranslateUi();
QWidget * mainWidget = new QWidget(this);
QWidget *mainWidget = new QWidget(this);
mainWidget->setLayout(vbox);
setCentralWidget(mainWidget);
}
@ -51,7 +55,8 @@ TabMessage::~TabMessage()
delete otherUserInfo;
}
void TabMessage::addMentionTag(QString mentionTag) {
void TabMessage::addMentionTag(QString mentionTag)
{
sayEdit->insert(mentionTag + " ");
sayEdit->setFocus();
}
@ -64,7 +69,7 @@ void TabMessage::retranslateUi()
void TabMessage::tabActivated()
{
if(!sayEdit->hasFocus())
if (!sayEdit->hasFocus())
sayEdit->setFocus();
}
@ -86,23 +91,24 @@ void TabMessage::closeRequest()
void TabMessage::sendMessage()
{
if (sayEdit->text().isEmpty() || !userOnline)
return;
return;
Command_Message cmd;
cmd.set_user_name(otherUserInfo->name());
cmd.set_message(sayEdit->text().toStdString());
PendingCommand *pend = client->prepareSessionCommand(cmd);
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(messageSent(const Response &)));
client->sendCommand(pend);
sayEdit->clear();
}
void TabMessage::messageSent(const Response &response)
{
if (response.response_code() == Response::RespInIgnoreList)
chatView->appendMessage(tr("This user is ignoring you, they cannot see your messages in main chat and you cannot join their games."));
chatView->appendMessage(tr(
"This user is ignoring you, they cannot see your messages in main chat and you cannot join their games."));
}
void TabMessage::actLeave()
@ -116,7 +122,8 @@ void TabMessage::processUserMessageEvent(const Event_UserMessage &event)
const UserLevelFlags userLevel(userInfo->user_level());
const QString userPriv = QString::fromStdString(userInfo->privlevel());
chatView->appendMessage(QString::fromStdString(event.message()), 0,QString::fromStdString(event.sender_name()), userLevel, userPriv, true);
chatView->appendMessage(QString::fromStdString(event.message()), 0, QString::fromStdString(event.sender_name()),
userLevel, userPriv, true);
if (tabSupervisor->currentIndex() != tabSupervisor->indexOf(this))
soundEngine->playSound("private_message");
if (settingsCache->getShowMessagePopup() && shouldShowSystemPopup(event))
@ -127,24 +134,27 @@ void TabMessage::processUserMessageEvent(const Event_UserMessage &event)
emit userEvent();
}
bool TabMessage::shouldShowSystemPopup(const Event_UserMessage &event) {
bool TabMessage::shouldShowSystemPopup(const Event_UserMessage &event)
{
return (QApplication::activeWindow() == 0 || QApplication::focusWidget() == 0 ||
(event.sender_name() == otherUserInfo->name() && tabSupervisor->currentIndex() != tabSupervisor->indexOf(this)));
(event.sender_name() == otherUserInfo->name() &&
tabSupervisor->currentIndex() != tabSupervisor->indexOf(this)));
}
void TabMessage::showSystemPopup(const Event_UserMessage &event) {
void TabMessage::showSystemPopup(const Event_UserMessage &event)
{
if (trayIcon) {
disconnect(trayIcon, SIGNAL(messageClicked()), 0, 0);
trayIcon->showMessage(tr("Private message from") + " " + otherUserInfo->name().c_str(), event.message().c_str());
trayIcon->showMessage(tr("Private message from") + " " + otherUserInfo->name().c_str(),
event.message().c_str());
connect(trayIcon, SIGNAL(messageClicked()), this, SLOT(messageClicked()));
}
else
{
} else {
qDebug() << "Error: trayIcon is NULL. TabMessage::showSystemPopup failed";
}
}
void TabMessage::messageClicked() {
void TabMessage::messageClicked()
{
tabSupervisor->setCurrentIndex(tabSupervisor->indexOf(this));
QApplication::setActiveWindow(this);
emit maximizeClient();