summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-09-21 18:58:03 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-09-21 18:58:03 +0200
commitf8d751440b15990d0779e8387a32e6bf92c33984 (patch)
tree1f8502530d06c135039c08951c3a607f9bed3c51
parent870bc2a4d1a86b9c889461a3981ee359ff45c15c (diff)
downloadserenity-f8d751440b15990d0779e8387a32e6bf92c33984.zip
LibGUI: Convert GRadioButton to ObjectPtr
-rw-r--r--Applications/Terminal/main.cpp11
-rwxr-xr-xDemos/WidgetGallery/main.cpp4
-rw-r--r--Libraries/LibGUI/GRadioButton.h2
3 files changed, 11 insertions, 6 deletions
diff --git a/Applications/Terminal/main.cpp b/Applications/Terminal/main.cpp
index bec782c3dc..c0a2f0a0ae 100644
--- a/Applications/Terminal/main.cpp
+++ b/Applications/Terminal/main.cpp
@@ -107,8 +107,8 @@ ObjectPtr<GWindow> create_settings_window(TerminalWidget& terminal, RefPtr<CConf
radio_container->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
radio_container->set_preferred_size(100, 70);
- auto* sysbell_radio = new GRadioButton("Use (Audible) System Bell", radio_container);
- auto* visbell_radio = new GRadioButton("Use (Visual) Terminal Bell", radio_container);
+ auto sysbell_radio = GRadioButton::construct("Use (Audible) System Bell", radio_container);
+ auto visbell_radio = GRadioButton::construct("Use (Visual) Terminal Bell", radio_container);
sysbell_radio->set_checked(terminal.should_beep());
visbell_radio->set_checked(!terminal.should_beep());
sysbell_radio->on_checked = [&terminal](const bool checked) {
@@ -181,8 +181,13 @@ int main(int argc, char** argv)
auto app_menu = make<GMenu>("Terminal");
app_menu->add_action(GAction::create("Settings...", load_png("/res/icons/gear16.png"),
[&](const GAction&) {
- if (!settings_window)
+ if (!settings_window) {
settings_window = create_settings_window(*terminal, config);
+ settings_window->on_close_request = [&] {
+ settings_window = nullptr;
+ return GWindow::CloseRequestDecision::Close;
+ };
+ }
settings_window->show();
settings_window->move_to_front();
}));
diff --git a/Demos/WidgetGallery/main.cpp b/Demos/WidgetGallery/main.cpp
index b19fd75a16..8dad129c2d 100755
--- a/Demos/WidgetGallery/main.cpp
+++ b/Demos/WidgetGallery/main.cpp
@@ -33,9 +33,9 @@ int main(int argc, char** argv)
auto* checkbox2 = new GCheckBox("GCheckBox 2", main_widget);
checkbox2->set_enabled(false);
- auto* radio1 = new GRadioButton("GRadioButton 1", main_widget);
+ auto radio1 = GRadioButton::construct("GRadioButton 1", main_widget);
(void)radio1;
- auto* radio2 = new GRadioButton("GRadioButton 2", main_widget);
+ auto radio2 = GRadioButton::construct("GRadioButton 2", main_widget);
radio2->set_enabled(false);
auto* button1 = new GButton("GButton 1", main_widget);
diff --git a/Libraries/LibGUI/GRadioButton.h b/Libraries/LibGUI/GRadioButton.h
index 5a1711386e..9a15c6b57b 100644
--- a/Libraries/LibGUI/GRadioButton.h
+++ b/Libraries/LibGUI/GRadioButton.h
@@ -5,12 +5,12 @@
class GRadioButton : public GAbstractButton {
C_OBJECT(GRadioButton)
public:
- GRadioButton(const StringView& text, GWidget* parent);
virtual ~GRadioButton() override;
virtual void click() override;
protected:
+ GRadioButton(const StringView& text, GWidget* parent);
virtual void paint_event(GPaintEvent&) override;
private: