mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:17:36 +00:00
LibGUI: Convert GLabel to ObjectPtr
This commit is contained in:
parent
6b347747f2
commit
c7437f9caa
22 changed files with 47 additions and 45 deletions
|
@ -24,12 +24,12 @@ int main(int argc, char** argv)
|
|||
widget->layout()->set_margins({ 0, 8, 0, 8 });
|
||||
widget->layout()->set_spacing(8);
|
||||
|
||||
auto* icon_label = new GLabel(widget);
|
||||
auto icon_label = GLabel::construct(widget);
|
||||
icon_label->set_icon(GraphicsBitmap::load_from_file("/res/icons/serenity.png"));
|
||||
icon_label->set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed);
|
||||
icon_label->set_preferred_size(icon_label->icon()->size());
|
||||
|
||||
auto* label = new GLabel(widget);
|
||||
auto label = GLabel::construct(widget);
|
||||
label->set_font(Font::default_bold_font());
|
||||
label->set_text("Serenity Operating System");
|
||||
label->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
|
@ -39,7 +39,7 @@ int main(int argc, char** argv)
|
|||
int rc = uname(&uts);
|
||||
ASSERT(rc == 0);
|
||||
|
||||
auto* version_label = new GLabel(widget);
|
||||
auto version_label = GLabel::construct(widget);
|
||||
version_label->set_text(String::format("Version %s", uts.release));
|
||||
version_label->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
version_label->set_preferred_size(0, 11);
|
||||
|
|
|
@ -13,7 +13,7 @@ CalculatorWidget::CalculatorWidget(GWidget* parent)
|
|||
m_entry->set_relative_rect(5, 5, 244, 26);
|
||||
m_entry->set_text_alignment(TextAlignment::CenterRight);
|
||||
|
||||
m_label = new GLabel(this);
|
||||
m_label = GLabel::construct(this);
|
||||
m_label->set_relative_rect(12, 42, 27, 27);
|
||||
m_label->set_foreground_color(Color::NamedColor::Red);
|
||||
m_label->set_frame_shadow(FrameShadow::Sunken);
|
||||
|
|
|
@ -26,5 +26,5 @@ private:
|
|||
Keypad m_keypad;
|
||||
|
||||
GTextBox* m_entry { nullptr };
|
||||
GLabel* m_label { nullptr };
|
||||
ObjectPtr<GLabel> m_label;
|
||||
};
|
||||
|
|
|
@ -101,19 +101,19 @@ void DisplayPropertiesWidget::create_frame()
|
|||
background_content->set_layout(make<GBoxLayout>(Orientation::Vertical));
|
||||
background_content->layout()->set_margins({ 4, 4, 4, 4 });
|
||||
|
||||
auto* wallpaper_preview = new GLabel(background_splitter);
|
||||
m_wallpaper_preview = GLabel::construct(background_splitter);
|
||||
|
||||
auto* wallpaper_list = new GListView(background_content);
|
||||
wallpaper_list->set_background_color(Color::White);
|
||||
wallpaper_list->set_model(*ItemListModel<AK::String>::create(m_wallpapers));
|
||||
wallpaper_list->horizontal_scrollbar().set_visible(false);
|
||||
wallpaper_list->on_selection = [this, wallpaper_preview](auto& index) {
|
||||
wallpaper_list->on_selection = [this](auto& index) {
|
||||
StringBuilder builder;
|
||||
m_selected_wallpaper = m_wallpapers.at(index.row());
|
||||
builder.append("/res/wallpapers/");
|
||||
builder.append(m_selected_wallpaper);
|
||||
wallpaper_preview->set_icon(load_png(builder.to_string()));
|
||||
wallpaper_preview->set_should_stretch_icon(true);
|
||||
m_wallpaper_preview->set_icon(load_png(builder.to_string()));
|
||||
m_wallpaper_preview->set_should_stretch_icon(true);
|
||||
};
|
||||
|
||||
// Let's add the settings tab
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <LibDraw/Color.h>
|
||||
#include <LibDraw/Size.h>
|
||||
#include <LibGUI/GWidget.h>
|
||||
#include <LibGUI/GLabel.h>
|
||||
|
||||
class DisplayPropertiesWidget final {
|
||||
public:
|
||||
|
@ -41,6 +42,7 @@ private:
|
|||
GWidget* m_root_widget { nullptr };
|
||||
Vector<Size> m_resolutions;
|
||||
Vector<String> m_wallpapers;
|
||||
ObjectPtr<GLabel> m_wallpaper_preview;
|
||||
|
||||
Size m_selected_resolution;
|
||||
String m_selected_wallpaper;
|
||||
|
|
|
@ -53,7 +53,7 @@ int main(int argc, char** argv)
|
|||
location_toolbar->layout()->set_margins({ 6, 3, 6, 3 });
|
||||
location_toolbar->set_preferred_size(0, 25);
|
||||
|
||||
auto* location_label = new GLabel("Location: ", location_toolbar);
|
||||
auto location_label = GLabel::construct("Location: ", location_toolbar);
|
||||
location_label->size_to_fit();
|
||||
|
||||
auto* location_textbox = new GTextEditor(GTextEditor::SingleLine, location_toolbar);
|
||||
|
|
|
@ -22,15 +22,15 @@ MemoryStatsWidget::MemoryStatsWidget(GraphWidget& graph, GWidget* parent)
|
|||
layout()->set_margins({ 0, 8, 0, 0 });
|
||||
layout()->set_spacing(3);
|
||||
|
||||
auto build_widgets_for_label = [this](const String& description) -> GLabel* {
|
||||
auto build_widgets_for_label = [this](const String& description) -> ObjectPtr<GLabel> {
|
||||
auto* container = new GWidget(this);
|
||||
container->set_layout(make<GBoxLayout>(Orientation::Horizontal));
|
||||
container->set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed);
|
||||
container->set_preferred_size(275, 12);
|
||||
auto* description_label = new GLabel(description, container);
|
||||
auto description_label = GLabel::construct(description, container);
|
||||
description_label->set_font(Font::default_bold_font());
|
||||
description_label->set_text_alignment(TextAlignment::CenterLeft);
|
||||
auto* label = new GLabel(container);
|
||||
auto label = GLabel::construct(container);
|
||||
label->set_text_alignment(TextAlignment::CenterRight);
|
||||
return label;
|
||||
};
|
||||
|
|
|
@ -17,9 +17,9 @@ private:
|
|||
virtual void timer_event(CTimerEvent&) override;
|
||||
|
||||
GraphWidget& m_graph;
|
||||
GLabel* m_user_physical_pages_label { nullptr };
|
||||
GLabel* m_supervisor_physical_pages_label { nullptr };
|
||||
GLabel* m_kmalloc_label { nullptr };
|
||||
GLabel* m_kmalloc_count_label { nullptr };
|
||||
ObjectPtr<GLabel> m_user_physical_pages_label;
|
||||
ObjectPtr<GLabel> m_supervisor_physical_pages_label;
|
||||
ObjectPtr<GLabel> m_kmalloc_label;
|
||||
ObjectPtr<GLabel> m_kmalloc_count_label;
|
||||
CFile m_proc_memstat;
|
||||
};
|
||||
|
|
|
@ -69,7 +69,7 @@ int main(int argc, char** argv)
|
|||
window->set_resizable(true);
|
||||
window->set_rect(window_rect);
|
||||
|
||||
auto* background = new GLabel;
|
||||
auto background = GLabel::construct();
|
||||
window->set_main_widget(background);
|
||||
background->set_fill_with_background_color(true);
|
||||
background->set_layout(make<GBoxLayout>(Orientation::Vertical));
|
||||
|
@ -83,7 +83,7 @@ int main(int argc, char** argv)
|
|||
// header
|
||||
//
|
||||
|
||||
auto* header = new GLabel(background);
|
||||
auto header = GLabel::construct(background);
|
||||
header->set_font(Font::default_bold_font());
|
||||
header->set_text("Welcome to Serenity");
|
||||
header->set_text_alignment(TextAlignment::CenterLeft);
|
||||
|
@ -117,7 +117,7 @@ int main(int argc, char** argv)
|
|||
content->layout()->set_spacing(8);
|
||||
content->set_size_policy(SizePolicy::Fill, SizePolicy::Fill);
|
||||
|
||||
auto* content_title = new GLabel(content);
|
||||
auto content_title = GLabel::construct(content);
|
||||
content_title->set_font(Font::default_bold_font());
|
||||
content_title->set_text(page.title);
|
||||
content_title->set_text_alignment(TextAlignment::CenterLeft);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue