1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 05:37:34 +00:00

HexEditor: Include annotation text in the "Delete annotation?" dialog

It's helpful to have some description of what you're deleting. :^)

40 characters is chosen completely arbitrarily, but seems reasonable.
This commit is contained in:
Sam Atkins 2024-02-06 17:09:17 +00:00 committed by Sam Atkins
parent 56eb45ccbc
commit c6e5581682

View file

@ -952,7 +952,18 @@ void HexEditor::show_edit_annotation_dialog(Annotation& annotation)
void HexEditor::show_delete_annotation_dialog(Annotation& annotation) void HexEditor::show_delete_annotation_dialog(Annotation& annotation)
{ {
auto result = GUI::MessageBox::show(window(), "Delete this annotation?"sv, "Delete annotation?"sv, GUI::MessageBox::Type::Question, GUI::MessageBox::InputType::YesNo); StringBuilder builder;
builder.append("Delete '"sv);
Utf8View comments_first_line { annotation.comments.bytes_as_string_view().find_first_split_view('\n') };
auto const max_annotation_text_length = 40;
if (comments_first_line.length() <= max_annotation_text_length) {
builder.append(comments_first_line.as_string());
} else {
builder.appendff("{}...", comments_first_line.unicode_substring_view(0, max_annotation_text_length));
}
builder.append("'?"sv);
auto result = GUI::MessageBox::show(window(), builder.string_view(), "Delete annotation?"sv, GUI::MessageBox::Type::Question, GUI::MessageBox::InputType::YesNo);
if (result == GUI::Dialog::ExecResult::Yes) { if (result == GUI::Dialog::ExecResult::Yes) {
m_document->annotations().delete_annotation(annotation); m_document->annotations().delete_annotation(annotation);
update(); update();