mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 09:57:34 +00:00
HexEditor: Add list of recently opened files
This commit is contained in:
parent
de970c2dce
commit
99de0b2c14
2 changed files with 11 additions and 0 deletions
|
@ -411,6 +411,15 @@ ErrorOr<void> HexEditorWidget::initialize_menubar(GUI::Window& window)
|
||||||
TRY(file_menu->try_add_action(*m_save_action));
|
TRY(file_menu->try_add_action(*m_save_action));
|
||||||
TRY(file_menu->try_add_action(*m_save_as_action));
|
TRY(file_menu->try_add_action(*m_save_as_action));
|
||||||
TRY(file_menu->try_add_separator());
|
TRY(file_menu->try_add_separator());
|
||||||
|
TRY(file_menu->add_recent_files_list([&](auto& action) {
|
||||||
|
auto path = action.text();
|
||||||
|
auto response = FileSystemAccessClient::Client::the().request_file_read_only_approved(&window, path);
|
||||||
|
if (response.is_error())
|
||||||
|
return;
|
||||||
|
|
||||||
|
auto file = response.release_value();
|
||||||
|
open_file(file.filename(), file.release_stream());
|
||||||
|
}));
|
||||||
TRY(file_menu->try_add_action(GUI::CommonActions::make_quit_action([this](auto&) {
|
TRY(file_menu->try_add_action(GUI::CommonActions::make_quit_action([this](auto&) {
|
||||||
if (!request_close())
|
if (!request_close())
|
||||||
return;
|
return;
|
||||||
|
@ -566,6 +575,7 @@ void HexEditorWidget::open_file(String const& filename, NonnullOwnPtr<Core::File
|
||||||
window()->set_modified(false);
|
window()->set_modified(false);
|
||||||
m_editor->open_file(move(file));
|
m_editor->open_file(move(file));
|
||||||
set_path(filename.to_deprecated_string());
|
set_path(filename.to_deprecated_string());
|
||||||
|
GUI::Application::the()->set_most_recently_open_file(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HexEditorWidget::request_close()
|
bool HexEditorWidget::request_close()
|
||||||
|
|
|
@ -28,6 +28,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
TRY(Desktop::Launcher::seal_allowlist());
|
TRY(Desktop::Launcher::seal_allowlist());
|
||||||
|
|
||||||
Config::pledge_domain("HexEditor");
|
Config::pledge_domain("HexEditor");
|
||||||
|
app->set_config_domain(TRY("HexEditor"_string));
|
||||||
|
|
||||||
auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-hex-editor"sv));
|
auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-hex-editor"sv));
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue