fix: replace defines with constexpr/const and use more absolute paths for includes (#5527)

bye bye nuuls
This commit is contained in:
nerix
2024-08-03 12:00:58 +02:00
committed by GitHub
parent 5ee5abf5b2
commit aed55ac1ba
83 changed files with 386 additions and 380 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
#include "ChannelChatters.hpp"
#include "common/ChannelChatters.hpp"
#include "common/Channel.hpp"
#include "messages/Message.hpp"
+13 -20
View File
@@ -5,17 +5,17 @@
#include <QWidget>
#include <memory>
#include <optional>
#include <string>
#define LINK_CHATTERINO_WIKI "https://wiki.chatterino.com"
#define LINK_CHATTERINO_DISCORD "https://discord.gg/7Y5AYhAK4z"
#define LINK_CHATTERINO_SOURCE "https://github.com/Chatterino/chatterino2"
namespace chatterino {
const inline auto TWITCH_PLAYER_URL =
QStringLiteral("https://player.twitch.tv/?channel=%1&parent=twitch.tv");
constexpr QStringView LINK_CHATTERINO_WIKI = u"https://wiki.chatterino.com";
constexpr QStringView LINK_CHATTERINO_DISCORD =
u"https://discord.gg/7Y5AYhAK4z";
constexpr QStringView LINK_CHATTERINO_SOURCE =
u"https://github.com/Chatterino/chatterino2";
constexpr QStringView TWITCH_PLAYER_URL =
u"https://player.twitch.tv/?channel=%1&parent=twitch.tv";
enum class HighlightState {
None,
@@ -23,21 +23,14 @@ enum class HighlightState {
NewMessage,
};
const Qt::KeyboardModifiers showSplitOverlayModifiers =
constexpr Qt::KeyboardModifiers SHOW_SPLIT_OVERLAY_MODIFIERS =
Qt::ControlModifier | Qt::AltModifier;
const Qt::KeyboardModifiers showAddSplitRegions =
constexpr Qt::KeyboardModifiers SHOW_ADD_SPLIT_REGIONS =
Qt::ControlModifier | Qt::AltModifier;
const Qt::KeyboardModifiers showResizeHandlesModifiers = Qt::ControlModifier;
constexpr Qt::KeyboardModifiers SHOW_RESIZE_HANDLES_MODIFIERS =
Qt::ControlModifier;
#ifndef ATTR_UNUSED
# ifdef Q_OS_WIN
# define ATTR_UNUSED
# else
# define ATTR_UNUSED __attribute__((unused))
# endif
#endif
static const char *ANONYMOUS_USERNAME_LABEL ATTR_UNUSED = " - anonymous - ";
constexpr const char *ANONYMOUS_USERNAME_LABEL = " - anonymous - ";
template <typename T>
std::weak_ptr<T> weakOf(T *element)
+10 -9
View File
@@ -11,6 +11,7 @@
#include <QJsonDocument>
#include <QJsonObject>
#include <QSaveFile>
#include <QStringBuilder>
#include <variant>
@@ -26,16 +27,16 @@
# endif
#endif
#define FORMAT_NAME \
([&] { \
assert(!provider.contains(":")); \
return QString("chatterino:%1:%2").arg(provider).arg(name_); \
})()
namespace {
using namespace chatterino;
QString formatName(const QString &provider, const QString &name)
{
assert(!provider.contains(":"));
return u"chatterino:" % provider % u':' % name;
}
bool useKeyring()
{
#ifdef NO_QTKEYCHAIN
@@ -184,7 +185,7 @@ void Credentials::get(const QString &provider, const QString &name_,
{
assertInGuiThread();
auto name = FORMAT_NAME;
auto name = formatName(provider, name_);
if (useKeyring())
{
@@ -219,7 +220,7 @@ void Credentials::set(const QString &provider, const QString &name_,
/// On linux, we try to use a keychain but show a message to disable it when it fails.
/// XXX: add said message
auto name = FORMAT_NAME;
auto name = formatName(provider, name_);
if (useKeyring())
{
@@ -242,7 +243,7 @@ void Credentials::erase(const QString &provider, const QString &name_)
{
assertInGuiThread();
auto name = FORMAT_NAME;
auto name = formatName(provider, name_);
if (useKeyring())
{
+1 -1
View File
@@ -1,4 +1,4 @@
#include "Modes.hpp"
#include "common/Modes.hpp"
#include "util/CombinePath.hpp"
+3 -16
View File
@@ -1,7 +1,8 @@
#pragma once
#include <QString>
#include <QtGlobal>
namespace chatterino {
/**
* Valid version formats, in order of latest to oldest
@@ -24,21 +25,7 @@
* - 2.4.0-alpha.2
* - 2.4.0-alpha
**/
#define CHATTERINO_VERSION "2.5.1"
#if defined(Q_OS_WIN)
# define CHATTERINO_OS "win"
#elif defined(Q_OS_MACOS)
# define CHATTERINO_OS "macos"
#elif defined(Q_OS_LINUX)
# define CHATTERINO_OS "linux"
#elif defined(Q_OS_FREEBSD)
# define CHATTERINO_OS "freebsd"
#else
# define CHATTERINO_OS "unknown"
#endif
namespace chatterino {
inline const QString CHATTERINO_VERSION = QStringLiteral("2.5.1");
class Version
{