Utilize templates for Settings class
Use boost2::signals for the valueChanged signal (a LOT less messy to
deal with than qt signals)
Remove unused settings classes (BoolSetting, FloatSetting, IntSetting,
StringSetting)
What's left: Implement the remaining signals
This commit is contained in:
+48
-49
@@ -6,13 +6,12 @@
|
||||
namespace chatterino {
|
||||
namespace settings {
|
||||
|
||||
Settings Settings::_;
|
||||
Settings Settings::instance;
|
||||
|
||||
Settings::Settings()
|
||||
: settings(
|
||||
QStandardPaths::writableLocation(QStandardPaths::AppDataLocation),
|
||||
QSettings::IniFormat)
|
||||
, settingsItems()
|
||||
, portable(false)
|
||||
, wordTypeMask(messages::Word::Default)
|
||||
, theme("", "dark")
|
||||
@@ -43,62 +42,61 @@ Settings::Settings()
|
||||
, windowTopMost("", true)
|
||||
, hideTabX("", false)
|
||||
{
|
||||
settingsItems.reserve(25);
|
||||
settingsItems.push_back(&theme);
|
||||
settingsItems.push_back(&user);
|
||||
settingsItems.push_back(&emoteScale);
|
||||
settingsItems.push_back(&scaleEmotesByLineHeight);
|
||||
settingsItems.push_back(&showTimestamps);
|
||||
settingsItems.push_back(&showTimestampSeconds);
|
||||
settingsItems.push_back(&showLastMessageIndicator);
|
||||
settingsItems.push_back(&allowDouplicateMessages);
|
||||
settingsItems.push_back(&linksDoubleClickOnly);
|
||||
settingsItems.push_back(&hideEmptyInput);
|
||||
settingsItems.push_back(&showMessageLength);
|
||||
settingsItems.push_back(&seperateMessages);
|
||||
settingsItems.push_back(&mentionUsersWithAt);
|
||||
settingsItems.push_back(&allowCommandsAtEnd);
|
||||
settingsItems.push_back(&enableHighlights);
|
||||
settingsItems.push_back(&enableHighlightSound);
|
||||
settingsItems.push_back(&enableHighlightTaskbar);
|
||||
settingsItems.push_back(&customHighlightSound);
|
||||
settingsItems.push_back(&enableTwitchEmotes);
|
||||
settingsItems.push_back(&enableBttvEmotes);
|
||||
settingsItems.push_back(&enableFfzEmotes);
|
||||
settingsItems.push_back(&enableEmojis);
|
||||
settingsItems.push_back(&enableGifAnimations);
|
||||
settingsItems.push_back(&enableGifs);
|
||||
settingsItems.push_back(&inlineWhispers);
|
||||
settingsItems.push_back(&windowTopMost);
|
||||
settingsItems.push_back(&hideTabX);
|
||||
settingsItems.push_back(theme);
|
||||
settingsItems.push_back(user);
|
||||
settingsItems.push_back(emoteScale);
|
||||
settingsItems.push_back(scaleEmotesByLineHeight);
|
||||
settingsItems.push_back(showTimestamps);
|
||||
settingsItems.push_back(showTimestampSeconds);
|
||||
settingsItems.push_back(showLastMessageIndicator);
|
||||
settingsItems.push_back(allowDouplicateMessages);
|
||||
settingsItems.push_back(linksDoubleClickOnly);
|
||||
settingsItems.push_back(hideEmptyInput);
|
||||
settingsItems.push_back(showMessageLength);
|
||||
settingsItems.push_back(seperateMessages);
|
||||
settingsItems.push_back(mentionUsersWithAt);
|
||||
settingsItems.push_back(allowCommandsAtEnd);
|
||||
settingsItems.push_back(enableHighlights);
|
||||
settingsItems.push_back(enableHighlightSound);
|
||||
settingsItems.push_back(enableHighlightTaskbar);
|
||||
settingsItems.push_back(customHighlightSound);
|
||||
settingsItems.push_back(enableTwitchEmotes);
|
||||
settingsItems.push_back(enableBttvEmotes);
|
||||
settingsItems.push_back(enableFfzEmotes);
|
||||
settingsItems.push_back(enableEmojis);
|
||||
settingsItems.push_back(enableGifAnimations);
|
||||
settingsItems.push_back(enableGifs);
|
||||
settingsItems.push_back(inlineWhispers);
|
||||
settingsItems.push_back(windowTopMost);
|
||||
settingsItems.push_back(hideTabX);
|
||||
|
||||
QObject::connect(&showTimestamps, &BoolSetting::valueChanged, this,
|
||||
&Settings::updateWordTypeMask);
|
||||
QObject::connect(&showTimestampSeconds, &BoolSetting::valueChanged, this,
|
||||
&Settings::updateWordTypeMask);
|
||||
QObject::connect(&enableBttvEmotes, &BoolSetting::valueChanged, this,
|
||||
&Settings::updateWordTypeMask);
|
||||
QObject::connect(&enableEmojis, &BoolSetting::valueChanged, this,
|
||||
&Settings::updateWordTypeMask);
|
||||
QObject::connect(&enableFfzEmotes, &BoolSetting::valueChanged, this,
|
||||
&Settings::updateWordTypeMask);
|
||||
QObject::connect(&enableTwitchEmotes, &BoolSetting::valueChanged, this,
|
||||
&Settings::updateWordTypeMask);
|
||||
this->showTimestamps.valueChanged.connect(
|
||||
[this](const auto &) { this->updateWordTypeMask(); });
|
||||
this->showTimestampSeconds.valueChanged.connect(
|
||||
[this](const auto &) { this->updateWordTypeMask(); });
|
||||
this->enableBttvEmotes.valueChanged.connect(
|
||||
[this](const auto &) { this->updateWordTypeMask(); });
|
||||
this->enableEmojis.valueChanged.connect(
|
||||
[this](const auto &) { this->updateWordTypeMask(); });
|
||||
this->enableFfzEmotes.valueChanged.connect(
|
||||
[this](const auto &) { this->updateWordTypeMask(); });
|
||||
this->enableTwitchEmotes.valueChanged.connect(
|
||||
[this](const auto &) { this->updateWordTypeMask(); });
|
||||
}
|
||||
|
||||
void
|
||||
Settings::save()
|
||||
{
|
||||
for (Setting *item : settingsItems) {
|
||||
item->save(settings);
|
||||
for (auto &item : settingsItems) {
|
||||
item.get().save(settings);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Settings::load()
|
||||
{
|
||||
for (Setting *item : settingsItems) {
|
||||
item->load(settings);
|
||||
for (auto &item : settingsItems) {
|
||||
item.get().load(settings);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,7 +107,7 @@ Settings::isIgnoredEmote(const QString &)
|
||||
}
|
||||
|
||||
void
|
||||
Settings::updateWordTypeMask(bool)
|
||||
Settings::updateWordTypeMask()
|
||||
|
||||
{
|
||||
using namespace messages;
|
||||
@@ -143,5 +141,6 @@ Settings::updateWordTypeMask(bool)
|
||||
emit wordTypeMaskChanged();
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace settings
|
||||
} // namespace chatterino
|
||||
|
||||
Reference in New Issue
Block a user