1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 02:07:36 +00:00

LibGUI: Make GMenu inherit from CObject

This is primarily to make it possible to pass a GMenu* where a CObject*
is expected.
This commit is contained in:
Andreas Kling 2019-12-09 21:05:28 +01:00
parent e9dda8d592
commit fd5eb79d19
39 changed files with 88 additions and 86 deletions

View file

@ -48,7 +48,7 @@ void EraseTool::on_mousemove(GMouseEvent& event)
void EraseTool::on_contextmenu(GContextMenuEvent& event)
{
if (!m_context_menu) {
m_context_menu = make<GMenu>();
m_context_menu = GMenu::construct();
NonnullRefPtr<GAction> eraser_color_toggler = GAction::create("Use secondary color", [&](GAction& action) {
bool toggled = !m_use_secondary_color;

View file

@ -18,7 +18,7 @@ private:
Color get_color() const;
virtual const char* class_name() const override { return "EraseTool"; }
Rect build_rect(const Point& pos, const Rect& widget_rect);
OwnPtr<GMenu> m_context_menu;
RefPtr<GMenu> m_context_menu;
bool m_use_secondary_color { true };
int m_thickness { 1 };

View file

@ -70,7 +70,7 @@ void LineTool::on_keydown(GKeyEvent& event)
void LineTool::on_contextmenu(GContextMenuEvent& event)
{
if (!m_context_menu) {
m_context_menu = make<GMenu>();
m_context_menu = GMenu::construct();
m_context_menu->add_action(GAction::create("1", [this](auto&) {
m_thickness = 1;
}));

View file

@ -23,6 +23,6 @@ private:
GMouseButton m_drawing_button { GMouseButton::None };
Point m_line_start_position;
Point m_line_end_position;
OwnPtr<GMenu> m_context_menu;
RefPtr<GMenu> m_context_menu;
int m_thickness { 1 };
};

View file

@ -50,7 +50,7 @@ void PenTool::on_mousemove(GMouseEvent& event)
void PenTool::on_contextmenu(GContextMenuEvent& event)
{
if (!m_context_menu) {
m_context_menu = make<GMenu>();
m_context_menu = GMenu::construct();
m_context_menu->add_action(GAction::create("1", [this](auto&) {
m_thickness = 1;
}));

View file

@ -19,6 +19,6 @@ private:
virtual const char* class_name() const override { return "PenTool"; }
Point m_last_drawing_event_position { -1, -1 };
OwnPtr<GMenu> m_context_menu;
RefPtr<GMenu> m_context_menu;
int m_thickness { 1 };
};

View file

@ -76,7 +76,7 @@ void SprayTool::on_mouseup(GMouseEvent&)
void SprayTool::on_contextmenu(GContextMenuEvent& event)
{
if (!m_context_menu) {
m_context_menu = make<GMenu>();
m_context_menu = GMenu::construct();
m_context_menu->add_action(GAction::create("1", [this](auto&) {
m_thickness = 1;
}));

View file

@ -22,6 +22,6 @@ private:
RefPtr<CTimer> m_timer;
Point m_last_pos;
Color m_color;
OwnPtr<GMenu> m_context_menu;
RefPtr<GMenu> m_context_menu;
int m_thickness { 1 };
};

View file

@ -39,7 +39,7 @@ int main(int argc, char** argv)
window->show();
auto menubar = make<GMenuBar>();
auto app_menu = make<GMenu>("PaintBrush");
auto app_menu = GMenu::construct("PaintBrush");
app_menu->add_action(GCommonActions::make_open_action([&](auto&) {
Optional<String> open_path = GFilePicker::get_open_filepath();
@ -62,10 +62,10 @@ int main(int argc, char** argv)
menubar->add_menu(move(app_menu));
auto edit_menu = make<GMenu>("Edit");
auto edit_menu = GMenu::construct("Edit");
menubar->add_menu(move(edit_menu));
auto help_menu = make<GMenu>("Help");
auto help_menu = GMenu::construct("Help");
help_menu->add_action(GAction::create("About", [&](auto&) {
GAboutDialog::show("PaintBrush", load_png("/res/icons/32x32/app-paintbrush.png"), window);
}));