mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 15:28:11 +00:00
LibWeb: Require parent window argument for MessageBox
Since the vast majority of message boxes should be modal, require the parent window to be passed in, which can be nullptr for the rare case that they don't. By it being the first argument, the default arguments also don't need to be explicitly stated in most cases, and it encourages passing in a parent window handle. Fix up several message boxes that should have been modal.
This commit is contained in:
parent
6568765e8f
commit
27bd2eab22
30 changed files with 109 additions and 135 deletions
|
@ -72,10 +72,7 @@ HexEditorWidget::HexEditorWidget()
|
|||
|
||||
m_new_action = GUI::Action::create("New", { Mod_Ctrl, Key_N }, Gfx::Bitmap::load_from_file("/res/icons/16x16/new.png"), [this](const GUI::Action&) {
|
||||
if (m_document_dirty) {
|
||||
auto save_document_first_box = GUI::MessageBox::construct("Save Document First?", "Warning", GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::OKCancel, window());
|
||||
auto save_document_first_result = save_document_first_box->exec();
|
||||
|
||||
if (save_document_first_result != GUI::Dialog::ExecResult::ExecOK)
|
||||
if (GUI::MessageBox::show(window(), "Save Document First?", "Warning", GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::OKCancel) != GUI::Dialog::ExecResult::ExecOK)
|
||||
return;
|
||||
m_save_action->activate();
|
||||
}
|
||||
|
@ -89,7 +86,7 @@ HexEditorWidget::HexEditorWidget()
|
|||
set_path(LexicalPath());
|
||||
update_title();
|
||||
} else {
|
||||
GUI::MessageBox::show("Invalid file size entered.", "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window());
|
||||
GUI::MessageBox::show(window(), "Invalid file size entered.", "Error", GUI::MessageBox::Type::Error);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -106,7 +103,7 @@ HexEditorWidget::HexEditorWidget()
|
|||
m_save_action = GUI::Action::create("Save", { Mod_Ctrl, Key_S }, Gfx::Bitmap::load_from_file("/res/icons/16x16/save.png"), [&](const GUI::Action&) {
|
||||
if (!m_path.is_empty()) {
|
||||
if (!m_editor->write_to_file(m_path)) {
|
||||
GUI::MessageBox::show("Unable to save file.\n", "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window());
|
||||
GUI::MessageBox::show(window(), "Unable to save file.\n", "Error", GUI::MessageBox::Type::Error);
|
||||
} else {
|
||||
m_document_dirty = false;
|
||||
update_title();
|
||||
|
@ -123,7 +120,7 @@ HexEditorWidget::HexEditorWidget()
|
|||
return;
|
||||
|
||||
if (!m_editor->write_to_file(save_path.value())) {
|
||||
GUI::MessageBox::show("Unable to save file.\n", "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window());
|
||||
GUI::MessageBox::show(window(), "Unable to save file.\n", "Error", GUI::MessageBox::Type::Error);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -230,7 +227,7 @@ void HexEditorWidget::open_file(const String& path)
|
|||
{
|
||||
auto file = Core::File::construct(path);
|
||||
if (!file->open(Core::IODevice::ReadOnly)) {
|
||||
GUI::MessageBox::show(String::format("Opening \"%s\" failed: %s", path.characters(), strerror(errno)), "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window());
|
||||
GUI::MessageBox::show(window(), String::format("Opening \"%s\" failed: %s", path.characters(), strerror(errno)), "Error", GUI::MessageBox::Type::Error);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -243,6 +240,6 @@ bool HexEditorWidget::request_close()
|
|||
{
|
||||
if (!m_document_dirty)
|
||||
return true;
|
||||
auto result = GUI::MessageBox::show("The file has been modified. Quit without saving?", "Quit without saving?", GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::OKCancel, window());
|
||||
auto result = GUI::MessageBox::show(window(), "The file has been modified. Quit without saving?", "Quit without saving?", GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::OKCancel);
|
||||
return result == GUI::MessageBox::ExecOK;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue