1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:57:35 +00:00

GButton: Convert most code to using ObjectPtr for GButton

This commit is contained in:
Andreas Kling 2019-09-21 19:28:28 +02:00
parent 55a6e4ac0b
commit 45cfd57f6e
20 changed files with 38 additions and 38 deletions

View file

@ -51,7 +51,7 @@ GAboutDialog::GAboutDialog(const StringView& name, const GraphicsBitmap* icon, C
button_container->set_preferred_size(0, 20);
button_container->set_layout(make<GBoxLayout>(Orientation::Horizontal));
button_container->layout()->add_spacer();
auto* ok_button = new GButton("OK", button_container);
auto ok_button = GButton::construct("OK", button_container);
ok_button->set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed);
ok_button->set_preferred_size(80, 20);
ok_button->on_click = [this](auto&) {

View file

@ -18,7 +18,7 @@ GComboBox::GComboBox(GWidget* parent)
if (on_return_pressed)
on_return_pressed();
};
m_open_button = new GButton(this);
m_open_button = GButton::construct(this);
m_open_button->set_focusable(false);
m_open_button->set_text("\xc3\xb7");
m_open_button->on_click = [this](auto&) {

View file

@ -37,7 +37,7 @@ protected:
private:
ObjectPtr<GTextEditor> m_editor;
GButton* m_open_button { nullptr };
ObjectPtr<GButton> m_open_button;
ObjectPtr<GWindow> m_list_window;
ObjectPtr<GListView> m_list_view;
bool m_only_allow_values_from_model { false };

View file

@ -162,7 +162,7 @@ GFilePicker::GFilePicker(Mode mode, const StringView& file_name, const StringVie
button_container->layout()->set_spacing(4);
button_container->layout()->add_spacer();
auto* cancel_button = new GButton(button_container);
auto cancel_button = GButton::construct(button_container);
cancel_button->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
cancel_button->set_preferred_size(80, 0);
cancel_button->set_text("Cancel");
@ -170,7 +170,7 @@ GFilePicker::GFilePicker(Mode mode, const StringView& file_name, const StringVie
done(ExecCancel);
};
auto* ok_button = new GButton(button_container);
auto ok_button = GButton::construct(button_container);
ok_button->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
ok_button->set_preferred_size(80, 0);
ok_button->set_text(ok_button_name(m_mode));

View file

@ -51,7 +51,7 @@ void GInputBox::build()
button_container_inner->set_layout(make<GBoxLayout>(Orientation::Horizontal));
button_container_inner->layout()->set_spacing(8);
m_cancel_button = new GButton(button_container_inner);
m_cancel_button = GButton::construct(button_container_inner);
m_cancel_button->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
m_cancel_button->set_preferred_size(0, 20);
m_cancel_button->set_text("Cancel");
@ -60,7 +60,7 @@ void GInputBox::build()
done(ExecCancel);
};
m_ok_button = new GButton(button_container_inner);
m_ok_button = GButton::construct(button_container_inner);
m_ok_button->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
m_ok_button->set_preferred_size(0, 20);
m_ok_button->set_text("OK");

View file

@ -18,7 +18,7 @@ private:
String m_prompt;
String m_text_value;
GButton* m_ok_button { nullptr };
GButton* m_cancel_button { nullptr };
ObjectPtr<GButton> m_ok_button;
ObjectPtr<GButton> m_cancel_button;
ObjectPtr<GTextEditor> m_text_editor;
};

View file

@ -86,7 +86,7 @@ void GMessageBox::build()
button_container->layout()->set_margins({ 15, 0, 15, 0 });
if (should_include_ok_button()) {
auto* ok_button = new GButton(button_container);
auto ok_button = GButton::construct(button_container);
ok_button->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
ok_button->set_preferred_size(0, 20);
ok_button->set_text("OK");
@ -97,7 +97,7 @@ void GMessageBox::build()
}
if (should_include_cancel_button()) {
auto* cancel_button = new GButton(button_container);
auto cancel_button = GButton::construct(button_container);
cancel_button->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
cancel_button->set_preferred_size(0, 20);
cancel_button->set_text("Cancel");

View file

@ -15,12 +15,12 @@ GSpinBox::GSpinBox(GWidget* parent)
else
m_editor->set_text(String::number(m_value));
};
m_increment_button = new GButton(this);
m_increment_button = GButton::construct(this);
m_increment_button->set_focusable(false);
m_increment_button->set_text("\xc3\xb6");
m_increment_button->on_click = [this](GButton&) { set_value(m_value + 1); };
m_increment_button->set_auto_repeat_interval(150);
m_decrement_button = new GButton(this);
m_decrement_button = GButton::construct(this);
m_decrement_button->set_focusable(false);
m_decrement_button->set_text("\xc3\xb7");
m_decrement_button->on_click = [this](GButton&) { set_value(m_value - 1); };

View file

@ -28,8 +28,8 @@ protected:
private:
ObjectPtr<GTextEditor> m_editor;
GButton* m_increment_button { nullptr };
GButton* m_decrement_button { nullptr };
ObjectPtr<GButton> m_increment_button;
ObjectPtr<GButton> m_decrement_button;
int m_min { 0 };
int m_max { 100 };

View file

@ -24,7 +24,7 @@ void GToolBar::add_action(GAction& action)
item->type = Item::Action;
item->action = action;
auto* button = new GButton(this);
auto button = GButton::construct(this);
button->set_action(*item->action);
button->set_tooltip(item->action->text());
if (item->action->icon())