1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 06:57:44 +00:00

LibGfx+Userland: Make Gfx::SystemTheme propagate errors

This patch introduces error propagation to Gfx::SystemTheme to remove
instances of release_value_but_fixme_should_propagate_errors().

Userland applications that have been affected by this change have been
updated to utilise this propagation and as a result 4 such instances of
the aforementioned method have been removed.
This commit is contained in:
Cygnix Proto 2022-12-06 16:26:13 +00:00 committed by Linus Groh
parent bdd9bc16de
commit 806a55eda1
15 changed files with 64 additions and 39 deletions

View file

@ -13,6 +13,7 @@
#include <LibGUI/Application.h>
#include <LibGUI/ConnectionToWindowServer.h>
#include <LibGUI/ItemListModel.h>
#include <LibGUI/MessageBox.h>
#include <LibGUI/Process.h>
namespace DisplaySettings {
@ -21,7 +22,7 @@ ThemesSettingsWidget::ThemesSettingsWidget(bool& background_settings_changed)
: m_background_settings_changed { background_settings_changed }
{
load_from_gml(themes_settings_gml);
m_themes = Gfx::list_installed_system_themes();
m_themes = MUST(Gfx::list_installed_system_themes());
size_t current_theme_index;
auto current_theme_name = GUI::ConnectionToWindowServer::the().get_system_theme();
@ -39,7 +40,10 @@ ThemesSettingsWidget::ThemesSettingsWidget(bool& background_settings_changed)
m_themes_combo->set_model(*GUI::ItemListModel<DeprecatedString>::create(m_theme_names));
m_themes_combo->on_change = [this](auto&, const GUI::ModelIndex& index) {
m_selected_theme = &m_themes.at(index.row());
m_theme_preview->set_theme(m_selected_theme->path);
auto set_theme_result = m_theme_preview->set_theme(m_selected_theme->path);
if (set_theme_result.is_error()) {
GUI::MessageBox::show_error(window(), DeprecatedString::formatted("There was an error generating the theme preview: {}", set_theme_result.error()));
}
set_modified(true);
};
m_themes_combo->set_selected_index(current_theme_index, GUI::AllowCallback::No);
@ -66,7 +70,10 @@ ThemesSettingsWidget::ThemesSettingsWidget(bool& background_settings_changed)
if (current_theme_name == theme_meta.name) {
m_themes_combo->set_selected_index(index, GUI::AllowCallback::No);
m_selected_theme = &m_themes.at(index);
m_theme_preview->set_theme(m_selected_theme->path);
auto set_theme_result = m_theme_preview->set_theme(m_selected_theme->path);
if (set_theme_result.is_error()) {
GUI::MessageBox::show_error(window(), DeprecatedString::formatted("There was an error setting the new theme: {}", set_theme_result.error()));
}
}
++index;
}