GApplication.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #pragma once
  2. #include <AK/Badge.h>
  3. #include <AK/HashMap.h>
  4. #include <AK/OwnPtr.h>
  5. #include <LibGUI/GShortcut.h>
  6. class GAction;
  7. class GEventLoop;
  8. class GKeyEvent;
  9. class GMenuBar;
  10. class GWindow;
  11. class Point;
  12. class GApplication {
  13. public:
  14. static GApplication& the();
  15. GApplication(int argc, char** argv);
  16. ~GApplication();
  17. int exec();
  18. void quit(int = 0);
  19. void set_menubar(OwnPtr<GMenuBar>&&);
  20. GAction* action_for_key_event(const GKeyEvent&);
  21. void register_global_shortcut_action(Badge<GAction>, GAction&);
  22. void unregister_global_shortcut_action(Badge<GAction>, GAction&);
  23. void show_tooltip(const StringView&, const Point& screen_location);
  24. void hide_tooltip();
  25. bool quit_when_last_window_deleted() const { return m_quit_when_last_window_deleted; }
  26. void set_quit_when_last_window_deleted(bool b) { m_quit_when_last_window_deleted = b; }
  27. void did_delete_last_window(Badge<GWindow>);
  28. private:
  29. OwnPtr<GEventLoop> m_event_loop;
  30. OwnPtr<GMenuBar> m_menubar;
  31. HashMap<GShortcut, GAction*> m_global_shortcut_actions;
  32. class TooltipWindow;
  33. TooltipWindow* m_tooltip_window { nullptr };
  34. bool m_quit_when_last_window_deleted { true };
  35. };