add more granular control over emojis

This commit is contained in:
ouwou
2021-05-24 02:03:42 -04:00
parent b2655260fa
commit c75a91d15f
5 changed files with 19 additions and 13 deletions

View File

@@ -184,7 +184,8 @@ For example, memory_db would be set by adding `memory_db = true` under the line
#### gui
* member_list_discriminator (true or false, default true) - show user discriminators in the member list
* emojis (true or false, default true) - resolve unicode and custom emojis to images. this needs to be false to allow GTK to render emojis by itself
* stock_emojis (true or false, default true) - allow abaddon to substitute unicode emojis with images from emojis.bin, must be false to allow GTK to render emojis itself
* custom_emojis (true or false, default true) - download and use custom Discord emojis
* css (string) - path to the main CSS file
* animations (true or false, default true) - use animated images where available (e.g. server icons, emojis, avatars). false means static images will be used
* owner_crown (true or false, default true) - show a crown next to the owner

View File

@@ -99,7 +99,7 @@ ChannelListRowDMChannel::ChannelListRowDMChannel(const ChannelData *data) {
else if (data->Type == ChannelType::GROUP_DM)
buf->set_text(std::to_string(recipients.size()) + " users");
static bool show_emojis = Abaddon::Get().GetSettings().GetShowEmojis();
static bool show_emojis = Abaddon::Get().GetSettings().GetShowStockEmojis();
if (show_emojis)
Abaddon::Get().GetEmojis().ReplaceEmojis(buf, ChannelEmojiSize);
@@ -172,7 +172,7 @@ ChannelListRowGuild::ChannelListRowGuild(const GuildData *data) {
Gtk::TextBuffer::iterator start, end;
buf->get_bounds(start, end);
buf->insert_markup(start, "<b>" + Glib::Markup::escape_text(data->Name) + "</b>");
static bool show_emojis = Abaddon::Get().GetSettings().GetShowEmojis();
static bool show_emojis = Abaddon::Get().GetSettings().GetShowStockEmojis();
if (show_emojis)
Abaddon::Get().GetEmojis().ReplaceEmojis(buf, ChannelEmojiSize);
m_box->set_halign(Gtk::ALIGN_START);
@@ -220,7 +220,7 @@ ChannelListRowCategory::ChannelListRowCategory(const ChannelData *data) {
auto buf = m_lbl->get_buffer();
buf->set_text(*data->Name);
static bool show_emojis = Abaddon::Get().GetSettings().GetShowEmojis();
static bool show_emojis = Abaddon::Get().GetSettings().GetShowStockEmojis();
if (show_emojis)
Abaddon::Get().GetEmojis().ReplaceEmojis(buf, ChannelEmojiSize);
m_box->set_halign(Gtk::ALIGN_START);
@@ -275,7 +275,7 @@ ChannelListRowChannel::ChannelListRowChannel(const ChannelData *data) {
lbl->get_style_context()->add_class("nsfw");
}
buf->set_text("#" + *data->Name);
static bool show_emojis = Abaddon::Get().GetSettings().GetShowEmojis();
static bool show_emojis = Abaddon::Get().GetSettings().GetShowStockEmojis();
if (show_emojis)
Abaddon::Get().GetEmojis().ReplaceEmojis(buf, ChannelEmojiSize);
ev->add(*lbl);

View File

@@ -810,11 +810,11 @@ void ChatMessageItemContainer::HandleCustomEmojis(Gtk::TextView &tv) {
}
void ChatMessageItemContainer::HandleEmojis(Gtk::TextView &tv) {
static bool emojis = Abaddon::Get().GetSettings().GetShowEmojis();
if (emojis) {
HandleStockEmojis(tv);
HandleCustomEmojis(tv);
}
static const bool stock_emojis = Abaddon::Get().GetSettings().GetShowStockEmojis();
static const bool custom_emojis = Abaddon::Get().GetSettings().GetShowCustomEmojis();
if (stock_emojis) HandleStockEmojis(tv);
if (custom_emojis) HandleCustomEmojis(tv);
}
void ChatMessageItemContainer::CleanupEmojis(Glib::RefPtr<Gtk::TextBuffer> buf) {

View File

@@ -54,8 +54,12 @@ bool SettingsManager::GetShowMemberListDiscriminators() const {
return GetSettingBool("gui", "member_list_discriminator", true);
}
bool SettingsManager::GetShowEmojis() const {
return GetSettingBool("gui", "emojis", true);
bool SettingsManager::GetShowStockEmojis() const {
return GetSettingBool("gui", "stock_emojis", true);
}
bool SettingsManager::GetShowCustomEmojis() const {
return GetSettingBool("gui", "custom_emojis", true);
}
std::string SettingsManager::GetLinkColor() const {

View File

@@ -13,7 +13,8 @@ public:
std::string GetUserAgent() const;
std::string GetDiscordToken() const;
bool GetShowMemberListDiscriminators() const;
bool GetShowEmojis() const;
bool GetShowStockEmojis() const;
bool GetShowCustomEmojis() const;
std::string GetLinkColor() const;
int GetCacheHTTPConcurrency() const;
bool GetPrefetch() const;