Reformat some files according to .clang-format

This commit is contained in:
Rasmus Karlsson 2017-12-16 02:22:35 +01:00
parent a372bae80d
commit 676c7b9017
4 changed files with 65 additions and 92 deletions

View file

@ -293,11 +293,9 @@ void IrcManager::handleUserNoticeMessage(Communi::IrcMessage *message)
void IrcManager::handleModeMessage(Communi::IrcMessage *message) void IrcManager::handleModeMessage(Communi::IrcMessage *message)
{ {
auto channel = channelManager.getTwitchChannel(message->parameter(0).remove(0, 1)); auto channel = channelManager.getTwitchChannel(message->parameter(0).remove(0, 1));
if(message->parameter(1) == "+o") if (message->parameter(1) == "+o") {
{
channel->modList.append(message->parameter(2)); channel->modList.append(message->parameter(2));
} else if(message->parameter(1) == "-o") } else if (message->parameter(1) == "-o") {
{
channel->modList.append(message->parameter(2)); channel->modList.append(message->parameter(2));
} }
} }

View file

@ -1,10 +1,10 @@
#include "widgets/accountpopup.hpp" #include "widgets/accountpopup.hpp"
#include "util/urlfetch.hpp"
#include "accountmanager.hpp" #include "accountmanager.hpp"
#include "channel.hpp" #include "channel.hpp"
#include "credentials.hpp" #include "credentials.hpp"
#include "settingsmanager.hpp" #include "settingsmanager.hpp"
#include "ui_accountpopupform.h" #include "ui_accountpopupform.h"
#include "util/urlfetch.hpp"
#include <QClipboard> #include <QClipboard>
#include <QDesktopServices> #include <QDesktopServices>
@ -32,20 +32,16 @@ AccountPopupWidget::AccountPopupWidget(std::shared_ptr<Channel> channel)
SettingsManager &settings = SettingsManager::getInstance(); SettingsManager &settings = SettingsManager::getInstance();
permission = permissions::User; permission = permissions::User;
for(auto button : this->_ui->profileLayout->findChildren<QPushButton*>()) for (auto button : this->_ui->profileLayout->findChildren<QPushButton *>()) {
{
button->setFocusProxy(this); button->setFocusProxy(this);
} }
for(auto button: this->_ui->userLayout->findChildren<QPushButton*>()) for (auto button : this->_ui->userLayout->findChildren<QPushButton *>()) {
{
button->setFocusProxy(this); button->setFocusProxy(this);
} }
for(auto button: this->_ui->modLayout->findChildren<QPushButton*>()) for (auto button : this->_ui->modLayout->findChildren<QPushButton *>()) {
{
button->setFocusProxy(this); button->setFocusProxy(this);
} }
for(auto button: this->_ui->ownerLayout->findChildren<QPushButton*>()) for (auto button : this->_ui->ownerLayout->findChildren<QPushButton *>()) {
{
button->setFocusProxy(this); button->setFocusProxy(this);
} }
@ -70,37 +66,29 @@ AccountPopupWidget::AccountPopupWidget(std::shared_ptr<Channel> channel)
} }
QObject::connect(this->_ui->profile, &QPushButton::clicked, this, [=]() { QObject::connect(this->_ui->profile, &QPushButton::clicked, this, [=]() {
QDesktopServices::openUrl(QUrl("https://twitch.tv/" + QDesktopServices::openUrl(QUrl("https://twitch.tv/" + this->_ui->lblUsername->text()));
this->_ui->lblUsername->text()));
}); });
QObject::connect(this->_ui->sendMessage, &QPushButton::clicked, this, [=]() { QObject::connect(this->_ui->sendMessage, &QPushButton::clicked, this, [=]() {
QDesktopServices::openUrl(QUrl("https://www.twitch.tv/message/compose?to=" + QDesktopServices::openUrl(
this->_ui->lblUsername->text())); QUrl("https://www.twitch.tv/message/compose?to=" + this->_ui->lblUsername->text()));
}); });
QObject::connect(this->_ui->copy, &QPushButton::clicked, this, [=](){ QObject::connect(this->_ui->copy, &QPushButton::clicked, this,
QApplication::clipboard()->setText(this->_ui->lblUsername->text()); [=]() { QApplication::clipboard()->setText(this->_ui->lblUsername->text()); });
});
QObject::connect(this->_ui->follow, &QPushButton::clicked, this, [=]() { QObject::connect(this->_ui->follow, &QPushButton::clicked, this, [=]() {
QUrl requestUrl("https://api.twitch.tv/kraken/users/" + QUrl requestUrl("https://api.twitch.tv/kraken/users/" + userId + "/follows/channels/" +
userId + this->userID);
"/follows/channels/" + this->userID);
util::twitch::put(requestUrl,[](QJsonObject obj){ util::twitch::put(requestUrl,
qDebug() << "follows channel: " << obj; [](QJsonObject obj) { qDebug() << "follows channel: " << obj; });
});
}); });
QObject::connect(this->_ui->ignore, &QPushButton::clicked, this, [=]() { QObject::connect(this->_ui->ignore, &QPushButton::clicked, this, [=]() {
QUrl requestUrl("https://api.twitch.tv/kraken/users/" + QUrl requestUrl("https://api.twitch.tv/kraken/users/" + userId + "/blocks/" + this->userID);
userId +
"/blocks/" + this->userID);
util::twitch::put(requestUrl,[](QJsonObject obj){ util::twitch::put(requestUrl, [](QJsonObject obj) { qDebug() << "blocks user: " << obj; });
qDebug() << "blocks user: " << obj;
});
}); });
QObject::connect(this->_ui->disableHighlights, &QPushButton::clicked, this, [=, &settings]() { QObject::connect(this->_ui->disableHighlights, &QPushButton::clicked, this, [=, &settings]() {
@ -120,7 +108,6 @@ AccountPopupWidget::AccountPopupWidget(std::shared_ptr<Channel> channel)
this->_ui->disableHighlights->show(); this->_ui->disableHighlights->show();
}); });
updateButtons(this->_ui->userLayout, false); updateButtons(this->_ui->userLayout, false);
updateButtons(this->_ui->modLayout, false); updateButtons(this->_ui->modLayout, false);
updateButtons(this->_ui->ownerLayout, false); updateButtons(this->_ui->ownerLayout, false);
@ -131,9 +118,7 @@ AccountPopupWidget::AccountPopupWidget(std::shared_ptr<Channel> channel)
}); });
util::twitch::getUserID(userNickname, this, util::twitch::getUserID(userNickname, this,
[=](const QString &id){ [=](const QString &id) { currentTwitchUser->setUserId(id); });
currentTwitchUser->setUserId(id);
});
} }
void AccountPopupWidget::setName(const QString &name) void AccountPopupWidget::setName(const QString &name)
@ -157,7 +142,8 @@ void AccountPopupWidget::getUserId()
void AccountPopupWidget::getUserData() void AccountPopupWidget::getUserData()
{ {
util::twitch::get("https://api.twitch.tv/kraken/channels/" + userID, this, [=](const QJsonObject &obj){ util::twitch::get(
"https://api.twitch.tv/kraken/channels/" + userID, this, [=](const QJsonObject &obj) {
_ui->lblFollowers->setText(QString::number(obj.value("followers").toInt())); _ui->lblFollowers->setText(QString::number(obj.value("followers").toInt()));
_ui->lblViews->setText(QString::number(obj.value("views").toInt())); _ui->lblViews->setText(QString::number(obj.value("views").toInt()));
_ui->lblAccountAge->setText(obj.value("created_at").toString().section("T", 0, 0)); _ui->lblAccountAge->setText(obj.value("created_at").toString().section("T", 0, 0));
@ -201,12 +187,9 @@ void AccountPopupWidget::updatePermissions()
return; return;
} }
if(this->_channel.get()->name == currentTwitchUser->getNickName()) if (this->_channel.get()->name == currentTwitchUser->getNickName()) {
{
permission = permissions::Owner; permission = permissions::Owner;
} } else if (this->_channel->modList.contains(currentTwitchUser->getNickName())) {
else if(this->_channel->modList.contains(currentTwitchUser->getNickName()))
{
// XXX(pajlada): This might always trigger if user is anonymous (if nickName is empty?) // XXX(pajlada): This might always trigger if user is anonymous (if nickName is empty?)
permission = permissions::Mod; permission = permissions::Mod;
} }
@ -214,8 +197,7 @@ void AccountPopupWidget::updatePermissions()
void AccountPopupWidget::updateButtons(QWidget *layout, bool state) void AccountPopupWidget::updateButtons(QWidget *layout, bool state)
{ {
for(auto button : layout->findChildren<QPushButton*>()) for (auto button : layout->findChildren<QPushButton *>()) {
{
button->setVisible(state); button->setVisible(state);
} }
} }
@ -223,7 +205,8 @@ void AccountPopupWidget::updateButtons(QWidget* layout, bool state)
void AccountPopupWidget::timeout(QPushButton *button, int time) void AccountPopupWidget::timeout(QPushButton *button, int time)
{ {
QObject::connect(button, &QPushButton::clicked, this, [=]() { QObject::connect(button, &QPushButton::clicked, this, [=]() {
this->_channel->sendMessage("/timeout " + this->_ui->lblUsername->text() + " " + QString::number(time)); this->_channel->sendMessage("/timeout " + this->_ui->lblUsername->text() + " " +
QString::number(time));
}); });
} }
@ -253,24 +236,18 @@ void AccountPopupWidget::showEvent(QShowEvent *event)
return; return;
} }
if(this->_ui->lblUsername->text() != currentTwitchUser->getNickName()) if (this->_ui->lblUsername->text() != currentTwitchUser->getNickName()) {
{
updateButtons(this->_ui->userLayout, true); updateButtons(this->_ui->userLayout, true);
if(permission != permissions::User) if (permission != permissions::User) {
{ if (!this->_channel->modList.contains(this->_ui->lblUsername->text())) {
if(!this->_channel->modList.contains(this->_ui->lblUsername->text()))
{
updateButtons(this->_ui->modLayout, true); updateButtons(this->_ui->modLayout, true);
} }
if(permission == permissions::Owner) if (permission == permissions::Owner) {
{
updateButtons(this->_ui->ownerLayout, true); updateButtons(this->_ui->ownerLayout, true);
updateButtons(this->_ui->modLayout, true); updateButtons(this->_ui->modLayout, true);
} }
} }
} } else {
else
{
updateButtons(this->_ui->modLayout, false); updateButtons(this->_ui->modLayout, false);
updateButtons(this->_ui->userLayout, false); updateButtons(this->_ui->userLayout, false);
updateButtons(this->_ui->ownerLayout, false); updateButtons(this->_ui->ownerLayout, false);
@ -278,17 +255,13 @@ void AccountPopupWidget::showEvent(QShowEvent *event)
QString blacklisted = SettingsManager::getInstance().highlightUserBlacklist.getnonConst(); QString blacklisted = SettingsManager::getInstance().highlightUserBlacklist.getnonConst();
QStringList list = blacklisted.split("\n", QString::SkipEmptyParts); QStringList list = blacklisted.split("\n", QString::SkipEmptyParts);
if(list.contains(this->_ui->lblUsername->text(),Qt::CaseInsensitive)) if (list.contains(this->_ui->lblUsername->text(), Qt::CaseInsensitive)) {
{
this->_ui->disableHighlights->hide(); this->_ui->disableHighlights->hide();
this->_ui->enableHighlights->show(); this->_ui->enableHighlights->show();
} } else {
else
{
this->_ui->disableHighlights->show(); this->_ui->disableHighlights->show();
this->_ui->enableHighlights->hide(); this->_ui->enableHighlights->hide();
} }
} }
} // namespace widgets } // namespace widgets

View file

@ -1,4 +1,5 @@
#pragma once #pragma once
#include "concurrentmap.hpp" #include "concurrentmap.hpp"
#include "twitch/twitchchannel.hpp" #include "twitch/twitchchannel.hpp"

View file

@ -135,7 +135,8 @@ QVBoxLayout *SettingsDialog::createAccountsTab()
// Select the currently logged in user // Select the currently logged in user
if (listWidget->count() > 0) { if (listWidget->count() > 0) {
const QString &currentUsername = AccountManager::getInstance().Twitch.getCurrent()->getUserName(); const QString &currentUsername =
AccountManager::getInstance().Twitch.getCurrent()->getUserName();
for (int i = 0; i < listWidget->count(); ++i) { for (int i = 0; i < listWidget->count(); ++i) {
QString itemText = listWidget->item(i)->text(); QString itemText = listWidget->item(i)->text();
if (itemText.compare(currentUsername, Qt::CaseInsensitive) == 0) { if (itemText.compare(currentUsername, Qt::CaseInsensitive) == 0) {