mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:07:34 +00:00
DisplayProperties: Allow going from a wallpaper to a background colour
Before this patch DisplayProperties couldn't handle correctly going from a set wallpaper to a background color. This patch adds a new "Use background color" as a first option for the Wallpaper combobox as well as correct handling of setting an invalid bitmap, thus making the WindowManager draw the background color
This commit is contained in:
parent
19c744ab82
commit
bcd5e97286
1 changed files with 17 additions and 9 deletions
|
@ -72,6 +72,8 @@ void DisplayPropertiesWidget::create_wallpaper_list()
|
||||||
{
|
{
|
||||||
Core::DirIterator iterator("/res/wallpapers/", Core::DirIterator::Flags::SkipDots);
|
Core::DirIterator iterator("/res/wallpapers/", Core::DirIterator::Flags::SkipDots);
|
||||||
|
|
||||||
|
m_wallpapers.append("Use background color");
|
||||||
|
|
||||||
while (iterator.has_next()) {
|
while (iterator.has_next()) {
|
||||||
m_wallpapers.append(iterator.next_path());
|
m_wallpapers.append(iterator.next_path());
|
||||||
}
|
}
|
||||||
|
@ -123,11 +125,15 @@ void DisplayPropertiesWidget::create_frame()
|
||||||
m_wallpaper_combo->set_model(*ItemListModel<AK::String>::create(m_wallpapers));
|
m_wallpaper_combo->set_model(*ItemListModel<AK::String>::create(m_wallpapers));
|
||||||
m_wallpaper_combo->on_change = [this](auto& text, const GUI::ModelIndex& index) {
|
m_wallpaper_combo->on_change = [this](auto& text, const GUI::ModelIndex& index) {
|
||||||
String path = text;
|
String path = text;
|
||||||
if (index.is_valid()) {
|
if (index.row() == 0) {
|
||||||
StringBuilder builder;
|
path = "";
|
||||||
builder.append("/res/wallpapers/");
|
} else {
|
||||||
builder.append(path);
|
if (index.is_valid()) {
|
||||||
path = builder.to_string();
|
StringBuilder builder;
|
||||||
|
builder.append("/res/wallpapers/");
|
||||||
|
builder.append(path);
|
||||||
|
path = builder.to_string();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this->m_monitor_widget->set_wallpaper(path);
|
this->m_monitor_widget->set_wallpaper(path);
|
||||||
|
@ -281,6 +287,8 @@ void DisplayPropertiesWidget::load_current_settings()
|
||||||
m_wallpaper_combo->set_text(selected_wallpaper);
|
m_wallpaper_combo->set_text(selected_wallpaper);
|
||||||
m_wallpaper_combo->set_only_allow_values_from_model(true);
|
m_wallpaper_combo->set_only_allow_values_from_model(true);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
m_wallpaper_combo->set_selected_index(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Mode //////////////////////////////////////////////////////////////////////////////////////
|
/// Mode //////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -340,11 +348,11 @@ void DisplayPropertiesWidget::send_settings_to_window_server()
|
||||||
|
|
||||||
if (!m_monitor_widget->wallpaper().is_empty()) {
|
if (!m_monitor_widget->wallpaper().is_empty()) {
|
||||||
GUI::Desktop::the().set_wallpaper(m_monitor_widget->wallpaper());
|
GUI::Desktop::the().set_wallpaper(m_monitor_widget->wallpaper());
|
||||||
|
} else {
|
||||||
|
dbg() << "Setting color input: __" << m_color_input->text() << "__";
|
||||||
|
GUI::Desktop::the().set_wallpaper("");
|
||||||
|
GUI::Desktop::the().set_background_color(m_color_input->text());
|
||||||
}
|
}
|
||||||
|
|
||||||
GUI::Desktop::the().set_wallpaper_mode(m_monitor_widget->wallpaper_mode());
|
GUI::Desktop::the().set_wallpaper_mode(m_monitor_widget->wallpaper_mode());
|
||||||
|
|
||||||
if (m_color_input->color() != this->palette().desktop_background()) {
|
|
||||||
GUI::Desktop::the().set_background_color(m_color_input->text());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue