[Settings] Split cache_settings monolith into multiple SettingsManager sub-classes (#7050)

* [Settings] Split cache_settings into multiple files

Took 9 minutes

Took 4 minutes

* [Settings] Fwd declare settings classes in cache_settings

Took 15 minutes

* Fix oracle includes.

Took 8 minutes

* Address comments, fix windows CI

Took 8 minutes

* fix copy constructor visibility

Took 3 minutes

* lint

Took 2 minutes

* Fix native format tests.

Took 5 minutes

* Remove test header guard

Took 4 seconds

* Remove tests invalid in CI environ

Took 24 seconds

* Adjust to rebase.

Took 11 minutes

* Change settings file name.

Took 8 minutes

---------

Co-authored-by: Lukas Brübach <lukas.bruebach@bdosecurity.de>
Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
BruebachL 2026-07-27 11:25:39 +02:00 committed by GitHub
parent cf0b453e75
commit 12f0f59453
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
166 changed files with 5589 additions and 3066 deletions

View file

@ -14,6 +14,7 @@
#include <QMouseEvent>
#include <QScrollBar>
#include <libcockatrice/network/server/remote/user_level.h>
#include <libcockatrice/settings/chat_settings.h>
const QColor DEFAULT_MENTION_COLOR = QColor(194, 31, 47);
@ -292,8 +293,8 @@ void ChatView::appendMessage(QString message,
}
cursor.setCharFormat(defaultFormat);
bool mentionEnabled = SettingsCache::instance().getChatMention();
highlightedWords = SettingsCache::instance().getHighlightWords().split(' ', Qt::SkipEmptyParts);
bool mentionEnabled = SettingsCache::instance().chat().getChatMention();
highlightedWords = SettingsCache::instance().chat().getHighlightWords().split(' ', Qt::SkipEmptyParts);
// parse the message
while (message.size()) {
@ -395,8 +396,9 @@ void ChatView::checkMention(QTextCursor &cursor, QString &message, const QString
// You have received a valid mention!!
soundEngine->playSound("chat_mention");
mentionFormat.setBackground(QBrush(getCustomMentionColor()));
mentionFormat.setForeground(SettingsCache::instance().getChatMentionForeground() ? QBrush(Qt::white)
: QBrush(Qt::black));
mentionFormat.setForeground(SettingsCache::instance().chat().getChatMentionForeground()
? QBrush(Qt::white)
: QBrush(Qt::black));
cursor.insertText(mention, mentionFormat);
message = message.mid(mention.size());
showSystemPopup(userName);
@ -417,8 +419,8 @@ void ChatView::checkMention(QTextCursor &cursor, QString &message, const QString
// Moderator Sending Global Message
soundEngine->playSound("all_mention");
mentionFormat.setBackground(QBrush(getCustomMentionColor()));
mentionFormat.setForeground(SettingsCache::instance().getChatMentionForeground() ? QBrush(Qt::white)
: QBrush(Qt::black));
mentionFormat.setForeground(
SettingsCache::instance().chat().getChatMentionForeground() ? QBrush(Qt::white) : QBrush(Qt::black));
cursor.insertText("@" + fullMentionUpToSpaceOrEnd, mentionFormat);
message = message.mid(fullMentionUpToSpaceOrEnd.size() + 1);
showSystemPopup(userName);
@ -465,8 +467,8 @@ void ChatView::checkWord(QTextCursor &cursor, QString &message)
if (fullWordUpToSpaceOrEnd.compare(word, Qt::CaseInsensitive) == 0) {
// You have received a valid mention of custom word!!
highlightFormat.setBackground(QBrush(getCustomHighlightColor()));
highlightFormat.setForeground(SettingsCache::instance().getChatHighlightForeground() ? QBrush(Qt::white)
: QBrush(Qt::black));
highlightFormat.setForeground(
SettingsCache::instance().chat().getChatHighlightForeground() ? QBrush(Qt::white) : QBrush(Qt::black));
cursor.insertText(fullWordUpToSpaceOrEnd, highlightFormat);
cursor.insertText(rest, defaultFormat);
QApplication::alert(this);
@ -522,7 +524,7 @@ void ChatView::actMessageClicked()
void ChatView::showSystemPopup(const QString &userName)
{
QApplication::alert(this);
if (SettingsCache::instance().getShowMentionPopup()) {
if (SettingsCache::instance().chat().getShowMentionPopup()) {
emit showMentionPopup(userName);
}
}
@ -530,10 +532,10 @@ void ChatView::showSystemPopup(const QString &userName)
QColor ChatView::getCustomMentionColor()
{
#if (QT_VERSION >= QT_VERSION_CHECK(6, 4, 0))
QColor customColor = QColor::fromString("#" + SettingsCache::instance().getChatMentionColor());
QColor customColor = QColor::fromString("#" + SettingsCache::instance().chat().getChatMentionColor());
#else
QColor customColor;
customColor.setNamedColor("#" + SettingsCache::instance().getChatMentionColor());
customColor.setNamedColor("#" + SettingsCache::instance().chat().getChatMentionColor());
#endif
return customColor.isValid() ? customColor : DEFAULT_MENTION_COLOR;
}
@ -541,10 +543,10 @@ QColor ChatView::getCustomMentionColor()
QColor ChatView::getCustomHighlightColor()
{
#if (QT_VERSION >= QT_VERSION_CHECK(6, 4, 0))
QColor customColor = QColor::fromString("#" + SettingsCache::instance().getChatMentionColor());
QColor customColor = QColor::fromString("#" + SettingsCache::instance().chat().getChatMentionColor());
#else
QColor customColor;
customColor.setNamedColor("#" + SettingsCache::instance().getChatMentionColor());
customColor.setNamedColor("#" + SettingsCache::instance().chat().getChatMentionColor());
#endif
return customColor.isValid() ? customColor : DEFAULT_MENTION_COLOR;
}

View file

@ -21,6 +21,7 @@
#include <libcockatrice/protocol/pb/room_commands.pb.h>
#include <libcockatrice/protocol/pb/serverinfo_game.pb.h>
#include <libcockatrice/protocol/pending_command.h>
#include <libcockatrice/settings/cards_display_settings.h>
GameSelector::GameSelector(AbstractClient *_client,
TabSupervisor *_tabSupervisor,
@ -78,11 +79,13 @@ GameSelector::GameSelector(AbstractClient *_client,
if (showFilters && restoresettings) {
quickFilterToolBar = new GameSelectorQuickFilterToolBar(this, tabSupervisor, gameListProxyModel, gameTypeMap);
quickFilterToolBar->setVisible(showFilters && restoresettings &&
SettingsCache::instance().getShowGameSelectorFilterToolbar());
SettingsCache::instance().cardsDisplay().getShowGameSelectorFilterToolbar());
connect(&SettingsCache::instance(), &SettingsCache::showGameSelectorFilterToolbarChanged, this, [this] {
quickFilterToolBar->setVisible(SettingsCache::instance().getShowGameSelectorFilterToolbar());
});
connect(&SettingsCache::instance().cardsDisplay(), &CardsDisplaySettings::showGameSelectorFilterToolbarChanged,
this, [this] {
quickFilterToolBar->setVisible(
SettingsCache::instance().cardsDisplay().getShowGameSelectorFilterToolbar());
});
} else {
quickFilterToolBar = nullptr;
}

View file

@ -10,6 +10,7 @@
#include <QIcon>
#include <QTimeZone>
#include <libcockatrice/protocol/pb/serverinfo_game.pb.h>
#include <libcockatrice/settings/game_filters_settings.h>
enum GameListColumn
{

View file

@ -5,6 +5,7 @@
#include <QJsonDocument>
#include <QNetworkReply>
#include <QUrl>
#include <libcockatrice/settings/servers_settings.h>
#define PUBLIC_SERVERS_JSON "https://cockatrice.github.io/public-servers.json"

View file

@ -3,6 +3,7 @@
#include "../../../../client/settings/cache_settings.h"
#include <QDebug>
#include <libcockatrice/settings/servers_settings.h>
#include <utility>
UserConnection_Information::UserConnection_Information() = default;

View file

@ -30,6 +30,7 @@
#include <libcockatrice/protocol/pb/response_get_games_of_user.pb.h>
#include <libcockatrice/protocol/pb/response_get_user_info.pb.h>
#include <libcockatrice/protocol/pending_command.h>
#include <libcockatrice/settings/interface_settings.h>
#include <libcockatrice/utility/string_limits.h>
BanDialog::BanDialog(const ServerInfo_User &info, QWidget *parent) : QDialog(parent)
@ -352,7 +353,7 @@ bool UserListItemDelegate::editorEvent(QEvent *event,
QSize UserListItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
{
if (!SettingsCache::instance().getStyleUserList()) {
if (!SettingsCache::instance().interface().getStyleUserList()) {
return QStyledItemDelegate::sizeHint(option, index);
}
return UserListPainter::sizeHint();
@ -360,7 +361,7 @@ QSize UserListItemDelegate::sizeHint(const QStyleOptionViewItem &option, const Q
void UserListItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
if (!SettingsCache::instance().getStyleUserList()) {
if (!SettingsCache::instance().interface().getStyleUserList()) {
QStyledItemDelegate::paint(painter, option, index);
return;
}
@ -524,7 +525,7 @@ UserListWidget::UserListWidget(TabSupervisor *_tabSupervisor,
// Pin on item click
connect(userTree, &QTreeWidget::itemClicked, this, [this](QTreeWidgetItem *item, int) {
if (!SettingsCache::instance().getStyleUserList()) {
if (!SettingsCache::instance().interface().getStyleUserList()) {
return;
}
const QString name = static_cast<UserListTWI *>(item)->getUserInfo().name().c_str();
@ -556,7 +557,8 @@ UserListWidget::UserListWidget(TabSupervisor *_tabSupervisor,
connect(cardArtProvider, &UserCardArtProvider::cardArtUpdated, this,
[this](const QString &) { userTree->viewport()->update(); });
connect(&SettingsCache::instance(), &SettingsCache::styleUserListChanged, this, &UserListWidget::applyDisplayMode);
connect(&SettingsCache::instance().interface(), &InterfaceSettings::styleUserListChanged, this,
&UserListWidget::applyDisplayMode);
applyDisplayMode();
QVBoxLayout *vbox = new QVBoxLayout;
@ -661,7 +663,7 @@ void UserListWidget::hideEvent(QHideEvent *e)
void UserListWidget::applyDisplayMode()
{
const bool styled = SettingsCache::instance().getStyleUserList();
const bool styled = SettingsCache::instance().interface().getStyleUserList();
if (styled) {
userTree->header()->setSectionResizeMode(0, QHeaderView::Stretch);
@ -720,7 +722,7 @@ bool UserListWidget::eventFilter(QObject *obj, QEvent *event)
{
if (obj == userTree->viewport()) {
if (event->type() == QEvent::MouseMove) {
if (!SettingsCache::instance().getStyleUserList()) {
if (!SettingsCache::instance().interface().getStyleUserList()) {
return QGroupBox::eventFilter(obj, event);
}
auto *me = static_cast<QMouseEvent *>(event);