1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-29 13:15:08 +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_fixed_height(22);
button_container.set_layout<HorizontalBoxLayout>(); button_container.set_layout<HorizontalBoxLayout>();
button_container.layout()->add_spacer(); button_container.layout()->add_spacer();
auto& ok_button = button_container.add<Button>("OK"); auto& ok_button = button_container.add<DialogButton>("OK");
ok_button.set_fixed_width(80);
ok_button.on_click = [this](auto) { ok_button.on_click = [this](auto) {
done(ExecResult::OK); done(ExecResult::OK);
}; };

View file

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

View file

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

View file

@ -73,16 +73,14 @@
@GUI::Widget {} @GUI::Widget {}
@GUI::Button { @GUI::DialogButton {
name: "ok_button" name: "ok_button"
text: "OK" text: "OK"
fixed_width: 80
} }
@GUI::Button { @GUI::DialogButton {
name: "cancel_button" name: "cancel_button"
text: "Cancel" 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()->set_margins({ 4, 0, 4, 4 });
button_container_inner.layout()->add_spacer(); 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->set_text("OK");
m_ok_button->on_click = [this](auto) { m_ok_button->on_click = [this](auto) {
dbgln("GUI::InputBox: OK button clicked"); dbgln("GUI::InputBox: OK button clicked");
@ -91,7 +91,7 @@ void InputBox::build(InputType input_type)
}; };
m_ok_button->set_default(true); 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->set_text("Cancel");
m_cancel_button->on_click = [this](auto) { m_cancel_button->on_click = [this](auto) {
dbgln("GUI::InputBox: Cancel button clicked"); dbgln("GUI::InputBox: Cancel button clicked");

View file

@ -78,16 +78,14 @@
@GUI::Widget {} @GUI::Widget {}
@GUI::Button { @GUI::DialogButton {
text: "OK" text: "OK"
name: "ok_button" name: "ok_button"
fixed_width: 75
} }
@GUI::Button { @GUI::DialogButton {
text: "Cancel" text: "Cancel"
name: "cancel_button" 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); button_container->layout()->set_spacing(6);
if (show_defaults_button == ShowDefaultsButton::Yes) { if (show_defaults_button == ShowDefaultsButton::Yes) {
window->m_reset_button = TRY(button_container->try_add<GUI::Button>("Defaults")); window->m_reset_button = TRY(button_container->try_add<GUI::DialogButton>("Defaults"));
window->m_reset_button->set_fixed_width(75);
window->m_reset_button->on_click = [window = window->make_weak_ptr<SettingsWindow>()](auto) mutable { window->m_reset_button->on_click = [window = window->make_weak_ptr<SettingsWindow>()](auto) mutable {
window->reset_default_values(); window->reset_default_values();
}; };
@ -55,22 +54,19 @@ ErrorOr<NonnullRefPtr<SettingsWindow>> SettingsWindow::create(String title, Show
TRY(button_container->layout()->try_add_spacer()); TRY(button_container->layout()->try_add_spacer());
window->m_ok_button = TRY(button_container->try_add<GUI::Button>("OK")); window->m_ok_button = TRY(button_container->try_add<GUI::DialogButton>("OK"));
window->m_ok_button->set_fixed_width(75);
window->m_ok_button->on_click = [window = window->make_weak_ptr<SettingsWindow>()](auto) mutable { window->m_ok_button->on_click = [window = window->make_weak_ptr<SettingsWindow>()](auto) mutable {
window->apply_settings(); window->apply_settings();
GUI::Application::the()->quit(); GUI::Application::the()->quit();
}; };
window->m_cancel_button = TRY(button_container->try_add<GUI::Button>("Cancel")); window->m_cancel_button = TRY(button_container->try_add<GUI::DialogButton>("Cancel"));
window->m_cancel_button->set_fixed_width(75);
window->m_cancel_button->on_click = [window = window->make_weak_ptr<SettingsWindow>()](auto) mutable { window->m_cancel_button->on_click = [window = window->make_weak_ptr<SettingsWindow>()](auto) mutable {
window->cancel_settings(); window->cancel_settings();
GUI::Application::the()->quit(); GUI::Application::the()->quit();
}; };
window->m_apply_button = TRY(button_container->try_add<GUI::Button>("Apply")); window->m_apply_button = TRY(button_container->try_add<GUI::DialogButton>("Apply"));
window->m_apply_button->set_fixed_width(75);
window->m_apply_button->on_click = [window = window->make_weak_ptr<SettingsWindow>()](auto) mutable { window->m_apply_button->on_click = [window = window->make_weak_ptr<SettingsWindow>()](auto) mutable {
window->apply_settings(); 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()->set_spacing(0);
nav_container_widget.layout()->add_spacer(); nav_container_widget.layout()->add_spacer();
m_back_button = nav_container_widget.add<Button>("< Back"); m_back_button = nav_container_widget.add<DialogButton>("< Back");
m_back_button->set_fixed_width(75);
m_back_button->on_click = [&](auto) { m_back_button->on_click = [&](auto) {
pop_page(); pop_page();
}; };
m_next_button = nav_container_widget.add<Button>("Next >"); m_next_button = nav_container_widget.add<DialogButton>("Next >");
m_next_button->set_fixed_width(75);
m_next_button->on_click = [&](auto) { m_next_button->on_click = [&](auto) {
VERIFY(has_pages()); VERIFY(has_pages());
@ -70,8 +68,7 @@ WizardDialog::WizardDialog(Window* parent_window)
auto& button_spacer = nav_container_widget.add<Widget>(); auto& button_spacer = nav_container_widget.add<Widget>();
button_spacer.set_fixed_width(10); button_spacer.set_fixed_width(10);
m_cancel_button = nav_container_widget.add<Button>("Cancel"); m_cancel_button = nav_container_widget.add<DialogButton>("Cancel");
m_cancel_button->set_fixed_width(75);
m_cancel_button->on_click = [&](auto) { m_cancel_button->on_click = [&](auto) {
handle_cancel(); handle_cancel();
}; };