mirror of
https://github.com/RGBCube/serenity
synced 2025-05-16 18:25:06 +00:00
LibWeb: Require parent window argument for MessageBox
Since the vast majority of message boxes should be modal, require the parent window to be passed in, which can be nullptr for the rare case that they don't. By it being the first argument, the default arguments also don't need to be explicitly stated in most cases, and it encourages passing in a parent window handle. Fix up several message boxes that should have been modal.
This commit is contained in:
parent
6568765e8f
commit
27bd2eab22
30 changed files with 109 additions and 135 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue