summaryrefslogtreecommitdiff
path: root/Applications
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-09-21 14:19:05 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-09-21 15:25:08 +0200
commitc7437f9caa5485d99e0101bfac98d968e767741f (patch)
tree0268e791f6d419da644eca6fc6789e5429c10848 /Applications
parent6b347747f2f912721bc076fcd4aabb8a4bfa9e98 (diff)
downloadserenity-c7437f9caa5485d99e0101bfac98d968e767741f.zip
LibGUI: Convert GLabel to ObjectPtr
Diffstat (limited to 'Applications')
-rw-r--r--Applications/About/main.cpp6
-rw-r--r--Applications/Calculator/CalculatorWidget.cpp2
-rw-r--r--Applications/Calculator/CalculatorWidget.h2
-rw-r--r--Applications/DisplayProperties/DisplayProperties.cpp8
-rw-r--r--Applications/DisplayProperties/DisplayProperties.h2
-rw-r--r--Applications/FileManager/main.cpp2
-rw-r--r--Applications/SystemMonitor/MemoryStatsWidget.cpp6
-rw-r--r--Applications/SystemMonitor/MemoryStatsWidget.h8
-rw-r--r--Applications/Welcome/main.cpp6
9 files changed, 22 insertions, 20 deletions
diff --git a/Applications/About/main.cpp b/Applications/About/main.cpp
index c948aea0f1..a559505cfc 100644
--- a/Applications/About/main.cpp
+++ b/Applications/About/main.cpp
@@ -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);
diff --git a/Applications/Calculator/CalculatorWidget.cpp b/Applications/Calculator/CalculatorWidget.cpp
index 38070cbe07..3d7e5ffa72 100644
--- a/Applications/Calculator/CalculatorWidget.cpp
+++ b/Applications/Calculator/CalculatorWidget.cpp
@@ -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);
diff --git a/Applications/Calculator/CalculatorWidget.h b/Applications/Calculator/CalculatorWidget.h
index 7ecfec5f0c..e167030cf8 100644
--- a/Applications/Calculator/CalculatorWidget.h
+++ b/Applications/Calculator/CalculatorWidget.h
@@ -26,5 +26,5 @@ private:
Keypad m_keypad;
GTextBox* m_entry { nullptr };
- GLabel* m_label { nullptr };
+ ObjectPtr<GLabel> m_label;
};
diff --git a/Applications/DisplayProperties/DisplayProperties.cpp b/Applications/DisplayProperties/DisplayProperties.cpp
index 12046f5113..a21caba385 100644
--- a/Applications/DisplayProperties/DisplayProperties.cpp
+++ b/Applications/DisplayProperties/DisplayProperties.cpp
@@ -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
diff --git a/Applications/DisplayProperties/DisplayProperties.h b/Applications/DisplayProperties/DisplayProperties.h
index c8c96988f1..afba1930cc 100644
--- a/Applications/DisplayProperties/DisplayProperties.h
+++ b/Applications/DisplayProperties/DisplayProperties.h
@@ -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;
diff --git a/Applications/FileManager/main.cpp b/Applications/FileManager/main.cpp
index debf987652..a89a5b5abf 100644
--- a/Applications/FileManager/main.cpp
+++ b/Applications/FileManager/main.cpp
@@ -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);
diff --git a/Applications/SystemMonitor/MemoryStatsWidget.cpp b/Applications/SystemMonitor/MemoryStatsWidget.cpp
index 6412dba161..b0d1331d61 100644
--- a/Applications/SystemMonitor/MemoryStatsWidget.cpp
+++ b/Applications/SystemMonitor/MemoryStatsWidget.cpp
@@ -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;
};
diff --git a/Applications/SystemMonitor/MemoryStatsWidget.h b/Applications/SystemMonitor/MemoryStatsWidget.h
index e3912b9b94..a7b94ef2c6 100644
--- a/Applications/SystemMonitor/MemoryStatsWidget.h
+++ b/Applications/SystemMonitor/MemoryStatsWidget.h
@@ -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;
};
diff --git a/Applications/Welcome/main.cpp b/Applications/Welcome/main.cpp
index 14a20e3d61..6e4bea273d 100644
--- a/Applications/Welcome/main.cpp
+++ b/Applications/Welcome/main.cpp
@@ -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);