diff options
author | Karol Kosek <krkk@serenityos.org> | 2022-02-14 15:29:24 +0100 |
---|---|---|
committer | Tim Flynn <trflynn89@pm.me> | 2022-02-20 08:40:26 -0500 |
commit | 42d19977b33e2d0c3309b299a5a24aaf513442fd (patch) | |
tree | 60a68c779c6324911b1c59b1fd79d35574aac966 /Userland/Applications | |
parent | cb332bdd2ad38aafb69ab2938cc5e163ce6dc2d7 (diff) | |
download | serenity-42d19977b33e2d0c3309b299a5a24aaf513442fd.zip |
HexEditor: Use the system-wide unsaved changes dialog
Diffstat (limited to 'Userland/Applications')
-rw-r--r-- | Userland/Applications/HexEditor/HexEditorWidget.cpp | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/Userland/Applications/HexEditor/HexEditorWidget.cpp b/Userland/Applications/HexEditor/HexEditorWidget.cpp index f49c5aaab7..378eb65dd4 100644 --- a/Userland/Applications/HexEditor/HexEditorWidget.cpp +++ b/Userland/Applications/HexEditor/HexEditorWidget.cpp @@ -89,13 +89,8 @@ HexEditorWidget::HexEditorWidget() if (response.is_error()) return; - if (window()->is_modified()) { - 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 && window()->is_modified()) - return; - } + if (!request_close()) + return; open_file(response.value()); }); @@ -337,14 +332,12 @@ bool HexEditorWidget::request_close() if (!window()->is_modified()) return true; - auto result = GUI::MessageBox::show(window(), "The file has been modified. Save before closing?", "Save changes", GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::YesNoCancel); - if (result == GUI::MessageBox::ExecCancel) - return false; + auto result = GUI::MessageBox::ask_about_unsaved_changes(window(), m_path); if (result == GUI::MessageBox::ExecYes) { m_save_action->activate(); return !window()->is_modified(); } - return true; + return result == GUI::MessageBox::ExecNo; } void HexEditorWidget::set_search_results_visible(bool visible) |