diff --git a/README.md b/README.md index 660323d4..41f415a5 100644 --- a/README.md +++ b/README.md @@ -306,6 +306,8 @@ For example, memory_db would be set by adding `memory_db = true` under the line | `hide_to_tray` | boolean | false | hide abaddon to the system tray on window close | | `show_deleted_indicator` | boolean | true | show \[deleted\] indicator next to deleted messages instead of actually deleting the message | | `font_scale` | double | | scale font rendering. 1 is unchanged | +| `image_embed_clamp_width` | int | 400 | maximum width of image embeds | +| `image_embed_clamp_height` | int | 300 | maximum height of image embeds | #### style diff --git a/src/components/chatmessage.cpp b/src/components/chatmessage.cpp index a5032945..05954da0 100644 --- a/src/components/chatmessage.cpp +++ b/src/components/chatmessage.cpp @@ -431,7 +431,9 @@ Gtk::Widget *ChatMessageItemContainer::CreateEmbedComponent(const EmbedData &emb if (embed.Image.has_value() && embed.Image->ProxyURL.has_value()) { int w = 0, h = 0; - GetImageDimensions(*embed.Image->Width, *embed.Image->Height, w, h, EmbedImageWidth, EmbedImageHeight); + const int clamp_width = Abaddon::Get().GetSettings().ImageEmbedClampWidth; + const int clamp_height = Abaddon::Get().GetSettings().ImageEmbedClampHeight; + GetImageDimensions(*embed.Image->Width, *embed.Image->Height, w, h, clamp_width, clamp_height); auto *img = Gtk::manage(new LazyImage(*embed.Image->ProxyURL, w, h, false)); img->set_halign(Gtk::ALIGN_CENTER); @@ -488,7 +490,9 @@ Gtk::Widget *ChatMessageItemContainer::CreateEmbedComponent(const EmbedData &emb Gtk::Widget *ChatMessageItemContainer::CreateImageComponent(const std::string &proxy_url, const std::string &url, int inw, int inh) { int w, h; - GetImageDimensions(inw, inh, w, h); + const int clamp_width = Abaddon::Get().GetSettings().ImageEmbedClampWidth; + const int clamp_height = Abaddon::Get().GetSettings().ImageEmbedClampHeight; + GetImageDimensions(inw, inh, w, h, clamp_width, clamp_height); Gtk::EventBox *ev = Gtk::manage(new Gtk::EventBox); Gtk::Image *widget = Gtk::manage(new LazyImage(proxy_url, w, h, false)); diff --git a/src/constants.hpp b/src/constants.hpp index 5ed123c1..8f39530d 100644 --- a/src/constants.hpp +++ b/src/constants.hpp @@ -12,7 +12,5 @@ constexpr static int BoostLevel3AttachmentSizeLimit = 100 * 1024 * 1024; constexpr static int MaxMessagePayloadSize = 199 * 1024 * 1024; constexpr static int EmojiSize = 24; // settings eventually constexpr static int AvatarSize = 32; -constexpr static int EmbedImageWidth = 400; -constexpr static int EmbedImageHeight = 300; constexpr static int ThumbnailSize = 100; constexpr static int StickerComponentSize = 160; diff --git a/src/settings.cpp b/src/settings.cpp index 23b2b898..85464a55 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -96,6 +96,8 @@ void SettingsManager::DefineSettings() { AddSetting("gui", "hide_to_try", false, &Settings::HideToTray); AddSetting("gui", "show_deleted_indicator", true, &Settings::ShowDeletedIndicator); AddSetting("gui", "font_scale", -1.0, &Settings::FontScale); + AddSetting("gui", "image_embed_clamp_width", 400, &Settings::ImageEmbedClampWidth); + AddSetting("gui", "image_embed_clamp_height", 300, &Settings::ImageEmbedClampHeight); AddSetting("http", "concurrent", 20, &Settings::CacheHTTPConcurrency); AddSetting("http", "user_agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36"s, &Settings::UserAgent); diff --git a/src/settings.hpp b/src/settings.hpp index be9660e2..d69d165e 100644 --- a/src/settings.hpp +++ b/src/settings.hpp @@ -28,6 +28,8 @@ class SettingsManager { bool HideToTray; bool ShowDeletedIndicator; double FontScale; + int ImageEmbedClampWidth; + int ImageEmbedClampHeight; // [http] int CacheHTTPConcurrency;