forked from OpenGamers/abaddon
add SettingsManager::GetSettingBool
This commit is contained in:
parent
b91c368668
commit
e562b75f95
@ -533,7 +533,7 @@ void ChatMessageItemContainer::HandleCustomEmojis(Gtk::TextView *tv) {
|
||||
}
|
||||
|
||||
void ChatMessageItemContainer::HandleEmojis(Gtk::TextView *tv) {
|
||||
static bool emojis = Abaddon::Get().GetSettings().GetSettingString("gui", "emojis", "true") != "false";
|
||||
static bool emojis = Abaddon::Get().GetSettings().GetSettingBool("gui", "emojis", true);
|
||||
if (emojis) {
|
||||
HandleStockEmojis(tv);
|
||||
HandleCustomEmojis(tv);
|
||||
|
@ -17,7 +17,7 @@ MemberListUserRow::MemberListUserRow(Snowflake guild_id, const User *data) {
|
||||
m_label->set_single_line_mode(true);
|
||||
m_label->set_ellipsize(Pango::ELLIPSIZE_END);
|
||||
if (data != nullptr) {
|
||||
static bool show_discriminator = Abaddon::Get().GetSettings().GetSettingString("gui", "member_list_discriminator", "true") != "false";
|
||||
static bool show_discriminator = Abaddon::Get().GetSettings().GetSettingBool("gui", "member_list_discriminator", true);
|
||||
std::string display = data->Username;
|
||||
if (show_discriminator)
|
||||
display += "#" + data->Discriminator;
|
||||
|
@ -14,14 +14,18 @@ SettingsManager::SettingsManager(std::string filename)
|
||||
m_ok = rc == SI_OK;
|
||||
}
|
||||
|
||||
std::string SettingsManager::GetSettingString(std::string section, std::string key, std::string fallback) const {
|
||||
std::string SettingsManager::GetSettingString(const std::string §ion, const std::string &key, std::string fallback) const {
|
||||
return m_ini.GetValue(section.c_str(), key.c_str(), fallback.c_str());
|
||||
}
|
||||
|
||||
int SettingsManager::GetSettingInt(std::string section, std::string key, int fallback) const {
|
||||
int SettingsManager::GetSettingInt(const std::string §ion, const std::string &key, int fallback) const {
|
||||
return std::stoul(GetSettingString(section, key, std::to_string(fallback)));
|
||||
}
|
||||
|
||||
bool SettingsManager::GetSettingBool(const std::string §ion, const std::string &key, bool fallback) const {
|
||||
return GetSettingString(section, key, "false") != "false";
|
||||
}
|
||||
|
||||
bool SettingsManager::IsValid() const {
|
||||
return m_ok;
|
||||
}
|
||||
@ -29,3 +33,4 @@ bool SettingsManager::IsValid() const {
|
||||
void SettingsManager::Close() {
|
||||
m_ini.SaveFile(m_filename.c_str());
|
||||
}
|
||||
|
||||
|
@ -8,12 +8,12 @@ public:
|
||||
SettingsManager(std::string filename);
|
||||
|
||||
void Close();
|
||||
std::string GetSettingString(std::string section, std::string key, std::string fallback = "") const;
|
||||
int GetSettingInt(std::string section, std::string key, int fallback) const;
|
||||
std::string GetSettingString(const std::string §ion, const std::string &key, std::string fallback = "") const;
|
||||
int GetSettingInt(const std::string §ion, const std::string &key, int fallback) const;
|
||||
bool GetSettingBool(const std::string §ion, const std::string &key, bool fallback) const;
|
||||
|
||||
template<typename T>
|
||||
void SetSetting(std::string section, std::string key, T value) {
|
||||
static_assert(std::is_convertible<T, std::string>::value);
|
||||
if constexpr (std::is_same<T, std::string>::value)
|
||||
m_ini.SetValue(section.c_str(), key.c_str(), value.c_str());
|
||||
else
|
||||
@ -21,6 +21,7 @@ public:
|
||||
|
||||
m_ini.SaveFile(m_filename.c_str());
|
||||
}
|
||||
|
||||
bool IsValid() const;
|
||||
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user