diff options
author | Nick Johnson <sylvyrfysh@gmail.com> | 2021-03-12 12:00:56 -0600 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-03-22 12:46:16 +0100 |
commit | 9d09594e4465bda1a3a62042997531a0de0332d9 (patch) | |
tree | 390630f3cbdf8da929ac11e02d1ef9f3d420ba8b | |
parent | c7f00717c3224b24d4c567693bdfc876e0fc8b62 (diff) | |
download | serenity-9d09594e4465bda1a3a62042997531a0de0332d9.zip |
Notification: Remove default image
This takes up a lot of space if it is not used, and the default image
does not give value. Therefore, we hide the image widget if an invalid
image is passed.
-rw-r--r-- | Userland/Services/NotificationServer/NotificationWindow.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/Userland/Services/NotificationServer/NotificationWindow.cpp b/Userland/Services/NotificationServer/NotificationWindow.cpp index d16af3bde4..96eb65cc07 100644 --- a/Userland/Services/NotificationServer/NotificationWindow.cpp +++ b/Userland/Services/NotificationServer/NotificationWindow.cpp @@ -38,7 +38,6 @@ namespace NotificationServer { static HashMap<u32, RefPtr<NotificationWindow>> s_windows; -static const Gfx::Bitmap* default_image = Gfx::Bitmap::load_from_file("/res/icons/32x32/ladybug.png"); void update_notification_window_locations() { @@ -94,7 +93,10 @@ NotificationWindow::NotificationWindow(i32 client_id, const String& text, const widget.layout()->set_spacing(6); m_image = &widget.add<GUI::ImageWidget>(); - m_image->set_bitmap(icon.is_valid() ? icon.bitmap() : default_image); + m_image->set_visible(icon.is_valid()); + if (icon.is_valid()) { + m_image->set_bitmap(icon.bitmap()); + } auto& left_container = widget.add<GUI::Widget>(); left_container.set_layout<GUI::VerticalBoxLayout>(); @@ -141,7 +143,10 @@ void NotificationWindow::set_title(const String& value) void NotificationWindow::set_image(const Gfx::ShareableBitmap& image) { - m_image->set_bitmap(image.is_valid() ? image.bitmap() : default_image); + m_image->set_visible(image.is_valid()); + if (image.is_valid()) { + m_image->set_bitmap(image.bitmap()); + } } } |