Move highlight phrases to new settings system
Add a setting serialize/deserializer for QString Add constructor to ChatterinoSetting that doesn't take a default value
This commit is contained in:
@@ -22,8 +22,6 @@ SettingManager::SettingManager()
|
||||
, preferredQuality("/behaviour/streamlink/quality", "Choose")
|
||||
, emoteScale(this->settingsItems, "emoteScale", 1.0)
|
||||
, pathHighlightSound(this->settingsItems, "pathHighlightSound", "qrc:/sounds/ping2.wav")
|
||||
, highlightProperties(this->settingsItems, "highlightProperties",
|
||||
QMap<QString, QPair<bool, bool>>())
|
||||
, highlightUserBlacklist(this->settingsItems, "highlightUserBlacklist", "")
|
||||
, snapshot(nullptr)
|
||||
, settings(Path::getAppdataPath() + "settings.ini", QSettings::IniFormat)
|
||||
@@ -40,49 +38,6 @@ SettingManager::SettingManager()
|
||||
};
|
||||
}
|
||||
|
||||
void SettingManager::save()
|
||||
{
|
||||
for (auto &item : this->settingsItems) {
|
||||
if (item.get().getName() != "highlightProperties") {
|
||||
this->settings.setValue(item.get().getName(), item.get().getVariant());
|
||||
} else {
|
||||
this->settings.beginGroup("Highlights");
|
||||
QStringList list = highlightProperties.get().keys();
|
||||
list.removeAll("");
|
||||
this->settings.remove("");
|
||||
for (auto string : list) {
|
||||
this->settings.beginGroup(string);
|
||||
this->settings.setValue("highlightSound",
|
||||
highlightProperties.get().value(string).first);
|
||||
this->settings.setValue("highlightTask",
|
||||
highlightProperties.get().value(string).second);
|
||||
this->settings.endGroup();
|
||||
}
|
||||
this->settings.endGroup();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SettingManager::load()
|
||||
{
|
||||
for (auto &item : this->settingsItems) {
|
||||
if (item.get().getName() != "highlightProperties") {
|
||||
item.get().setVariant(this->settings.value(item.get().getName()));
|
||||
} else {
|
||||
this->settings.beginGroup("Highlights");
|
||||
QStringList list = this->settings.childGroups();
|
||||
for (auto string : list) {
|
||||
this->settings.beginGroup(string);
|
||||
highlightProperties.insertMap(string,
|
||||
this->settings.value("highlightSound").toBool(),
|
||||
this->settings.value("highlightTask").toBool());
|
||||
this->settings.endGroup();
|
||||
}
|
||||
this->settings.endGroup();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Word::Flags SettingManager::getWordTypeMask()
|
||||
{
|
||||
return this->wordTypeMask;
|
||||
@@ -98,6 +53,12 @@ QSettings &SettingManager::getQSettings()
|
||||
return this->settings;
|
||||
}
|
||||
|
||||
void SettingManager::load()
|
||||
{
|
||||
// Just to make sure the singleton is initialized
|
||||
debug::Log(".");
|
||||
}
|
||||
|
||||
void SettingManager::updateWordTypeMask()
|
||||
{
|
||||
uint32_t newMaskUint = Word::Text;
|
||||
@@ -184,5 +145,5 @@ void SettingManager::recallSnapshot()
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace singletons
|
||||
} // namespace chatterino
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user