diff --git a/Applications/Browser/DownloadWidget.cpp b/Applications/Browser/DownloadWidget.cpp index 5a4fe9a021..2a7de0e05f 100644 --- a/Applications/Browser/DownloadWidget.cpp +++ b/Applications/Browser/DownloadWidget.cpp @@ -173,14 +173,14 @@ void DownloadWidget::did_finish(bool success, const ByteBuffer& payload, RefPtr< m_cancel_button->update(); if (!success) { - GUI::MessageBox::show(String::format("Download failed for some reason"), "Download failed", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window()); + GUI::MessageBox::show(window(), String::format("Download failed for some reason"), "Download failed", GUI::MessageBox::Type::Error); window()->close(); return; } auto file_or_error = Core::File::open(m_destination_path, Core::IODevice::WriteOnly); if (file_or_error.is_error()) { - GUI::MessageBox::show(String::format("Cannot open %s for writing", m_destination_path.characters()), "Download failed", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window()); + GUI::MessageBox::show(window(), String::format("Cannot open %s for writing", m_destination_path.characters()), "Download failed", GUI::MessageBox::Type::Error); window()->close(); return; } diff --git a/Applications/DisplaySettings/DisplaySettings.cpp b/Applications/DisplaySettings/DisplaySettings.cpp index 5c26f7156c..22fd9bdeb3 100644 --- a/Applications/DisplaySettings/DisplaySettings.cpp +++ b/Applications/DisplaySettings/DisplaySettings.cpp @@ -338,8 +338,8 @@ void DisplaySettingsWidget::send_settings_to_window_server() { auto result = GUI::WindowServerConnection::the().send_sync(m_monitor_widget->desktop_resolution()); if (!result->success()) { - GUI::MessageBox::show(String::format("Reverting to resolution %dx%d", result->resolution().width(), result->resolution().height()), - "Unable to set resolution", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK); + GUI::MessageBox::show(root_widget()->window(), String::format("Reverting to resolution %dx%d", result->resolution().width(), result->resolution().height()), + "Unable to set resolution", GUI::MessageBox::Type::Error); } if (!m_monitor_widget->wallpaper().is_empty()) { diff --git a/Applications/FileManager/DirectoryView.cpp b/Applications/FileManager/DirectoryView.cpp index f271bd06e4..0b3d83ec68 100644 --- a/Applications/FileManager/DirectoryView.cpp +++ b/Applications/FileManager/DirectoryView.cpp @@ -108,7 +108,7 @@ void DirectoryView::handle_activation(const GUI::ModelIndex& index) on_launch(url, *default_launcher); } else { auto error_message = String::format("Could not open %s", path.characters()); - GUI::MessageBox::show(error_message, "File Manager", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window(), error_message, "File Manager", GUI::MessageBox::Type::Error); } } diff --git a/Applications/FileManager/PropertiesDialog.cpp b/Applications/FileManager/PropertiesDialog.cpp index f9426f91f4..f56a2bbc85 100644 --- a/Applications/FileManager/PropertiesDialog.cpp +++ b/Applications/FileManager/PropertiesDialog.cpp @@ -198,12 +198,12 @@ bool PropertiesDialog::apply_changes() String new_file = make_full_path(new_name).characters(); if (GUI::FilePicker::file_exists(new_file)) { - GUI::MessageBox::show(String::format("A file \"%s\" already exists!", new_name.characters()), "Error", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(this, String::format("A file \"%s\" already exists!", new_name.characters()), "Error", GUI::MessageBox::Type::Error); return false; } if (rename(make_full_path(m_name).characters(), new_file.characters())) { - GUI::MessageBox::show(String::format("Could not rename file: %s!", strerror(errno)), "Error", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(this, String::format("Could not rename file: %s!", strerror(errno)), "Error", GUI::MessageBox::Type::Error); return false; } @@ -214,7 +214,7 @@ bool PropertiesDialog::apply_changes() if (m_permissions_dirty) { if (chmod(make_full_path(m_name).characters(), m_mode)) { - GUI::MessageBox::show(String::format("Could not update permissions: %s!", strerror(errno)), "Error", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(this, String::format("Could not update permissions: %s!", strerror(errno)), "Error", GUI::MessageBox::Type::Error); return false; } diff --git a/Applications/FileManager/main.cpp b/Applications/FileManager/main.cpp index c39c6028b7..dc092ba5cf 100644 --- a/Applications/FileManager/main.cpp +++ b/Applications/FileManager/main.cpp @@ -172,7 +172,7 @@ int run_in_desktop_mode(RefPtr config, String initial_location input_box->text_value().characters())); int rc = mkdir(new_dir_path.characters(), 0777); if (rc < 0) { - GUI::MessageBox::show(String::format("mkdir(\"%s\") failed: %s", new_dir_path.characters(), strerror(errno)), "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window); + GUI::MessageBox::show(window, String::format("mkdir(\"%s\") failed: %s", new_dir_path.characters(), strerror(errno)), "Error", GUI::MessageBox::Type::Error); } } }); @@ -187,16 +187,16 @@ int run_in_desktop_mode(RefPtr config, String initial_location struct stat st; int rc = stat(new_file_path.characters(), &st); if ((rc < 0 && errno != ENOENT)) { - GUI::MessageBox::show(String::format("stat(\"%s\") failed: %s", new_file_path.characters(), strerror(errno)), "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window); + GUI::MessageBox::show(window, String::format("stat(\"%s\") failed: %s", new_file_path.characters(), strerror(errno)), "Error", GUI::MessageBox::Type::Error); return; } if (rc == 0) { - GUI::MessageBox::show(String::format("%s: Already exists", new_file_path.characters()), "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window); + GUI::MessageBox::show(window, String::format("%s: Already exists", new_file_path.characters()), "Error", GUI::MessageBox::Type::Error); return; } int fd = creat(new_file_path.characters(), 0666); if (fd < 0) { - GUI::MessageBox::show(String::format("creat(\"%s\") failed: %s", new_file_path.characters(), strerror(errno)), "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window); + GUI::MessageBox::show(window, String::format("creat(\"%s\") failed: %s", new_file_path.characters(), strerror(errno)), "Error", GUI::MessageBox::Type::Error); return; } rc = close(fd); @@ -330,7 +330,7 @@ int run_in_windowed_mode(RefPtr config, String initial_locatio input_box->text_value().characters())); int rc = mkdir(new_dir_path.characters(), 0777); if (rc < 0) { - GUI::MessageBox::show(String::format("mkdir(\"%s\") failed: %s", new_dir_path.characters(), strerror(errno)), "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window); + GUI::MessageBox::show(window, String::format("mkdir(\"%s\") failed: %s", new_dir_path.characters(), strerror(errno)), "Error", GUI::MessageBox::Type::Error); } else { refresh_tree_view(); } @@ -347,16 +347,16 @@ int run_in_windowed_mode(RefPtr config, String initial_locatio struct stat st; int rc = stat(new_file_path.characters(), &st); if ((rc < 0 && errno != ENOENT)) { - GUI::MessageBox::show(String::format("stat(\"%s\") failed: %s", new_file_path.characters(), strerror(errno)), "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window); + GUI::MessageBox::show(window, String::format("stat(\"%s\") failed: %s", new_file_path.characters(), strerror(errno)), "Error", GUI::MessageBox::Type::Error); return; } if (rc == 0) { - GUI::MessageBox::show(String::format("%s: Already exists", new_file_path.characters()), "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window); + GUI::MessageBox::show(window, String::format("%s: Already exists", new_file_path.characters()), "Error", GUI::MessageBox::Type::Error); return; } int fd = creat(new_file_path.characters(), 0666); if (fd < 0) { - GUI::MessageBox::show(String::format("creat(\"%s\") failed: %s", new_file_path.characters(), strerror(errno)), "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window); + GUI::MessageBox::show(window, String::format("creat(\"%s\") failed: %s", new_file_path.characters(), strerror(errno)), "Error", GUI::MessageBox::Type::Error); return; } rc = close(fd); @@ -518,7 +518,7 @@ int run_in_windowed_mode(RefPtr config, String initial_locatio auto new_path = String::format("%s/%s", target_directory.characters(), url.basename().characters()); if (!FileUtils::copy_file_or_directory(url.path(), new_path)) { auto error_message = String::format("Could not paste %s.", url.path().characters()); - GUI::MessageBox::show(error_message, "File Manager", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window, error_message, "File Manager", GUI::MessageBox::Type::Error); } else { refresh_tree_view(); } @@ -542,12 +542,11 @@ int run_in_windowed_mode(RefPtr config, String initial_locatio } if (confirm == ConfirmBeforeDelete::Yes) { - auto result = GUI::MessageBox::show( + auto result = GUI::MessageBox::show(window, message, "Confirm deletion", GUI::MessageBox::Type::Warning, - GUI::MessageBox::InputType::OKCancel, - window); + GUI::MessageBox::InputType::OKCancel); if (result == GUI::MessageBox::ExecCancel) return; } @@ -555,12 +554,10 @@ int run_in_windowed_mode(RefPtr config, String initial_locatio for (auto& path : paths) { struct stat st; if (lstat(path.characters(), &st)) { - GUI::MessageBox::show( + GUI::MessageBox::show(window, String::format("lstat(%s) failed: %s", path.characters(), strerror(errno)), "Delete failed", - GUI::MessageBox::Type::Error, - GUI::MessageBox::InputType::OK, - window); + GUI::MessageBox::Type::Error); break; } else { refresh_tree_view(); @@ -571,24 +568,20 @@ int run_in_windowed_mode(RefPtr config, String initial_locatio int error = FileUtils::delete_directory(path, error_path); if (error) { - GUI::MessageBox::show( + GUI::MessageBox::show(window, String::format("Failed to delete directory \"%s\": %s", error_path.characters(), strerror(error)), "Delete failed", - GUI::MessageBox::Type::Error, - GUI::MessageBox::InputType::OK, - window); + GUI::MessageBox::Type::Error); break; } else { refresh_tree_view(); } } else if (unlink(path.characters()) < 0) { int saved_errno = errno; - GUI::MessageBox::show( + GUI::MessageBox::show(window, String::format("unlink(%s) failed: %s", path.characters(), strerror(saved_errno)), "Delete failed", - GUI::MessageBox::Type::Error, - GUI::MessageBox::InputType::OK, - window); + GUI::MessageBox::Type::Error); break; } } @@ -726,7 +719,7 @@ int run_in_windowed_mode(RefPtr config, String initial_locatio directory_view.on_error = [&](int, const char* error_string, bool quit) { auto error_message = String::format("Could not read directory: %s", error_string); - GUI::MessageBox::show(error_message, "File Manager", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window, error_message, "File Manager", GUI::MessageBox::Type::Error); if (quit) exit(1); @@ -880,7 +873,7 @@ int run_in_windowed_mode(RefPtr config, String initial_locatio auto error_message = String::format("Could not copy %s into %s.", url_to_copy.to_string().characters(), new_path.characters()); - GUI::MessageBox::show(error_message, "File Manager", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window, error_message, "File Manager", GUI::MessageBox::Type::Error); } else { refresh_tree_view(); } diff --git a/Applications/FontEditor/FontEditor.cpp b/Applications/FontEditor/FontEditor.cpp index a3bbc78286..a7d32a4706 100644 --- a/Applications/FontEditor/FontEditor.cpp +++ b/Applications/FontEditor/FontEditor.cpp @@ -296,7 +296,7 @@ bool FontEditorWidget::save_as(const String& path) { auto ret_val = m_edited_font->write_to_file(path); if (!ret_val) { - GUI::MessageBox::show("The font file could not be saved.", "Save failed", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window()); + GUI::MessageBox::show(window(), "The font file could not be saved.", "Save failed", GUI::MessageBox::Type::Error); return false; } m_path = path; diff --git a/Applications/FontEditor/main.cpp b/Applications/FontEditor/main.cpp index b764050c43..9dfbdd14b4 100644 --- a/Applications/FontEditor/main.cpp +++ b/Applications/FontEditor/main.cpp @@ -67,7 +67,7 @@ int main(int argc, char** argv) edited_font = Gfx::Font::load_from_file(path)->clone(); if (!edited_font) { String message = String::format("Couldn't load font: %s\n", path); - GUI::MessageBox::show(message, "Font Editor", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK); + GUI::MessageBox::show(nullptr, message, "Font Editor", GUI::MessageBox::Type::Error); return 1; } } @@ -99,7 +99,7 @@ int main(int argc, char** argv) RefPtr new_font = Gfx::Font::load_from_file(open_path.value())->clone(); if (!new_font) { String message = String::format("Couldn't load font: %s\n", open_path.value().characters()); - GUI::MessageBox::show(message, "Font Editor", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK); + GUI::MessageBox::show(window, message, "Font Editor", GUI::MessageBox::Type::Error); return; } diff --git a/Applications/Help/main.cpp b/Applications/Help/main.cpp index 145fdd0acf..406bcab5d6 100644 --- a/Applications/Help/main.cpp +++ b/Applications/Help/main.cpp @@ -130,7 +130,7 @@ int main(int argc, char* argv[]) if (!file->open(Core::IODevice::OpenMode::ReadOnly)) { int saved_errno = errno; - GUI::MessageBox::show(strerror(saved_errno), "Failed to open man page", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window); + GUI::MessageBox::show(window, strerror(saved_errno), "Failed to open man page", GUI::MessageBox::Type::Error); return; } auto buffer = file->read_all(); @@ -167,12 +167,10 @@ int main(int argc, char* argv[]) auto open_external = [&](auto& url) { if (!Desktop::Launcher::open(url)) { - GUI::MessageBox::show( + GUI::MessageBox::show(window, String::format("The link to '%s' could not be opened.", url.to_string().characters()), "Failed to open link", - GUI::MessageBox::Type::Error, - GUI::MessageBox::InputType::OK, - window); + GUI::MessageBox::Type::Error); } }; diff --git a/Applications/HexEditor/HexEditorWidget.cpp b/Applications/HexEditor/HexEditorWidget.cpp index 922ec6481c..5e978d4004 100644 --- a/Applications/HexEditor/HexEditorWidget.cpp +++ b/Applications/HexEditor/HexEditorWidget.cpp @@ -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; } diff --git a/Applications/KeyboardMapper/KeyboardMapperWidget.cpp b/Applications/KeyboardMapper/KeyboardMapperWidget.cpp index 9c56464c83..c4eca7c29f 100644 --- a/Applications/KeyboardMapper/KeyboardMapperWidget.cpp +++ b/Applications/KeyboardMapper/KeyboardMapperWidget.cpp @@ -205,7 +205,7 @@ void KeyboardMapperWidget::save_to_file(const StringView& file_name) sb.append(" for write. Error: "); sb.append(file->error_string()); - GUI::MessageBox::show(sb.to_string(), "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window()); + GUI::MessageBox::show(window(), sb.to_string(), "Error", GUI::MessageBox::Type::Error); return; } @@ -216,7 +216,7 @@ void KeyboardMapperWidget::save_to_file(const StringView& file_name) sb.append("Unable to save file. Error: "); sb.append(strerror(error_number)); - GUI::MessageBox::show(sb.to_string(), "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window()); + GUI::MessageBox::show(window(), sb.to_string(), "Error", GUI::MessageBox::Type::Error); return; } diff --git a/Applications/KeyboardSettings/main.cpp b/Applications/KeyboardSettings/main.cpp index dae47939cf..a79ce7f081 100644 --- a/Applications/KeyboardSettings/main.cpp +++ b/Applications/KeyboardSettings/main.cpp @@ -77,7 +77,7 @@ int main(int argc, char** argv) Vector character_map_files; Core::DirIterator iterator("/res/keymaps/", Core::DirIterator::Flags::SkipDots); if (iterator.has_error()) { - GUI::MessageBox::show(String::format("Error on reading mapping file list: %d", iterator.error_string()), "Keyboard settings", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK); + GUI::MessageBox::show(nullptr, String::format("Error on reading mapping file list: %d", iterator.error_string()), "Keyboard settings", GUI::MessageBox::Type::Error); return -1; } @@ -121,7 +121,7 @@ int main(int argc, char** argv) auto apply_settings = [&](bool quit) { String character_map_file = character_map_file_combo.text(); if (character_map_file.is_empty()) { - GUI::MessageBox::show("Please select character mapping file.", "Keyboard settings", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window); + GUI::MessageBox::show(window, "Please select character mapping file.", "Keyboard settings", GUI::MessageBox::Type::Error); return; } pid_t child_pid; diff --git a/Applications/Piano/SamplerWidget.cpp b/Applications/Piano/SamplerWidget.cpp index bc522754e8..83ac5ca3b3 100644 --- a/Applications/Piano/SamplerWidget.cpp +++ b/Applications/Piano/SamplerWidget.cpp @@ -113,7 +113,7 @@ SamplerWidget::SamplerWidget(TrackManager& track_manager) return; String error_string = m_track_manager.current_track().set_recorded_sample(open_path.value()); if (!error_string.is_empty()) { - GUI::MessageBox::show(String::format("Failed to load WAV file: %s", error_string.characters()), "Error", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window(), String::format("Failed to load WAV file: %s", error_string.characters()), "Error", GUI::MessageBox::Type::Error); return; } m_recorded_sample_name->set_text(open_path.value()); diff --git a/Applications/Piano/main.cpp b/Applications/Piano/main.cpp index 53ce80d80d..2ed6c0f0f7 100644 --- a/Applications/Piano/main.cpp +++ b/Applications/Piano/main.cpp @@ -101,7 +101,7 @@ int main(int argc, char** argv) return; wav_writer.set_file(save_path.value()); if (wav_writer.has_error()) { - GUI::MessageBox::show(String::format("Failed to export WAV file: %s", wav_writer.error_string()), "Error", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window, String::format("Failed to export WAV file: %s", wav_writer.error_string()), "Error", GUI::MessageBox::Type::Error); wav_writer.clear_error(); return; } diff --git a/Applications/PixelPaint/main.cpp b/Applications/PixelPaint/main.cpp index 542ffbd336..3538d5c509 100644 --- a/Applications/PixelPaint/main.cpp +++ b/Applications/PixelPaint/main.cpp @@ -107,7 +107,7 @@ int main(int argc, char** argv) auto bitmap = Gfx::Bitmap::load_from_file(open_path.value()); if (!bitmap) { - GUI::MessageBox::show(String::format("Failed to load '%s'", open_path.value().characters()), "Open failed", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window); + GUI::MessageBox::show(window, String::format("Failed to load '%s'", open_path.value().characters()), "Open failed", GUI::MessageBox::Type::Error); return; } })); @@ -133,7 +133,7 @@ int main(int argc, char** argv) if (dialog->exec() == GUI::Dialog::ExecOK) { auto layer = PixelPaint::Layer::create_with_size(dialog->layer_size(), dialog->layer_name()); if (!layer) { - GUI::MessageBox::show_error(String::format("Unable to create layer with size %s", dialog->size().to_string().characters())); + GUI::MessageBox::show_error(window, String::format("Unable to create layer with size %s", dialog->size().to_string().characters())); return; } image_editor.image()->add_layer(layer.release_nonnull()); diff --git a/Applications/QuickShow/QSWidget.cpp b/Applications/QuickShow/QSWidget.cpp index d440e62748..8a92a1b0d8 100644 --- a/Applications/QuickShow/QSWidget.cpp +++ b/Applications/QuickShow/QSWidget.cpp @@ -98,14 +98,14 @@ void QSWidget::navigate(Directions direction) size_t index = current_index.value(); if (direction == Directions::Back) { if (index == 0) { - GUI::MessageBox::show(String::format("This is the first file.", index), "Cannot open image", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window()); + GUI::MessageBox::show(window(), String::format("This is the first file.", index), "Cannot open image", GUI::MessageBox::Type::Error); return; } index--; } else if (direction == Directions::Forward) { if (index == m_files_in_same_dir.size() - 1) { - GUI::MessageBox::show(String::format("This is the last file.", index), "Cannot open image", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window()); + GUI::MessageBox::show(window(), String::format("This is the last file.", index), "Cannot open image", GUI::MessageBox::Type::Error); return; } @@ -249,7 +249,7 @@ void QSWidget::load_from_file(const String& path) { auto bitmap = Gfx::Bitmap::load_from_file(path); if (!bitmap) { - GUI::MessageBox::show(String::format("Failed to open %s", path.characters()), "Cannot open image", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window()); + GUI::MessageBox::show(window(), String::format("Failed to open %s", path.characters()), "Cannot open image", GUI::MessageBox::Type::Error); return; } diff --git a/Applications/QuickShow/main.cpp b/Applications/QuickShow/main.cpp index 99f28540ea..2d00285421 100644 --- a/Applications/QuickShow/main.cpp +++ b/Applications/QuickShow/main.cpp @@ -138,11 +138,11 @@ int main(int argc, char** argv) if (path.is_empty()) return; - auto msgbox_result = GUI::MessageBox::show(String::format("Really delete %s?", path.characters()), + auto msgbox_result = GUI::MessageBox::show(window, + String::format("Really delete %s?", path.characters()), "Confirm deletion", GUI::MessageBox::Type::Warning, - GUI::MessageBox::InputType::OKCancel, - window); + GUI::MessageBox::InputType::OKCancel); if (msgbox_result == GUI::MessageBox::ExecCancel) return; @@ -152,11 +152,10 @@ int main(int argc, char** argv) if (unlink_result < 0) { int saved_errno = errno; - GUI::MessageBox::show(String::format("unlink(%s) failed: %s", path.characters(), strerror(saved_errno)), + GUI::MessageBox::show(window, + String::format("unlink(%s) failed: %s", path.characters(), strerror(saved_errno)), "Delete failed", - GUI::MessageBox::Type::Error, - GUI::MessageBox::InputType::OK, - window); + GUI::MessageBox::Type::Error); return; } diff --git a/Applications/SoundPlayer/SoundPlayerWidget.cpp b/Applications/SoundPlayer/SoundPlayerWidget.cpp index 082e5738c3..0b416c0833 100644 --- a/Applications/SoundPlayer/SoundPlayerWidget.cpp +++ b/Applications/SoundPlayer/SoundPlayerWidget.cpp @@ -120,13 +120,13 @@ void SoundPlayerWidget::hide_scope(bool hide) void SoundPlayerWidget::open_file(String path) { if (!path.ends_with(".wav")) { - GUI::MessageBox::show("Selected file is not a \".wav\" file!", "Filetype error", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window(), "Selected file is not a \".wav\" file!", "Filetype error", GUI::MessageBox::Type::Error); return; } OwnPtr loader = make(path); if (loader->has_error()) { - GUI::MessageBox::show( + GUI::MessageBox::show(window(), String::format( "Failed to load WAV file: %s (%s)", path.characters(), diff --git a/Applications/TextEditor/TextEditorWidget.cpp b/Applications/TextEditor/TextEditorWidget.cpp index c368b73017..6407117344 100644 --- a/Applications/TextEditor/TextEditorWidget.cpp +++ b/Applications/TextEditor/TextEditorWidget.cpp @@ -124,11 +124,10 @@ TextEditorWidget::TextEditorWidget() if (found_range.is_valid()) { m_editor->set_selection(found_range); } else { - GUI::MessageBox::show( + GUI::MessageBox::show(window(), String::format("Not found: \"%s\"", needle.characters()), "Not found", - GUI::MessageBox::Type::Information, - GUI::MessageBox::InputType::OK, window()); + GUI::MessageBox::Type::Information); } }); @@ -149,11 +148,10 @@ TextEditorWidget::TextEditorWidget() if (found_range.is_valid()) { m_editor->set_selection(found_range); } else { - GUI::MessageBox::show( + GUI::MessageBox::show(window(), String::format("Not found: \"%s\"", needle.characters()), "Not found", - GUI::MessageBox::Type::Information, - GUI::MessageBox::InputType::OK, window()); + GUI::MessageBox::Type::Information); } }); @@ -174,11 +172,10 @@ TextEditorWidget::TextEditorWidget() m_editor->set_selection(found_range); m_editor->insert_at_cursor_or_replace_selection(substitute); } else { - GUI::MessageBox::show( + GUI::MessageBox::show(window(), String::format("Not found: \"%s\"", needle.characters()), "Not found", - GUI::MessageBox::Type::Information, - GUI::MessageBox::InputType::OK, window()); + GUI::MessageBox::Type::Information); } }); @@ -198,11 +195,10 @@ TextEditorWidget::TextEditorWidget() m_editor->set_selection(found_range); m_editor->insert_at_cursor_or_replace_selection(substitute); } else { - GUI::MessageBox::show( + GUI::MessageBox::show(window(), String::format("Not found: \"%s\"", needle.characters()), "Not found", - GUI::MessageBox::Type::Information, - GUI::MessageBox::InputType::OK, window()); + GUI::MessageBox::Type::Information); } }); @@ -290,7 +286,7 @@ TextEditorWidget::TextEditorWidget() 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_result = GUI::MessageBox::show("Save Document First?", "Warning", GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::YesNoCancel); + auto save_document_first_result = GUI::MessageBox::show(window(), "Save 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::ExecCancel) @@ -310,7 +306,7 @@ TextEditorWidget::TextEditorWidget() return; if (m_document_dirty) { - auto save_document_first_result = GUI::MessageBox::show("Save Document First?", "Warning", GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::YesNoCancel, window()); + auto save_document_first_result = GUI::MessageBox::show(window(), "Save 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::ExecCancel) @@ -326,7 +322,7 @@ TextEditorWidget::TextEditorWidget() 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; } @@ -338,7 +334,7 @@ TextEditorWidget::TextEditorWidget() 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(); @@ -523,7 +519,7 @@ void TextEditorWidget::open_sesame(const String& path) { auto file = Core::File::construct(path); if (!file->open(Core::IODevice::ReadOnly) && file->error() != ENOENT) { - 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; } @@ -540,7 +536,7 @@ bool TextEditorWidget::request_close() { if (!m_document_dirty) return true; - auto result = GUI::MessageBox::show("The document has been modified. Would you like to save?", "Unsaved changes", GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::YesNoCancel, window()); + auto result = GUI::MessageBox::show(window(), "The document has been modified. Would you like to save?", "Unsaved changes", GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::YesNoCancel); if (result == GUI::MessageBox::ExecYes) { m_save_action->activate(); @@ -563,7 +559,7 @@ void TextEditorWidget::drop_event(GUI::DropEvent& event) if (urls.is_empty()) return; if (urls.size() > 1) { - GUI::MessageBox::show("TextEditor can only open one file at a time!", "One at a time please!", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window()); + GUI::MessageBox::show(window(), "TextEditor can only open one file at a time!", "One at a time please!", GUI::MessageBox::Type::Error); return; } open_sesame(urls.first().path()); diff --git a/Applications/Welcome/main.cpp b/Applications/Welcome/main.cpp index 937bc46d7a..a5d8616516 100644 --- a/Applications/Welcome/main.cpp +++ b/Applications/Welcome/main.cpp @@ -149,7 +149,7 @@ int main(int argc, char** argv) Optional> _pages = parse_welcome_file("/res/welcome.txt"); if (!_pages.has_value()) { - GUI::MessageBox::show("Could not open Welcome file.", "Welcome", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, nullptr); + GUI::MessageBox::show(nullptr, "Could not open Welcome file.", "Welcome", GUI::MessageBox::Type::Error); return 1; } auto pages = _pages.value(); diff --git a/Demos/WidgetGallery/main.cpp b/Demos/WidgetGallery/main.cpp index 46889b1a6e..7f8b6c55bf 100644 --- a/Demos/WidgetGallery/main.cpp +++ b/Demos/WidgetGallery/main.cpp @@ -245,7 +245,7 @@ int main(int argc, char** argv) show_buton.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); show_buton.set_preferred_size(0, 20); show_buton.on_click = [&](auto) { - GUI::MessageBox::show(content_textbox.text(), title_textbox.text(), msg_box_type, msg_box_input_type, window); + GUI::MessageBox::show(window, content_textbox.text(), title_textbox.text(), msg_box_type, msg_box_input_type); }; tab_msgbox.layout()->add_spacer(); diff --git a/DevTools/HackStudio/Debugger/VariablesModel.cpp b/DevTools/HackStudio/Debugger/VariablesModel.cpp index 83aadc8c22..7c8e914d30 100644 --- a/DevTools/HackStudio/Debugger/VariablesModel.cpp +++ b/DevTools/HackStudio/Debugger/VariablesModel.cpp @@ -153,12 +153,10 @@ void VariablesModel::set_variable_value(const GUI::ModelIndex& index, const Stri return; } - GUI::MessageBox::show( + GUI::MessageBox::show(parent_window, String::format("String value \"%s\" could not be converted to a value of type %s.", string_value.to_string().characters(), variable->type_name.characters()), "Set value failed", - GUI::MessageBox::Type::Error, - GUI::MessageBox::InputType::OK, - parent_window); + GUI::MessageBox::Type::Error); } GUI::Variant VariablesModel::data(const GUI::ModelIndex& index, Role role) const diff --git a/DevTools/HackStudio/TerminalWrapper.cpp b/DevTools/HackStudio/TerminalWrapper.cpp index 58b39506bf..aad9241fc3 100644 --- a/DevTools/HackStudio/TerminalWrapper.cpp +++ b/DevTools/HackStudio/TerminalWrapper.cpp @@ -44,12 +44,10 @@ void TerminalWrapper::run_command(const String& command) { if (m_pid != -1) { - GUI::MessageBox::show( + GUI::MessageBox::show(window(), "A command is already running in this TerminalWrapper", "Can't run command", - GUI::MessageBox::Type::Error, - GUI::MessageBox::InputType::OK, - window()); + GUI::MessageBox::Type::Error); return; } diff --git a/DevTools/HackStudio/main.cpp b/DevTools/HackStudio/main.cpp index a5ad71be9a..13f2937c44 100644 --- a/DevTools/HackStudio/main.cpp +++ b/DevTools/HackStudio/main.cpp @@ -187,7 +187,7 @@ int main(int argc, char** argv) setenv("PATH", path.to_string().characters(), true); if (!make_is_available()) - GUI::MessageBox::show("The 'make' command is not available. You probably want to install the binutils, gcc, and make ports from the root of the Serenity repository.", "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, g_window); + GUI::MessageBox::show(g_window, "The 'make' command is not available. You probably want to install the binutils, gcc, and make ports from the root of the Serenity repository.", "Error", GUI::MessageBox::Type::Error); open_project("/home/anon/little/little.files"); @@ -209,11 +209,11 @@ int main(int argc, char** argv) auto filename = input_box->text_value(); auto file = Core::File::construct(filename); if (!file->open((Core::IODevice::OpenMode)(Core::IODevice::WriteOnly | Core::IODevice::MustBeNew))) { - GUI::MessageBox::show(String::format("Failed to create '%s'", filename.characters()), "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, g_window); + GUI::MessageBox::show(g_window, String::format("Failed to create '%s'", filename.characters()), "Error", GUI::MessageBox::Type::Error); return; } if (!g_project->add_file(filename)) { - GUI::MessageBox::show(String::format("Failed to add '%s' to project", filename.characters()), "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, g_window); + GUI::MessageBox::show(g_window, String::format("Failed to add '%s' to project", filename.characters()), "Error", GUI::MessageBox::Type::Error); // FIXME: Should we unlink the file here maybe? return; } @@ -227,7 +227,7 @@ int main(int argc, char** argv) return; auto& filename = result.value(); if (!g_project->add_file(filename)) { - GUI::MessageBox::show(String::format("Failed to add '%s' to project", filename.characters()), "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, g_window); + GUI::MessageBox::show(g_window, String::format("Failed to add '%s' to project", filename.characters()), "Error", GUI::MessageBox::Type::Error); return; } g_project_tree_view->toggle_index(g_project_tree_view->model()->index(0, 0)); @@ -248,23 +248,20 @@ int main(int argc, char** argv) message = String::format("Really remove %d files from the project?", files.size()); } - auto result = GUI::MessageBox::show( + auto result = GUI::MessageBox::show(g_window, message, "Confirm deletion", GUI::MessageBox::Type::Warning, - GUI::MessageBox::InputType::OKCancel, - g_window); + GUI::MessageBox::InputType::OKCancel); if (result == GUI::MessageBox::ExecCancel) return; for (auto& file : files) { if (!g_project->remove_file(file)) { - GUI::MessageBox::show( + GUI::MessageBox::show(g_window, String::format("Removing file %s from the project failed.", file.characters()), "Removal failed", - GUI::MessageBox::Type::Error, - GUI::MessageBox::InputType::OK, - g_window); + GUI::MessageBox::Type::Error); break; } } @@ -564,15 +561,15 @@ int main(int argc, char** argv) RefPtr debugger_thread; auto debug_action = GUI::Action::create("Debug", Gfx::Bitmap::load_from_file("/res/icons/16x16/debug-run.png"), [&](auto&) { if (g_project->type() != ProjectType::Cpp) { - GUI::MessageBox::show(String::format("Cannot debug current project type", get_project_executable_path().characters()), "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, g_window); + GUI::MessageBox::show(g_window, String::format("Cannot debug current project type", get_project_executable_path().characters()), "Error", GUI::MessageBox::Type::Error); return; } if (!GUI::FilePicker::file_exists(get_project_executable_path())) { - GUI::MessageBox::show(String::format("Could not find file: %s. (did you build the project?)", get_project_executable_path().characters()), "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, g_window); + GUI::MessageBox::show(g_window, String::format("Could not find file: %s. (did you build the project?)", get_project_executable_path().characters()), "Error", GUI::MessageBox::Type::Error); return; } if (Debugger::the().session()) { - GUI::MessageBox::show("Debugger is already running", "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, g_window); + GUI::MessageBox::show(g_window, "Debugger is already running", "Error", GUI::MessageBox::Type::Error); return; } Debugger::the().set_executable_path(get_project_executable_path()); @@ -637,7 +634,7 @@ int main(int argc, char** argv) debug_info_widget.program_stopped(); hide_action_tabs(); Core::EventLoop::main().post_event(*g_window, make([=](auto&) { - GUI::MessageBox::show("Program Exited", "Debugger", GUI::MessageBox::Type::Information, GUI::MessageBox::InputType::OK, g_window); + GUI::MessageBox::show(g_window, "Program Exited", "Debugger", GUI::MessageBox::Type::Information); })); Core::EventLoop::wake(); }); diff --git a/DevTools/Profiler/ProcessChooser.cpp b/DevTools/Profiler/ProcessChooser.cpp index 3689176ad6..4070b09f2b 100644 --- a/DevTools/Profiler/ProcessChooser.cpp +++ b/DevTools/Profiler/ProcessChooser.cpp @@ -63,7 +63,7 @@ void ProcessChooser::build() auto& profile_button = button_container.add("Profile"); profile_button.on_click = [&](auto) { if (table_view.selection().is_empty()) { - GUI::MessageBox::show("No process selected!", "Profiler", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, this); + GUI::MessageBox::show(this, "No process selected!", "Profiler", GUI::MessageBox::Type::Error); return; } auto index = table_view.selection().first(); diff --git a/DevTools/Profiler/main.cpp b/DevTools/Profiler/main.cpp index 2b0be42a15..a04a0d50f4 100644 --- a/DevTools/Profiler/main.cpp +++ b/DevTools/Profiler/main.cpp @@ -162,7 +162,7 @@ bool generate_profile(pid_t pid) if (profiling_enable(pid) < 0) { int saved_errno = errno; - GUI::MessageBox::show(String::format("Unable to profile PID %d: %s", pid, strerror(saved_errno)), "Profiler", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK); + GUI::MessageBox::show(nullptr, String::format("Unable to profile PID %d: %s", pid, strerror(saved_errno)), "Profiler", GUI::MessageBox::Type::Error); return false; } diff --git a/DevTools/VisualBuilder/VBForm.cpp b/DevTools/VisualBuilder/VBForm.cpp index 6f813a4e55..d56dc82702 100644 --- a/DevTools/VisualBuilder/VBForm.cpp +++ b/DevTools/VisualBuilder/VBForm.cpp @@ -383,7 +383,7 @@ void VBForm::load_from_file(const String& path) { auto file = Core::File::construct(path); if (!file->open(Core::IODevice::ReadOnly)) { - GUI::MessageBox::show(String::format("Could not open '%s' for reading", path.characters()), "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window()); + GUI::MessageBox::show(window(), String::format("Could not open '%s' for reading", path.characters()), "Error", GUI::MessageBox::Type::Error); return; } @@ -392,7 +392,7 @@ void VBForm::load_from_file(const String& path) ASSERT(form_json.has_value()); if (!form_json.value().is_object()) { - GUI::MessageBox::show(String::format("Could not parse '%s'", path.characters()), "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window()); + GUI::MessageBox::show(window(), String::format("Could not parse '%s'", path.characters()), "Error", GUI::MessageBox::Type::Error); return; } @@ -420,7 +420,7 @@ void VBForm::write_to_file(const String& path) { auto file = Core::File::construct(path); if (!file->open(Core::IODevice::WriteOnly)) { - GUI::MessageBox::show(String::format("Could not open '%s' for writing", path.characters()), "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window()); + GUI::MessageBox::show(window(), String::format("Could not open '%s' for writing", path.characters()), "Error", GUI::MessageBox::Type::Error); return; } diff --git a/Libraries/LibGUI/FilePicker.cpp b/Libraries/LibGUI/FilePicker.cpp index 3877df01d8..8cc3f4c0fa 100644 --- a/Libraries/LibGUI/FilePicker.cpp +++ b/Libraries/LibGUI/FilePicker.cpp @@ -160,7 +160,7 @@ FilePicker::FilePicker(Window* parent_window, Mode mode, Options options, const .string(); int rc = mkdir(new_dir_path.characters(), 0777); if (rc < 0) { - MessageBox::show(String::format("mkdir(\"%s\") failed: %s", new_dir_path.characters(), strerror(errno)), "Error", MessageBox::Type::Error, MessageBox::InputType::OK, this); + MessageBox::show(this, String::format("mkdir(\"%s\") failed: %s", new_dir_path.characters(), strerror(errno)), "Error", MessageBox::Type::Error); } else { m_model->update(); } @@ -322,7 +322,7 @@ void FilePicker::on_file_return() LexicalPath path(String::format("%s/%s", m_model->root_path().characters(), m_filename_textbox->text().characters())); if (FilePicker::file_exists(path.string()) && m_mode == Mode::Save) { - auto result = MessageBox::show("File already exists, overwrite?", "Existing File", MessageBox::Type::Warning, MessageBox::InputType::OKCancel); + auto result = MessageBox::show(this, "File already exists, overwrite?", "Existing File", MessageBox::Type::Warning, MessageBox::InputType::OKCancel); if (result == MessageBox::ExecCancel) return; } diff --git a/Libraries/LibGUI/MessageBox.cpp b/Libraries/LibGUI/MessageBox.cpp index df357a02fb..9af920a8c7 100644 --- a/Libraries/LibGUI/MessageBox.cpp +++ b/Libraries/LibGUI/MessageBox.cpp @@ -34,22 +34,20 @@ namespace GUI { -int MessageBox::show(const StringView& text, const StringView& title, Type type, InputType input_type, Window* parent_window) +int MessageBox::show(Window* parent_window, const StringView& text, const StringView& title, Type type, InputType input_type) { - auto box = MessageBox::construct(text, title, type, input_type); - if (parent_window) { - parent_window->add_child(box); + auto box = MessageBox::construct(parent_window, text, title, type, input_type); + if (parent_window) box->set_icon(parent_window->icon()); - } return box->exec(); } -int MessageBox::show_error(const StringView& text, Window* parent_window) +int MessageBox::show_error(Window* parent_window, const StringView& text) { - return show(text, "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, parent_window); + return show(parent_window, text, "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK); } -MessageBox::MessageBox(const StringView& text, const StringView& title, Type type, InputType input_type, Window* parent_window) +MessageBox::MessageBox(Window* parent_window, const StringView& text, const StringView& title, Type type, InputType input_type) : Dialog(parent_window) , m_text(text) , m_type(type) diff --git a/Libraries/LibGUI/MessageBox.h b/Libraries/LibGUI/MessageBox.h index 243b3469e8..dcd4c64d3c 100644 --- a/Libraries/LibGUI/MessageBox.h +++ b/Libraries/LibGUI/MessageBox.h @@ -50,11 +50,11 @@ public: virtual ~MessageBox() override; - static int show(const StringView& text, const StringView& title, Type type = Type::None, InputType = InputType::OK, Window* parent_window = nullptr); - static int show_error(const StringView& text, Window* parent_window = nullptr); + static int show(Window* parent_window, const StringView& text, const StringView& title, Type type = Type::None, InputType input_type = InputType::OK); + static int show_error(Window* parent_window, const StringView& text); private: - explicit MessageBox(const StringView& text, const StringView& title, Type type = Type::None, InputType = InputType::OK, Window* parent_window = nullptr); + explicit MessageBox(Window* parent_window, const StringView& text, const StringView& title, Type type = Type::None, InputType input_type = InputType::OK); bool should_include_ok_button() const; bool should_include_cancel_button() const; diff --git a/Libraries/LibWeb/DOM/Window.cpp b/Libraries/LibWeb/DOM/Window.cpp index 4e4d335a8a..c3bf22ac29 100644 --- a/Libraries/LibWeb/DOM/Window.cpp +++ b/Libraries/LibWeb/DOM/Window.cpp @@ -58,12 +58,12 @@ void Window::set_wrapper(Badge, Bindings::WindowObject& void Window::alert(const String& message) { - GUI::MessageBox::show(message, "Alert", GUI::MessageBox::Type::Information); + GUI::MessageBox::show(nullptr, message, "Alert", GUI::MessageBox::Type::Information); } bool Window::confirm(const String& message) { - auto confirm_result = GUI::MessageBox::show(message, "Confirm", GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::OKCancel); + auto confirm_result = GUI::MessageBox::show(nullptr, message, "Confirm", GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::OKCancel); return confirm_result == GUI::Dialog::ExecResult::ExecOK; }