summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-09-21 16:29:47 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-09-21 16:29:47 +0200
commit3476a634156fa22dbfbecbfc28c29602ee017b0f (patch)
tree15767200c0316df9c5e8ba19de7a24f7529a4f0d
parentf4531c976ce8ea8cceb17d7a75a4635ac5c6ba6f (diff)
downloadserenity-3476a634156fa22dbfbecbfc28c29602ee017b0f.zip
LibGUI: Convert GStatusBar to ObjectPtr
-rw-r--r--Applications/ChanViewer/main.cpp2
-rw-r--r--Applications/FileManager/main.cpp4
-rw-r--r--Applications/TextEditor/TextEditorWidget.cpp6
-rw-r--r--Applications/TextEditor/TextEditorWidget.h3
-rw-r--r--Libraries/LibGUI/GStatusBar.h5
5 files changed, 12 insertions, 8 deletions
diff --git a/Applications/ChanViewer/main.cpp b/Applications/ChanViewer/main.cpp
index 73ecb52c70..625c17d348 100644
--- a/Applications/ChanViewer/main.cpp
+++ b/Applications/ChanViewer/main.cpp
@@ -32,7 +32,7 @@ int main(int argc, char** argv)
catalog_view->set_model(ThreadCatalogModel::create());
auto& catalog_model = *static_cast<ThreadCatalogModel*>(catalog_view->model());
- auto* statusbar = new GStatusBar(widget);
+ auto statusbar = GStatusBar::construct(widget);
board_combo->on_change = [&] (auto&, const GModelIndex& index) {
auto selected_board = board_combo->model()->data(index, GModel::Role::Custom);
diff --git a/Applications/FileManager/main.cpp b/Applications/FileManager/main.cpp
index 6a294e1c31..ae0244b442 100644
--- a/Applications/FileManager/main.cpp
+++ b/Applications/FileManager/main.cpp
@@ -66,7 +66,7 @@ int main(int argc, char** argv)
tree_view->set_preferred_size(200, 0);
auto* directory_view = new DirectoryView(splitter);
- auto* statusbar = new GStatusBar(widget);
+ auto statusbar = GStatusBar::construct(widget);
auto* progressbar = new GProgressBar(statusbar);
progressbar->set_caption("Generating thumbnails: ");
@@ -325,7 +325,7 @@ int main(int argc, char** argv)
go_back_action->set_enabled(directory_view->path_history_position() > 0);
};
- directory_view->on_status_message = [statusbar](const StringView& message) {
+ directory_view->on_status_message = [&](const StringView& message) {
statusbar->set_text(message);
};
diff --git a/Applications/TextEditor/TextEditorWidget.cpp b/Applications/TextEditor/TextEditorWidget.cpp
index d62b4bdb8e..723414a3b1 100644
--- a/Applications/TextEditor/TextEditorWidget.cpp
+++ b/Applications/TextEditor/TextEditorWidget.cpp
@@ -108,12 +108,12 @@ TextEditorWidget::TextEditorWidget()
m_editor->add_custom_context_menu_action(*m_find_next_action);
m_editor->add_custom_context_menu_action(*m_find_previous_action);
- auto* statusbar = new GStatusBar(this);
+ m_statusbar = GStatusBar::construct(this);
- m_editor->on_cursor_change = [statusbar, this] {
+ m_editor->on_cursor_change = [this] {
StringBuilder builder;
builder.appendf("Line: %d, Column: %d", m_editor->cursor().line() + 1, m_editor->cursor().column());
- statusbar->set_text(builder.to_string());
+ m_statusbar->set_text(builder.to_string());
};
m_new_action = GAction::create("New", { Mod_Ctrl, Key_N }, GraphicsBitmap::load_from_file("/res/icons/16x16/new.png"), [this](const GAction&) {
diff --git a/Applications/TextEditor/TextEditorWidget.h b/Applications/TextEditor/TextEditorWidget.h
index 304f92a31e..3d465ea447 100644
--- a/Applications/TextEditor/TextEditorWidget.h
+++ b/Applications/TextEditor/TextEditorWidget.h
@@ -10,6 +10,7 @@
class GButton;
class GTextBox;
class GTextEditor;
+class GStatusBar;
class TextEditorWidget final : public GWidget {
public:
@@ -35,6 +36,8 @@ private:
RefPtr<GAction> m_find_next_action;
RefPtr<GAction> m_find_previous_action;
+ ObjectPtr<GStatusBar> m_statusbar;
+
ObjectPtr<GTextBox> m_find_textbox;
GButton* m_find_previous_button { nullptr };
GButton* m_find_next_button { nullptr };
diff --git a/Libraries/LibGUI/GStatusBar.h b/Libraries/LibGUI/GStatusBar.h
index 90d5f146a4..39ecc812ff 100644
--- a/Libraries/LibGUI/GStatusBar.h
+++ b/Libraries/LibGUI/GStatusBar.h
@@ -8,15 +8,16 @@ class GResizeCorner;
class GStatusBar : public GWidget {
C_OBJECT(GStatusBar)
public:
- explicit GStatusBar(GWidget* parent);
virtual ~GStatusBar() override;
String text() const;
void set_text(const StringView&);
-private:
+protected:
+ explicit GStatusBar(GWidget* parent);
virtual void paint_event(GPaintEvent&) override;
+private:
ObjectPtr<GLabel> m_label;
ObjectPtr<GResizeCorner> m_corner;
};