formatted all files with clang 9

This commit is contained in:
fourtf 2019-09-26 00:51:05 +02:00
parent e47a043a27
commit 9874bd779a
27 changed files with 102 additions and 185 deletions

View file

@ -166,11 +166,12 @@ void Credentials::get(const QString &provider, const QString &name_,
auto job = new QKeychain::ReadPasswordJob("chatterino");
job->setAutoDelete(true);
job->setKey(name);
QObject::connect(job, &QKeychain::Job::finished, receiver,
[job, onLoaded = std::move(onLoaded)](auto) mutable {
onLoaded(job->textData());
},
Qt::DirectConnection);
QObject::connect(
job, &QKeychain::Job::finished, receiver,
[job, onLoaded = std::move(onLoaded)](auto) mutable {
onLoaded(job->textData());
},
Qt::DirectConnection);
job->start();
}
else

View file

@ -48,13 +48,11 @@ void DownloadManager::onFinished(QNetworkReply *reply)
{
switch (reply->error())
{
case QNetworkReply::NoError:
{
case QNetworkReply::NoError: {
qDebug("file is downloaded successfully.");
}
break;
default:
{
default: {
qDebug() << reply->errorString().toLatin1();
};
}

View file

@ -27,8 +27,7 @@ AccountController::AccountController()
this->accounts_.itemRemoved.connect([this](const auto &args) {
switch (args.item->getProviderId())
{
case ProviderId::Twitch:
{
case ProviderId::Twitch: {
if (args.caller != this)
{
auto accs = this->twitch.accounts.cloneVector();

View file

@ -70,8 +70,7 @@ void HighlightModel::customRowSetData(const std::vector<QStandardItem *> &row,
{
switch (column)
{
case 0:
{
case 0: {
if (role == Qt::CheckStateRole)
{
if (rowIndex == 0)
@ -86,8 +85,7 @@ void HighlightModel::customRowSetData(const std::vector<QStandardItem *> &row,
}
}
break;
case 1:
{
case 1: {
if (role == Qt::CheckStateRole)
{
if (rowIndex == 0)
@ -103,8 +101,7 @@ void HighlightModel::customRowSetData(const std::vector<QStandardItem *> &row,
}
}
break;
case 2:
{
case 2: {
if (role == Qt::CheckStateRole)
{
if (rowIndex == 0)
@ -120,8 +117,7 @@ void HighlightModel::customRowSetData(const std::vector<QStandardItem *> &row,
}
}
break;
case 3:
{
case 3: {
// empty element
}
break;

View file

@ -119,8 +119,8 @@ struct Deserialize<chatterino::HighlightPhrase> {
chatterino::rj::getSafe(value, "regex", _isRegex);
chatterino::rj::getSafe(value, "case", _caseSensitive);
return chatterino::HighlightPhrase(_pattern, _alert, _sound,
_isRegex, _caseSensitive);
return chatterino::HighlightPhrase(_pattern, _alert, _sound, _isRegex,
_caseSensitive);
}
};

View file

@ -32,9 +32,8 @@ std::pair<MessagePtr, MessagePtr> makeAutomodMessage(
builder.message().flags.set(MessageFlag::PubSub);
builder
.emplace<ImageElement>(
Image::fromPixmap(getResources().twitch.automod),
MessageElementFlag::BadgeChannelAuthority)
.emplace<ImageElement>(Image::fromPixmap(getResources().twitch.automod),
MessageElementFlag::BadgeChannelAuthority)
->setTooltip("AutoMod");
builder.emplace<TextElement>("AutoMod:", MessageElementFlag::BoldUsername,
MessageColor(QColor("blue")),
@ -258,40 +257,35 @@ MessageBuilder::MessageBuilder(const AutomodUserAction &action)
QString text;
switch (action.type)
{
case AutomodUserAction::AddPermitted:
{
case AutomodUserAction::AddPermitted: {
text = QString("%1 added %2 as a permitted term on AutoMod.")
.arg(action.source.name)
.arg(action.message);
}
break;
case AutomodUserAction::AddBlocked:
{
case AutomodUserAction::AddBlocked: {
text = QString("%1 added %2 as a blocked term on AutoMod.")
.arg(action.source.name)
.arg(action.message);
}
break;
case AutomodUserAction::RemovePermitted:
{
case AutomodUserAction::RemovePermitted: {
text = QString("%1 removed %2 as a permitted term term on AutoMod.")
.arg(action.source.name)
.arg(action.message);
}
break;
case AutomodUserAction::RemoveBlocked:
{
case AutomodUserAction::RemoveBlocked: {
text = QString("%1 removed %2 as a blocked term on AutoMod.")
.arg(action.source.name)
.arg(action.message);
}
break;
case AutomodUserAction::Properties:
{
case AutomodUserAction::Properties: {
text = QString("%1 modified the AutoMod properties.")
.arg(action.source.name);
}

View file

@ -182,8 +182,7 @@ void IrcServer::readConnectionMessageReceived(Communi::IrcMessage *message)
switch (message->type())
{
case Communi::IrcMessage::Join:
{
case Communi::IrcMessage::Join: {
auto x = static_cast<Communi::IrcJoinMessage *>(message);
if (auto it =
@ -208,8 +207,7 @@ void IrcServer::readConnectionMessageReceived(Communi::IrcMessage *message)
return;
}
case Communi::IrcMessage::Part:
{
case Communi::IrcMessage::Part: {
auto x = static_cast<Communi::IrcPartMessage *>(message);
if (auto it =

View file

@ -102,14 +102,12 @@ void TwitchAccountManager::reloadUsers()
switch (this->addUser(userData))
{
case AddUserResponse::UserAlreadyExists:
{
case AddUserResponse::UserAlreadyExists: {
log("User {} already exists", userData.username);
// Do nothing
}
break;
case AddUserResponse::UserValuesUpdated:
{
case AddUserResponse::UserValuesUpdated: {
log("User {} already exists, and values updated!",
userData.username);
if (userData.username == this->getCurrent()->getUserName())
@ -120,8 +118,7 @@ void TwitchAccountManager::reloadUsers()
}
}
break;
case AddUserResponse::UserAdded:
{
case AddUserResponse::UserAdded: {
log("Added user {}", userData.username);
listUpdated = true;
}

View file

@ -617,14 +617,12 @@ void TwitchMessageBuilder::appendUsername()
switch (usernameDisplayMode.getValue())
{
case UsernameDisplayMode::Username:
{
case UsernameDisplayMode::Username: {
usernameText = username;
}
break;
case UsernameDisplayMode::LocalizedName:
{
case UsernameDisplayMode::LocalizedName: {
if (hasLocalizedName)
{
usernameText = localizedName;
@ -637,8 +635,7 @@ void TwitchMessageBuilder::appendUsername()
break;
default:
case UsernameDisplayMode::UsernameAndLocalizedName:
{
case UsernameDisplayMode::UsernameAndLocalizedName: {
if (hasLocalizedName)
{
usernameText = username + "(" + localizedName + ")";
@ -1240,8 +1237,7 @@ void TwitchMessageBuilder::appendTwitchBadges()
int index = badge.midRef(8).toInt();
switch (index)
{
case 1:
{
case 1: {
this->emplace<ImageElement>(
Image::fromPixmap(getResources().twitch.verified,
0.25),
@ -1249,8 +1245,7 @@ void TwitchMessageBuilder::appendTwitchBadges()
->setTooltip("Twitch Verified");
}
break;
default:
{
default: {
printf("[TwitchMessageBuilder] Unhandled partner badge "
"index: %d\n",
index);

View file

@ -134,8 +134,7 @@ public:
}
QDesktopServices::openUrl(QUrl(link));
break;
case ToastReaction::OpenInStreamlink:
{
case ToastReaction::OpenInStreamlink: {
openStreamlinkForChannel(channelName_);
break;
}

View file

@ -22,13 +22,11 @@ void initUpdateButton(Button &button,
dialog->buttonClicked.connect([&button](auto buttonType) {
switch (buttonType)
{
case UpdateDialog::Dismiss:
{
case UpdateDialog::Dismiss: {
button.hide();
}
break;
case UpdateDialog::Install:
{
case UpdateDialog::Install: {
Updates::getInstance().installUpdates();
}
break;

View file

@ -19,38 +19,32 @@ inline QString parseTagString(const QString &input)
switch (c.cell())
{
case 'n':
{
case 'n': {
output.replace(i, 2, '\n');
}
break;
case 'r':
{
case 'r': {
output.replace(i, 2, '\r');
}
break;
case 's':
{
case 's': {
output.replace(i, 2, ' ');
}
break;
case '\\':
{
case '\\': {
output.replace(i, 2, '\\');
}
break;
case ':':
{
case ':': {
output.replace(i, 2, ';');
}
break;
default:
{
default: {
output.remove(i, 1);
}
break;

View file

@ -61,10 +61,10 @@ private:
// new
if (other)
{
this->conn_ =
QObject::connect(other, &QObject::destroyed, qApp,
[this](QObject *) { this->set(nullptr); },
Qt::DirectConnection);
this->conn_ = QObject::connect(
other, &QObject::destroyed, qApp,
[this](QObject *) { this->set(nullptr); },
Qt::DirectConnection);
}
this->t_ = other;

View file

@ -297,15 +297,13 @@ void Scrollbar::paintEvent(QPaintEvent *)
switch (highlight.getStyle())
{
case ScrollbarHighlight::Default:
{
case ScrollbarHighlight::Default: {
painter.fillRect(w / 8 * 3, int(y), w / 4, highlightHeight,
color);
}
break;
case ScrollbarHighlight::Line:
{
case ScrollbarHighlight::Line: {
painter.fillRect(0, int(y), w, 1, color);
}
break;

View file

@ -85,8 +85,7 @@ bool Window::event(QEvent *event)
case QEvent::WindowActivate:
break;
case QEvent::WindowDeactivate:
{
case QEvent::WindowDeactivate: {
auto page = this->notebook_->getOrAddSelectedPage();
if (page != nullptr)

View file

@ -35,8 +35,7 @@ void NotificationPopup::updatePosition()
switch (location)
{
case BottomRight:
{
case BottomRight: {
this->move(rect.right() - this->width(),
rect.bottom() - this->height());
}

View file

@ -258,33 +258,28 @@ void SelectChannelDialog::setSelectedChannel(IndirectChannel _channel)
switch (_channel.getType())
{
case Channel::Type::Twitch:
{
case Channel::Type::Twitch: {
this->ui_.notebook->selectIndex(TAB_TWITCH);
this->ui_.twitch.channel->setFocus();
this->ui_.twitch.channelName->setText(channel->getName());
}
break;
case Channel::Type::TwitchWatching:
{
case Channel::Type::TwitchWatching: {
this->ui_.notebook->selectIndex(TAB_TWITCH);
this->ui_.twitch.watching->setFocus();
}
break;
case Channel::Type::TwitchMentions:
{
case Channel::Type::TwitchMentions: {
this->ui_.notebook->selectIndex(TAB_TWITCH);
this->ui_.twitch.mentions->setFocus();
}
break;
case Channel::Type::TwitchWhispers:
{
case Channel::Type::TwitchWhispers: {
this->ui_.notebook->selectIndex(TAB_TWITCH);
this->ui_.twitch.whispers->setFocus();
}
break;
case Channel::Type::Irc:
{
case Channel::Type::Irc: {
this->ui_.notebook->selectIndex(TAB_IRC);
this->ui_.irc.channel->setText(_channel.get()->getName());
@ -309,8 +304,7 @@ void SelectChannelDialog::setSelectedChannel(IndirectChannel _channel)
this->ui_.irc.channel->setFocus();
}
break;
default:
{
default: {
this->ui_.notebook->selectIndex(TAB_TWITCH);
this->ui_.twitch.channel->setFocus();
}
@ -330,8 +324,7 @@ IndirectChannel SelectChannelDialog::getSelectedChannel() const
switch (this->ui_.notebook->getSelectedIndex())
{
case TAB_TWITCH:
{
case TAB_TWITCH: {
if (this->ui_.twitch.channel->isChecked())
{
return app->twitch.server->getOrAddChannel(
@ -351,8 +344,7 @@ IndirectChannel SelectChannelDialog::getSelectedChannel() const
}
}
break;
case TAB_IRC:
{
case TAB_IRC: {
int row = this->ui_.irc.servers->getTableView()
->selectionModel()
->currentIndex()

View file

@ -48,8 +48,7 @@ void UpdateDialog::updateStatusChanged(Updates::Status status)
switch (status)
{
case Updates::UpdateAvailable:
{
case Updates::UpdateAvailable: {
this->ui_.label->setText(
QString("An update (%1) is available.\n\nDo you want to "
"download and install it?")
@ -58,28 +57,24 @@ void UpdateDialog::updateStatusChanged(Updates::Status status)
}
break;
case Updates::SearchFailed:
{
case Updates::SearchFailed: {
this->ui_.label->setText("Failed to load version information.");
}
break;
case Updates::Downloading:
{
case Updates::Downloading: {
this->ui_.label->setText(
"Downloading updates.\n\nChatterino will restart "
"automatically when the download is done.");
}
break;
case Updates::DownloadFailed:
{
case Updates::DownloadFailed: {
this->ui_.label->setText("Failed to download the update.");
}
break;
case Updates::WriteFileFailed:
{
case Updates::WriteFileFailed: {
this->ui_.label->setText("Failed to save the update to disk.");
}
break;

View file

@ -191,16 +191,14 @@ UserInfoPopup::UserInfoPopup()
switch (action)
{
case TimeoutWidget::Ban:
{
case TimeoutWidget::Ban: {
if (this->channel_)
{
this->channel_->sendMessage("/ban " + this->userName_);
}
}
break;
case TimeoutWidget::Unban:
{
case TimeoutWidget::Unban: {
if (this->channel_)
{
this->channel_->sendMessage("/unban " +
@ -208,8 +206,7 @@ UserInfoPopup::UserInfoPopup()
}
}
break;
case TimeoutWidget::Timeout:
{
case TimeoutWidget::Timeout: {
if (this->channel_)
{
this->channel_->sendMessage("/timeout " +

View file

@ -1335,8 +1335,7 @@ void ChannelView::mousePressEvent(QMouseEvent *event)
// check if message is collapsed
switch (event->button())
{
case Qt::LeftButton:
{
case Qt::LeftButton: {
this->lastPressPosition_ = event->screenPos();
this->isMouseDown_ = true;
@ -1354,8 +1353,7 @@ void ChannelView::mousePressEvent(QMouseEvent *event)
}
break;
case Qt::RightButton:
{
case Qt::RightButton: {
this->lastRightPressPosition_ = event->screenPos();
this->isRightMouseDown_ = true;
}
@ -1473,8 +1471,7 @@ void ChannelView::handleMouseClick(QMouseEvent *event,
{
switch (event->button())
{
case Qt::LeftButton:
{
case Qt::LeftButton: {
if (this->selecting_)
{
// this->pausedBySelection = false;
@ -1498,8 +1495,7 @@ void ChannelView::handleMouseClick(QMouseEvent *event,
}
}
break;
case Qt::RightButton:
{
case Qt::RightButton: {
auto insertText = [=](QString text) {
if (auto split = dynamic_cast<Split *>(this->parentWidget()))
{
@ -1714,16 +1710,14 @@ void ChannelView::handleLinkClick(QMouseEvent *event, const Link &link,
switch (link.type)
{
case Link::UserWhisper:
case Link::UserInfo:
{
case Link::UserInfo: {
auto user = link.value;
this->showUserInfoPopup(user);
qDebug() << "Clicked " << user << "s message";
}
break;
case Link::Url:
{
case Link::Url: {
if (getSettings()->openLinksIncognito && supportsIncognitoLinks())
openLinkIncognito(link.value);
else
@ -1731,8 +1725,7 @@ void ChannelView::handleLinkClick(QMouseEvent *event, const Link &link,
}
break;
case Link::UserAction:
{
case Link::UserAction: {
QString value = link.value;
value.replace("{user}", layout->getMessage()->loginName)
@ -1744,14 +1737,12 @@ void ChannelView::handleLinkClick(QMouseEvent *event, const Link &link,
}
break;
case Link::AutoModAllow:
{
case Link::AutoModAllow: {
getApp()->accounts->twitch.getCurrent()->autoModAllow(link.value);
}
break;
case Link::AutoModDeny:
{
case Link::AutoModDeny: {
getApp()->accounts->twitch.getCurrent()->autoModDeny(link.value);
}

View file

@ -62,8 +62,7 @@ void NotebookButton::paintEvent(QPaintEvent *event)
switch (icon_)
{
case Plus:
{
case Plus: {
painter.setPen([&] {
QColor tmp = foreground;
if (SplitContainer::isDraggingSplit)
@ -90,8 +89,7 @@ void NotebookButton::paintEvent(QPaintEvent *event)
}
break;
case User:
{
case User: {
painter.setRenderHint(QPainter::Antialiasing);
painter.setRenderHint(QPainter::HighQualityAntialiasing);
@ -111,8 +109,7 @@ void NotebookButton::paintEvent(QPaintEvent *event)
}
break;
case Settings:
{
case Settings: {
painter.setRenderHint(QPainter::Antialiasing);
painter.setRenderHint(QPainter::HighQualityAntialiasing);

View file

@ -432,8 +432,7 @@ void NotebookTab::mousePressEvent(QMouseEvent *event)
{
switch (event->button())
{
case Qt::RightButton:
{
case Qt::RightButton: {
this->menu_.popup(event->globalPos());
}
break;

View file

@ -83,7 +83,9 @@ AboutPage::AboutPage()
"chatterino2/commit/" +
version.getCommitHash() + "\">" +
version.getCommitHash() + "</a>")
.arg(Modes::getInstance().isNightly ? ", " + version.getDateOfBuild() : "");
.arg(Modes::getInstance().isNightly
? ", " + version.getDateOfBuild()
: "");
auto versionLabel = versionInfo.emplace<QLabel>(text);
versionLabel->setOpenExternalLinks(true);

View file

@ -6,8 +6,8 @@
#include "debug/Log.hpp"
#include "providers/twitch/EmoteValue.hpp"
#include "providers/twitch/TwitchChannel.hpp"
#include "providers/twitch/TwitchMessageBuilder.hpp"
#include "providers/twitch/TwitchIrcServer.hpp"
#include "providers/twitch/TwitchMessageBuilder.hpp"
#include "singletons/Settings.hpp"
#include "singletons/Theme.hpp"
#include "singletons/WindowManager.hpp"

View file

@ -339,15 +339,13 @@ void SplitContainer::focusSplitRecursive(Node *node, Direction direction)
{
switch (node->type_)
{
case Node::_Split:
{
case Node::_Split: {
node->split_->giveFocus(Qt::OtherFocusReason);
}
break;
case Node::HorizontalContainer:
case Node::VerticalContainer:
{
case Node::VerticalContainer: {
auto &children = node->children_;
auto it = std::find_if(
@ -898,23 +896,19 @@ void SplitContainer::Node::insertSplitRelative(Split *_split,
{
switch (this->type_)
{
case Node::EmptyRoot:
{
case Node::EmptyRoot: {
this->setSplit(_split);
}
break;
case Node::_Split:
{
case Node::_Split: {
this->nestSplitIntoCollection(_split, _direction);
}
break;
case Node::HorizontalContainer:
{
case Node::HorizontalContainer: {
this->nestSplitIntoCollection(_split, _direction);
}
break;
case Node::VerticalContainer:
{
case Node::VerticalContainer: {
this->nestSplitIntoCollection(_split, _direction);
}
break;
@ -1110,16 +1104,14 @@ void SplitContainer::Node::layout(bool addSpacing, float _scale,
switch (this->type_)
{
case Node::_Split:
{
case Node::_Split: {
QRect rect = this->geometry_.toRect();
this->split_->setGeometry(
rect.marginsRemoved(QMargins(1, 1, 0, 0)));
}
break;
case Node::VerticalContainer:
case Node::HorizontalContainer:
{
case Node::HorizontalContainer: {
bool isVertical = this->type_ == Node::VerticalContainer;
// vars

View file

@ -301,7 +301,6 @@ std::unique_ptr<QMenu> SplitHeader::createMainMenu()
// sub menu
auto moreMenu = new QMenu("More", this);
moreMenu->addAction("Toggle moderation mode", this->split_, [this]() {
this->split_->setModerationMode(!this->split_->getModerationMode());
});
@ -591,16 +590,14 @@ void SplitHeader::mousePressEvent(QMouseEvent *event)
{
switch (event->button())
{
case Qt::LeftButton:
{
case Qt::LeftButton: {
this->dragging_ = true;
this->dragStart_ = event->pos();
}
break;
case Qt::RightButton:
{
case Qt::RightButton: {
this->mainMenu_->popup(this->mapToGlobal(event->pos()));
}
break;
@ -718,8 +715,7 @@ void SplitHeader::themeChangedEvent()
}
else
{
this->dropdownButton_->setPixmap(
getResources().buttons.menuLight);
this->dropdownButton_->setPixmap(getResources().buttons.menuLight);
this->addButton_->setPixmap(getResources().buttons.addSplitDark);
}
}

View file

@ -35,8 +35,7 @@ SplitOverlay::SplitOverlay(Split *parent)
new QPushButton(getResources().split.left, QString());
auto *right = this->right_ =
new QPushButton(getResources().split.right, QString());
auto *up = this->up_ =
new QPushButton(getResources().split.up, QString());
auto *up = this->up_ = new QPushButton(getResources().split.up, QString());
auto *down = this->down_ =
new QPushButton(getResources().split.down, QString());
@ -107,27 +106,23 @@ void SplitOverlay::paintEvent(QPaintEvent *)
QRect rect;
switch (this->hoveredElement_)
{
case SplitLeft:
{
case SplitLeft: {
rect = QRect(0, 0, this->width() / 2, this->height());
}
break;
case SplitRight:
{
case SplitRight: {
rect =
QRect(this->width() / 2, 0, this->width() / 2, this->height());
}
break;
case SplitUp:
{
case SplitUp: {
rect = QRect(0, 0, this->width(), this->height() / 2);
}
break;
case SplitDown:
{
case SplitDown: {
rect =
QRect(0, this->height() / 2, this->width(), this->height() / 2);
}
@ -184,8 +179,7 @@ bool SplitOverlay::ButtonEventFilter::eventFilter(QObject *watched,
{
switch (event->type())
{
case QEvent::Enter:
{
case QEvent::Enter: {
QGraphicsOpacityEffect *effect =
dynamic_cast<QGraphicsOpacityEffect *>(
((QWidget *)watched)->graphicsEffect());
@ -199,8 +193,7 @@ bool SplitOverlay::ButtonEventFilter::eventFilter(QObject *watched,
this->parent->update();
}
break;
case QEvent::Leave:
{
case QEvent::Leave: {
QGraphicsOpacityEffect *effect =
dynamic_cast<QGraphicsOpacityEffect *>(
((QWidget *)watched)->graphicsEffect());
@ -214,8 +207,7 @@ bool SplitOverlay::ButtonEventFilter::eventFilter(QObject *watched,
this->parent->update();
}
break;
case QEvent::MouseButtonPress:
{
case QEvent::MouseButtonPress: {
if (this->hoveredElement == HoveredElement::SplitMove)
{
QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
@ -227,8 +219,7 @@ bool SplitOverlay::ButtonEventFilter::eventFilter(QObject *watched,
}
}
break;
case QEvent::MouseButtonRelease:
{
case QEvent::MouseButtonRelease: {
if (this->hoveredElement != HoveredElement::SplitMove)
{
SplitContainer *container =