1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-23 19:47:42 +00:00

LibGUI: Convert GProgressBar to ObjectPtr

This commit is contained in:
Andreas Kling 2019-09-21 16:31:12 +02:00
parent 3476a63415
commit ceb5508fea
4 changed files with 7 additions and 5 deletions

View file

@ -68,7 +68,7 @@ int main(int argc, char** argv)
auto statusbar = GStatusBar::construct(widget); auto statusbar = GStatusBar::construct(widget);
auto* progressbar = new GProgressBar(statusbar); auto progressbar = GProgressBar::construct(statusbar);
progressbar->set_caption("Generating thumbnails: "); progressbar->set_caption("Generating thumbnails: ");
progressbar->set_format(GProgressBar::Format::ValueSlashMax); progressbar->set_format(GProgressBar::Format::ValueSlashMax);
progressbar->set_visible(false); progressbar->set_visible(false);

View file

@ -43,8 +43,8 @@ int main(int argc, char** argv)
auto* button2 = new GButton("GButton 2", main_widget); auto* button2 = new GButton("GButton 2", main_widget);
button2->set_enabled(false); button2->set_enabled(false);
auto* progress1 = new GProgressBar(main_widget); auto progress1 = GProgressBar::construct(main_widget);
auto timer = CTimer::create(100, [progress1] { auto timer = CTimer::create(100, [&] {
progress1->set_value(progress1->value() + 1); progress1->set_value(progress1->value() + 1);
if (progress1->value() == progress1->max()) if (progress1->value() == progress1->max())
progress1->set_value(progress1->min()); progress1->set_value(progress1->min());

View file

@ -100,7 +100,7 @@ static GWidget* build_gwidget(VBWidgetType type, GWidget* parent)
return editor; return editor;
} }
case VBWidgetType::GProgressBar: { case VBWidgetType::GProgressBar: {
auto* bar = new GProgressBar(parent); auto bar = GProgressBar::construct(parent);
bar->set_format(GProgressBar::Format::NoText); bar->set_format(GProgressBar::Format::NoText);
bar->set_range(0, 100); bar->set_range(0, 100);
bar->set_value(50); bar->set_value(50);

View file

@ -3,8 +3,8 @@
#include <LibGUI/GFrame.h> #include <LibGUI/GFrame.h>
class GProgressBar : public GFrame { class GProgressBar : public GFrame {
C_OBJECT(GProgressBar)
public: public:
explicit GProgressBar(GWidget* parent);
virtual ~GProgressBar() override; virtual ~GProgressBar() override;
void set_range(int min, int max); void set_range(int min, int max);
@ -28,6 +28,8 @@ public:
void set_format(Format format) { m_format = format; } void set_format(Format format) { m_format = format; }
protected: protected:
explicit GProgressBar(GWidget* parent);
virtual void paint_event(GPaintEvent&) override; virtual void paint_event(GPaintEvent&) override;
private: private: