mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 21:27:34 +00:00
HexEditor: Use the system-wide unsaved changes dialog
This commit is contained in:
parent
cb332bdd2a
commit
42d19977b3
1 changed files with 4 additions and 11 deletions
|
@ -89,13 +89,8 @@ HexEditorWidget::HexEditorWidget()
|
||||||
if (response.is_error())
|
if (response.is_error())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (window()->is_modified()) {
|
if (!request_close())
|
||||||
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;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
open_file(response.value());
|
open_file(response.value());
|
||||||
});
|
});
|
||||||
|
@ -337,14 +332,12 @@ bool HexEditorWidget::request_close()
|
||||||
if (!window()->is_modified())
|
if (!window()->is_modified())
|
||||||
return true;
|
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);
|
auto result = GUI::MessageBox::ask_about_unsaved_changes(window(), m_path);
|
||||||
if (result == GUI::MessageBox::ExecCancel)
|
|
||||||
return false;
|
|
||||||
if (result == GUI::MessageBox::ExecYes) {
|
if (result == GUI::MessageBox::ExecYes) {
|
||||||
m_save_action->activate();
|
m_save_action->activate();
|
||||||
return !window()->is_modified();
|
return !window()->is_modified();
|
||||||
}
|
}
|
||||||
return true;
|
return result == GUI::MessageBox::ExecNo;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HexEditorWidget::set_search_results_visible(bool visible)
|
void HexEditorWidget::set_search_results_visible(bool visible)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue