Made a start with the notification system. However need to figure out
how i want to handle multithreading and screen updates.
This commit is contained in:
parent
5494e5076b
commit
7f09d5fe07
7 changed files with 216 additions and 0 deletions
59
pglab/NotificationService.cpp
Normal file
59
pglab/NotificationService.cpp
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
#include "NotificationService.h"
|
||||
|
||||
namespace {
|
||||
|
||||
class registerMetaTypes {
|
||||
public:
|
||||
registerMetaTypes()
|
||||
{
|
||||
qRegisterMetaType<NotificationSeverity>();
|
||||
qRegisterMetaType<Notification>();
|
||||
}
|
||||
} registerMetaTypes_instance;
|
||||
|
||||
}
|
||||
|
||||
std::shared_ptr<NotificationService> NotificationService::s_instance;
|
||||
|
||||
std::shared_ptr<NotificationService> NotificationService::instance()
|
||||
{
|
||||
if (!s_instance) {
|
||||
s_instance = std::make_shared<NotificationService>();
|
||||
}
|
||||
return s_instance;
|
||||
}
|
||||
|
||||
NotificationService::NotificationService()
|
||||
{
|
||||
}
|
||||
|
||||
void NotificationService::addInformational(const QString &msg, const QString &detail)
|
||||
{
|
||||
add(NotificationSeverity::Informational, msg, detail);
|
||||
}
|
||||
|
||||
void NotificationService::addWarning(const QString &msg, const QString &detail)
|
||||
{
|
||||
add(NotificationSeverity::Warning, msg, detail);
|
||||
}
|
||||
|
||||
void NotificationService::addError(const QString &msg, const QString &detail)
|
||||
{
|
||||
add(NotificationSeverity::Error, msg, detail);
|
||||
}
|
||||
|
||||
void NotificationService::add(NotificationSeverity severity, const QString &msg, const QString &detail)
|
||||
{
|
||||
m_notifications.push_back({ severity, msg, detail });
|
||||
}
|
||||
|
||||
int NotificationService::count() const
|
||||
{
|
||||
return m_notifications.size();
|
||||
}
|
||||
|
||||
const Notification& NotificationService::notification(int index)
|
||||
{
|
||||
return m_notifications.at(index);
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue