mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:57:35 +00:00
CatDog: Remove global menu and add context menu
There was no way to close catdog since it relied on global menus, this adds a context menu for opening the about dialog and quitting. Fixes #7252
This commit is contained in:
parent
9c963fa17b
commit
e5367c13d8
3 changed files with 18 additions and 9 deletions
|
@ -53,15 +53,10 @@ int main(int argc, char** argv)
|
|||
catdog_widget.set_layout<GUI::VerticalBoxLayout>();
|
||||
catdog_widget.layout()->set_spacing(0);
|
||||
|
||||
auto menubar = GUI::Menubar::construct();
|
||||
|
||||
auto& file_menu = menubar->add_menu("&File");
|
||||
file_menu.add_action(GUI::CommonActions::make_quit_action([&](auto&) { app->quit(); }));
|
||||
|
||||
auto& help_menu = menubar->add_menu("&Help");
|
||||
help_menu.add_action(GUI::CommonActions::make_about_action("CatDog Demo", app_icon, window));
|
||||
|
||||
window->set_menubar(move(menubar));
|
||||
auto context_menu = GUI::Menu::construct();
|
||||
context_menu->add_action(GUI::CommonActions::make_about_action("CatDog Demo", app_icon, window));
|
||||
context_menu->add_separator();
|
||||
context_menu->add_action(GUI::CommonActions::make_quit_action([&](auto&) { app->quit(); }));
|
||||
|
||||
window->show();
|
||||
catdog_widget.track_cursor_globally();
|
||||
|
@ -106,5 +101,9 @@ int main(int argc, char** argv)
|
|||
advice_timer->start();
|
||||
};
|
||||
|
||||
catdog_widget.on_context_menu_request = [&](GUI::ContextMenuEvent event) {
|
||||
context_menu->popup(event.screen_position());
|
||||
};
|
||||
|
||||
return app->exec();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue