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