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"); auto job = new QKeychain::ReadPasswordJob("chatterino");
job->setAutoDelete(true); job->setAutoDelete(true);
job->setKey(name); job->setKey(name);
QObject::connect(job, &QKeychain::Job::finished, receiver, QObject::connect(
[job, onLoaded = std::move(onLoaded)](auto) mutable { job, &QKeychain::Job::finished, receiver,
onLoaded(job->textData()); [job, onLoaded = std::move(onLoaded)](auto) mutable {
}, onLoaded(job->textData());
Qt::DirectConnection); },
Qt::DirectConnection);
job->start(); job->start();
} }
else else

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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