-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherrorsingleton.h
52 lines (42 loc) · 1.77 KB
/
errorsingleton.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#ifndef ERRORSINGLETON_H
#define ERRORSINGLETON_H
#define DEF_DEBUG 0
#include <QObject>
#include <QDebug>
#include <memory>
#include <QQueue>
#include <QMutexLocker>
#include "notifyenums.h"
// QTimer::singleShot(5000,[](){});
class ErrorSingleton : public QObject
{
Q_OBJECT
Q_PROPERTY(bool notifyBellState READ getNotifyBellState WRITE setNotifyBellState NOTIFY notifyBellStateChanged)
// notifyBellState < - set according to notify bell reaction (QML)
public:
ErrorSingleton(const ErrorSingleton& errSing) = delete;
ErrorSingleton& operator=(const ErrorSingleton& errSing) = delete;
static ErrorSingleton* getInstance();
static void showErrorsQueue();
static ErrorSingleton& AppWariningRegister(const WindowType& wType,
const MessageType& mType);
void setNotifyBellState(bool bellState);
bool getNotifyBellState() const;
friend void operator<<(ErrorSingleton& debug,
const QByteArray& reply);
signals:
void notifyBellStateChanged();
void sendMessageToDialogWindow(const QString& message,
int type);
void sendMessageToMainNotification(const QString& message,
int type);
private:
explicit ErrorSingleton(QObject *parent = nullptr): QObject(parent) {}
bool notifyBellState = true;
static QMutex handlerLocker;
static std::shared_ptr<ErrorSingleton> error_Handler;
QQueue<QByteArray> errorQueue; // TODO: QPair: message and message type!
QPair<WindowType, MessageType> enumTypes;
};
constexpr auto RegisterError = &ErrorSingleton::AppWariningRegister;
#endif // ERRORSINGLETON_H