2020-01-18 05:38:21 -03:00
/*
2020-02-26 08:02:25 -03:00
* Copyright ( c ) 2019 - 2020 , Jesse Buhagiar < jooster669 @ gmail . com >
2020-01-18 05:38:21 -03:00
* All rights reserved .
*
* Redistribution and use in source and binary forms , with or without
* modification , are permitted provided that the following conditions are met :
*
* 1. Redistributions of source code must retain the above copyright notice , this
* list of conditions and the following disclaimer .
*
* 2. Redistributions in binary form must reproduce the above copyright notice ,
* this list of conditions and the following disclaimer in the documentation
* and / or other materials provided with the distribution .
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS " AS IS "
* AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT LIMITED TO , THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT , INDIRECT , INCIDENTAL , SPECIAL , EXEMPLARY , OR CONSEQUENTIAL
* DAMAGES ( INCLUDING , BUT NOT LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES ; LOSS OF USE , DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY ,
* OR TORT ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE .
*/
2020-04-29 10:53:51 -03:00
# include "DisplaySettings.h"
2019-09-03 08:45:02 -03:00
# include <AK/StringBuilder.h>
2020-03-29 13:01:55 -03:00
# include <LibCore/ConfigFile.h>
2020-02-06 11:04:03 -03:00
# include <LibCore/DirIterator.h>
2020-02-06 16:33:02 -03:00
# include <LibGUI/Application.h>
# include <LibGUI/BoxLayout.h>
# include <LibGUI/Button.h>
2020-03-29 13:01:55 -03:00
# include <LibGUI/ComboBox.h>
2020-02-06 16:33:02 -03:00
# include <LibGUI/Desktop.h>
2020-03-29 13:01:55 -03:00
# include <LibGUI/FilePicker.h>
2020-09-18 04:49:51 -03:00
# include <LibGUI/ItemListModel.h>
2020-02-06 16:33:02 -03:00
# include <LibGUI/Label.h>
2020-02-27 12:20:56 -03:00
# include <LibGUI/MessageBox.h>
2020-02-06 16:33:02 -03:00
# include <LibGUI/WindowServerConnection.h>
2020-04-10 06:03:01 -03:00
# include <LibGfx/Palette.h>
# include <LibGfx/SystemTheme.h>
2020-03-29 13:01:55 -03:00
2020-04-29 10:53:51 -03:00
DisplaySettingsWidget : : DisplaySettingsWidget ( )
2019-09-03 08:45:02 -03:00
{
create_resolution_list ( ) ;
create_wallpaper_list ( ) ;
2020-03-29 13:01:55 -03:00
2019-12-17 18:16:00 -03:00
create_frame ( ) ;
2020-03-29 13:01:55 -03:00
load_current_settings ( ) ;
2019-09-03 08:45:02 -03:00
}
2020-04-29 10:53:51 -03:00
void DisplaySettingsWidget : : create_resolution_list ( )
2019-09-03 08:45:02 -03:00
{
// TODO: Find a better way to get the default resolution
m_resolutions . append ( { 640 , 480 } ) ;
m_resolutions . append ( { 800 , 600 } ) ;
m_resolutions . append ( { 1024 , 768 } ) ;
2019-11-29 17:07:24 -03:00
m_resolutions . append ( { 1280 , 720 } ) ;
2020-03-29 13:01:55 -03:00
m_resolutions . append ( { 1280 , 768 } ) ;
2019-09-03 08:45:02 -03:00
m_resolutions . append ( { 1280 , 1024 } ) ;
2020-03-29 13:01:55 -03:00
m_resolutions . append ( { 1360 , 768 } ) ;
m_resolutions . append ( { 1368 , 768 } ) ;
2019-09-03 08:45:02 -03:00
m_resolutions . append ( { 1440 , 900 } ) ;
m_resolutions . append ( { 1600 , 900 } ) ;
m_resolutions . append ( { 1920 , 1080 } ) ;
m_resolutions . append ( { 2560 , 1080 } ) ;
2020-03-29 13:01:55 -03:00
}
2019-09-03 08:45:02 -03:00
2020-04-29 10:53:51 -03:00
void DisplaySettingsWidget : : create_wallpaper_list ( )
2020-03-29 13:01:55 -03:00
{
Core : : DirIterator iterator ( " /res/wallpapers/ " , Core : : DirIterator : : Flags : : SkipDots ) ;
2019-09-16 02:50:47 -03:00
2020-04-28 10:20:07 -03:00
m_wallpapers . append ( " Use background color " ) ;
2020-03-29 13:01:55 -03:00
while ( iterator . has_next ( ) ) {
m_wallpapers . append ( iterator . next_path ( ) ) ;
2019-09-16 02:50:47 -03:00
}
2020-03-29 13:01:55 -03:00
m_modes . append ( " simple " ) ;
m_modes . append ( " tile " ) ;
m_modes . append ( " center " ) ;
m_modes . append ( " scaled " ) ;
2019-09-03 08:45:02 -03:00
}
2020-04-29 10:53:51 -03:00
void DisplaySettingsWidget : : create_frame ( )
2019-09-03 08:45:02 -03:00
{
2020-02-02 11:07:41 -03:00
m_root_widget = GUI : : Widget : : construct ( ) ;
2020-03-04 05:43:54 -03:00
m_root_widget - > set_layout < GUI : : VerticalBoxLayout > ( ) ;
2019-09-03 08:45:02 -03:00
m_root_widget - > set_fill_with_background_color ( true ) ;
2020-03-29 13:01:55 -03:00
m_root_widget - > layout ( ) - > set_margins ( { 4 , 4 , 4 , 4 } ) ;
2019-09-03 08:45:02 -03:00
2020-03-29 13:01:55 -03:00
auto & settings_content = m_root_widget - > add < GUI : : Widget > ( ) ;
settings_content . set_layout < GUI : : VerticalBoxLayout > ( ) ;
settings_content . set_backcolor ( " red " ) ;
settings_content . set_background_color ( Color : : Blue ) ;
2020-04-10 06:03:01 -03:00
settings_content . set_background_role ( Gfx : : ColorRole : : Window ) ;
2020-03-29 13:01:55 -03:00
settings_content . layout ( ) - > set_margins ( { 4 , 4 , 4 , 4 } ) ;
2020-02-02 08:47:47 -03:00
2020-03-29 13:01:55 -03:00
/// Wallpaper Preview /////////////////////////////////////////////////////////////////////////
2019-09-03 08:45:02 -03:00
2020-03-29 13:01:55 -03:00
m_monitor_widget = settings_content . add < MonitorWidget > ( ) ;
m_monitor_widget - > set_size_policy ( GUI : : SizePolicy : : Fixed , GUI : : SizePolicy : : Fixed ) ;
m_monitor_widget - > set_preferred_size ( 338 , 248 ) ;
2019-09-03 08:45:02 -03:00
2020-03-29 13:01:55 -03:00
/// Wallpaper Row /////////////////////////////////////////////////////////////////////////////
2019-09-03 08:45:02 -03:00
2020-04-10 06:03:01 -03:00
auto & wallpaper_selection_container = settings_content . add < GUI : : Widget > ( ) ;
wallpaper_selection_container . set_layout < GUI : : HorizontalBoxLayout > ( ) ;
wallpaper_selection_container . layout ( ) - > set_margins ( { 0 , 4 , 0 , 0 } ) ;
wallpaper_selection_container . set_size_policy ( GUI : : SizePolicy : : Fill , GUI : : SizePolicy : : Fixed ) ;
wallpaper_selection_container . set_preferred_size ( 0 , 22 ) ;
2019-09-03 08:45:02 -03:00
2020-04-10 06:03:01 -03:00
auto & wallpaper_label = wallpaper_selection_container . add < GUI : : Label > ( ) ;
wallpaper_label . set_text_alignment ( Gfx : : TextAlignment : : CenterLeft ) ;
wallpaper_label . set_size_policy ( GUI : : SizePolicy : : Fixed , GUI : : SizePolicy : : Fill ) ;
wallpaper_label . set_preferred_size ( { 70 , 0 } ) ;
wallpaper_label . set_text ( " Wallpaper: " ) ;
2019-09-03 08:45:02 -03:00
2020-04-10 06:03:01 -03:00
m_wallpaper_combo = wallpaper_selection_container . add < GUI : : ComboBox > ( ) ;
2020-03-29 13:01:55 -03:00
m_wallpaper_combo - > set_size_policy ( GUI : : SizePolicy : : Fill , GUI : : SizePolicy : : Fixed ) ;
m_wallpaper_combo - > set_preferred_size ( 0 , 22 ) ;
m_wallpaper_combo - > set_only_allow_values_from_model ( true ) ;
2020-08-29 00:56:44 -03:00
m_wallpaper_combo - > set_model ( * GUI : : ItemListModel < AK : : String > : : create ( m_wallpapers ) ) ;
2020-03-29 13:01:55 -03:00
m_wallpaper_combo - > on_change = [ this ] ( auto & text , const GUI : : ModelIndex & index ) {
String path = text ;
2020-09-02 23:53:49 -03:00
if ( path . starts_with ( " / " ) & & m_monitor_widget - > set_wallpaper ( path ) ) {
2020-06-27 06:04:43 -03:00
m_monitor_widget - > update ( ) ;
return ;
}
2020-04-28 10:20:07 -03:00
if ( index . row ( ) = = 0 ) {
path = " " ;
} else {
if ( index . is_valid ( ) ) {
StringBuilder builder ;
builder . append ( " /res/wallpapers/ " ) ;
builder . append ( path ) ;
path = builder . to_string ( ) ;
}
2020-03-29 13:01:55 -03:00
}
2020-02-02 08:47:47 -03:00
2020-06-27 06:04:43 -03:00
m_monitor_widget - > set_wallpaper ( path ) ;
m_monitor_widget - > update ( ) ;
2019-09-03 08:45:02 -03:00
} ;
2020-04-10 06:03:01 -03:00
auto & button = wallpaper_selection_container . add < GUI : : Button > ( ) ;
2020-03-29 13:01:55 -03:00
button . set_tooltip ( " Select Wallpaper from file system. " ) ;
button . set_icon ( Gfx : : Bitmap : : load_from_file ( " /res/icons/16x16/open.png " ) ) ;
button . set_button_style ( Gfx : : ButtonStyle : : CoolBar ) ;
button . set_size_policy ( GUI : : SizePolicy : : Fixed , GUI : : SizePolicy : : Fixed ) ;
button . set_preferred_size ( 22 , 22 ) ;
2020-05-12 15:30:33 -03:00
button . on_click = [ this ] ( auto ) {
2020-07-15 22:52:02 -03:00
Optional < String > open_path = GUI : : FilePicker : : get_open_filepath ( root_widget ( ) - > window ( ) , " Select wallpaper from file system. " ) ;
2019-09-03 08:45:02 -03:00
2020-03-29 13:01:55 -03:00
if ( ! open_path . has_value ( ) )
return ;
2019-09-03 08:45:02 -03:00
2020-03-29 13:01:55 -03:00
m_wallpaper_combo - > set_only_allow_values_from_model ( false ) ;
this - > m_wallpaper_combo - > set_text ( open_path . value ( ) ) ;
m_wallpaper_combo - > set_only_allow_values_from_model ( true ) ;
} ;
/// Mode //////////////////////////////////////////////////////////////////////////////////////
2020-04-10 06:03:01 -03:00
auto & mode_selection_container = settings_content . add < GUI : : Widget > ( ) ;
mode_selection_container . set_layout < GUI : : HorizontalBoxLayout > ( ) ;
mode_selection_container . layout ( ) - > set_margins ( { 0 , 4 , 0 , 0 } ) ;
mode_selection_container . set_size_policy ( GUI : : SizePolicy : : Fill , GUI : : SizePolicy : : Fixed ) ;
mode_selection_container . set_preferred_size ( 0 , 22 ) ;
2019-12-17 18:16:00 -03:00
2020-04-10 06:03:01 -03:00
auto & mode_label = mode_selection_container . add < GUI : : Label > ( ) ;
mode_label . set_text_alignment ( Gfx : : TextAlignment : : CenterLeft ) ;
mode_label . set_size_policy ( GUI : : SizePolicy : : Fixed , GUI : : SizePolicy : : Fill ) ;
mode_label . set_preferred_size ( { 70 , 0 } ) ;
mode_label . set_text ( " Mode: " ) ;
2020-03-29 13:01:55 -03:00
2020-04-10 06:03:01 -03:00
m_mode_combo = mode_selection_container . add < GUI : : ComboBox > ( ) ;
2020-03-29 13:01:55 -03:00
m_mode_combo - > set_size_policy ( GUI : : SizePolicy : : Fill , GUI : : SizePolicy : : Fixed ) ;
m_mode_combo - > set_preferred_size ( 0 , 22 ) ;
m_mode_combo - > set_only_allow_values_from_model ( true ) ;
2020-08-29 00:56:44 -03:00
m_mode_combo - > set_model ( * GUI : : ItemListModel < AK : : String > : : create ( m_modes ) ) ;
2020-03-29 13:01:55 -03:00
m_mode_combo - > on_change = [ this ] ( auto & , const GUI : : ModelIndex & index ) {
this - > m_monitor_widget - > set_wallpaper_mode ( m_modes . at ( index . row ( ) ) ) ;
this - > m_monitor_widget - > update ( ) ;
2019-09-03 08:45:02 -03:00
} ;
2020-07-11 14:36:01 -03:00
/// Resolution Row ////////////////////////////////////////////////////////////////////////////
2020-03-29 13:01:55 -03:00
2020-04-10 06:03:01 -03:00
auto & resolution_selection_container = settings_content . add < GUI : : Widget > ( ) ;
resolution_selection_container . set_layout < GUI : : HorizontalBoxLayout > ( ) ;
resolution_selection_container . set_size_policy ( GUI : : SizePolicy : : Fill , GUI : : SizePolicy : : Fixed ) ;
resolution_selection_container . set_preferred_size ( 0 , 22 ) ;
2020-03-29 13:01:55 -03:00
2020-04-10 06:03:01 -03:00
auto & m_resolution_label = resolution_selection_container . add < GUI : : Label > ( ) ;
2020-03-29 13:01:55 -03:00
m_resolution_label . set_text_alignment ( Gfx : : TextAlignment : : CenterLeft ) ;
m_resolution_label . set_size_policy ( GUI : : SizePolicy : : Fixed , GUI : : SizePolicy : : Fill ) ;
m_resolution_label . set_preferred_size ( { 70 , 0 } ) ;
m_resolution_label . set_text ( " Resolution: " ) ;
2019-09-16 02:50:47 -03:00
2020-04-10 06:03:01 -03:00
m_resolution_combo = resolution_selection_container . add < GUI : : ComboBox > ( ) ;
2020-03-29 13:01:55 -03:00
m_resolution_combo - > set_size_policy ( GUI : : SizePolicy : : Fill , GUI : : SizePolicy : : Fixed ) ;
m_resolution_combo - > set_preferred_size ( 0 , 22 ) ;
m_resolution_combo - > set_only_allow_values_from_model ( true ) ;
2020-08-29 00:56:44 -03:00
m_resolution_combo - > set_model ( * GUI : : ItemListModel < Gfx : : IntSize > : : create ( m_resolutions ) ) ;
2020-03-29 13:01:55 -03:00
m_resolution_combo - > on_change = [ this ] ( auto & , const GUI : : ModelIndex & index ) {
this - > m_monitor_widget - > set_desktop_resolution ( m_resolutions . at ( index . row ( ) ) ) ;
this - > m_monitor_widget - > update ( ) ;
} ;
/// Background Color Row //////////////////////////////////////////////////////////////////////
2020-04-10 06:03:01 -03:00
auto & color_selection_container = settings_content . add < GUI : : Widget > ( ) ;
color_selection_container . set_layout < GUI : : HorizontalBoxLayout > ( ) ;
color_selection_container . set_size_policy ( GUI : : SizePolicy : : Fill , GUI : : SizePolicy : : Fixed ) ;
color_selection_container . set_preferred_size ( 0 , 22 ) ;
auto & color_label = color_selection_container . add < GUI : : Label > ( ) ;
color_label . set_text_alignment ( Gfx : : TextAlignment : : CenterLeft ) ;
color_label . set_size_policy ( GUI : : SizePolicy : : Fixed , GUI : : SizePolicy : : Fill ) ;
color_label . set_preferred_size ( { 70 , 0 } ) ;
2020-04-30 08:22:56 -03:00
color_label . set_text ( " Color: " ) ;
2020-04-10 06:03:01 -03:00
m_color_input = color_selection_container . add < GUI : : ColorInput > ( ) ;
2020-04-29 11:22:29 -03:00
m_color_input - > set_color_has_alpha_channel ( false ) ;
2020-04-10 06:03:01 -03:00
m_color_input - > set_size_policy ( GUI : : SizePolicy : : Fixed , GUI : : SizePolicy : : Fill ) ;
m_color_input - > set_preferred_size ( 90 , 0 ) ;
m_color_input - > set_color_picker_title ( " Select color for desktop " ) ;
m_color_input - > on_change = [ this ] {
this - > m_monitor_widget - > set_background_color ( m_color_input - > color ( ) ) ;
2020-03-29 13:01:55 -03:00
this - > m_monitor_widget - > update ( ) ;
} ;
/// Add the apply and cancel buttons //////////////////////////////////////////////////////////
auto & bottom_widget = settings_content . add < GUI : : Widget > ( ) ;
2020-03-04 15:07:55 -03:00
bottom_widget . set_layout < GUI : : HorizontalBoxLayout > ( ) ;
bottom_widget . layout ( ) - > add_spacer ( ) ;
2020-03-29 13:01:55 -03:00
//bottom_widget.layout()->set_margins({ 4, 10, 4, 10 });
2020-03-04 15:07:55 -03:00
bottom_widget . set_size_policy ( Orientation : : Vertical , GUI : : SizePolicy : : Fixed ) ;
bottom_widget . set_preferred_size ( 1 , 22 ) ;
auto & ok_button = bottom_widget . add < GUI : : Button > ( ) ;
ok_button . set_text ( " OK " ) ;
ok_button . set_size_policy ( Orientation : : Horizontal , GUI : : SizePolicy : : Fixed ) ;
ok_button . set_preferred_size ( 60 , 22 ) ;
2020-05-12 15:30:33 -03:00
ok_button . on_click = [ this ] ( auto ) {
2020-03-29 13:01:55 -03:00
send_settings_to_window_server ( ) ;
2020-07-04 11:52:01 -03:00
GUI : : Application : : the ( ) - > quit ( ) ;
2019-09-03 08:45:02 -03:00
} ;
2020-03-04 15:07:55 -03:00
auto & cancel_button = bottom_widget . add < GUI : : Button > ( ) ;
cancel_button . set_text ( " Cancel " ) ;
cancel_button . set_size_policy ( Orientation : : Horizontal , GUI : : SizePolicy : : Fixed ) ;
cancel_button . set_preferred_size ( 60 , 22 ) ;
2020-05-12 15:30:33 -03:00
cancel_button . on_click = [ ] ( auto ) {
2020-07-04 11:52:01 -03:00
GUI : : Application : : the ( ) - > quit ( ) ;
2019-09-03 08:45:02 -03:00
} ;
2020-04-29 11:24:21 -03:00
auto & apply_button = bottom_widget . add < GUI : : Button > ( ) ;
apply_button . set_text ( " Apply " ) ;
apply_button . set_size_policy ( Orientation : : Horizontal , GUI : : SizePolicy : : Fixed ) ;
apply_button . set_preferred_size ( 60 , 22 ) ;
2020-05-12 15:30:33 -03:00
apply_button . on_click = [ this ] ( auto ) {
2020-04-29 11:24:21 -03:00
send_settings_to_window_server ( ) ;
} ;
2019-09-03 08:45:02 -03:00
}
2020-04-29 10:53:51 -03:00
void DisplaySettingsWidget : : load_current_settings ( )
2019-09-03 08:45:02 -03:00
{
2020-04-10 06:03:01 -03:00
auto ws_config ( Core : : ConfigFile : : open ( " /etc/WindowServer/WindowServer.ini " ) ) ;
2020-03-29 13:01:55 -03:00
auto wm_config = Core : : ConfigFile : : get_for_app ( " WindowManager " ) ;
/// Wallpaper path ////////////////////////////////////////////////////////////////////////////
/// Read wallpaper path from config file and set value to monitor widget and combo box.
2020-04-10 06:03:01 -03:00
auto selected_wallpaper = wm_config - > read_entry ( " Background " , " Wallpaper " , " " ) ;
if ( ! selected_wallpaper . is_empty ( ) ) {
m_monitor_widget - > set_wallpaper ( selected_wallpaper ) ;
2020-03-29 13:01:55 -03:00
Optional < size_t > optional_index ;
2020-04-10 06:03:01 -03:00
if ( selected_wallpaper . starts_with ( " /res/wallpapers/ " ) ) {
2020-04-30 22:52:54 -03:00
auto name_parts = selected_wallpaper . split ( ' / ' , true ) ;
2020-03-29 13:01:55 -03:00
optional_index = m_wallpapers . find_first_index ( name_parts [ 2 ] ) ;
if ( optional_index . has_value ( ) ) {
m_wallpaper_combo - > set_selected_index ( optional_index . value ( ) ) ;
}
}
if ( ! optional_index . has_value ( ) ) {
m_wallpaper_combo - > set_only_allow_values_from_model ( false ) ;
2020-04-10 06:03:01 -03:00
m_wallpaper_combo - > set_text ( selected_wallpaper ) ;
2020-03-29 13:01:55 -03:00
m_wallpaper_combo - > set_only_allow_values_from_model ( true ) ;
}
2020-04-28 10:20:07 -03:00
} else {
m_wallpaper_combo - > set_selected_index ( 0 ) ;
2020-03-29 13:01:55 -03:00
}
/// Mode //////////////////////////////////////////////////////////////////////////////////////
2020-04-10 06:03:01 -03:00
auto mode = ws_config - > read_entry ( " Background " , " Mode " ) ;
2020-03-29 13:01:55 -03:00
if ( ! mode . is_empty ( ) ) {
this - > m_monitor_widget - > set_wallpaper_mode ( mode ) ;
auto index = m_modes . find_first_index ( mode ) . value ( ) ;
m_mode_combo - > set_selected_index ( index ) ;
}
/// Resolution ////////////////////////////////////////////////////////////////////////////////
2020-06-10 05:57:59 -03:00
Gfx : : IntSize find_size ;
2020-03-29 13:01:55 -03:00
// Let's attempt to find the current resolution and select it!
2020-06-12 16:07:52 -03:00
find_size . set_width ( ws_config - > read_num_entry ( " Screen " , " Width " , 1024 ) ) ;
find_size . set_height ( ws_config - > read_num_entry ( " Screen " , " Height " , 768 ) ) ;
2020-03-29 13:01:55 -03:00
size_t index = m_resolutions . find_first_index ( find_size ) . value_or ( 0 ) ;
2020-06-10 05:57:59 -03:00
Gfx : : IntSize m_current_resolution = m_resolutions . at ( index ) ;
2020-03-29 13:01:55 -03:00
m_monitor_widget - > set_desktop_resolution ( m_current_resolution ) ;
m_resolution_combo - > set_selected_index ( index ) ;
/// Color /////////////////////////////////////////////////////////////////////////////////////
/// If presend read from config file. If not paint with palet color.
2020-04-10 06:03:01 -03:00
Color palette_desktop_color = this - > palette ( ) . desktop_background ( ) ;
auto background_color = ws_config - > read_entry ( " Background " , " Color " , " " ) ;
2020-03-29 13:01:55 -03:00
if ( ! background_color . is_empty ( ) ) {
2020-04-10 06:03:01 -03:00
auto opt_color = Color : : from_string ( background_color ) ;
if ( opt_color . has_value ( ) )
palette_desktop_color = opt_color . value ( ) ;
2020-03-29 13:01:55 -03:00
}
2020-04-10 06:03:01 -03:00
m_color_input - > set_color ( palette_desktop_color ) ;
m_monitor_widget - > set_background_color ( palette_desktop_color ) ;
2020-03-29 13:01:55 -03:00
m_monitor_widget - > update ( ) ;
}
2020-04-29 10:53:51 -03:00
void DisplaySettingsWidget : : send_settings_to_window_server ( )
2020-03-29 13:01:55 -03:00
{
auto result = GUI : : WindowServerConnection : : the ( ) . send_sync < Messages : : WindowServer : : SetResolution > ( m_monitor_widget - > desktop_resolution ( ) ) ;
if ( ! result - > success ( ) ) {
2020-10-04 16:14:40 -03:00
GUI : : MessageBox : : show ( root_widget ( ) - > window ( ) , String : : formatted ( " Reverting to resolution {}x{} " , result - > resolution ( ) . width ( ) , result - > resolution ( ) . height ( ) ) ,
2020-07-15 23:45:11 -03:00
" Unable to set resolution " , GUI : : MessageBox : : Type : : Error ) ;
2020-03-29 13:01:55 -03:00
}
if ( ! m_monitor_widget - > wallpaper ( ) . is_empty ( ) ) {
GUI : : Desktop : : the ( ) . set_wallpaper ( m_monitor_widget - > wallpaper ( ) ) ;
2020-04-28 10:20:07 -03:00
} else {
2020-10-04 16:14:40 -03:00
dbgln ( " Setting color input: __{}__ " , m_color_input - > text ( ) ) ;
2020-04-28 10:20:07 -03:00
GUI : : Desktop : : the ( ) . set_wallpaper ( " " ) ;
GUI : : Desktop : : the ( ) . set_background_color ( m_color_input - > text ( ) ) ;
2020-03-29 13:01:55 -03:00
}
GUI : : Desktop : : the ( ) . set_wallpaper_mode ( m_monitor_widget - > wallpaper_mode ( ) ) ;
2019-09-03 08:45:02 -03:00
}