summaryrefslogtreecommitdiff
path: root/Userland/Applications/HexEditor
diff options
context:
space:
mode:
authorCaoimhe <caoimhebyrne06@gmail.com>2023-05-11 16:07:27 +0100
committerSam Atkins <atkinssj@gmail.com>2023-05-11 20:20:40 +0100
commit99de0b2c14b2ffbd74f3a32e50f89fc3a14025f3 (patch)
treee71076f6a979cddc396c1ade224e6f35b6aa8375 /Userland/Applications/HexEditor
parentde970c2dce6989272ff594a255f765061944212c (diff)
downloadserenity-99de0b2c14b2ffbd74f3a32e50f89fc3a14025f3.zip
HexEditor: Add list of recently opened files
Diffstat (limited to 'Userland/Applications/HexEditor')
-rw-r--r--Userland/Applications/HexEditor/HexEditorWidget.cpp10
-rw-r--r--Userland/Applications/HexEditor/main.cpp1
2 files changed, 11 insertions, 0 deletions
diff --git a/Userland/Applications/HexEditor/HexEditorWidget.cpp b/Userland/Applications/HexEditor/HexEditorWidget.cpp
index 57659f3faa..dde8d28e8c 100644
--- a/Userland/Applications/HexEditor/HexEditorWidget.cpp
+++ b/Userland/Applications/HexEditor/HexEditorWidget.cpp
@@ -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_as_action));
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&) {
if (!request_close())
return;
@@ -566,6 +575,7 @@ void HexEditorWidget::open_file(String const& filename, NonnullOwnPtr<Core::File
window()->set_modified(false);
m_editor->open_file(move(file));
set_path(filename.to_deprecated_string());
+ GUI::Application::the()->set_most_recently_open_file(filename);
}
bool HexEditorWidget::request_close()
diff --git a/Userland/Applications/HexEditor/main.cpp b/Userland/Applications/HexEditor/main.cpp
index 7a55832e16..bfe6cc3df2 100644
--- a/Userland/Applications/HexEditor/main.cpp
+++ b/Userland/Applications/HexEditor/main.cpp
@@ -28,6 +28,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
TRY(Desktop::Launcher::seal_allowlist());
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));