-
Notifications
You must be signed in to change notification settings - Fork 341
/
mythuinotificationcenter.h
115 lines (96 loc) · 3.5 KB
/
mythuinotificationcenter.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
//
// mythuinotificationcenter.h
// MythTV
//
// Created by Jean-Yves Avenard on 25/06/13.
// Copyright (c) 2013 Bubblestuff Pty Ltd. All rights reserved.
//
#ifndef __MythTV__mythnotifications__
#define __MythTV__mythnotifications__
#include <QMutex>
#include <QList>
#include <QMap>
#include <QRect>
#include "mythuiexp.h"
#include "mythevent.h"
#include "mythnotification.h"
// .h
class MythUINotificationScreen;
class MythScreenStack;
class MythPainter;
class QPaintDevice;
class MythNotificationScreenStack;
class MUI_PUBLIC MythUINotificationCenterEvent : public MythEvent
{
public:
MythUINotificationCenterEvent() : MythEvent(kEventType) { }
static Type kEventType;
};
class MUI_PUBLIC MythUINotificationCenter : public QObject
{
Q_OBJECT
public:
MythUINotificationCenter(void);
virtual ~MythUINotificationCenter();
/**
* Queue a notification
* Queue() is thread-safe and can be called from anywhere.
* Typical use would be MythUINotificationCenter::GetInstance()->Queue(notification)
*/
bool Queue(MythNotification ¬ification);
/**
* returns the MythUINotificationCenter singleton
*/
static MythUINotificationCenter *GetInstance(void);
/**
* An application can register in which case it will be assigned a
* reusable screen, which can be modified or updated
* Register takes a pointer of the client registering. This is used
* to make sure a registered Id can only be used by the client who registered
* for it.
* Returns a unique Id that can be provided with a MythNotification
* Return -1 is case of error
*/
int Register(void *from);
/**
* Unregister the client and release/remove the corresponding screen
*/
void UnRegister(void *from, int id);
/**
* For UI screens not using MythUIScreenStack for display (e.g. video playback),
* provide own custom drawing routine.
*/
QRegion Draw(MythPainter *painter, QPaintDevice *device, QSize size,
QRegion &changed, int alignx = 0, int aligny = 0);
bool DrawDirect(MythPainter *painter, QSize size, bool repaint = false);
/**
* ProcessQueue will be called by the GUI event handler and will process
* all queued MythNotifications and delete screens marked to be deleted
* ProcessQueue must be called from GUI thread
*/
void ProcessQueue(void);
private slots:
void ScreenDeleted(void);
private:
MythUINotificationScreen *CreateScreen(MythNotification *notification,
int id = -1);
MythNotificationScreenStack *GetScreenStack(void);
void DeleteAllScreens(void);
int InsertScreen(MythUINotificationScreen *screen);
int RemoveScreen(MythUINotificationScreen *screen);
void AdjustScreenPosition(int from, bool down);
private:
MythNotificationScreenStack *m_screenStack;
QList<MythNotification*> m_notifications;
QList<MythUINotificationScreen*> m_screens;
QList<MythUINotificationScreen*> m_deletedScreens;
QMap<int, MythUINotificationScreen*> m_registrations;
QMap<int, void*> m_clients;
QMutex m_lock;
int m_currentId;
bool m_refresh;
// protected by g_lock
static QMutex g_lock;
static MythUINotificationCenter *g_singleton;
};
#endif /* defined(__MythTV__mythnotifications__) */