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
+10 -11
View File
@@ -1,30 +1,29 @@
#include "AboutPage.hpp"
#include "widgets/settingspages/AboutPage.hpp"
#include "common/Common.hpp"
#include "common/Modes.hpp"
#include "common/QLogging.hpp"
#include "common/Version.hpp"
#include "util/LayoutCreator.hpp"
#include "util/RemoveScrollAreaBackground.hpp"
#include "widgets/BasePopup.hpp"
#include "widgets/helper/SignalLabel.hpp"
#include "widgets/layout/FlowLayout.hpp"
#include <QFile>
#include <QFormLayout>
#include <QGroupBox>
#include <QLabel>
#include <QStringBuilder>
#include <QTextEdit>
#include <QTextStream>
#include <QVBoxLayout>
#define PIXMAP_WIDTH 500
#define LINK_DONATE "https://streamelements.com/fourtf/tip"
#define LINK_CHATTERINO_FEATURES "https://chatterino.com/#features"
namespace chatterino {
constexpr int PIXMAP_WIDTH = 500;
constexpr QStringView LINK_CHATTERINO_FEATURES =
u"https://chatterino.com/#features";
AboutPage::AboutPage()
{
LayoutCreator<AboutPage> layoutCreator(this);
@@ -66,9 +65,9 @@ AboutPage::AboutPage()
auto l = aboutChatterino.emplace<QVBoxLayout>();
// clang-format off
l.emplace<QLabel>("Chatterino Wiki can be found <a href=\"" LINK_CHATTERINO_WIKI "\">here</a>")->setOpenExternalLinks(true);
l.emplace<QLabel>("All about Chatterino's <a href=\"" LINK_CHATTERINO_FEATURES "\">features</a>")->setOpenExternalLinks(true);
l.emplace<QLabel>("Join the official Chatterino <a href=\"" LINK_CHATTERINO_DISCORD "\">Discord</a>")->setOpenExternalLinks(true);
l.emplace<QLabel>("Chatterino Wiki can be found <a href=\"" % LINK_CHATTERINO_WIKI % "\">here</a>")->setOpenExternalLinks(true);
l.emplace<QLabel>("All about Chatterino's <a href=\"" % LINK_CHATTERINO_FEATURES % "\">features</a>")->setOpenExternalLinks(true);
l.emplace<QLabel>("Join the official Chatterino <a href=\"" % LINK_CHATTERINO_DISCORD % "\">Discord</a>")->setOpenExternalLinks(true);
// clang-format on
}
+1 -1
View File
@@ -1,4 +1,4 @@
#include "AccountsPage.hpp"
#include "widgets/settingspages/AccountsPage.hpp"
#include "Application.hpp"
#include "controllers/accounts/AccountController.hpp"
+9 -7
View File
@@ -1,6 +1,7 @@
#include "CommandPage.hpp"
#include "widgets/settingspages/CommandPage.hpp"
#include "Application.hpp"
#include "common/Literals.hpp"
#include "controllers/commands/Command.hpp"
#include "controllers/commands/CommandController.hpp"
#include "controllers/commands/CommandModel.hpp"
@@ -18,13 +19,14 @@
#include <QTableView>
#include <QTextEdit>
// clang-format off
#define TEXT "{1} => first word &nbsp;&nbsp;&nbsp; {1+} => first word and after &nbsp;&nbsp;&nbsp; {{ => { &nbsp;&nbsp;&nbsp; <a href='https://chatterino.com/help/commands'>more info</a>"
// clang-format on
namespace {
using namespace chatterino;
using namespace literals;
// clang-format off
inline const QString HELP_TEXT = u"{1} => first word &nbsp;&nbsp;&nbsp; {1+} => first word and after &nbsp;&nbsp;&nbsp; {{ => { &nbsp;&nbsp;&nbsp; <a href='https://chatterino.com/help/commands'>more info</a>"_s;
// clang-format on
QString c1settingsPath()
{
@@ -106,7 +108,7 @@ CommandPage::CommandPage()
view->addCustomButton(button);
QObject::connect(button, &QPushButton::clicked, this, [] {
QFile c1settings = c1settingsPath();
QFile c1settings(c1settingsPath());
c1settings.open(QIODevice::ReadOnly);
for (auto line :
QString(c1settings.readAll())
@@ -125,7 +127,7 @@ CommandPage::CommandPage()
this->createCheckBox("Also match the trigger at the end of the message",
getSettings()->allowCommandsAtEnd));
QLabel *text = layout.emplace<QLabel>(TEXT).getElement();
QLabel *text = layout.emplace<QLabel>(HELP_TEXT).getElement();
text->setWordWrap(true);
text->setStyleSheet("color: #bbb");
text->setOpenExternalLinks(true);
@@ -10,11 +10,11 @@
#include <QGroupBox>
#include <QLabel>
#define STREAMLINK_QUALITY \
"Choose", "Source", "High", "Medium", "Low", "Audio only"
namespace chatterino {
inline const QStringList STREAMLINK_QUALITY = {
"Choose", "Source", "High", "Medium", "Low", "Audio only"};
ExternalToolsPage::ExternalToolsPage()
{
LayoutCreator<ExternalToolsPage> layoutCreator(this);
@@ -75,7 +75,7 @@ ExternalToolsPage::ExternalToolsPage()
groupLayout->addRow("Custom streamlink path:", customPath);
groupLayout->addRow(
"Preferred quality:",
this->createComboBox({STREAMLINK_QUALITY},
this->createComboBox(STREAMLINK_QUALITY,
getSettings()->preferredQuality));
groupLayout->addRow(
"Additional options:",
+6 -6
View File
@@ -1,4 +1,4 @@
#include "FiltersPage.hpp"
#include "widgets/settingspages/FiltersPage.hpp"
#include "Application.hpp"
#include "controllers/filters/FilterModel.hpp"
@@ -8,15 +8,15 @@
#include "util/LayoutCreator.hpp"
#include "widgets/dialogs/ChannelFilterEditorDialog.hpp"
#include "widgets/helper/EditableModelView.hpp"
#include "widgets/Window.hpp"
#include <QHeaderView>
#include <QTableView>
#define FILTERS_DOCUMENTATION "https://wiki.chatterino.com/Filters"
namespace chatterino {
constexpr QStringView FILTERS_DOCUMENTATION =
u"https://wiki.chatterino.com/Filters";
FiltersPage::FiltersPage()
{
LayoutCreator<FiltersPage> layoutCreator(this);
@@ -67,8 +67,8 @@ FiltersPage::FiltersPage()
});
auto *filterHelpLabel =
new QLabel(QString("<a href='%1'><span "
"style='color:#99f'>filter info</span></a>")
new QLabel(QStringView(u"<a href='%1'><span "
"style='color:#99f'>filter info</span></a>")
.arg(FILTERS_DOCUMENTATION));
filterHelpLabel->setOpenExternalLinks(true);
view->addCustomButton(filterHelpLabel);
+50 -51
View File
@@ -1,6 +1,7 @@
#include "widgets/settingspages/GeneralPage.hpp"
#include "Application.hpp"
#include "common/Literals.hpp"
#include "common/QLogging.hpp"
#include "common/Version.hpp"
#include "controllers/hotkeys/HotkeyCategory.hpp"
@@ -19,7 +20,6 @@
#include "util/IncognitoBrowser.hpp"
#include "widgets/BaseWindow.hpp"
#include "widgets/settingspages/GeneralPageView.hpp"
#include "widgets/splits/SplitInput.hpp"
#include <magic_enum/magic_enum.hpp>
#include <QDesktopServices>
@@ -28,64 +28,63 @@
#include <QLabel>
#include <QScrollArea>
#define CHROME_EXTENSION_LINK \
"https://chrome.google.com/webstore/detail/chatterino-native-host/" \
"glknmaideaikkmemifbfkhnomoknepka"
#define FIREFOX_EXTENSION_LINK \
"https://addons.mozilla.org/en-US/firefox/addon/chatterino-native-host/"
namespace {
// define to highlight sections in editor
#define addTitle addTitle
#define addSubtitle addSubtitle
using namespace chatterino;
using namespace literals;
const QString CHROME_EXTENSION_LINK =
u"https://chrome.google.com/webstore/detail/chatterino-native-host/glknmaideaikkmemifbfkhnomoknepka"_s;
const QString FIREFOX_EXTENSION_LINK =
u"https://addons.mozilla.org/en-US/firefox/addon/chatterino-native-host/"_s;
#ifdef Q_OS_WIN
# define META_KEY "Windows"
const QString META_KEY = u"Windows"_s;
#else
# define META_KEY "Meta"
const QString META_KEY = u"Meta"_s;
#endif
namespace chatterino {
namespace {
void addKeyboardModifierSetting(GeneralPageView &layout,
const QString &title,
EnumSetting<Qt::KeyboardModifier> &setting)
{
layout.addDropdown<std::underlying_type<Qt::KeyboardModifier>::type>(
title, {"None", "Shift", "Control", "Alt", META_KEY}, setting,
[](int index) {
switch (index)
{
case Qt::ShiftModifier:
return 1;
case Qt::ControlModifier:
return 2;
case Qt::AltModifier:
return 3;
case Qt::MetaModifier:
return 4;
default:
return 0;
}
},
[](DropdownArgs args) {
switch (args.index)
{
case 1:
return Qt::ShiftModifier;
case 2:
return Qt::ControlModifier;
case 3:
return Qt::AltModifier;
case 4:
return Qt::MetaModifier;
default:
return Qt::NoModifier;
}
},
false);
}
void addKeyboardModifierSetting(GeneralPageView &layout, const QString &title,
EnumSetting<Qt::KeyboardModifier> &setting)
{
layout.addDropdown<std::underlying_type<Qt::KeyboardModifier>::type>(
title, {"None", "Shift", "Control", "Alt", META_KEY}, setting,
[](int index) {
switch (index)
{
case Qt::ShiftModifier:
return 1;
case Qt::ControlModifier:
return 2;
case Qt::AltModifier:
return 3;
case Qt::MetaModifier:
return 4;
default:
return 0;
}
},
[](DropdownArgs args) {
switch (args.index)
{
case 1:
return Qt::ShiftModifier;
case 2:
return Qt::ControlModifier;
case 3:
return Qt::AltModifier;
case 4:
return Qt::MetaModifier;
default:
return Qt::NoModifier;
}
},
false);
}
} // namespace
namespace chatterino {
GeneralPage::GeneralPage()
{
auto *y = new QVBoxLayout;
@@ -1,4 +1,4 @@
#include "HighlightingPage.hpp"
#include "widgets/settingspages/HighlightingPage.hpp"
#include "Application.hpp"
#include "controllers/highlights/BadgeHighlightModel.hpp"
@@ -10,7 +10,6 @@
#include "controllers/highlights/UserHighlightModel.hpp"
#include "providers/colors/ColorProvider.hpp"
#include "singletons/Settings.hpp"
#include "singletons/Theme.hpp"
#include "util/Helpers.hpp"
#include "util/LayoutCreator.hpp"
#include "widgets/dialogs/BadgePickerDialog.hpp"
@@ -25,8 +24,6 @@
#include <QTableView>
#include <QTabWidget>
#define ALWAYS_PLAY "Play highlight sound even when Chatterino is focused"
namespace chatterino {
namespace {
@@ -312,8 +309,9 @@ HighlightingPage::HighlightingPage()
this->managedConnections_);
}
layout.append(createCheckBox(ALWAYS_PLAY,
getSettings()->highlightAlwaysPlaySound));
layout.append(createCheckBox(
"Play highlight sound even when Chatterino is focused",
getSettings()->highlightAlwaysPlaySound));
layout.append(createCheckBox(
"Flash taskbar only stops highlighting when Chatterino is focused",
getSettings()->longAlerts));
+5 -5
View File
@@ -1,6 +1,7 @@
#include "widgets/settingspages/IgnoresPage.hpp"
#include "Application.hpp"
#include "common/Literals.hpp"
#include "controllers/accounts/AccountController.hpp"
#include "controllers/ignores/IgnoreModel.hpp"
#include "controllers/ignores/IgnorePhrase.hpp"
@@ -19,12 +20,10 @@
#include <QTableView>
#include <QVBoxLayout>
// clang-format off
#define INFO "/block <user> in chat blocks a user.\n/unblock <user> in chat unblocks a user.\nYou can also click on a user to open the usercard."
// clang-format on
namespace chatterino {
using namespace literals;
static void addPhrasesTab(LayoutCreator<QVBoxLayout> box);
static void addUsersTab(IgnoresPage &page, LayoutCreator<QVBoxLayout> box,
QStringListModel &model);
@@ -74,7 +73,8 @@ void addPhrasesTab(LayoutCreator<QVBoxLayout> layout)
void addUsersTab(IgnoresPage &page, LayoutCreator<QVBoxLayout> users,
QStringListModel &userModel)
{
auto label = users.emplace<QLabel>(INFO);
auto label = users.emplace<QLabel>(
u"/block <user> in chat blocks a user.\n/unblock <user> in chat unblocks a user.\nYou can also click on a user to open the usercard."_s);
label->setWordWrap(true);
users.append(page.createCheckBox("Enable Twitch blocked users",
getSettings()->enableTwitchBlockedUsers));
+1 -1
View File
@@ -1,4 +1,4 @@
#include "ModerationPage.hpp"
#include "widgets/settingspages/ModerationPage.hpp"
#include "Application.hpp"
#include "controllers/logging/ChannelLoggingModel.hpp"
+1 -1
View File
@@ -1,4 +1,4 @@
#include "NicknamesPage.hpp"
#include "widgets/settingspages/NicknamesPage.hpp"
#include "controllers/nicknames/Nickname.hpp"
#include "controllers/nicknames/NicknamesModel.hpp"
@@ -1,4 +1,4 @@
#include "NotificationPage.hpp"
#include "widgets/settingspages/NotificationPage.hpp"
#include "Application.hpp"
#include "controllers/notifications/NotificationController.hpp"
+1 -1
View File
@@ -1,4 +1,4 @@
#include "SettingsPage.hpp"
#include "widgets/settingspages/SettingsPage.hpp"
#include "Application.hpp"
#include "singletons/WindowManager.hpp"