2020-04-06 11:09:01 +02:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-04-06 11:09:01 +02:00
|
|
|
*/
|
|
|
|
|
|
2020-02-16 19:28:08 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <LibCore/Object.h>
|
2020-03-29 19:04:05 +02:00
|
|
|
#include <LibGfx/Bitmap.h>
|
2020-02-16 19:28:08 +01:00
|
|
|
|
|
|
|
|
namespace GUI {
|
2021-03-11 14:21:06 -06:00
|
|
|
|
2022-02-25 13:09:27 +02:00
|
|
|
class ConnectionToNotificationServer;
|
2020-02-16 19:28:08 +01:00
|
|
|
|
|
|
|
|
class Notification : public Core::Object {
|
|
|
|
|
C_OBJECT(Notification);
|
|
|
|
|
|
2022-02-25 13:09:27 +02:00
|
|
|
friend class ConnectionToNotificationServer;
|
2021-03-13 15:51:33 -06:00
|
|
|
|
2020-02-16 19:28:08 +01:00
|
|
|
public:
|
|
|
|
|
virtual ~Notification() override;
|
|
|
|
|
|
2022-04-01 20:58:27 +03:00
|
|
|
String const& text() const { return m_text; }
|
|
|
|
|
void set_text(String const& text)
|
2021-03-11 15:43:01 -06:00
|
|
|
{
|
|
|
|
|
m_text_dirty = true;
|
|
|
|
|
m_text = text;
|
|
|
|
|
}
|
2020-02-16 19:28:08 +01:00
|
|
|
|
2022-04-01 20:58:27 +03:00
|
|
|
String const& title() const { return m_title; }
|
|
|
|
|
void set_title(String const& title)
|
2021-03-11 15:43:01 -06:00
|
|
|
{
|
|
|
|
|
m_title_dirty = true;
|
|
|
|
|
m_title = title;
|
|
|
|
|
}
|
2020-02-16 19:28:08 +01:00
|
|
|
|
2022-04-01 20:58:27 +03:00
|
|
|
Gfx::Bitmap const* icon() const { return m_icon; }
|
|
|
|
|
void set_icon(Gfx::Bitmap const* icon)
|
2021-03-11 15:43:01 -06:00
|
|
|
{
|
|
|
|
|
m_icon_dirty = true;
|
|
|
|
|
m_icon = icon;
|
|
|
|
|
}
|
2020-03-26 20:38:28 +01:00
|
|
|
|
2020-02-16 19:28:08 +01:00
|
|
|
void show();
|
2021-03-11 15:43:01 -06:00
|
|
|
bool update();
|
2021-03-11 14:21:06 -06:00
|
|
|
void close();
|
2020-02-16 19:28:08 +01:00
|
|
|
|
2021-03-13 15:51:33 -06:00
|
|
|
bool is_showing() const { return m_shown && !m_destroyed; }
|
|
|
|
|
|
2020-02-16 19:28:08 +01:00
|
|
|
private:
|
|
|
|
|
Notification();
|
|
|
|
|
|
2021-03-13 15:51:33 -06:00
|
|
|
void connection_closed();
|
|
|
|
|
|
2020-02-16 19:28:08 +01:00
|
|
|
String m_title;
|
2021-03-11 15:43:01 -06:00
|
|
|
bool m_title_dirty;
|
2020-02-16 19:28:08 +01:00
|
|
|
String m_text;
|
2021-03-11 15:43:01 -06:00
|
|
|
bool m_text_dirty;
|
2020-03-29 19:04:05 +02:00
|
|
|
RefPtr<Gfx::Bitmap> m_icon;
|
2021-03-11 15:43:01 -06:00
|
|
|
bool m_icon_dirty;
|
2021-03-11 13:37:26 -06:00
|
|
|
|
2021-03-13 15:51:33 -06:00
|
|
|
bool m_destroyed { false };
|
|
|
|
|
bool m_shown { false };
|
2022-02-25 13:09:27 +02:00
|
|
|
RefPtr<ConnectionToNotificationServer> m_connection;
|
2020-02-16 19:28:08 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|