mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 07:37:46 +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:
parent
56eb45ccbc
commit
c6e5581682
1 changed files with 12 additions and 1 deletions
|
@ -952,7 +952,18 @@ void HexEditor::show_edit_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) {
|
||||
m_document->annotations().delete_annotation(annotation);
|
||||
update();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue