HexEditor: Prompt the user to save changes when opening a file
This commit is contained in:
parent
5edc0d11b0
commit
b246221eac
Notes:
sideshowbarker
2024-07-18 11:37:51 +09:00
Author: https://github.com/gunnarbeutner Commit: https://github.com/SerenityOS/serenity/commit/b246221eac4 Pull-request: https://github.com/SerenityOS/serenity/pull/8216
1 changed files with 8 additions and 0 deletions
|
@ -92,6 +92,14 @@ HexEditorWidget::HexEditorWidget()
|
|||
if (!open_path.has_value())
|
||||
return;
|
||||
|
||||
if (m_document_dirty) {
|
||||
auto save_document_first_result = GUI::MessageBox::show(window(), "Save changes to current document first?", "Warning", GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::YesNoCancel);
|
||||
if (save_document_first_result == GUI::Dialog::ExecResult::ExecYes)
|
||||
m_save_action->activate();
|
||||
if (save_document_first_result != GUI::Dialog::ExecResult::ExecNo && m_document_dirty)
|
||||
return;
|
||||
}
|
||||
|
||||
open_file(open_path.value());
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue