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
+5 -5
View File
@@ -2,11 +2,11 @@
namespace chatterino {
namespace {
void appendDuration(int count, QChar &&order, QString &outString)
{
outString.append(QString::number(count));
outString.append(order);
}
void appendDuration(int count, QChar &&order, QString &outString)
{
outString.append(QString::number(count));
outString.append(order);
}
} // namespace
QString formatTime(int totalSeconds)
+1 -1
View File
@@ -4,7 +4,7 @@
namespace pajlada {
namespace Signals {
class SignalHolder;
class SignalHolder;
}
} // namespace pajlada
+29 -29
View File
@@ -6,38 +6,38 @@
namespace pajlada {
namespace Settings {
template <>
struct Serialize<QString> {
static rapidjson::Value get(const QString &value,
rapidjson::Document::AllocatorType &a)
{
return rapidjson::Value(value.toUtf8(), a);
}
};
template <>
struct Serialize<QString> {
static rapidjson::Value get(const QString &value,
rapidjson::Document::AllocatorType &a)
{
return rapidjson::Value(value.toUtf8(), a);
}
};
template <>
struct Deserialize<QString> {
static QString get(const rapidjson::Value &value, bool *error = nullptr)
{
if (!value.IsString()) {
PAJLADA_REPORT_ERROR(error)
PAJLADA_THROW_EXCEPTION(
"Deserialized rapidjson::Value is not a string");
return QString{};
}
try {
return QString::fromUtf8(value.GetString(),
value.GetStringLength());
} catch (const std::exception &) {
// int x = 5;
} catch (...) {
// int y = 5;
}
template <>
struct Deserialize<QString> {
static QString get(const rapidjson::Value &value, bool *error = nullptr)
{
if (!value.IsString()) {
PAJLADA_REPORT_ERROR(error)
PAJLADA_THROW_EXCEPTION(
"Deserialized rapidjson::Value is not a string");
return QString{};
}
try {
return QString::fromUtf8(value.GetString(),
value.GetStringLength());
} catch (const std::exception &) {
// int x = 5;
} catch (...) {
// int y = 5;
}
return QString{};
}
};
};
} // namespace Settings
} // namespace pajlada
+19 -17
View File
@@ -5,26 +5,28 @@
namespace chatterino {
namespace rj {
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,
rapidjson::Document::AllocatorType &a)
{
obj.AddMember(rapidjson::Value(key, a).Move(), value, a);
}
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);
}
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);
}
std::string stringify(const rapidjson::Value &value)
{
rapidjson::StringBuffer buffer;
rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
value.Accept(writer);
std::string stringify(const rapidjson::Value &value)
{
rapidjson::StringBuffer buffer;
rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
value.Accept(writer);
return std::string(buffer.GetString());
}
return std::string(buffer.GetString());
}
} // namespace rj
} // namespace chatterino
+77 -73
View File
@@ -11,91 +11,95 @@
namespace chatterino {
namespace rj {
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,
rapidjson::Document::AllocatorType &a);
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,
rapidjson::Document::AllocatorType &a);
template <typename Type>
void set(rapidjson::Value &obj, const char *key, const Type &value,
rapidjson::Document::AllocatorType &a)
{
assert(obj.IsObject());
template <typename Type>
void set(rapidjson::Value &obj, const char *key, const Type &value,
rapidjson::Document::AllocatorType &a)
{
assert(obj.IsObject());
addMember(obj, key, pajlada::Settings::Serialize<Type>::get(value, a), a);
}
template <>
inline void set(rapidjson::Value &obj, const char *key,
const rapidjson::Value &value,
rapidjson::Document::AllocatorType &a)
{
assert(obj.IsObject());
addMember(obj, key, const_cast<rapidjson::Value &>(value), a);
}
template <typename Type>
void set(rapidjson::Document &obj, const char *key, const Type &value)
{
assert(obj.IsObject());
auto &a = obj.GetAllocator();
addMember(obj, key, pajlada::Settings::Serialize<Type>::get(value, a), a);
}
template <>
inline void set(rapidjson::Document &obj, const char *key,
const rapidjson::Value &value)
{
assert(obj.IsObject());
auto &a = obj.GetAllocator();
addMember(obj, key, const_cast<rapidjson::Value &>(value), a);
}
template <typename Type>
void add(rapidjson::Value &arr, const Type &value,
rapidjson::Document::AllocatorType &a)
{
assert(arr.IsArray());
arr.PushBack(pajlada::Settings::Serialize<Type>::get(value, a), a);
}
template <typename Type>
bool getSafe(const rapidjson::Value &obj, const char *key, Type &out)
{
if (!obj.IsObject()) {
return false;
addMember(obj, key, pajlada::Settings::Serialize<Type>::get(value, a),
a);
}
if (!obj.HasMember(key)) {
return false;
template <>
inline void set(rapidjson::Value &obj, const char *key,
const rapidjson::Value &value,
rapidjson::Document::AllocatorType &a)
{
assert(obj.IsObject());
addMember(obj, key, const_cast<rapidjson::Value &>(value), a);
}
if (obj.IsNull()) {
return false;
template <typename Type>
void set(rapidjson::Document &obj, const char *key, const Type &value)
{
assert(obj.IsObject());
auto &a = obj.GetAllocator();
addMember(obj, key, pajlada::Settings::Serialize<Type>::get(value, a),
a);
}
bool error = false;
out = pajlada::Settings::Deserialize<Type>::get(obj[key], &error);
template <>
inline void set(rapidjson::Document &obj, const char *key,
const rapidjson::Value &value)
{
assert(obj.IsObject());
return !error;
}
auto &a = obj.GetAllocator();
template <typename Type>
bool getSafe(const rapidjson::Value &value, Type &out)
{
bool error = false;
out = pajlada::Settings::Deserialize<Type>::get(value, &error);
addMember(obj, key, const_cast<rapidjson::Value &>(value), a);
}
return !error;
}
template <typename Type>
void add(rapidjson::Value &arr, const Type &value,
rapidjson::Document::AllocatorType &a)
{
assert(arr.IsArray());
std::string stringify(const rapidjson::Value &value);
arr.PushBack(pajlada::Settings::Serialize<Type>::get(value, a), a);
}
template <typename Type>
bool getSafe(const rapidjson::Value &obj, const char *key, Type &out)
{
if (!obj.IsObject()) {
return false;
}
if (!obj.HasMember(key)) {
return false;
}
if (obj.IsNull()) {
return false;
}
bool error = false;
out = pajlada::Settings::Deserialize<Type>::get(obj[key], &error);
return !error;
}
template <typename Type>
bool getSafe(const rapidjson::Value &value, Type &out)
{
bool error = false;
out = pajlada::Settings::Deserialize<Type>::get(value, &error);
return !error;
}
std::string stringify(const rapidjson::Value &value);
} // namespace rj
} // namespace chatterino
+69 -68
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>
@@ -16,88 +16,89 @@ namespace chatterino {
namespace {
const char *getBinaryName()
{
const char *getBinaryName()
{
#ifdef _WIN32
return "streamlink.exe";
return "streamlink.exe";
#else
return "streamlink";
return "streamlink";
#endif
}
}
const char *getDefaultBinaryPath()
{
const char *getDefaultBinaryPath()
{
#ifdef _WIN32
return "C:\\Program Files (x86)\\Streamlink\\bin\\streamlink.exe";
return "C:\\Program Files (x86)\\Streamlink\\bin\\streamlink.exe";
#else
return "/usr/bin/streamlink";
return "/usr/bin/streamlink";
#endif
}
QString getStreamlinkProgram()
{
auto app = getApp();
if (getSettings()->streamlinkUseCustomPath) {
return getSettings()->streamlinkPath + "/" + getBinaryName();
} else {
return getBinaryName();
}
}
bool checkStreamlinkPath(const QString &path)
{
QFileInfo fileinfo(path);
if (!fileinfo.exists()) {
return false;
// throw Exception(fS("Streamlink path ({}) is invalid, file does not
// exist", path));
}
return fileinfo.isExecutable();
}
QString getStreamlinkProgram()
{
auto app = getApp();
void showStreamlinkNotFoundError()
{
static QErrorMessage *msg = new QErrorMessage;
auto app = getApp();
if (getSettings()->streamlinkUseCustomPath) {
msg->showMessage(
"Unable to find Streamlink executable\nMake sure your custom path "
"is pointing "
"to the DIRECTORY where the streamlink executable is located");
} else {
msg->showMessage(
"Unable to find Streamlink executable.\nIf you have Streamlink "
"installed, you might need to enable the custom path option");
}
}
QProcess *createStreamlinkProcess()
{
auto p = new QProcess;
p->setProgram(getStreamlinkProgram());
QObject::connect(p, &QProcess::errorOccurred, [=](auto err) {
if (err == QProcess::FailedToStart) {
showStreamlinkNotFoundError();
if (getSettings()->streamlinkUseCustomPath) {
return getSettings()->streamlinkPath + "/" + getBinaryName();
} else {
log("Error occured {}", err);
return getBinaryName();
}
}
bool checkStreamlinkPath(const QString &path)
{
QFileInfo fileinfo(path);
if (!fileinfo.exists()) {
return false;
// throw Exception(fS("Streamlink path ({}) is invalid, file does
// not exist", path));
}
p->deleteLater();
});
return fileinfo.isExecutable();
}
QObject::connect(p,
static_cast<void (QProcess::*)(int)>(&QProcess::finished),
[=](int res) {
p->deleteLater(); //
});
void showStreamlinkNotFoundError()
{
static QErrorMessage *msg = new QErrorMessage;
return p;
}
auto app = getApp();
if (getSettings()->streamlinkUseCustomPath) {
msg->showMessage(
"Unable to find Streamlink executable\nMake sure your custom "
"path "
"is pointing "
"to the DIRECTORY where the streamlink executable is located");
} else {
msg->showMessage(
"Unable to find Streamlink executable.\nIf you have Streamlink "
"installed, you might need to enable the custom path option");
}
}
QProcess *createStreamlinkProcess()
{
auto p = new QProcess;
p->setProgram(getStreamlinkProgram());
QObject::connect(p, &QProcess::errorOccurred, [=](auto err) {
if (err == QProcess::FailedToStart) {
showStreamlinkNotFoundError();
} else {
log("Error occured {}", err);
}
p->deleteLater();
});
QObject::connect(
p, static_cast<void (QProcess::*)(int)>(&QProcess::finished),
[=](int res) {
p->deleteLater(); //
});
return p;
}
} // namespace
+2 -2
View File
@@ -2,8 +2,8 @@
#ifdef USEWINSDK
#include <Windows.h>
#include <boost/optional.hpp>
# include <Windows.h>
# include <boost/optional.hpp>
namespace chatterino {