diff options
author | ouwou <26526779+ouwou@users.noreply.github.com> | 2024-01-11 21:50:13 -0500 |
---|---|---|
committer | ouwou <26526779+ouwou@users.noreply.github.com> | 2024-01-11 21:50:13 -0500 |
commit | 012c2dab59b0202586a88af6286b27d79eac61b6 (patch) | |
tree | d2726374a078305bdf546afa04a93c41c85addcf /src | |
parent | c45c090d8449a917b1549e2ec93ddbd0a6fa870c (diff) | |
download | abaddon-portaudio-012c2dab59b0202586a88af6286b27d79eac61b6.tar.gz abaddon-portaudio-012c2dab59b0202586a88af6286b27d79eac61b6.zip |
make image clamp dimensions a setting
Diffstat (limited to 'src')
-rw-r--r-- | src/components/chatmessage.cpp | 8 | ||||
-rw-r--r-- | src/constants.hpp | 2 | ||||
-rw-r--r-- | src/settings.cpp | 2 | ||||
-rw-r--r-- | src/settings.hpp | 2 |
4 files changed, 10 insertions, 4 deletions
diff --git a/src/components/chatmessage.cpp b/src/components/chatmessage.cpp index a503294..05954da 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 5ed123c..8f39530 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 23b2b89..85464a5 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 be9660e..d69d165 100644 --- a/src/settings.hpp +++ b/src/settings.hpp @@ -28,6 +28,8 @@ public: bool HideToTray; bool ShowDeletedIndicator; double FontScale; + int ImageEmbedClampWidth; + int ImageEmbedClampHeight; // [http] int CacheHTTPConcurrency; |