changed .clang-format

This commit is contained in:
fourtf 2018-08-15 22:46:20 +02:00
parent 44c16f1b3a
commit af7b742a23
46 changed files with 1636 additions and 1611 deletions

View file

@ -25,6 +25,9 @@ DerivePointerBinding: false
FixNamespaceComments: true
IndentCaseLabels: true
IndentWidth: 4
IndentWrappedFunctionNames: true
IndentPPDirectives: AfterHash
NamespaceIndentation: Inner
PointerBindsToType: false
SpacesBeforeTrailingComments: 2
Standard: Auto

View file

@ -52,8 +52,8 @@ void runLoop(NativeMessagingClient &client)
std::cin.read(buffer.get(), size);
*(buffer.get() + size) = '\0';
client.sendMessage(
QByteArray::fromRawData(buffer.get(), static_cast<int32_t>(size)));
client.sendMessage(QByteArray::fromRawData(
buffer.get(), static_cast<int32_t>(size)));
}
}
} // namespace

View file

@ -38,7 +38,8 @@ void installCustomPalette()
dark.setColor(QPalette::AlternateBase, QColor("#444"));
dark.setColor(QPalette::ToolTipBase, Qt::white);
dark.setColor(QPalette::ToolTipText, Qt::white);
dark.setColor(QPalette::Disabled, QPalette::Text, QColor(127, 127, 127));
dark.setColor(QPalette::Disabled, QPalette::Text,
QColor(127, 127, 127));
dark.setColor(QPalette::Dark, QColor(35, 35, 35));
dark.setColor(QPalette::Shadow, QColor(20, 20, 20));
dark.setColor(QPalette::Button, QColor(70, 70, 70));
@ -48,7 +49,8 @@ void installCustomPalette()
dark.setColor(QPalette::BrightText, Qt::red);
dark.setColor(QPalette::Link, QColor(42, 130, 218));
dark.setColor(QPalette::Highlight, QColor(42, 130, 218));
dark.setColor(QPalette::Disabled, QPalette::Highlight, QColor(80, 80, 80));
dark.setColor(QPalette::Disabled, QPalette::Highlight,
QColor(80, 80, 80));
dark.setColor(QPalette::HighlightedText, Qt::white);
dark.setColor(QPalette::Disabled, QPalette::HighlightedText,
QColor(127, 127, 127));

View file

@ -70,7 +70,8 @@ namespace Settings {
template <>
struct Serialize<chatterino::HighlightBlacklistUser> {
static rapidjson::Value get(const chatterino::HighlightBlacklistUser &value,
static rapidjson::Value get(
const chatterino::HighlightBlacklistUser &value,
rapidjson::Document::AllocatorType &a)
{
rapidjson::Value ret(rapidjson::kObjectType);
@ -84,7 +85,8 @@ struct Serialize<chatterino::HighlightBlacklistUser> {
template <>
struct Deserialize<chatterino::HighlightBlacklistUser> {
static chatterino::HighlightBlacklistUser get(const rapidjson::Value &value)
static chatterino::HighlightBlacklistUser get(
const rapidjson::Value &value)
{
QString pattern;
bool isRegex = false;

View file

@ -93,7 +93,8 @@ struct Deserialize<chatterino::HighlightPhrase> {
static chatterino::HighlightPhrase get(const rapidjson::Value &value)
{
if (!value.IsObject()) {
return chatterino::HighlightPhrase(QString(), true, false, false);
return chatterino::HighlightPhrase(QString(), true, false,
false);
}
QString _pattern;
@ -106,7 +107,8 @@ struct Deserialize<chatterino::HighlightPhrase> {
chatterino::rj::getSafe(value, "sound", _sound);
chatterino::rj::getSafe(value, "regex", _isRegex);
return chatterino::HighlightPhrase(_pattern, _alert, _sound, _isRegex);
return chatterino::HighlightPhrase(_pattern, _alert, _sound,
_isRegex);
}
};

View file

@ -37,7 +37,8 @@ Frames::Frames(const QVector<Frame<QPixmap>> &frames)
if (this->animated()) {
DebugCount::increase("animated images");
this->gifTimerConnection_ = getApp()->emotes->gifTimer.signal.connect(
this->gifTimerConnection_ =
getApp()->emotes->gifTimer.signal.connect(
[this] { this->advance(); });
}
}
@ -134,8 +135,9 @@ void assignDelayed(
queued.pop();
if (++i > 50) {
QTimer::singleShot(
3, [&] { assignDelayed(queued, mutex, loadedEventQueued); });
QTimer::singleShot(3, [&] {
assignDelayed(queued, mutex, loadedEventQueued);
});
return;
}
}
@ -145,19 +147,22 @@ void assignDelayed(
}
template <typename Assign>
auto makeConvertCallback(const QVector<Frame<QImage>> &parsed, Assign assign)
auto makeConvertCallback(const QVector<Frame<QImage>> &parsed,
Assign assign)
{
return [parsed, assign] {
// convert to pixmap
auto frames = QVector<Frame<QPixmap>>();
std::transform(parsed.begin(), parsed.end(), std::back_inserter(frames),
[](auto &frame) {
std::transform(parsed.begin(), parsed.end(),
std::back_inserter(frames), [](auto &frame) {
return Frame<QPixmap>{
QPixmap::fromImage(frame.image), frame.duration};
QPixmap::fromImage(frame.image),
frame.duration};
});
// put into stack
static std::queue<std::pair<Assign, QVector<Frame<QPixmap>>>> queued;
static std::queue<std::pair<Assign, QVector<Frame<QPixmap>>>>
queued;
static std::mutex mutex;
std::lock_guard<std::mutex> lock(mutex);
@ -168,8 +173,9 @@ auto makeConvertCallback(const QVector<Frame<QImage>> &parsed, Assign assign)
if (!loadedEventQueued) {
loadedEventQueued = true;
QTimer::singleShot(
100, [=] { assignDelayed(queued, mutex, loadedEventQueued); });
QTimer::singleShot(100, [=] {
assignDelayed(queued, mutex, loadedEventQueued);
});
}
};
}

View file

@ -2,5 +2,4 @@
namespace chatterino {
} // namespace chatterino

View file

@ -21,16 +21,18 @@ Url getEmoteLink(QString urlTemplate, const EmoteId &id,
return {urlTemplate.replace("{{id}}", id.string)
.replace("{{image}}", emoteScale)};
}
std::pair<Outcome, EmoteMap> parseGlobalEmotes(const QJsonObject &jsonRoot,
const EmoteMap &currentEmotes)
std::pair<Outcome, EmoteMap> parseGlobalEmotes(
const QJsonObject &jsonRoot, const EmoteMap &currentEmotes)
{
auto emotes = EmoteMap();
auto jsonEmotes = jsonRoot.value("emotes").toArray();
auto urlTemplate = qS("https:") + jsonRoot.value("urlTemplate").toString();
auto urlTemplate =
qS("https:") + jsonRoot.value("urlTemplate").toString();
for (auto jsonEmote : jsonEmotes) {
auto id = EmoteId{jsonEmote.toObject().value("id").toString()};
auto name = EmoteName{jsonEmote.toObject().value("code").toString()};
auto name =
EmoteName{jsonEmote.toObject().value("code").toString()};
auto emote = Emote(
{name,
@ -41,7 +43,8 @@ std::pair<Outcome, EmoteMap> parseGlobalEmotes(const QJsonObject &jsonRoot,
Tooltip{name.string + "<br />Global Bttv Emote"},
Url{"https://manage.betterttv.net/emotes/" + id.string}});
emotes[name] = cachedOrMakeEmotePtr(std::move(emote), currentEmotes);
emotes[name] =
cachedOrMakeEmotePtr(std::move(emote), currentEmotes);
}
return {Success, std::move(emotes)};

View file

@ -13,9 +13,7 @@
#include <memory>
namespace chatterino {
namespace {
void parseEmoji(const std::shared_ptr<EmojiData> &emojiData,
const rapidjson::Value &unparsedEmoji,
QString shortCode = QString())
@ -40,7 +38,8 @@ void parseEmoji(const std::shared_ptr<EmojiData> &emojiData,
}
}
rj::getSafe(unparsedEmoji, "non_qualified", emojiData->nonQualifiedCode);
rj::getSafe(unparsedEmoji, "non_qualified",
emojiData->nonQualifiedCode);
rj::getSafe(unparsedEmoji, "unified", emojiData->unifiedCode);
rj::getSafe(unparsedEmoji, "has_img_apple", capabilities.apple);
@ -71,7 +70,8 @@ void parseEmoji(const std::shared_ptr<EmojiData> &emojiData,
QStringList unicodeCharacters;
if (!emojiData->nonQualifiedCode.isEmpty()) {
unicodeCharacters = emojiData->nonQualifiedCode.toLower().split('-');
unicodeCharacters =
emojiData->nonQualifiedCode.toLower().split('-');
} else {
unicodeCharacters = emojiData->unifiedCode.toLower().split('-');
}
@ -88,7 +88,6 @@ void parseEmoji(const std::shared_ptr<EmojiData> &emojiData,
emojiData->value = QString::fromUcs4(unicodeBytes, numUnicodeBytes);
}
} // namespace
void Emojis::load()

View file

@ -42,8 +42,8 @@ EmotePtr cachedOrMake(Emote &&emote, const EmoteId &id)
return cachedOrMakeEmotePtr(std::move(emote), cache, mutex, id);
}
std::pair<Outcome, EmoteMap> parseGlobalEmotes(const QJsonObject &jsonRoot,
const EmoteMap &currentEmotes)
std::pair<Outcome, EmoteMap> parseGlobalEmotes(
const QJsonObject &jsonRoot, const EmoteMap &currentEmotes)
{
auto jsonSets = jsonRoot.value("sets").toObject();
auto emotes = EmoteMap();
@ -59,8 +59,8 @@ std::pair<Outcome, EmoteMap> parseGlobalEmotes(const QJsonObject &jsonRoot,
auto urls = jsonEmote.value("urls").toObject();
auto emote = Emote();
fillInEmoteData(urls, name, name.string + "<br/>Global FFZ Emote",
emote);
fillInEmoteData(urls, name,
name.string + "<br/>Global FFZ Emote", emote);
emote.homePage =
Url{QString("https://www.frankerfacez.com/emoticon/%1-%2")
.arg(id.string)
@ -85,13 +85,14 @@ std::pair<Outcome, EmoteMap> parseChannelEmotes(const QJsonObject &jsonRoot)
auto jsonEmote = _jsonEmote.toObject();
// margins
auto id = EmoteId{QString::number(jsonEmote.value("id").toInt())};
auto id =
EmoteId{QString::number(jsonEmote.value("id").toInt())};
auto name = EmoteName{jsonEmote.value("name").toString()};
auto urls = jsonEmote.value("urls").toObject();
Emote emote;
fillInEmoteData(urls, name, name.string + "<br/>Channel FFZ Emote",
emote);
fillInEmoteData(urls, name,
name.string + "<br/>Channel FFZ Emote", emote);
emote.homePage =
Url{QString("https://www.frankerfacez.com/emoticon/%1-%2")
.arg(id.string)

View file

@ -79,7 +79,8 @@ void PubSubClient::unlistenPrefix(const std::string &prefix)
{
std::vector<std::string> topics;
for (auto it = this->listeners_.begin(); it != this->listeners_.end();) {
for (auto it = this->listeners_.begin();
it != this->listeners_.end();) {
const auto &listener = *it;
if (listener.topic.find(prefix) == 0) {
topics.push_back(listener.topic);
@ -137,20 +138,21 @@ void PubSubClient::ping()
auto self = this->shared_from_this();
runAfter(this->websocketClient_.get_io_service(), std::chrono::seconds(15),
[self](auto timer) {
runAfter(this->websocketClient_.get_io_service(),
std::chrono::seconds(15), [self](auto timer) {
if (!self->started_) {
return;
}
if (self->awaitingPong_) {
log("No pong respnose, disconnect!");
// TODO(pajlada): Label this connection as "disconnect me"
// TODO(pajlada): Label this connection as "disconnect
// me"
}
});
runAfter(this->websocketClient_.get_io_service(), std::chrono::minutes(5),
[self](auto timer) {
runAfter(this->websocketClient_.get_io_service(),
std::chrono::minutes(5), [self](auto timer) {
if (!self->started_) {
return;
}
@ -167,8 +169,8 @@ bool PubSubClient::send(const char *payload)
if (ec) {
log("Error sending message {}: {}", payload, ec.message());
// TODO(pajlada): Check which error code happened and maybe gracefully
// handle it
// TODO(pajlada): Check which error code happened and maybe
// gracefully handle it
return false;
}

View file

@ -42,7 +42,8 @@ struct Listener {
class PubSubClient : public std::enable_shared_from_this<PubSubClient>
{
public:
PubSubClient(WebsocketClient &_websocketClient, WebsocketHandle _handle);
PubSubClient(WebsocketClient &_websocketClient,
WebsocketHandle _handle);
void start();
void stop();

View file

@ -1,11 +1,10 @@
#pragma once
#include "debug/Log.hpp"
#include "util/RapidjsonHelpers.hpp"
#include "debug/Log.hpp"
#include <boost/asio.hpp>
#include <boost/asio/steady_timer.hpp>
#include <memory>
#include "debug/Log.hpp"
#include "util/RapidjsonHelpers.hpp"
namespace chatterino {

View file

@ -25,7 +25,8 @@
namespace chatterino {
namespace {
auto parseRecentMessages(const QJsonObject &jsonRoot, TwitchChannel &channel)
auto parseRecentMessages(const QJsonObject &jsonRoot,
TwitchChannel &channel)
{
QJsonArray jsonMessages = jsonRoot.value("messages").toArray();
std::vector<MessagePtr> messages;
@ -34,8 +35,8 @@ auto parseRecentMessages(const QJsonObject &jsonRoot, TwitchChannel &channel)
for (const auto jsonMessage : jsonMessages) {
auto content = jsonMessage.toString().toUtf8();
// passing nullptr as the channel makes the message invalid but we don't
// check for that anyways
// passing nullptr as the channel makes the message invalid but we
// don't check for that anyways
auto message = Communi::IrcMessage::fromData(content, nullptr);
auto privMsg = dynamic_cast<Communi::IrcPrivateMessage *>(message);
assert(privMsg);

View file

@ -28,8 +28,8 @@ inline bool ReadValue(const rapidjson::Value &object, const char *key,
}
template <>
inline bool ReadValue<QString>(const rapidjson::Value &object, const char *key,
QString &out)
inline bool ReadValue<QString>(const rapidjson::Value &object,
const char *key, QString &out)
{
if (!object.HasMember(key)) {
return false;

View file

@ -104,8 +104,7 @@ Fonts::FontData Fonts::createFontData(FontStyle type, float scale)
{FontStyle::ChatMediumSmall, {0.8f, false, QFont::Normal}},
{FontStyle::ChatMedium, {1, false, QFont::Normal}},
{FontStyle::ChatMediumBold,
{1, false,
QFont::Weight(getSettings()->boldScale.getValue())}},
{1, false, QFont::Weight(getSettings()->boldScale.getValue())}},
{FontStyle::ChatMediumItalic, {1, true, QFont::Normal}},
{FontStyle::ChatLarge, {1.2f, false, QFont::Normal}},
{FontStyle::ChatVeryLarge, {1.4f, false, QFont::Normal}},

View file

@ -5,13 +5,15 @@
namespace chatterino {
namespace rj {
void addMember(rapidjson::Value &obj, const char *key, rapidjson::Value &&value,
void addMember(rapidjson::Value &obj, const char *key,
rapidjson::Value &&value,
rapidjson::Document::AllocatorType &a)
{
obj.AddMember(rapidjson::Value(key, a).Move(), value, a);
}
void addMember(rapidjson::Value &obj, const char *key, rapidjson::Value &value,
void addMember(rapidjson::Value &obj, const char *key,
rapidjson::Value &value,
rapidjson::Document::AllocatorType &a)
{
obj.AddMember(rapidjson::Value(key, a).Move(), value.Move(), a);

View file

@ -11,9 +11,11 @@
namespace chatterino {
namespace rj {
void addMember(rapidjson::Value &obj, const char *key, rapidjson::Value &&value,
void addMember(rapidjson::Value &obj, const char *key,
rapidjson::Value &&value,
rapidjson::Document::AllocatorType &a);
void addMember(rapidjson::Value &obj, const char *key, rapidjson::Value &value,
void addMember(rapidjson::Value &obj, const char *key,
rapidjson::Value &value,
rapidjson::Document::AllocatorType &a);
template <typename Type>
@ -22,7 +24,8 @@ void set(rapidjson::Value &obj, const char *key, const Type &value,
{
assert(obj.IsObject());
addMember(obj, key, pajlada::Settings::Serialize<Type>::get(value, a), a);
addMember(obj, key, pajlada::Settings::Serialize<Type>::get(value, a),
a);
}
template <>
@ -42,7 +45,8 @@ void set(rapidjson::Document &obj, const char *key, const Type &value)
auto &a = obj.GetAllocator();
addMember(obj, key, pajlada::Settings::Serialize<Type>::get(value, a), a);
addMember(obj, key, pajlada::Settings::Serialize<Type>::get(value, a),
a);
}
template <>

View file

@ -2,9 +2,9 @@
#include "Application.hpp"
#include "Helpers.hpp"
#include "debug/Log.hpp"
#include "singletons/Settings.hpp"
#include "widgets/dialogs/QualityPopup.hpp"
#include "debug/Log.hpp"
#include <QErrorMessage>
#include <QFileInfo>
@ -51,8 +51,8 @@ bool checkStreamlinkPath(const QString &path)
if (!fileinfo.exists()) {
return false;
// throw Exception(fS("Streamlink path ({}) is invalid, file does not
// exist", path));
// throw Exception(fS("Streamlink path ({}) is invalid, file does
// not exist", path));
}
return fileinfo.isExecutable();
@ -65,7 +65,8 @@ void showStreamlinkNotFoundError()
auto app = getApp();
if (getSettings()->streamlinkUseCustomPath) {
msg->showMessage(
"Unable to find Streamlink executable\nMake sure your custom path "
"Unable to find Streamlink executable\nMake sure your custom "
"path "
"is pointing "
"to the DIRECTORY where the streamlink executable is located");
} else {
@ -90,8 +91,8 @@ QProcess *createStreamlinkProcess()
p->deleteLater();
});
QObject::connect(p,
static_cast<void (QProcess::*)(int)>(&QProcess::finished),
QObject::connect(
p, static_cast<void (QProcess::*)(int)>(&QProcess::finished),
[=](int res) {
p->deleteLater(); //
});

View file

@ -433,8 +433,7 @@ void SplitNotebook::addCustomButtons()
// settings
auto settingsBtn = this->addCustomButton();
settingsBtn->setVisible(
!getSettings()->hidePreferencesButton.getValue());
settingsBtn->setVisible(!getSettings()->hidePreferencesButton.getValue());
getSettings()->hidePreferencesButton.connect(
[settingsBtn](bool hide, auto) { settingsBtn->setVisible(!hide); },

View file

@ -31,13 +31,15 @@ auto makeEmoteMessage(const EmoteMap &map)
for (const auto &emote : map) {
builder
.emplace<EmoteElement>(emote.second, MessageElementFlag::AlwaysShow)
.emplace<EmoteElement>(emote.second,
MessageElementFlag::AlwaysShow)
->setLink(Link(Link::InsertText, emote.first.string));
}
return builder.release();
}
void addEmoteSets(std::vector<std::shared_ptr<TwitchAccount::EmoteSet>> sets,
void addEmoteSets(
std::vector<std::shared_ptr<TwitchAccount::EmoteSet>> sets,
Channel &globalChannel, Channel &subChannel)
{
for (const auto &set : sets) {

View file

@ -63,8 +63,8 @@ void addEmoteContextMenuItems(const Emote &emote,
QString(scale) + "x link", [url = image->url()] {
QApplication::clipboard()->setText(url.string);
});
openMenu->addAction(QString(scale) + "x link",
[url = image->url()] {
openMenu->addAction(
QString(scale) + "x link", [url = image->url()] {
QDesktopServices::openUrl(QUrl(url.string));
});
}
@ -83,8 +83,8 @@ void addEmoteContextMenuItems(const Emote &emote,
"Copy " + name + " emote link", [url = emote.homePage] {
QApplication::clipboard()->setText(url.string); //
});
openMenu->addAction("Open " + name + " emote link",
[url = emote.homePage] {
openMenu->addAction(
"Open " + name + " emote link", [url = emote.homePage] {
QDesktopServices::openUrl(QUrl(url.string)); //
});
};

View file

@ -9,15 +9,13 @@
"Choose", "Source", "High", "Medium", "Low", "Audio only"
namespace chatterino {
namespace {
QString CreateLink(const QString &url, const QString &name)
QString createLink(const QString &url, const QString &name)
{
return QString("<a href=\"" + url + "\"><span style=\"color: white;\">" +
name + "</span></a>");
return QString("<a href=\"" + url +
"\"><span style=\"color: white;\">" + name +
"</span></a>");
}
} // namespace
ExternalToolsPage::ExternalToolsPage()
@ -41,8 +39,8 @@ ExternalToolsPage::ExternalToolsPage()
description->setStyleSheet("color: #bbb");
auto links = new QLabel(
CreateLink("https://streamlink.github.io/", "Website") + " " +
CreateLink(
createLink("https://streamlink.github.io/", "Website") + " " +
createLink(
"https://github.com/streamlink/streamlink/releases/latest",
"Download"));
links->setTextFormat(Qt::RichText);

View file

@ -69,8 +69,7 @@ void addPhrasesTab(LayoutCreator<QVBoxLayout> layout)
void addUsersTab(IgnoresPage &page, LayoutCreator<QVBoxLayout> users,
QStringListModel &userModel)
{
users.append(
page.createCheckBox("Enable twitch ignored users",
users.append(page.createCheckBox("Enable twitch ignored users",
getSettings()->enableTwitchIgnoredUsers));
auto anyways = users.emplace<QHBoxLayout>().withoutMargin();

View file

@ -25,7 +25,7 @@
namespace chatterino {
inline QString CreateLink(const QString &url, bool file = false)
inline QString createLink(const QString &url, bool file = false)
{
if (file) {
return QString("<a href=\"file:///" + url +

View file

@ -40,7 +40,8 @@ auto formatRoomMode(TwitchChannel &channel) -> QString
if (modes->r9k) text += "r9k, ";
if (modes->slowMode)
text += QString("slow(%1), ").arg(QString::number(modes->slowMode));
text +=
QString("slow(%1), ").arg(QString::number(modes->slowMode));
if (modes->emoteOnly) text += "emote, ";
if (modes->submode) text += "sub, ";
}