mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 14:28:12 +00:00
LibGUI: Convert GStatusBar to ObjectPtr
This commit is contained in:
parent
f4531c976c
commit
3476a63415
5 changed files with 12 additions and 8 deletions
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
|
||||
|
|
|
@ -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&) {
|
||||
|
|
|
@ -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 };
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue