1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-28 09:15:07 +00:00

LibGUI: Use new DialogButton for consistency

This commit is contained in:
FrHun 2022-06-10 23:03:11 +02:00 committed by Linus Groh
parent 4c84e64b2a
commit 992ff4bd63
8 changed files with 18 additions and 34 deletions

View file

@ -79,8 +79,7 @@ AboutDialog::AboutDialog(StringView name, Gfx::Bitmap const* icon, Window* paren
button_container.set_fixed_height(22);
button_container.set_layout<HorizontalBoxLayout>();
button_container.layout()->add_spacer();
auto& ok_button = button_container.add<Button>("OK");
ok_button.set_fixed_width(80);
auto& ok_button = button_container.add<DialogButton>("OK");
ok_button.on_click = [this](auto) {
done(ExecResult::OK);
};

View file

@ -232,16 +232,14 @@ void ColorPicker::build_ui()
button_container.layout()->set_spacing(4);
button_container.layout()->add_spacer();
auto& ok_button = button_container.add<Button>();
ok_button.set_fixed_width(80);
auto& ok_button = button_container.add<DialogButton>();
ok_button.set_text("OK");
ok_button.on_click = [this](auto) {
done(ExecResult::OK);
};
ok_button.set_default(true);
auto& cancel_button = button_container.add<Button>();
cancel_button.set_fixed_width(80);
auto& cancel_button = button_container.add<DialogButton>();
cancel_button.set_text("Cancel");
cancel_button.on_click = [this](auto) {
done(ExecResult::Cancel);

View file

@ -69,10 +69,9 @@
fixed_width: 20
}
@GUI::Button {
@GUI::DialogButton {
name: "ok_button"
text: "OK"
fixed_width: 75
}
}
@ -82,10 +81,9 @@
@GUI::Layout::Spacer {}
@GUI::Button {
@GUI::DialogButton {
name: "cancel_button"
text: "Cancel"
fixed_width: 75
}
}
}

View file

@ -73,16 +73,14 @@
@GUI::Widget {}
@GUI::Button {
@GUI::DialogButton {
name: "ok_button"
text: "OK"
fixed_width: 80
}
@GUI::Button {
@GUI::DialogButton {
name: "cancel_button"
text: "Cancel"
fixed_width: 80
}
}
}

View file

@ -82,7 +82,7 @@ void InputBox::build(InputType input_type)
button_container_inner.layout()->set_margins({ 4, 0, 4, 4 });
button_container_inner.layout()->add_spacer();
m_ok_button = button_container_inner.add<Button>();
m_ok_button = button_container_inner.add<DialogButton>();
m_ok_button->set_text("OK");
m_ok_button->on_click = [this](auto) {
dbgln("GUI::InputBox: OK button clicked");
@ -91,7 +91,7 @@ void InputBox::build(InputType input_type)
};
m_ok_button->set_default(true);
m_cancel_button = button_container_inner.add<Button>();
m_cancel_button = button_container_inner.add<DialogButton>();
m_cancel_button->set_text("Cancel");
m_cancel_button->on_click = [this](auto) {
dbgln("GUI::InputBox: Cancel button clicked");

View file

@ -78,16 +78,14 @@
@GUI::Widget {}
@GUI::Button {
@GUI::DialogButton {
text: "OK"
name: "ok_button"
fixed_width: 75
}
@GUI::Button {
@GUI::DialogButton {
text: "Cancel"
name: "cancel_button"
fixed_width: 75
}
}
}

View file

@ -46,8 +46,7 @@ ErrorOr<NonnullRefPtr<SettingsWindow>> SettingsWindow::create(String title, Show
button_container->layout()->set_spacing(6);
if (show_defaults_button == ShowDefaultsButton::Yes) {
window->m_reset_button = TRY(button_container->try_add<GUI::Button>("Defaults"));
window->m_reset_button->set_fixed_width(75);
window->m_reset_button = TRY(button_container->try_add<GUI::DialogButton>("Defaults"));
window->m_reset_button->on_click = [window = window->make_weak_ptr<SettingsWindow>()](auto) mutable {
window->reset_default_values();
};
@ -55,22 +54,19 @@ ErrorOr<NonnullRefPtr<SettingsWindow>> SettingsWindow::create(String title, Show
TRY(button_container->layout()->try_add_spacer());
window->m_ok_button = TRY(button_container->try_add<GUI::Button>("OK"));
window->m_ok_button->set_fixed_width(75);
window->m_ok_button = TRY(button_container->try_add<GUI::DialogButton>("OK"));
window->m_ok_button->on_click = [window = window->make_weak_ptr<SettingsWindow>()](auto) mutable {
window->apply_settings();
GUI::Application::the()->quit();
};
window->m_cancel_button = TRY(button_container->try_add<GUI::Button>("Cancel"));
window->m_cancel_button->set_fixed_width(75);
window->m_cancel_button = TRY(button_container->try_add<GUI::DialogButton>("Cancel"));
window->m_cancel_button->on_click = [window = window->make_weak_ptr<SettingsWindow>()](auto) mutable {
window->cancel_settings();
GUI::Application::the()->quit();
};
window->m_apply_button = TRY(button_container->try_add<GUI::Button>("Apply"));
window->m_apply_button->set_fixed_width(75);
window->m_apply_button = TRY(button_container->try_add<GUI::DialogButton>("Apply"));
window->m_apply_button->on_click = [window = window->make_weak_ptr<SettingsWindow>()](auto) mutable {
window->apply_settings();
};

View file

@ -46,14 +46,12 @@ WizardDialog::WizardDialog(Window* parent_window)
nav_container_widget.layout()->set_spacing(0);
nav_container_widget.layout()->add_spacer();
m_back_button = nav_container_widget.add<Button>("< Back");
m_back_button->set_fixed_width(75);
m_back_button = nav_container_widget.add<DialogButton>("< Back");
m_back_button->on_click = [&](auto) {
pop_page();
};
m_next_button = nav_container_widget.add<Button>("Next >");
m_next_button->set_fixed_width(75);
m_next_button = nav_container_widget.add<DialogButton>("Next >");
m_next_button->on_click = [&](auto) {
VERIFY(has_pages());
@ -70,8 +68,7 @@ WizardDialog::WizardDialog(Window* parent_window)
auto& button_spacer = nav_container_widget.add<Widget>();
button_spacer.set_fixed_width(10);
m_cancel_button = nav_container_widget.add<Button>("Cancel");
m_cancel_button->set_fixed_width(75);
m_cancel_button = nav_container_widget.add<DialogButton>("Cancel");
m_cancel_button->on_click = [&](auto) {
handle_cancel();
};