Skip to content

Commit

Permalink
Remove BaseSettings & merge ConcurrentSettings (#4775)
Browse files Browse the repository at this point in the history
  • Loading branch information
pajlada authored Aug 28, 2023
1 parent 4c942a2 commit 7cb04bf
Show file tree
Hide file tree
Showing 18 changed files with 238 additions and 284 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- Dev: Fixed UTF16 encoding of `modes` file for the installer. (#4791)
- Dev: Temporarily disable High DPI scaling on Qt6 builds on Windows. (#4767)
- Dev: Tests now run on Ubuntu 22.04 instead of 20.04 to loosen C++ restrictions in tests. (#4774)
- Dev: Do a pretty major refactor of the Settings classes. List settings (e.g. highlights) are most heavily modified, and should have an extra eye kept on them. (#4775)

## 2.4.5

Expand Down
128 changes: 0 additions & 128 deletions src/BaseSettings.cpp

This file was deleted.

47 changes: 0 additions & 47 deletions src/BaseSettings.hpp

This file was deleted.

2 changes: 0 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ option(CHATTERINO_DEBUG_NATIVE_MESSAGES "Debug native messages" OFF)
set(SOURCE_FILES
Application.cpp
Application.hpp
BaseSettings.cpp
BaseSettings.hpp
BrowserExtension.cpp
BrowserExtension.hpp
RunGui.cpp
Expand Down
2 changes: 1 addition & 1 deletion src/common/ChatterinoSetting.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "common/ChatterinoSetting.hpp"

#include "BaseSettings.hpp"
#include "singletons/Settings.hpp"

namespace chatterino {

Expand Down
8 changes: 4 additions & 4 deletions src/controllers/filters/FilterSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@ namespace chatterino {
FilterSet::FilterSet()
{
this->listener_ =
getCSettings().filterRecords.delayedItemsChanged.connect([this] {
getSettings()->filterRecords.delayedItemsChanged.connect([this] {
this->reloadFilters();
});
}

FilterSet::FilterSet(const QList<QUuid> &filterIds)
{
auto filters = getCSettings().filterRecords.readOnly();
auto filters = getSettings()->filterRecords.readOnly();
for (const auto &f : *filters)
{
if (filterIds.contains(f->getId()))
this->filters_.insert(f->getId(), f);
}

this->listener_ =
getCSettings().filterRecords.delayedItemsChanged.connect([this] {
getSettings()->filterRecords.delayedItemsChanged.connect([this] {
this->reloadFilters();
});
}
Expand Down Expand Up @@ -55,7 +55,7 @@ const QList<QUuid> FilterSet::filterIds() const

void FilterSet::reloadFilters()
{
auto filters = getCSettings().filterRecords.readOnly();
auto filters = getSettings()->filterRecords.readOnly();
for (const auto &key : this->filters_.keys())
{
bool found = false;
Expand Down
6 changes: 3 additions & 3 deletions src/controllers/highlights/HighlightController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -441,22 +441,22 @@ void HighlightController::initialize(Settings &settings, Paths & /*paths*/)
});

this->signalHolder_.managedConnect(
getCSettings().highlightedBadges.delayedItemsChanged,
getSettings()->highlightedBadges.delayedItemsChanged,
[this, &settings] {
qCDebug(chatterinoHighlights)
<< "Rebuild checks because highlight badges changed";
this->rebuildChecks(settings);
});

this->signalHolder_.managedConnect(
getCSettings().highlightedUsers.delayedItemsChanged, [this, &settings] {
getSettings()->highlightedUsers.delayedItemsChanged, [this, &settings] {
qCDebug(chatterinoHighlights)
<< "Rebuild checks because highlight users changed";
this->rebuildChecks(settings);
});

this->signalHolder_.managedConnect(
getCSettings().highlightedMessages.delayedItemsChanged,
getSettings()->highlightedMessages.delayedItemsChanged,
[this, &settings] {
qCDebug(chatterinoHighlights)
<< "Rebuild checks because highlight messages changed";
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/ignores/IgnoreController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ bool isIgnoredMessage(IgnoredMessageParameters &&params)
if (!params.message.isEmpty())
{
// TODO(pajlada): Do we need to check if the phrase is valid first?
auto phrases = getCSettings().ignoredMessages.readOnly();
auto phrases = getSettings()->ignoredMessages.readOnly();
for (const auto &phrase : *phrases)
{
if (phrase.isBlock() && phrase.isMatch(params.message))
Expand Down
2 changes: 1 addition & 1 deletion src/messages/MessageElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@ void TwitchModerationElement::addToContainer(MessageLayoutContainer &container,
{
QSize size(int(container.getScale() * 16),
int(container.getScale() * 16));
auto actions = getCSettings().moderationActions.readOnly();
auto actions = getSettings()->moderationActions.readOnly();
for (const auto &action : *actions)
{
if (auto image = action.getImage())
Expand Down
6 changes: 3 additions & 3 deletions src/messages/SharedMessageBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ void SharedMessageBuilder::parseUsername()

void SharedMessageBuilder::parseHighlights()
{
if (getCSettings().isBlacklistedUser(this->ircMessage->nick()))
if (getSettings()->isBlacklistedUser(this->ircMessage->nick()))
{
// Do nothing. We ignore highlights from this user.
return;
Expand Down Expand Up @@ -206,7 +206,7 @@ void SharedMessageBuilder::triggerHighlights()
return;
}

if (getCSettings().isMutedChannel(this->channel->getName()))
if (getSettings()->isMutedChannel(this->channel->getName()))
{
// Do nothing. Pings are muted in this channel.
return;
Expand Down Expand Up @@ -270,7 +270,7 @@ QString SharedMessageBuilder::stylizeUsername(const QString &username,
break;
}

if (auto nicknameText = getCSettings().matchNickname(usernameText))
if (auto nicknameText = getSettings()->matchNickname(usernameText))
{
usernameText = *nicknameText;
}
Expand Down
2 changes: 1 addition & 1 deletion src/providers/twitch/TwitchMessageBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,7 @@ void TwitchMessageBuilder::appendUsername()
void TwitchMessageBuilder::runIgnoreReplaces(
std::vector<TwitchEmoteOccurrence> &twitchEmotes)
{
auto phrases = getCSettings().ignoredMessages.readOnly();
auto phrases = getSettings()->ignoredMessages.readOnly();
auto removeEmotesInRange = [](int pos, int len,
auto &twitchEmotes) mutable {
auto it = std::partition(
Expand Down
Loading

0 comments on commit 7cb04bf

Please sign in to comment.