1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 18:37:35 +00:00

HexEditor: Add an option to load an annotations file on startup

This commit is contained in:
Sam Atkins 2024-01-30 12:53:36 +00:00 committed by Sam Atkins
parent 4cef57a021
commit d930ea1242
4 changed files with 29 additions and 2 deletions

View file

@ -676,6 +676,20 @@ void HexEditorWidget::open_file(ByteString const& filename, NonnullOwnPtr<Core::
GUI::Application::the()->set_most_recently_open_file(filename);
}
void HexEditorWidget::open_annotations_file(StringView filename)
{
auto response = FileSystemAccessClient::Client::the().request_file_read_only_approved(window(), filename);
if (response.is_error())
return;
auto result = m_editor->document().annotations().load_from_file(response.value().stream());
if (result.is_error()) {
GUI::MessageBox::show(window(), ByteString::formatted("Unable to load annotations: {}\n"sv, result.error()), "Error"sv, GUI::MessageBox::Type::Error);
return;
}
m_annotations_path = filename;
}
bool HexEditorWidget::request_close()
{
if (!window()->is_modified())