diff options
author | Tom <tomut@yahoo.com> | 2020-07-15 20:45:11 -0600 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-07-16 16:10:21 +0200 |
commit | 27bd2eab2288c79206f3571bc2c46a20fc9a4254 (patch) | |
tree | 2391eb84dc9fc1a7be2bf1391daf13020b1e0076 /DevTools/HackStudio | |
parent | 6568765e8f89563fa76407ce5e369ec1eb09c125 (diff) | |
download | serenity-27bd2eab2288c79206f3571bc2c46a20fc9a4254.zip |
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.
Diffstat (limited to 'DevTools/HackStudio')
-rw-r--r-- | DevTools/HackStudio/Debugger/VariablesModel.cpp | 6 | ||||
-rw-r--r-- | DevTools/HackStudio/TerminalWrapper.cpp | 6 | ||||
-rw-r--r-- | DevTools/HackStudio/main.cpp | 27 |
3 files changed, 16 insertions, 23 deletions
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<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(); }); |