fix: don't indent inner namespaces (#6235)
This commit is contained in:
+1
-1
@@ -45,7 +45,7 @@ IncludeCategories:
|
|||||||
# Third party library includes
|
# Third party library includes
|
||||||
- Regex: "^<([a-zA-Z_0-9-]+/)*[a-zA-Z_0-9-]+.h(pp)?>$"
|
- Regex: "^<([a-zA-Z_0-9-]+/)*[a-zA-Z_0-9-]+.h(pp)?>$"
|
||||||
Priority: 3
|
Priority: 3
|
||||||
NamespaceIndentation: Inner
|
NamespaceIndentation: None
|
||||||
PointerBindsToType: false
|
PointerBindsToType: false
|
||||||
SpacesBeforeTrailingComments: 2
|
SpacesBeforeTrailingComments: 2
|
||||||
Standard: Auto
|
Standard: Auto
|
||||||
|
|||||||
+2
-2
@@ -54,10 +54,10 @@ class IStreamerMode;
|
|||||||
class ITwitchUsers;
|
class ITwitchUsers;
|
||||||
class NativeMessagingServer;
|
class NativeMessagingServer;
|
||||||
namespace pronouns {
|
namespace pronouns {
|
||||||
class Pronouns;
|
class Pronouns;
|
||||||
} // namespace pronouns
|
} // namespace pronouns
|
||||||
namespace eventsub {
|
namespace eventsub {
|
||||||
class IController;
|
class IController;
|
||||||
} // namespace eventsub
|
} // namespace eventsub
|
||||||
|
|
||||||
class IApplication
|
class IApplication
|
||||||
|
|||||||
+39
-44
@@ -40,8 +40,8 @@
|
|||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
namespace {
|
namespace {
|
||||||
void installCustomPalette()
|
void installCustomPalette()
|
||||||
{
|
{
|
||||||
// borrowed from
|
// borrowed from
|
||||||
// https://stackoverflow.com/questions/15035767/is-the-qt-5-dark-fusion-theme-available-for-windows
|
// https://stackoverflow.com/questions/15035767/is-the-qt-5-dark-fusion-theme-available-for-windows
|
||||||
auto dark = QApplication::palette();
|
auto dark = QApplication::palette();
|
||||||
@@ -63,22 +63,20 @@ namespace {
|
|||||||
dark.setColor(QPalette::HighlightedText, Qt::white);
|
dark.setColor(QPalette::HighlightedText, Qt::white);
|
||||||
dark.setColor(QPalette::PlaceholderText, QColor(127, 127, 127));
|
dark.setColor(QPalette::PlaceholderText, QColor(127, 127, 127));
|
||||||
|
|
||||||
dark.setColor(QPalette::Disabled, QPalette::Highlight,
|
dark.setColor(QPalette::Disabled, QPalette::Highlight, QColor(80, 80, 80));
|
||||||
QColor(80, 80, 80));
|
|
||||||
dark.setColor(QPalette::Disabled, QPalette::HighlightedText,
|
dark.setColor(QPalette::Disabled, QPalette::HighlightedText,
|
||||||
QColor(127, 127, 127));
|
QColor(127, 127, 127));
|
||||||
dark.setColor(QPalette::Disabled, QPalette::ButtonText,
|
dark.setColor(QPalette::Disabled, QPalette::ButtonText,
|
||||||
QColor(127, 127, 127));
|
QColor(127, 127, 127));
|
||||||
dark.setColor(QPalette::Disabled, QPalette::Text,
|
dark.setColor(QPalette::Disabled, QPalette::Text, QColor(127, 127, 127));
|
||||||
QColor(127, 127, 127));
|
|
||||||
dark.setColor(QPalette::Disabled, QPalette::WindowText,
|
dark.setColor(QPalette::Disabled, QPalette::WindowText,
|
||||||
QColor(127, 127, 127));
|
QColor(127, 127, 127));
|
||||||
|
|
||||||
QApplication::setPalette(dark);
|
QApplication::setPalette(dark);
|
||||||
}
|
}
|
||||||
|
|
||||||
void initQt()
|
void initQt()
|
||||||
{
|
{
|
||||||
// set up the QApplication flags
|
// set up the QApplication flags
|
||||||
QApplication::setAttribute(Qt::AA_Use96Dpi, true);
|
QApplication::setAttribute(Qt::AA_Use96Dpi, true);
|
||||||
|
|
||||||
@@ -98,39 +96,38 @@ namespace {
|
|||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
// On the Mac/Cocoa platform this attribute is enabled by default
|
// On the Mac/Cocoa platform this attribute is enabled by default
|
||||||
// We override it to ensure shortcuts show in context menus on that platform
|
// We override it to ensure shortcuts show in context menus on that platform
|
||||||
QApplication::setAttribute(Qt::AA_DontShowShortcutsInContextMenus,
|
QApplication::setAttribute(Qt::AA_DontShowShortcutsInContextMenus, false);
|
||||||
false);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
installCustomPalette();
|
installCustomPalette();
|
||||||
}
|
}
|
||||||
|
|
||||||
void showLastCrashDialog(const Args &args, const Paths &paths)
|
void showLastCrashDialog(const Args &args, const Paths &paths)
|
||||||
{
|
{
|
||||||
auto *dialog = new LastRunCrashDialog(args, paths);
|
auto *dialog = new LastRunCrashDialog(args, paths);
|
||||||
// Use exec() over open() to block the app from being loaded
|
// Use exec() over open() to block the app from being loaded
|
||||||
// and to be able to set the safe mode.
|
// and to be able to set the safe mode.
|
||||||
dialog->exec();
|
dialog->exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
void createRunningFile(const QString &path)
|
void createRunningFile(const QString &path)
|
||||||
{
|
{
|
||||||
QFile runningFile(path);
|
QFile runningFile(path);
|
||||||
|
|
||||||
runningFile.open(QIODevice::WriteOnly | QIODevice::Truncate);
|
runningFile.open(QIODevice::WriteOnly | QIODevice::Truncate);
|
||||||
runningFile.flush();
|
runningFile.flush();
|
||||||
runningFile.close();
|
runningFile.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void removeRunningFile(const QString &path)
|
void removeRunningFile(const QString &path)
|
||||||
{
|
{
|
||||||
QFile::remove(path);
|
QFile::remove(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::chrono::steady_clock::time_point signalsInitTime;
|
std::chrono::steady_clock::time_point signalsInitTime;
|
||||||
|
|
||||||
[[noreturn]] void handleSignal(int signum)
|
[[noreturn]] void handleSignal(int signum)
|
||||||
{
|
{
|
||||||
using namespace std::chrono_literals;
|
using namespace std::chrono_literals;
|
||||||
|
|
||||||
if (std::chrono::steady_clock::now() - signalsInitTime > 30s &&
|
if (std::chrono::steady_clock::now() - signalsInitTime > 30s &&
|
||||||
@@ -164,12 +161,12 @@ namespace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::_Exit(signum);
|
std::_Exit(signum);
|
||||||
}
|
}
|
||||||
|
|
||||||
// We want to restart Chatterino when it crashes and the setting is set to
|
// We want to restart Chatterino when it crashes and the setting is set to
|
||||||
// true.
|
// true.
|
||||||
void initSignalHandler()
|
void initSignalHandler()
|
||||||
{
|
{
|
||||||
#if defined(NDEBUG) && !defined(CHATTERINO_WITH_CRASHPAD)
|
#if defined(NDEBUG) && !defined(CHATTERINO_WITH_CRASHPAD)
|
||||||
signalsInitTime = std::chrono::steady_clock::now();
|
signalsInitTime = std::chrono::steady_clock::now();
|
||||||
|
|
||||||
@@ -179,23 +176,21 @@ namespace {
|
|||||||
#if defined(Q_OS_UNIX)
|
#if defined(Q_OS_UNIX)
|
||||||
auto *sigintHandler = new UnixSignalHandler(SIGINT);
|
auto *sigintHandler = new UnixSignalHandler(SIGINT);
|
||||||
QObject::connect(sigintHandler, &UnixSignalHandler::signalFired, [] {
|
QObject::connect(sigintHandler, &UnixSignalHandler::signalFired, [] {
|
||||||
qCInfo(chatterinoApp)
|
qCInfo(chatterinoApp) << "Received SIGINT, request application quit";
|
||||||
<< "Received SIGINT, request application quit";
|
|
||||||
QApplication::quit();
|
QApplication::quit();
|
||||||
});
|
});
|
||||||
auto *sigtermHandler = new UnixSignalHandler(SIGTERM);
|
auto *sigtermHandler = new UnixSignalHandler(SIGTERM);
|
||||||
QObject::connect(sigtermHandler, &UnixSignalHandler::signalFired, [] {
|
QObject::connect(sigtermHandler, &UnixSignalHandler::signalFired, [] {
|
||||||
qCInfo(chatterinoApp)
|
qCInfo(chatterinoApp) << "Received SIGTERM, request application quit";
|
||||||
<< "Received SIGTERM, request application quit";
|
|
||||||
QApplication::quit();
|
QApplication::quit();
|
||||||
});
|
});
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// We delete cache files that haven't been modified in 14 days. This strategy may be
|
// We delete cache files that haven't been modified in 14 days. This strategy may be
|
||||||
// improved in the future.
|
// improved in the future.
|
||||||
void clearCache(const QDir &dir)
|
void clearCache(const QDir &dir)
|
||||||
{
|
{
|
||||||
size_t deletedCount = 0;
|
size_t deletedCount = 0;
|
||||||
for (const auto &info : dir.entryInfoList(QDir::Files))
|
for (const auto &info : dir.entryInfoList(QDir::Files))
|
||||||
{
|
{
|
||||||
@@ -210,12 +205,12 @@ namespace {
|
|||||||
}
|
}
|
||||||
qCDebug(chatterinoCache)
|
qCDebug(chatterinoCache)
|
||||||
<< "Deleted" << deletedCount << "files in" << dir.path();
|
<< "Deleted" << deletedCount << "files in" << dir.path();
|
||||||
}
|
}
|
||||||
|
|
||||||
// We delete all but the five most recent crashdumps. This strategy may be
|
// We delete all but the five most recent crashdumps. This strategy may be
|
||||||
// improved in the future.
|
// improved in the future.
|
||||||
void clearCrashes(QDir dir)
|
void clearCrashes(QDir dir)
|
||||||
{
|
{
|
||||||
// crashpad crashdumps are stored inside the Crashes/report directory
|
// crashpad crashdumps are stored inside the Crashes/report directory
|
||||||
if (!dir.cd("reports"))
|
if (!dir.cd("reports"))
|
||||||
{
|
{
|
||||||
@@ -242,7 +237,7 @@ namespace {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
qCDebug(chatterinoApp) << "Deleted" << deletedCount << "crashdumps";
|
qCDebug(chatterinoApp) << "Deleted" << deletedCount << "crashdumps";
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void runGui(QApplication &a, const Paths &paths, Settings &settings,
|
void runGui(QApplication &a, const Paths &paths, Settings &settings,
|
||||||
|
|||||||
+13
-13
@@ -10,9 +10,9 @@ namespace chatterino {
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void warn(const char *envName, const QString &envString, T defaultValue)
|
void warn(const char *envName, const QString &envString, T defaultValue)
|
||||||
{
|
{
|
||||||
const auto typeName = QString::fromStdString(
|
const auto typeName = QString::fromStdString(
|
||||||
std::string(type_name<decltype(defaultValue)>()));
|
std::string(type_name<decltype(defaultValue)>()));
|
||||||
|
|
||||||
@@ -24,10 +24,10 @@ namespace {
|
|||||||
.arg(envName)
|
.arg(envName)
|
||||||
.arg(typeName)
|
.arg(typeName)
|
||||||
.arg(defaultValue);
|
.arg(defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<QString> readOptionalStringEnv(const char *envName)
|
std::optional<QString> readOptionalStringEnv(const char *envName)
|
||||||
{
|
{
|
||||||
auto envString = qEnvironmentVariable(envName);
|
auto envString = qEnvironmentVariable(envName);
|
||||||
if (!envString.isEmpty())
|
if (!envString.isEmpty())
|
||||||
{
|
{
|
||||||
@@ -35,10 +35,10 @@ namespace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t readPortEnv(const char *envName, uint16_t defaultValue)
|
uint16_t readPortEnv(const char *envName, uint16_t defaultValue)
|
||||||
{
|
{
|
||||||
auto envString = qEnvironmentVariable(envName);
|
auto envString = qEnvironmentVariable(envName);
|
||||||
if (!envString.isEmpty())
|
if (!envString.isEmpty())
|
||||||
{
|
{
|
||||||
@@ -53,10 +53,10 @@ namespace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool readBoolEnv(const char *envName, bool defaultValue)
|
bool readBoolEnv(const char *envName, bool defaultValue)
|
||||||
{
|
{
|
||||||
auto envString = qEnvironmentVariable(envName);
|
auto envString = qEnvironmentVariable(envName);
|
||||||
if (!envString.isEmpty())
|
if (!envString.isEmpty())
|
||||||
{
|
{
|
||||||
@@ -64,7 +64,7 @@ namespace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
|||||||
@@ -11,26 +11,26 @@ namespace chatterino {
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
QJsonArray loadWindowArray(const QString &settingsPath)
|
QJsonArray loadWindowArray(const QString &settingsPath)
|
||||||
{
|
{
|
||||||
QFile file(settingsPath);
|
QFile file(settingsPath);
|
||||||
file.open(QIODevice::ReadOnly);
|
file.open(QIODevice::ReadOnly);
|
||||||
QByteArray data = file.readAll();
|
QByteArray data = file.readAll();
|
||||||
QJsonDocument document = QJsonDocument::fromJson(data);
|
QJsonDocument document = QJsonDocument::fromJson(data);
|
||||||
QJsonArray windows_arr = document.object().value("windows").toArray();
|
QJsonArray windows_arr = document.object().value("windows").toArray();
|
||||||
return windows_arr;
|
return windows_arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T loadNodes(const QJsonObject &obj)
|
T loadNodes(const QJsonObject &obj)
|
||||||
{
|
{
|
||||||
static_assert("loadNodes must be called with the SplitNodeDescriptor "
|
static_assert("loadNodes must be called with the SplitNodeDescriptor "
|
||||||
"or ContainerNodeDescriptor type");
|
"or ContainerNodeDescriptor type");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
SplitNodeDescriptor loadNodes(const QJsonObject &root)
|
SplitNodeDescriptor loadNodes(const QJsonObject &root)
|
||||||
{
|
{
|
||||||
SplitNodeDescriptor descriptor;
|
SplitNodeDescriptor descriptor;
|
||||||
|
|
||||||
descriptor.flexH_ = root.value("flexh").toDouble(1.0);
|
descriptor.flexH_ = root.value("flexh").toDouble(1.0);
|
||||||
@@ -41,11 +41,11 @@ namespace {
|
|||||||
SplitDescriptor::loadFromJSON(descriptor, root, data);
|
SplitDescriptor::loadFromJSON(descriptor, root, data);
|
||||||
|
|
||||||
return descriptor;
|
return descriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
ContainerNodeDescriptor loadNodes(const QJsonObject &root)
|
ContainerNodeDescriptor loadNodes(const QJsonObject &root)
|
||||||
{
|
{
|
||||||
ContainerNodeDescriptor descriptor;
|
ContainerNodeDescriptor descriptor;
|
||||||
|
|
||||||
descriptor.flexH_ = root.value("flexh").toDouble(1.0);
|
descriptor.flexH_ = root.value("flexh").toDouble(1.0);
|
||||||
@@ -71,10 +71,10 @@ namespace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return descriptor;
|
return descriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QList<QUuid> loadFilters(QJsonValue val)
|
const QList<QUuid> loadFilters(QJsonValue val)
|
||||||
{
|
{
|
||||||
QList<QUuid> filterIds;
|
QList<QUuid> filterIds;
|
||||||
|
|
||||||
if (!val.isUndefined())
|
if (!val.isUndefined())
|
||||||
@@ -88,7 +88,7 @@ namespace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return filterIds;
|
return filterIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
|||||||
@@ -8,20 +8,20 @@ struct CommandContext;
|
|||||||
|
|
||||||
namespace commands {
|
namespace commands {
|
||||||
|
|
||||||
QString emoteOnly(const CommandContext &ctx);
|
QString emoteOnly(const CommandContext &ctx);
|
||||||
QString emoteOnlyOff(const CommandContext &ctx);
|
QString emoteOnlyOff(const CommandContext &ctx);
|
||||||
|
|
||||||
QString subscribers(const CommandContext &ctx);
|
QString subscribers(const CommandContext &ctx);
|
||||||
QString subscribersOff(const CommandContext &ctx);
|
QString subscribersOff(const CommandContext &ctx);
|
||||||
|
|
||||||
QString slow(const CommandContext &ctx);
|
QString slow(const CommandContext &ctx);
|
||||||
QString slowOff(const CommandContext &ctx);
|
QString slowOff(const CommandContext &ctx);
|
||||||
|
|
||||||
QString followers(const CommandContext &ctx);
|
QString followers(const CommandContext &ctx);
|
||||||
QString followersOff(const CommandContext &ctx);
|
QString followersOff(const CommandContext &ctx);
|
||||||
|
|
||||||
QString uniqueChat(const CommandContext &ctx);
|
QString uniqueChat(const CommandContext &ctx);
|
||||||
QString uniqueChatOff(const CommandContext &ctx);
|
QString uniqueChatOff(const CommandContext &ctx);
|
||||||
|
|
||||||
} // namespace commands
|
} // namespace commands
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
namespace completion {
|
namespace completion {
|
||||||
class Source;
|
class Source;
|
||||||
} // namespace completion
|
} // namespace completion
|
||||||
|
|
||||||
/// @brief Represents the kind of completion occurring
|
/// @brief Represents the kind of completion occurring
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ namespace chatterino::completion {
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
void addCommand(const QString &command, std::vector<CommandItem> &out)
|
void addCommand(const QString &command, std::vector<CommandItem> &out)
|
||||||
{
|
{
|
||||||
if (command.startsWith('/') || command.startsWith('.'))
|
if (command.startsWith('/') || command.startsWith('.'))
|
||||||
{
|
{
|
||||||
out.push_back({
|
out.push_back({
|
||||||
@@ -27,7 +27,7 @@ namespace {
|
|||||||
.prefix = "",
|
.prefix = "",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
|||||||
@@ -17,9 +17,9 @@ namespace chatterino::completion {
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
void addEmotes(std::vector<EmoteItem> &out, const EmoteMap &map,
|
void addEmotes(std::vector<EmoteItem> &out, const EmoteMap &map,
|
||||||
const QString &providerName)
|
const QString &providerName)
|
||||||
{
|
{
|
||||||
for (auto &&emote : map)
|
for (auto &&emote : map)
|
||||||
{
|
{
|
||||||
out.push_back({.emote = emote.second,
|
out.push_back({.emote = emote.second,
|
||||||
@@ -29,11 +29,10 @@ namespace {
|
|||||||
.providerName = providerName,
|
.providerName = providerName,
|
||||||
.isEmoji = false});
|
.isEmoji = false});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void addEmojis(std::vector<EmoteItem> &out,
|
void addEmojis(std::vector<EmoteItem> &out, const std::vector<EmojiPtr> &map)
|
||||||
const std::vector<EmojiPtr> &map)
|
{
|
||||||
{
|
|
||||||
for (const auto &emoji : map)
|
for (const auto &emoji : map)
|
||||||
{
|
{
|
||||||
for (auto &&shortCode : emoji->shortCodes)
|
for (auto &&shortCode : emoji->shortCodes)
|
||||||
@@ -47,7 +46,7 @@ namespace {
|
|||||||
.isEmoji = true});
|
.isEmoji = true});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
|||||||
@@ -10,14 +10,14 @@ namespace chatterino::completion {
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
size_t sizeWithinLimit(size_t size, size_t limit)
|
size_t sizeWithinLimit(size_t size, size_t limit)
|
||||||
{
|
{
|
||||||
if (limit == 0)
|
if (limit == 0)
|
||||||
{
|
{
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
return std::min(size, limit);
|
return std::min(size, limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
namespace chatterino::completion {
|
namespace chatterino::completion {
|
||||||
namespace {
|
namespace {
|
||||||
/**
|
/**
|
||||||
* @brief This function calculates the "cost" of the changes that need to
|
* @brief This function calculates the "cost" of the changes that need to
|
||||||
* be done to the query to make it the value.
|
* be done to the query to make it the value.
|
||||||
*
|
*
|
||||||
@@ -25,8 +25,8 @@ namespace {
|
|||||||
* @return How different the emote is from query. Values in the range [-10,
|
* @return How different the emote is from query. Values in the range [-10,
|
||||||
* \infty].
|
* \infty].
|
||||||
*/
|
*/
|
||||||
int costOfEmote(QStringView query, QStringView emote, bool prioritizeUpper)
|
int costOfEmote(QStringView query, QStringView emote, bool prioritizeUpper)
|
||||||
{
|
{
|
||||||
int score = 0;
|
int score = 0;
|
||||||
|
|
||||||
if (prioritizeUpper)
|
if (prioritizeUpper)
|
||||||
@@ -60,17 +60,16 @@ namespace {
|
|||||||
score += diff * 100;
|
score += diff * 100;
|
||||||
}
|
}
|
||||||
return score;
|
return score;
|
||||||
};
|
};
|
||||||
|
|
||||||
// This contains the brains of emote tab completion. Updates output to sorted completions.
|
// This contains the brains of emote tab completion. Updates output to sorted completions.
|
||||||
// Ensure that the query string is already normalized, that is doesn't have a leading ':'
|
// Ensure that the query string is already normalized, that is doesn't have a leading ':'
|
||||||
// matchingFunction is used for testing if the emote should be included in the search.
|
// matchingFunction is used for testing if the emote should be included in the search.
|
||||||
void completeEmotes(
|
void completeEmotes(
|
||||||
const std::vector<EmoteItem> &items, std::vector<EmoteItem> &output,
|
const std::vector<EmoteItem> &items, std::vector<EmoteItem> &output,
|
||||||
QStringView query, bool ignoreColonForCost,
|
QStringView query, bool ignoreColonForCost,
|
||||||
const std::function<bool(EmoteItem, Qt::CaseSensitivity)>
|
const std::function<bool(EmoteItem, Qt::CaseSensitivity)> &matchingFunction)
|
||||||
&matchingFunction)
|
{
|
||||||
{
|
|
||||||
// Given these emotes: pajaW, PAJAW
|
// Given these emotes: pajaW, PAJAW
|
||||||
// There are a few cases of input:
|
// There are a few cases of input:
|
||||||
// 1. "pajaw" expect {pajaW, PAJAW} - no uppercase characters, do regular case insensitive search
|
// 1. "pajaw" expect {pajaW, PAJAW} - no uppercase characters, do regular case insensitive search
|
||||||
@@ -153,7 +152,7 @@ namespace {
|
|||||||
|
|
||||||
return costA < costB;
|
return costA < costB;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void SmartEmoteStrategy::apply(const std::vector<EmoteItem> &items,
|
void SmartEmoteStrategy::apply(const std::vector<EmoteItem> &items,
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ namespace chatterino {
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
constexpr QStringView REGEX_START_BOUNDARY(u"(?:\\b|\\s|^)");
|
constexpr QStringView REGEX_START_BOUNDARY(u"(?:\\b|\\s|^)");
|
||||||
constexpr QStringView REGEX_END_BOUNDARY(u"(?:\\b|\\s|$)");
|
constexpr QStringView REGEX_END_BOUNDARY(u"(?:\\b|\\s|$)");
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
|||||||
@@ -105,11 +105,11 @@ private:
|
|||||||
namespace pajlada {
|
namespace pajlada {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
chatterino::HighlightPhrase constructError()
|
chatterino::HighlightPhrase constructError()
|
||||||
{
|
{
|
||||||
return chatterino::HighlightPhrase(QString(), false, false, false,
|
return chatterino::HighlightPhrase(QString(), false, false, false, false,
|
||||||
false, false, QString(), QColor());
|
false, QString(), QColor());
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ struct ChannelPointReward;
|
|||||||
struct TwitchEmoteOccurrence;
|
struct TwitchEmoteOccurrence;
|
||||||
|
|
||||||
namespace linkparser {
|
namespace linkparser {
|
||||||
struct Parsed;
|
struct Parsed;
|
||||||
} // namespace linkparser
|
} // namespace linkparser
|
||||||
|
|
||||||
struct SystemMessageTag {
|
struct SystemMessageTag {
|
||||||
|
|||||||
@@ -26,9 +26,9 @@ using namespace literals;
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
// Computes the bounding box for the given vector of images
|
// Computes the bounding box for the given vector of images
|
||||||
QSizeF getBoundingBoxSize(const std::vector<ImagePtr> &images)
|
QSizeF getBoundingBoxSize(const std::vector<ImagePtr> &images)
|
||||||
{
|
{
|
||||||
qreal width = 0;
|
qreal width = 0;
|
||||||
qreal height = 0;
|
qreal height = 0;
|
||||||
for (const auto &img : images)
|
for (const auto &img : images)
|
||||||
@@ -39,7 +39,7 @@ namespace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return {width, height};
|
return {width, height};
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
|||||||
@@ -23,15 +23,15 @@ namespace chatterino {
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
QColor blendColors(const QColor &base, const QColor &apply)
|
QColor blendColors(const QColor &base, const QColor &apply)
|
||||||
{
|
{
|
||||||
const qreal &alpha = apply.alphaF();
|
const qreal &alpha = apply.alphaF();
|
||||||
QColor result;
|
QColor result;
|
||||||
result.setRgbF(base.redF() * (1 - alpha) + apply.redF() * alpha,
|
result.setRgbF(base.redF() * (1 - alpha) + apply.redF() * alpha,
|
||||||
base.greenF() * (1 - alpha) + apply.greenF() * alpha,
|
base.greenF() * (1 - alpha) + apply.greenF() * alpha,
|
||||||
base.blueF() * (1 - alpha) + apply.blueF() * alpha);
|
base.blueF() * (1 - alpha) + apply.blueF() * alpha);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
MessageLayout::MessageLayout(MessagePtr message)
|
MessageLayout::MessageLayout(MessagePtr message)
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ struct BttvLiveUpdateEmoteRemoveMessage;
|
|||||||
|
|
||||||
namespace bttv::detail {
|
namespace bttv::detail {
|
||||||
|
|
||||||
EmoteMap parseChannelEmotes(const QJsonObject &jsonRoot,
|
EmoteMap parseChannelEmotes(const QJsonObject &jsonRoot,
|
||||||
const QString &channelDisplayName);
|
const QString &channelDisplayName);
|
||||||
|
|
||||||
} // namespace bttv::detail
|
} // namespace bttv::detail
|
||||||
|
|||||||
@@ -27,12 +27,10 @@ using FfzChannelBadgeMap =
|
|||||||
|
|
||||||
namespace ffz::detail {
|
namespace ffz::detail {
|
||||||
|
|
||||||
EmoteMap parseChannelEmotes(const QJsonObject &jsonRoot);
|
EmoteMap parseChannelEmotes(const QJsonObject &jsonRoot);
|
||||||
|
|
||||||
/**
|
/// Parse the `user_badge_ids` into a map of User IDs -> Badge IDs
|
||||||
* Parse the `user_badge_ids` into a map of User IDs -> Badge IDs
|
FfzChannelBadgeMap parseChannelBadges(const QJsonObject &badgeRoot);
|
||||||
*/
|
|
||||||
FfzChannelBadgeMap parseChannelBadges(const QJsonObject &badgeRoot);
|
|
||||||
|
|
||||||
} // namespace ffz::detail
|
} // namespace ffz::detail
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ namespace chatterino {
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
const auto payload = "chatterino/" + CHATTERINO_VERSION;
|
const auto payload = "chatterino/" + CHATTERINO_VERSION;
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
|||||||
@@ -28,9 +28,9 @@ struct BasicPubSubConfig : public websocketpp::config::asio_tls_client {
|
|||||||
};
|
};
|
||||||
|
|
||||||
namespace liveupdates {
|
namespace liveupdates {
|
||||||
using WebsocketClient = websocketpp::client<chatterino::BasicPubSubConfig>;
|
using WebsocketClient = websocketpp::client<chatterino::BasicPubSubConfig>;
|
||||||
using WebsocketHandle = websocketpp::connection_hdl;
|
using WebsocketHandle = websocketpp::connection_hdl;
|
||||||
using WebsocketErrorCode = websocketpp::lib::error_code;
|
using WebsocketErrorCode = websocketpp::lib::error_code;
|
||||||
} // namespace liveupdates
|
} // namespace liveupdates
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|||||||
@@ -21,9 +21,9 @@ namespace chatterino {
|
|||||||
class ImageSet;
|
class ImageSet;
|
||||||
class Channel;
|
class Channel;
|
||||||
namespace seventv::eventapi {
|
namespace seventv::eventapi {
|
||||||
struct EmoteAddDispatch;
|
struct EmoteAddDispatch;
|
||||||
struct EmoteUpdateDispatch;
|
struct EmoteUpdateDispatch;
|
||||||
struct EmoteRemoveDispatch;
|
struct EmoteRemoveDispatch;
|
||||||
} // namespace seventv::eventapi
|
} // namespace seventv::eventapi
|
||||||
|
|
||||||
// https://github.com/SevenTV/API/blob/a84e884b5590dbb5d91a5c6b3548afabb228f385/data/model/emote-set.model.go#L29-L36
|
// https://github.com/SevenTV/API/blob/a84e884b5590dbb5d91a5c6b3548afabb228f385/data/model/emote-set.model.go#L29-L36
|
||||||
@@ -86,7 +86,7 @@ using SeventvEmoteSetFlags = FlagsEnum<SeventvEmoteSetFlag>;
|
|||||||
|
|
||||||
namespace seventv::detail {
|
namespace seventv::detail {
|
||||||
|
|
||||||
EmoteMap parseEmotes(const QJsonArray &emoteSetEmotes, bool isGlobal);
|
EmoteMap parseEmotes(const QJsonArray &emoteSetEmotes, bool isGlobal);
|
||||||
|
|
||||||
} // namespace seventv::detail
|
} // namespace seventv::detail
|
||||||
|
|
||||||
|
|||||||
@@ -10,13 +10,13 @@
|
|||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
namespace seventv::eventapi {
|
namespace seventv::eventapi {
|
||||||
struct Dispatch;
|
struct Dispatch;
|
||||||
struct EmoteAddDispatch;
|
struct EmoteAddDispatch;
|
||||||
struct EmoteUpdateDispatch;
|
struct EmoteUpdateDispatch;
|
||||||
struct EmoteRemoveDispatch;
|
struct EmoteRemoveDispatch;
|
||||||
struct UserConnectionUpdateDispatch;
|
struct UserConnectionUpdateDispatch;
|
||||||
struct CosmeticCreateDispatch;
|
struct CosmeticCreateDispatch;
|
||||||
struct EntitlementCreateDeleteDispatch;
|
struct EntitlementCreateDeleteDispatch;
|
||||||
} // namespace seventv::eventapi
|
} // namespace seventv::eventapi
|
||||||
|
|
||||||
class SeventvBadges;
|
class SeventvBadges;
|
||||||
|
|||||||
@@ -63,35 +63,34 @@ using namespace literals;
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 1, 0)
|
#if QT_VERSION < QT_VERSION_CHECK(6, 1, 0)
|
||||||
const QString MAGIC_MESSAGE_SUFFIX = QString((const char *)u8" \U000E0000");
|
const QString MAGIC_MESSAGE_SUFFIX = QString((const char *)u8" \U000E0000");
|
||||||
#else
|
#else
|
||||||
const QString MAGIC_MESSAGE_SUFFIX = QString::fromUtf8(u8" \U000E0000");
|
const QString MAGIC_MESSAGE_SUFFIX = QString::fromUtf8(u8" \U000E0000");
|
||||||
#endif
|
#endif
|
||||||
constexpr int CLIP_CREATION_COOLDOWN = 5000;
|
constexpr int CLIP_CREATION_COOLDOWN = 5000;
|
||||||
const QString CLIPS_LINK("https://clips.twitch.tv/%1");
|
const QString CLIPS_LINK("https://clips.twitch.tv/%1");
|
||||||
const QString CLIPS_FAILURE_CLIPS_UNAVAILABLE_TEXT(
|
const QString CLIPS_FAILURE_CLIPS_UNAVAILABLE_TEXT(
|
||||||
"Failed to create a clip - clips are temporarily unavailable: %1");
|
"Failed to create a clip - clips are temporarily unavailable: %1");
|
||||||
const QString CLIPS_FAILURE_CLIPS_DISABLED_TEXT(
|
const QString CLIPS_FAILURE_CLIPS_DISABLED_TEXT(
|
||||||
"Failed to create a clip - the streamer has clips disabled in their "
|
"Failed to create a clip - the streamer has clips disabled in their "
|
||||||
"channel.");
|
"channel.");
|
||||||
const QString CLIPS_FAILURE_CLIPS_RESTRICTED_TEXT(
|
const QString CLIPS_FAILURE_CLIPS_RESTRICTED_TEXT(
|
||||||
"Failed to create a clip - the streamer has restricted clip creation "
|
"Failed to create a clip - the streamer has restricted clip creation "
|
||||||
"to subscribers, or followers of an unknown duration.");
|
"to subscribers, or followers of an unknown duration.");
|
||||||
const QString CLIPS_FAILURE_CLIPS_RESTRICTED_CATEGORY_TEXT(
|
const QString CLIPS_FAILURE_CLIPS_RESTRICTED_CATEGORY_TEXT(
|
||||||
"Failed to create a clip - the streamer has disabled clips while in "
|
"Failed to create a clip - the streamer has disabled clips while in "
|
||||||
"this category.");
|
"this category.");
|
||||||
const QString CLIPS_FAILURE_NOT_AUTHENTICATED_TEXT(
|
const QString CLIPS_FAILURE_NOT_AUTHENTICATED_TEXT(
|
||||||
"Failed to create a clip - you need to re-authenticate.");
|
"Failed to create a clip - you need to re-authenticate.");
|
||||||
const QString CLIPS_FAILURE_UNKNOWN_ERROR_TEXT(
|
const QString CLIPS_FAILURE_UNKNOWN_ERROR_TEXT("Failed to create a clip: %1");
|
||||||
"Failed to create a clip: %1");
|
const QString LOGIN_PROMPT_TEXT("Click here to add your account again.");
|
||||||
const QString LOGIN_PROMPT_TEXT("Click here to add your account again.");
|
const Link ACCOUNTS_LINK(Link::OpenAccountsPage, QString());
|
||||||
const Link ACCOUNTS_LINK(Link::OpenAccountsPage, QString());
|
|
||||||
|
|
||||||
// Maximum number of chatters to fetch when refreshing chatters
|
// Maximum number of chatters to fetch when refreshing chatters
|
||||||
constexpr auto MAX_CHATTERS_TO_FETCH = 5000;
|
constexpr auto MAX_CHATTERS_TO_FETCH = 5000;
|
||||||
|
|
||||||
// From Twitch docs - expected size for a badge (1x)
|
// From Twitch docs - expected size for a badge (1x)
|
||||||
constexpr QSize BASE_BADGE_SIZE(18, 18);
|
constexpr QSize BASE_BADGE_SIZE(18, 18);
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
TwitchChannel::TwitchChannel(const QString &name)
|
TwitchChannel::TwitchChannel(const QString &name)
|
||||||
|
|||||||
@@ -45,10 +45,10 @@ struct BttvLiveUpdateEmoteRemoveMessage;
|
|||||||
|
|
||||||
class SeventvEmotes;
|
class SeventvEmotes;
|
||||||
namespace seventv::eventapi {
|
namespace seventv::eventapi {
|
||||||
struct EmoteAddDispatch;
|
struct EmoteAddDispatch;
|
||||||
struct EmoteUpdateDispatch;
|
struct EmoteUpdateDispatch;
|
||||||
struct EmoteRemoveDispatch;
|
struct EmoteRemoveDispatch;
|
||||||
struct UserConnectionUpdateDispatch;
|
struct UserConnectionUpdateDispatch;
|
||||||
} // namespace seventv::eventapi
|
} // namespace seventv::eventapi
|
||||||
|
|
||||||
struct ChannelPointReward;
|
struct ChannelPointReward;
|
||||||
|
|||||||
@@ -200,13 +200,13 @@ std::string &getNmQueueName(const Paths &paths)
|
|||||||
|
|
||||||
namespace nm::client {
|
namespace nm::client {
|
||||||
|
|
||||||
void sendMessage(const QByteArray &array)
|
void sendMessage(const QByteArray &array)
|
||||||
{
|
{
|
||||||
ipc::sendMessage("chatterino_gui", array);
|
ipc::sendMessage("chatterino_gui", array);
|
||||||
}
|
}
|
||||||
|
|
||||||
void writeToCout(const QByteArray &array)
|
void writeToCout(const QByteArray &array)
|
||||||
{
|
{
|
||||||
const auto *data = array.data();
|
const auto *data = array.data();
|
||||||
auto size = uint32_t(array.size());
|
auto size = uint32_t(array.size());
|
||||||
|
|
||||||
@@ -215,7 +215,7 @@ namespace nm::client {
|
|||||||
std::cout.write(reinterpret_cast<char *>(&size), 4);
|
std::cout.write(reinterpret_cast<char *>(&size), 4);
|
||||||
std::cout.write(data, size);
|
std::cout.write(data, size);
|
||||||
std::cout.flush();
|
std::cout.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace nm::client
|
} // namespace nm::client
|
||||||
|
|
||||||
|
|||||||
@@ -37,8 +37,8 @@ Atomic<std::optional<QString>> &nmIpcError();
|
|||||||
|
|
||||||
namespace nm::client {
|
namespace nm::client {
|
||||||
|
|
||||||
void sendMessage(const QByteArray &array);
|
void sendMessage(const QByteArray &array);
|
||||||
void writeToCout(const QByteArray &array);
|
void writeToCout(const QByteArray &array);
|
||||||
|
|
||||||
} // namespace nm::client
|
} // namespace nm::client
|
||||||
|
|
||||||
|
|||||||
@@ -7,15 +7,15 @@ namespace chatterino {
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
void appendDuration(int count, QChar &&suffix, QString &out)
|
void appendDuration(int count, QChar &&suffix, QString &out)
|
||||||
{
|
{
|
||||||
if (!out.isEmpty())
|
if (!out.isEmpty())
|
||||||
{
|
{
|
||||||
out.append(' ');
|
out.append(' ');
|
||||||
}
|
}
|
||||||
out.append(QString::number(count));
|
out.append(QString::number(count));
|
||||||
out.append(suffix);
|
out.append(suffix);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
|||||||
@@ -33,17 +33,17 @@ namespace chatterino {
|
|||||||
|
|
||||||
namespace helpers::detail {
|
namespace helpers::detail {
|
||||||
|
|
||||||
SizeType skipSpace(QStringView view, SizeType startPos)
|
SizeType skipSpace(QStringView view, SizeType startPos)
|
||||||
{
|
{
|
||||||
while (startPos < view.length() && view.at(startPos).isSpace())
|
while (startPos < view.length() && view.at(startPos).isSpace())
|
||||||
{
|
{
|
||||||
startPos++;
|
startPos++;
|
||||||
}
|
}
|
||||||
return startPos - 1;
|
return startPos - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool matchesIgnorePlural(QStringView word, const QString &expected)
|
bool matchesIgnorePlural(QStringView word, const QString &expected)
|
||||||
{
|
{
|
||||||
if (!word.startsWith(expected))
|
if (!word.startsWith(expected))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@@ -54,11 +54,11 @@ namespace helpers::detail {
|
|||||||
}
|
}
|
||||||
return word.length() == expected.length() + 1 &&
|
return word.length() == expected.length() + 1 &&
|
||||||
word.at(word.length() - 1).toLatin1() == 's';
|
word.at(word.length() - 1).toLatin1() == 's';
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<uint64_t, bool> findUnitMultiplierToSec(QStringView view,
|
std::pair<uint64_t, bool> findUnitMultiplierToSec(QStringView view,
|
||||||
SizeType &pos)
|
SizeType &pos)
|
||||||
{
|
{
|
||||||
// Step 1. find end of unit
|
// Step 1. find end of unit
|
||||||
auto startIdx = pos;
|
auto startIdx = pos;
|
||||||
auto endIdx = view.length();
|
auto endIdx = view.length();
|
||||||
@@ -130,7 +130,7 @@ namespace helpers::detail {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return std::make_pair(0, false);
|
return std::make_pair(0, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace helpers::detail
|
} // namespace helpers::detail
|
||||||
using namespace helpers::detail;
|
using namespace helpers::detail;
|
||||||
|
|||||||
@@ -18,9 +18,9 @@ namespace chatterino {
|
|||||||
// only qualified for tests
|
// only qualified for tests
|
||||||
namespace helpers::detail {
|
namespace helpers::detail {
|
||||||
|
|
||||||
using SizeType = QStringView::size_type;
|
using SizeType = QStringView::size_type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Skips all spaces.
|
* Skips all spaces.
|
||||||
* The caller must guarantee view.at(startPos).isSpace().
|
* The caller must guarantee view.at(startPos).isSpace().
|
||||||
*
|
*
|
||||||
@@ -28,18 +28,18 @@ namespace helpers::detail {
|
|||||||
* @param startPos The starting position (there must be a space in the view).
|
* @param startPos The starting position (there must be a space in the view).
|
||||||
* @return The position of the last space.
|
* @return The position of the last space.
|
||||||
*/
|
*/
|
||||||
SizeType skipSpace(QStringView view, SizeType startPos);
|
SizeType skipSpace(QStringView view, SizeType startPos);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if `word` equals `expected` (singular) or `expected` + 's' (plural).
|
* Checks if `word` equals `expected` (singular) or `expected` + 's' (plural).
|
||||||
*
|
*
|
||||||
* @param word Word to test. Must not be empty.
|
* @param word Word to test. Must not be empty.
|
||||||
* @param expected Singular of the expected word.
|
* @param expected Singular of the expected word.
|
||||||
* @return true if `word` is singular or plural of `expected`.
|
* @return true if `word` is singular or plural of `expected`.
|
||||||
*/
|
*/
|
||||||
bool matchesIgnorePlural(QStringView word, const QString &expected);
|
bool matchesIgnorePlural(QStringView word, const QString &expected);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tries to find the unit starting at `pos` and returns its multiplier so
|
* Tries to find the unit starting at `pos` and returns its multiplier so
|
||||||
* `valueInUnit * multiplier = valueInSeconds` (e.g. 60 for minutes).
|
* `valueInUnit * multiplier = valueInSeconds` (e.g. 60 for minutes).
|
||||||
*
|
*
|
||||||
@@ -54,7 +54,7 @@ namespace helpers::detail {
|
|||||||
* if it's a valid unit, undefined otherwise.
|
* if it's a valid unit, undefined otherwise.
|
||||||
* @return (multiplier, ok)
|
* @return (multiplier, ok)
|
||||||
*/
|
*/
|
||||||
std::pair<uint64_t, bool> findUnitMultiplierToSec(QStringView view,
|
std::pair<uint64_t, bool> findUnitMultiplierToSec(QStringView view,
|
||||||
SizeType &pos);
|
SizeType &pos);
|
||||||
|
|
||||||
} // namespace helpers::detail
|
} // namespace helpers::detail
|
||||||
|
|||||||
@@ -5,32 +5,30 @@
|
|||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
namespace rj {
|
namespace rj {
|
||||||
|
|
||||||
void addMember(rapidjson::Value &obj, const char *key,
|
void addMember(rapidjson::Value &obj, const char *key, rapidjson::Value &&value,
|
||||||
rapidjson::Value &&value,
|
|
||||||
rapidjson::Document::AllocatorType &a)
|
rapidjson::Document::AllocatorType &a)
|
||||||
{
|
{
|
||||||
obj.AddMember(rapidjson::Value(key, a).Move(), value, a);
|
obj.AddMember(rapidjson::Value(key, a).Move(), value, a);
|
||||||
}
|
}
|
||||||
|
|
||||||
void addMember(rapidjson::Value &obj, const char *key,
|
void addMember(rapidjson::Value &obj, const char *key, rapidjson::Value &value,
|
||||||
rapidjson::Value &value,
|
|
||||||
rapidjson::Document::AllocatorType &a)
|
rapidjson::Document::AllocatorType &a)
|
||||||
{
|
{
|
||||||
obj.AddMember(rapidjson::Value(key, a).Move(), value.Move(), a);
|
obj.AddMember(rapidjson::Value(key, a).Move(), value.Move(), a);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString stringify(const rapidjson::Value &value)
|
QString stringify(const rapidjson::Value &value)
|
||||||
{
|
{
|
||||||
rapidjson::StringBuffer buffer;
|
rapidjson::StringBuffer buffer;
|
||||||
rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
|
rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
|
||||||
value.Accept(writer);
|
value.Accept(writer);
|
||||||
|
|
||||||
return buffer.GetString();
|
return buffer.GetString();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool getSafeObject(rapidjson::Value &obj, const char *key,
|
bool getSafeObject(rapidjson::Value &obj, const char *key,
|
||||||
rapidjson::Value &out)
|
rapidjson::Value &out)
|
||||||
{
|
{
|
||||||
if (!checkJsonValue(obj, key))
|
if (!checkJsonValue(obj, key))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@@ -38,12 +36,12 @@ namespace rj {
|
|||||||
|
|
||||||
out = obj[key].Move();
|
out = obj[key].Move();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool checkJsonValue(const rapidjson::Value &obj, const char *key)
|
bool checkJsonValue(const rapidjson::Value &obj, const char *key)
|
||||||
{
|
{
|
||||||
return obj.IsObject() && !obj.IsNull() && obj.HasMember(key);
|
return obj.IsObject() && !obj.IsNull() && obj.HasMember(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace rj
|
} // namespace rj
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|||||||
@@ -11,67 +11,65 @@
|
|||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
namespace rj {
|
namespace rj {
|
||||||
|
|
||||||
void addMember(rapidjson::Value &obj, const char *key,
|
void addMember(rapidjson::Value &obj, const char *key, rapidjson::Value &&value,
|
||||||
rapidjson::Value &&value,
|
|
||||||
rapidjson::Document::AllocatorType &a);
|
rapidjson::Document::AllocatorType &a);
|
||||||
void addMember(rapidjson::Value &obj, const char *key,
|
void addMember(rapidjson::Value &obj, const char *key, rapidjson::Value &value,
|
||||||
rapidjson::Value &value,
|
|
||||||
rapidjson::Document::AllocatorType &a);
|
rapidjson::Document::AllocatorType &a);
|
||||||
|
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
void set(rapidjson::Value &obj, const char *key, const Type &value,
|
void set(rapidjson::Value &obj, const char *key, const Type &value,
|
||||||
rapidjson::Document::AllocatorType &a)
|
rapidjson::Document::AllocatorType &a)
|
||||||
{
|
{
|
||||||
assert(obj.IsObject());
|
assert(obj.IsObject());
|
||||||
|
|
||||||
addMember(obj, key, pajlada::Serialize<Type>::get(value, a), a);
|
addMember(obj, key, pajlada::Serialize<Type>::get(value, a), a);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
inline void set(rapidjson::Value &obj, const char *key,
|
inline void set(rapidjson::Value &obj, const char *key,
|
||||||
const rapidjson::Value &value,
|
const rapidjson::Value &value,
|
||||||
rapidjson::Document::AllocatorType &a)
|
rapidjson::Document::AllocatorType &a)
|
||||||
{
|
{
|
||||||
assert(obj.IsObject());
|
assert(obj.IsObject());
|
||||||
|
|
||||||
addMember(obj, key, const_cast<rapidjson::Value &>(value), a);
|
addMember(obj, key, const_cast<rapidjson::Value &>(value), a);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
void set(rapidjson::Document &obj, const char *key, const Type &value)
|
void set(rapidjson::Document &obj, const char *key, const Type &value)
|
||||||
{
|
{
|
||||||
assert(obj.IsObject());
|
assert(obj.IsObject());
|
||||||
|
|
||||||
auto &a = obj.GetAllocator();
|
auto &a = obj.GetAllocator();
|
||||||
|
|
||||||
addMember(obj, key, pajlada::Serialize<Type>::get(value, a), a);
|
addMember(obj, key, pajlada::Serialize<Type>::get(value, a), a);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
inline void set(rapidjson::Document &obj, const char *key,
|
inline void set(rapidjson::Document &obj, const char *key,
|
||||||
const rapidjson::Value &value)
|
const rapidjson::Value &value)
|
||||||
{
|
{
|
||||||
assert(obj.IsObject());
|
assert(obj.IsObject());
|
||||||
|
|
||||||
auto &a = obj.GetAllocator();
|
auto &a = obj.GetAllocator();
|
||||||
|
|
||||||
addMember(obj, key, const_cast<rapidjson::Value &>(value), a);
|
addMember(obj, key, const_cast<rapidjson::Value &>(value), a);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
void add(rapidjson::Value &arr, const Type &value,
|
void add(rapidjson::Value &arr, const Type &value,
|
||||||
rapidjson::Document::AllocatorType &a)
|
rapidjson::Document::AllocatorType &a)
|
||||||
{
|
{
|
||||||
assert(arr.IsArray());
|
assert(arr.IsArray());
|
||||||
|
|
||||||
arr.PushBack(pajlada::Serialize<Type>::get(value, a), a);
|
arr.PushBack(pajlada::Serialize<Type>::get(value, a), a);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool checkJsonValue(const rapidjson::Value &obj, const char *key);
|
bool checkJsonValue(const rapidjson::Value &obj, const char *key);
|
||||||
|
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
bool getSafe(const rapidjson::Value &obj, const char *key, Type &out)
|
bool getSafe(const rapidjson::Value &obj, const char *key, Type &out)
|
||||||
{
|
{
|
||||||
if (!checkJsonValue(obj, key))
|
if (!checkJsonValue(obj, key))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@@ -81,21 +79,21 @@ namespace rj {
|
|||||||
out = pajlada::Deserialize<Type>::get(obj[key], &error);
|
out = pajlada::Deserialize<Type>::get(obj[key], &error);
|
||||||
|
|
||||||
return !error;
|
return !error;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
bool getSafe(const rapidjson::Value &value, Type &out)
|
bool getSafe(const rapidjson::Value &value, Type &out)
|
||||||
{
|
{
|
||||||
bool error = false;
|
bool error = false;
|
||||||
out = pajlada::Deserialize<Type>::get(value, &error);
|
out = pajlada::Deserialize<Type>::get(value, &error);
|
||||||
|
|
||||||
return !error;
|
return !error;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool getSafeObject(rapidjson::Value &obj, const char *key,
|
bool getSafeObject(rapidjson::Value &obj, const char *key,
|
||||||
rapidjson::Value &out);
|
rapidjson::Value &out);
|
||||||
|
|
||||||
QString stringify(const rapidjson::Value &value);
|
QString stringify(const rapidjson::Value &value);
|
||||||
|
|
||||||
} // namespace rj
|
} // namespace rj
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ namespace chatterino {
|
|||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
namespace windows::detail {
|
namespace windows::detail {
|
||||||
void renameThread(void *hThread, const QString &name);
|
void renameThread(void *hThread, const QString &name);
|
||||||
} // namespace windows::detail
|
} // namespace windows::detail
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -11,16 +11,16 @@ namespace chatterino {
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
const auto TWITCH_USER_LOGIN_PATTERN = R"(^[a-z0-9]\w{0,24}$)";
|
const auto TWITCH_USER_LOGIN_PATTERN = R"(^[a-z0-9]\w{0,24}$)";
|
||||||
|
|
||||||
// Remember to keep VALID_HELIX_COLORS up-to-date if a new color is implemented to keep naming for users consistent
|
// Remember to keep VALID_HELIX_COLORS up-to-date if a new color is implemented to keep naming for users consistent
|
||||||
const std::unordered_map<QString, QString> HELIX_COLOR_REPLACEMENTS{
|
const std::unordered_map<QString, QString> HELIX_COLOR_REPLACEMENTS{
|
||||||
{"blueviolet", "blue_violet"}, {"cadetblue", "cadet_blue"},
|
{"blueviolet", "blue_violet"}, {"cadetblue", "cadet_blue"},
|
||||||
{"dodgerblue", "dodger_blue"}, {"goldenrod", "golden_rod"},
|
{"dodgerblue", "dodger_blue"}, {"goldenrod", "golden_rod"},
|
||||||
{"hotpink", "hot_pink"}, {"orangered", "orange_red"},
|
{"hotpink", "hot_pink"}, {"orangered", "orange_red"},
|
||||||
{"seagreen", "sea_green"}, {"springgreen", "spring_green"},
|
{"seagreen", "sea_green"}, {"springgreen", "spring_green"},
|
||||||
{"yellowgreen", "yellow_green"},
|
{"yellowgreen", "yellow_green"},
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
|||||||
@@ -13,23 +13,23 @@ namespace chatterino {
|
|||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
#ifdef Q_OS_LINUX
|
#ifdef Q_OS_LINUX
|
||||||
FlagsEnum<BaseWindow::Flags> popupFlags{
|
FlagsEnum<BaseWindow::Flags> popupFlags{
|
||||||
BaseWindow::Dialog,
|
BaseWindow::Dialog,
|
||||||
BaseWindow::EnableCustomFrame,
|
BaseWindow::EnableCustomFrame,
|
||||||
};
|
};
|
||||||
FlagsEnum<BaseWindow::Flags> popupFlagsCloseAutomatically{
|
FlagsEnum<BaseWindow::Flags> popupFlagsCloseAutomatically{
|
||||||
BaseWindow::Dialog,
|
BaseWindow::Dialog,
|
||||||
BaseWindow::EnableCustomFrame,
|
BaseWindow::EnableCustomFrame,
|
||||||
};
|
};
|
||||||
#else
|
#else
|
||||||
FlagsEnum<BaseWindow::Flags> popupFlags{
|
FlagsEnum<BaseWindow::Flags> popupFlags{
|
||||||
BaseWindow::EnableCustomFrame,
|
BaseWindow::EnableCustomFrame,
|
||||||
};
|
};
|
||||||
FlagsEnum<BaseWindow::Flags> popupFlagsCloseAutomatically{
|
FlagsEnum<BaseWindow::Flags> popupFlagsCloseAutomatically{
|
||||||
BaseWindow::EnableCustomFrame,
|
BaseWindow::EnableCustomFrame,
|
||||||
BaseWindow::Frameless,
|
BaseWindow::Frameless,
|
||||||
BaseWindow::FramelessDraggable,
|
BaseWindow::FramelessDraggable,
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -8,14 +8,13 @@
|
|||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
const QStringList friendlyBinaryOps = {
|
const QStringList friendlyBinaryOps = {
|
||||||
"and", "or", "+", "-", "*", "/",
|
"and", "or", "+", "-", "*", "/",
|
||||||
"%", "equals", "not equals", "<", ">", "<=",
|
"%", "equals", "not equals", "<", ">", "<=",
|
||||||
">=", "contains", "starts with", "ends with", "(nothing)"};
|
">=", "contains", "starts with", "ends with", "(nothing)"};
|
||||||
const QStringList realBinaryOps = {
|
const QStringList realBinaryOps = {
|
||||||
"&&", "||", "+", "-", "*", "/",
|
"&&", "||", "+", "-", "*", "/", "%", "==", "!=",
|
||||||
"%", "==", "!=", "<", ">", "<=",
|
"<", ">", "<=", ">=", "contains", "startswith", "endswith", ""};
|
||||||
">=", "contains", "startswith", "endswith", ""};
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
ChannelFilterEditorDialog::ChannelFilterEditorDialog(QWidget *parent)
|
ChannelFilterEditorDialog::ChannelFilterEditorDialog(QWidget *parent)
|
||||||
|
|||||||
@@ -25,10 +25,10 @@ namespace chatterino {
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
bool logInWithCredentials(QWidget *parent, const QString &userID,
|
bool logInWithCredentials(QWidget *parent, const QString &userID,
|
||||||
const QString &username, const QString &clientID,
|
const QString &username, const QString &clientID,
|
||||||
const QString &oauthToken)
|
const QString &oauthToken)
|
||||||
{
|
{
|
||||||
QStringList errors;
|
QStringList errors;
|
||||||
|
|
||||||
if (userID.isEmpty())
|
if (userID.isEmpty())
|
||||||
@@ -59,11 +59,9 @@ namespace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string basePath = "/accounts/uid" + userID.toStdString();
|
std::string basePath = "/accounts/uid" + userID.toStdString();
|
||||||
pajlada::Settings::Setting<QString>::set(basePath + "/username",
|
pajlada::Settings::Setting<QString>::set(basePath + "/username", username);
|
||||||
username);
|
|
||||||
pajlada::Settings::Setting<QString>::set(basePath + "/userID", userID);
|
pajlada::Settings::Setting<QString>::set(basePath + "/userID", userID);
|
||||||
pajlada::Settings::Setting<QString>::set(basePath + "/clientID",
|
pajlada::Settings::Setting<QString>::set(basePath + "/clientID", clientID);
|
||||||
clientID);
|
|
||||||
pajlada::Settings::Setting<QString>::set(basePath + "/oauthToken",
|
pajlada::Settings::Setting<QString>::set(basePath + "/oauthToken",
|
||||||
oauthToken);
|
oauthToken);
|
||||||
|
|
||||||
@@ -71,7 +69,7 @@ namespace {
|
|||||||
getApp()->getAccounts()->twitch.currentUsername = username;
|
getApp()->getAccounts()->twitch.currentUsername = username;
|
||||||
getSettings()->requestSave();
|
getSettings()->requestSave();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
|||||||
@@ -33,12 +33,12 @@
|
|||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
namespace {
|
namespace {
|
||||||
// Translates the given rectangle by an amount in the direction to appear like the tab is selected.
|
// Translates the given rectangle by an amount in the direction to appear like the tab is selected.
|
||||||
// For example, if location is Top, the rectangle will be translated in the negative Y direction,
|
// For example, if location is Top, the rectangle will be translated in the negative Y direction,
|
||||||
// or "up" on the screen, by amount.
|
// or "up" on the screen, by amount.
|
||||||
void translateRectForLocation(QRect &rect, NotebookTabLocation location,
|
void translateRectForLocation(QRect &rect, NotebookTabLocation location,
|
||||||
int amount)
|
int amount)
|
||||||
{
|
{
|
||||||
switch (location)
|
switch (location)
|
||||||
{
|
{
|
||||||
case NotebookTabLocation::Top:
|
case NotebookTabLocation::Top:
|
||||||
@@ -54,10 +54,10 @@ namespace {
|
|||||||
rect.translate(0, amount);
|
rect.translate(0, amount);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float getCompactDivider(TabStyle tabStyle)
|
float getCompactDivider(TabStyle tabStyle)
|
||||||
{
|
{
|
||||||
switch (tabStyle)
|
switch (tabStyle)
|
||||||
{
|
{
|
||||||
case TabStyle::Compact:
|
case TabStyle::Compact:
|
||||||
@@ -66,10 +66,10 @@ namespace {
|
|||||||
default:
|
default:
|
||||||
return 1.0;
|
return 1.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float getCompactReducer(TabStyle tabStyle)
|
float getCompactReducer(TabStyle tabStyle)
|
||||||
{
|
{
|
||||||
switch (tabStyle)
|
switch (tabStyle)
|
||||||
{
|
{
|
||||||
case TabStyle::Compact:
|
case TabStyle::Compact:
|
||||||
@@ -78,7 +78,7 @@ namespace {
|
|||||||
default:
|
default:
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
NotebookTab::NotebookTab(Notebook *notebook)
|
NotebookTab::NotebookTab(Notebook *notebook)
|
||||||
|
|||||||
@@ -27,8 +27,8 @@
|
|||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
// Add additional badges for highlights here
|
// Add additional badges for highlights here
|
||||||
QList<DisplayBadge> availableBadges = {
|
QList<DisplayBadge> availableBadges = {
|
||||||
{"Broadcaster", "broadcaster"},
|
{"Broadcaster", "broadcaster"},
|
||||||
{"Admin", "admin"},
|
{"Admin", "admin"},
|
||||||
{"Staff", "staff"},
|
{"Staff", "staff"},
|
||||||
@@ -39,7 +39,7 @@ namespace {
|
|||||||
{"Subscriber", "subscriber"},
|
{"Subscriber", "subscriber"},
|
||||||
{"Predicted Blue", "predictions/blue-1,predictions/blue-2"},
|
{"Predicted Blue", "predictions/blue-1,predictions/blue-2"},
|
||||||
{"Predicted Pink", "predictions/pink-2,predictions/pink-1"},
|
{"Predicted Pink", "predictions/pink-2,predictions/pink-1"},
|
||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
HighlightingPage::HighlightingPage()
|
HighlightingPage::HighlightingPage()
|
||||||
|
|||||||
@@ -183,9 +183,9 @@ QString formatChattersError(HelixGetChattersError error, const QString &message)
|
|||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
namespace {
|
namespace {
|
||||||
void showTutorialVideo(QWidget *parent, const QString &source,
|
void showTutorialVideo(QWidget *parent, const QString &source,
|
||||||
const QString &title, const QString &description)
|
const QString &title, const QString &description)
|
||||||
{
|
{
|
||||||
auto *window = new BasePopup(
|
auto *window = new BasePopup(
|
||||||
{
|
{
|
||||||
BaseWindow::EnableCustomFrame,
|
BaseWindow::EnableCustomFrame,
|
||||||
@@ -204,7 +204,7 @@ namespace {
|
|||||||
movie->start();
|
movie->start();
|
||||||
window->getLayoutContainer()->setLayout(layout);
|
window->getLayoutContainer()->setLayout(layout);
|
||||||
window->show();
|
window->show();
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
pajlada::Signals::Signal<Qt::KeyboardModifiers> Split::modifierStatusChanged;
|
pajlada::Signals::Signal<Qt::KeyboardModifiers> Split::modifierStatusChanged;
|
||||||
|
|||||||
Reference in New Issue
Block a user