mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-02 15:46:33 +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
Notes:
sideshowbarker
2024-07-18 12:30:40 +09:00
Author: https://github.com/metmo
Commit: d5fa0ea60f
Pull-request: https://github.com/SerenityOS/serenity/pull/7855
Reviewed-by: https://github.com/awesomekling
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 width = config->read_num_entry("Window", "Width", 640);
|
||||
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>();
|
||||
|
||||
|
@ -1141,6 +1141,10 @@ int run_in_windowed_mode(RefPtr<Core::ConfigFile> config, String initial_locatio
|
|||
|
||||
window->show();
|
||||
|
||||
window->set_rect({ left, top, width, height });
|
||||
if (was_maximized)
|
||||
window->set_maximized(true);
|
||||
|
||||
// Read directory read mode from config.
|
||||
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.
|
||||
window->on_close_request = [&] {
|
||||
config->write_num_entry("Window", "Left", window->x());
|
||||
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->write_bool_entry("Window", "Maximized", window->is_maximized());
|
||||
if (!window->is_maximized()) {
|
||||
config->write_num_entry("Window", "Left", window->x());
|
||||
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();
|
||||
|
||||
return GUI::Window::CloseRequestDecision::Close;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue