GApplication.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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 CEventLoop;
  7. class GAction;
  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_create_window(Badge<GWindow>);
  28. void did_delete_last_window(Badge<GWindow>);
  29. const String& invoked_as() const { return m_invoked_as; }
  30. const Vector<String>& args() const { return m_args; }
  31. private:
  32. OwnPtr<CEventLoop> m_event_loop;
  33. OwnPtr<GMenuBar> m_menubar;
  34. HashMap<GShortcut, GAction*> m_global_shortcut_actions;
  35. class TooltipWindow;
  36. TooltipWindow* m_tooltip_window { nullptr };
  37. bool m_quit_when_last_window_deleted { true };
  38. String m_invoked_as;
  39. Vector<String> m_args;
  40. };