mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:07:35 +00:00
FileManager: Save maximized window state on exit
When exiting FileManager in maximized state, save it and start in maximized state on next launch.
This commit is contained in:
parent
2f7dc29ab7
commit
d5fa0ea60f
1 changed files with 12 additions and 5 deletions
|
@ -430,7 +430,7 @@ int run_in_windowed_mode(RefPtr<Core::ConfigFile> config, String initial_locatio
|
||||||
auto top = config->read_num_entry("Window", "Top", 75);
|
auto top = config->read_num_entry("Window", "Top", 75);
|
||||||
auto width = config->read_num_entry("Window", "Width", 640);
|
auto width = config->read_num_entry("Window", "Width", 640);
|
||||||
auto height = config->read_num_entry("Window", "Height", 480);
|
auto height = config->read_num_entry("Window", "Height", 480);
|
||||||
window->set_rect({ left, top, width, height });
|
auto was_maximized = config->read_bool_entry("Window", "Maximized", false);
|
||||||
|
|
||||||
auto& widget = window->set_main_widget<GUI::Widget>();
|
auto& widget = window->set_main_widget<GUI::Widget>();
|
||||||
|
|
||||||
|
@ -1141,6 +1141,10 @@ int run_in_windowed_mode(RefPtr<Core::ConfigFile> config, String initial_locatio
|
||||||
|
|
||||||
window->show();
|
window->show();
|
||||||
|
|
||||||
|
window->set_rect({ left, top, width, height });
|
||||||
|
if (was_maximized)
|
||||||
|
window->set_maximized(true);
|
||||||
|
|
||||||
// Read directory read mode from config.
|
// Read directory read mode from config.
|
||||||
auto dir_view_mode = config->read_entry("DirectoryView", "ViewMode", "Icon");
|
auto dir_view_mode = config->read_entry("DirectoryView", "ViewMode", "Icon");
|
||||||
|
|
||||||
|
@ -1163,10 +1167,13 @@ int run_in_windowed_mode(RefPtr<Core::ConfigFile> config, String initial_locatio
|
||||||
|
|
||||||
// Write window position to config file on close request.
|
// Write window position to config file on close request.
|
||||||
window->on_close_request = [&] {
|
window->on_close_request = [&] {
|
||||||
config->write_num_entry("Window", "Left", window->x());
|
config->write_bool_entry("Window", "Maximized", window->is_maximized());
|
||||||
config->write_num_entry("Window", "Top", window->y());
|
if (!window->is_maximized()) {
|
||||||
config->write_num_entry("Window", "Width", window->width());
|
config->write_num_entry("Window", "Left", window->x());
|
||||||
config->write_num_entry("Window", "Height", window->height());
|
config->write_num_entry("Window", "Top", window->y());
|
||||||
|
config->write_num_entry("Window", "Width", window->width());
|
||||||
|
config->write_num_entry("Window", "Height", window->height());
|
||||||
|
}
|
||||||
config->sync();
|
config->sync();
|
||||||
|
|
||||||
return GUI::Window::CloseRequestDecision::Close;
|
return GUI::Window::CloseRequestDecision::Close;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue