Notification.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibCore/Object.h>
  8. #include <LibGfx/Bitmap.h>
  9. namespace GUI {
  10. class ConnectionToNotificationServer;
  11. class Notification : public Core::Object {
  12. C_OBJECT(Notification);
  13. friend class ConnectionToNotificationServer;
  14. public:
  15. virtual ~Notification() override;
  16. String const& text() const { return m_text; }
  17. void set_text(String const& text)
  18. {
  19. m_text_dirty = true;
  20. m_text = text;
  21. }
  22. String const& title() const { return m_title; }
  23. void set_title(String const& title)
  24. {
  25. m_title_dirty = true;
  26. m_title = title;
  27. }
  28. Gfx::Bitmap const* icon() const { return m_icon; }
  29. void set_icon(Gfx::Bitmap const* icon)
  30. {
  31. m_icon_dirty = true;
  32. m_icon = icon;
  33. }
  34. void show();
  35. bool update();
  36. void close();
  37. bool is_showing() const { return m_shown && !m_destroyed; }
  38. private:
  39. Notification();
  40. void connection_closed();
  41. String m_title;
  42. bool m_title_dirty;
  43. String m_text;
  44. bool m_text_dirty;
  45. RefPtr<Gfx::Bitmap> m_icon;
  46. bool m_icon_dirty;
  47. bool m_destroyed { false };
  48. bool m_shown { false };
  49. RefPtr<ConnectionToNotificationServer> m_connection;
  50. };
  51. }