DisplaySettings: Update wallpaper config path only on success

The Window Server is ignoring incorrect files since 235f39e449, so let's
not update the config when that happens and an error message instead!
This commit is contained in:
Karol Kosek 2021-11-21 21:23:02 +01:00 committed by Brian Gianforcaro
parent e56ffd11ce
commit 20191b58e2
Notes: sideshowbarker 2024-07-18 00:39:41 +09:00

View file

@ -20,6 +20,7 @@
#include <LibGUI/FileSystemModel.h>
#include <LibGUI/IconView.h>
#include <LibGUI/ItemListModel.h>
#include <LibGUI/MessageBox.h>
#include <LibGUI/WindowServerConnection.h>
#include <LibGfx/Palette.h>
#include <LibGfx/SystemTheme.h>
@ -139,11 +140,12 @@ void BackgroundSettingsWidget::load_current_settings()
void BackgroundSettingsWidget::apply_settings()
{
Config::write_string("WindowManager", "Background", "Wallpaper", m_monitor_widget->wallpaper());
if (GUI::Desktop::the().set_wallpaper(m_monitor_widget->wallpaper()))
Config::write_string("WindowManager", "Background", "Wallpaper", m_monitor_widget->wallpaper());
else
GUI::MessageBox::show_error(window(), String::formatted("Unable to load file {} as wallpaper", m_monitor_widget->wallpaper()));
GUI::Desktop::the().set_wallpaper(m_monitor_widget->wallpaper());
GUI::Desktop::the().set_background_color(m_color_input->text());
GUI::Desktop::the().set_wallpaper_mode(m_monitor_widget->wallpaper_mode());
}