From c1d26c884d6f35c7b43140bca6f4153cb190eaf3 Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Wed, 27 Oct 2021 19:27:43 +0100 Subject: [PATCH] ThemeEditor: Display the theme's window icons in the preview If the icons could not be loaded, we fall back to the defaults (which are the bitmaps that were always used before.) --- .../ThemeEditor/PreviewWidget.cpp | 25 ++++++++++++++----- .../Applications/ThemeEditor/PreviewWidget.h | 7 ++++++ 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/Userland/Applications/ThemeEditor/PreviewWidget.cpp b/Userland/Applications/ThemeEditor/PreviewWidget.cpp index 8f59466d9c..bd501c5126 100644 --- a/Userland/Applications/ThemeEditor/PreviewWidget.cpp +++ b/Userland/Applications/ThemeEditor/PreviewWidget.cpp @@ -6,6 +6,7 @@ */ #include "PreviewWidget.h" +#include #include #include #include @@ -81,9 +82,15 @@ PreviewWidget::PreviewWidget(const Gfx::Palette& preview_palette) m_active_window_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/window.png"); m_inactive_window_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/window.png"); - m_close_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/window-close.png"); - m_maximize_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/upward-triangle.png"); - m_minimize_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/downward-triangle.png"); + m_default_close_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/window-close.png"); + m_default_maximize_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/upward-triangle.png"); + m_default_minimize_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/downward-triangle.png"); + + VERIFY(m_active_window_icon); + VERIFY(m_inactive_window_icon); + VERIFY(m_default_close_bitmap); + VERIFY(m_default_maximize_bitmap); + VERIFY(m_default_minimize_bitmap); load_theme_bitmaps(); @@ -110,6 +117,12 @@ void PreviewWidget::load_theme_bitmaps() } }; + auto buttons_path = m_preview_palette.title_button_icons_path(); + + load_bitmap(LexicalPath::absolute_path(buttons_path, "window-close.png"), m_last_close_path, m_close_bitmap); + load_bitmap(LexicalPath::absolute_path(buttons_path, "window-maximize.png"), m_last_maximize_path, m_maximize_bitmap); + load_bitmap(LexicalPath::absolute_path(buttons_path, "window-minimize.png"), m_last_minimize_path, m_minimize_bitmap); + load_bitmap(m_preview_palette.active_window_shadow_path(), m_last_active_window_shadow_path, m_active_window_shadow); load_bitmap(m_preview_palette.inactive_window_shadow_path(), m_last_inactive_window_shadow_path, m_inactive_window_shadow); load_bitmap(m_preview_palette.menu_shadow_path(), m_last_menu_shadow_path, m_menu_shadow); @@ -159,9 +172,9 @@ void PreviewWidget::paint_event(GUI::PaintEvent& event) int pos = titlebar_text_rect.right() + 1; Vector