mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-10 13:00:29 +03: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
Notes:
sideshowbarker
2024-07-19 04:46:11 +09:00
Author: https://github.com/tomuta Commit: https://github.com/SerenityOS/serenity/commit/27bd2eab228 Pull-request: https://github.com/SerenityOS/serenity/pull/2820
@ -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;
|
||||
}
|
||||
|
@ -338,8 +338,8 @@ void DisplaySettingsWidget::send_settings_to_window_server()
|
||||
{
|
||||
auto result = GUI::WindowServerConnection::the().send_sync<Messages::WindowServer::SetResolution>(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()) {
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -172,7 +172,7 @@ int run_in_desktop_mode(RefPtr<Core::ConfigFile> 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<Core::ConfigFile> 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<Core::ConfigFile> 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<Core::ConfigFile> 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<Core::ConfigFile> 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<Core::ConfigFile> 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<Core::ConfigFile> 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<Core::ConfigFile> 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<Core::ConfigFile> 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<Core::ConfigFile> 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();
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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<Gfx::Font> 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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ int main(int argc, char** argv)
|
||||
Vector<String> 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;
|
||||
|
@ -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());
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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());
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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<Audio::WavLoader> loader = make<Audio::WavLoader>(path);
|
||||
if (loader->has_error()) {
|
||||
GUI::MessageBox::show(
|
||||
GUI::MessageBox::show(window(),
|
||||
String::format(
|
||||
"Failed to load WAV file: %s (%s)",
|
||||
path.characters(),
|
||||
|
@ -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());
|
||||
|
@ -149,7 +149,7 @@ int main(int argc, char** argv)
|
||||
|
||||
Optional<Vector<ContentPage>> _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();
|
||||
|
@ -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();
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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<LibThread::Thread> 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<Core::DeferredInvocationEvent>([=](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();
|
||||
});
|
||||
|
@ -63,7 +63,7 @@ void ProcessChooser::build()
|
||||
auto& profile_button = button_container.add<GUI::Button>("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();
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -58,12 +58,12 @@ void Window::set_wrapper(Badge<Bindings::WindowObject>, 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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user