mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 02:47:35 +00:00
Userspace: Use Core::Object::add() when building interfaces
This commit is contained in:
parent
7ec758773c
commit
3d20da9ee4
87 changed files with 403 additions and 438 deletions
|
@ -52,9 +52,9 @@ PropertiesDialog::PropertiesDialog(GUI::FileSystemModel& model, String path, boo
|
|||
set_rect({ 0, 0, 360, 420 });
|
||||
set_resizable(false);
|
||||
|
||||
auto tab_widget = GUI::TabWidget::construct(main_widget);
|
||||
auto tab_widget = main_widget->add<GUI::TabWidget>();
|
||||
|
||||
auto general_tab = GUI::Widget::construct(tab_widget.ptr());
|
||||
auto general_tab = tab_widget->add<GUI::Widget>();
|
||||
general_tab->set_layout(make<GUI::VerticalBoxLayout>());
|
||||
general_tab->layout()->set_margins({ 12, 8, 12, 8 });
|
||||
general_tab->layout()->set_spacing(10);
|
||||
|
@ -62,19 +62,19 @@ PropertiesDialog::PropertiesDialog(GUI::FileSystemModel& model, String path, boo
|
|||
|
||||
general_tab->layout()->add_spacer();
|
||||
|
||||
auto file_container = GUI::Widget::construct(general_tab.ptr());
|
||||
auto file_container = general_tab->add<GUI::Widget>();
|
||||
file_container->set_layout(make<GUI::HorizontalBoxLayout>());
|
||||
file_container->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||
file_container->layout()->set_spacing(20);
|
||||
file_container->set_preferred_size(0, 34);
|
||||
|
||||
m_icon = GUI::Label::construct(file_container);
|
||||
m_icon = file_container->add<GUI::Label>();
|
||||
m_icon->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed);
|
||||
m_icon->set_preferred_size(32, 32);
|
||||
|
||||
m_name = file_path.basename();
|
||||
|
||||
m_name_box = GUI::TextBox::construct(file_container);
|
||||
m_name_box = file_container->add<GUI::TextBox>();
|
||||
m_name_box->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||
m_name_box->set_preferred_size({ 0, 22 });
|
||||
m_name_box->set_text(m_name);
|
||||
|
@ -132,7 +132,7 @@ PropertiesDialog::PropertiesDialog(GUI::FileSystemModel& model, String path, boo
|
|||
|
||||
general_tab->layout()->add_spacer();
|
||||
|
||||
auto button_widget = GUI::Widget::construct(main_widget.ptr());
|
||||
auto button_widget = main_widget->add<GUI::Widget>();
|
||||
button_widget->set_layout(make<GUI::HorizontalBoxLayout>());
|
||||
button_widget->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||
button_widget->set_preferred_size(0, 24);
|
||||
|
@ -212,24 +212,24 @@ bool PropertiesDialog::apply_changes()
|
|||
|
||||
void PropertiesDialog::make_permission_checkboxes(NonnullRefPtr<GUI::Widget>& parent, PermissionMasks masks, String label_string, mode_t mode)
|
||||
{
|
||||
auto widget = GUI::Widget::construct(parent.ptr());
|
||||
auto widget = parent->add<GUI::Widget>();
|
||||
widget->set_layout(make<GUI::HorizontalBoxLayout>());
|
||||
widget->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||
widget->set_preferred_size(0, 16);
|
||||
widget->layout()->set_spacing(10);
|
||||
|
||||
auto label = GUI::Label::construct(label_string, widget);
|
||||
auto label = widget->add<GUI::Label>(label_string);
|
||||
label->set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
||||
|
||||
auto box_read = GUI::CheckBox::construct("Read", widget);
|
||||
auto box_read = widget->add<GUI::CheckBox>("Read");
|
||||
box_read->set_checked(mode & masks.read);
|
||||
box_read->on_checked = [&, masks](bool checked) { permission_changed(masks.read, checked); };
|
||||
|
||||
auto box_write = GUI::CheckBox::construct("Write", widget);
|
||||
auto box_write = widget->add<GUI::CheckBox>("Write");
|
||||
box_write->set_checked(mode & masks.write);
|
||||
box_write->on_checked = [&, masks](bool checked) { permission_changed(masks.write, checked); };
|
||||
|
||||
auto box_execute = GUI::CheckBox::construct("Execute", widget);
|
||||
auto box_execute = widget->add<GUI::CheckBox>("Execute");
|
||||
box_execute->set_checked(mode & masks.execute);
|
||||
box_execute->on_checked = [&, masks](bool checked) { permission_changed(masks.execute, checked); };
|
||||
}
|
||||
|
@ -241,17 +241,17 @@ void PropertiesDialog::make_property_value_pairs(const Vector<PropertyValuePair>
|
|||
|
||||
property_labels.ensure_capacity(pairs.size());
|
||||
for (auto pair : pairs) {
|
||||
auto label_container = GUI::Widget::construct(parent.ptr());
|
||||
auto label_container = parent->add<GUI::Widget>();
|
||||
label_container->set_layout(make<GUI::HorizontalBoxLayout>());
|
||||
label_container->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||
label_container->set_preferred_size(0, 14);
|
||||
label_container->layout()->set_spacing(12);
|
||||
|
||||
auto label_property = GUI::Label::construct(pair.property, label_container);
|
||||
auto label_property = label_container->add<GUI::Label>(pair.property);
|
||||
label_property->set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
||||
label_property->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill);
|
||||
|
||||
GUI::Label::construct(pair.value, label_container)->set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
||||
label_container->add<GUI::Label>(pair.value)->set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
||||
|
||||
max_width = max(max_width, label_property->font().width(pair.property));
|
||||
property_labels.append(label_property);
|
||||
|
@ -263,7 +263,7 @@ void PropertiesDialog::make_property_value_pairs(const Vector<PropertyValuePair>
|
|||
|
||||
NonnullRefPtr<GUI::Button> PropertiesDialog::make_button(String text, NonnullRefPtr<GUI::Widget>& parent)
|
||||
{
|
||||
auto button = GUI::Button::construct(text, parent.ptr());
|
||||
auto button = parent->add<GUI::Button>(text);
|
||||
button->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed);
|
||||
button->set_preferred_size(70, 22);
|
||||
return button;
|
||||
|
@ -273,7 +273,7 @@ void PropertiesDialog::make_divider(NonnullRefPtr<GUI::Widget>& parent)
|
|||
{
|
||||
parent->layout()->add_spacer();
|
||||
|
||||
auto divider = GUI::Frame::construct(parent.ptr());
|
||||
auto divider = parent->add<GUI::Frame>();
|
||||
divider->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||
divider->set_preferred_size({ 0, 2 });
|
||||
divider->set_frame_shape(Gfx::FrameShape::HorizontalLine);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue