MythTV master
mythnotificationcenter_private.h
Go to the documentation of this file.
1//
2// mythnotificationcenter_private.h
3// MythTV
4//
5// Created by Jean-Yves Avenard on 30/06/13.
6// Copyright (c) 2013 Bubblestuff Pty Ltd. All rights reserved.
7//
8
9#ifndef MythTV_mythnotificationcenter_private_h
10#define MythTV_mythnotificationcenter_private_h
11
12#include <QTimer>
13#include <QMutex>
14#include <QList>
15#include <QMap>
16
17#include <cstdint>
18
19#include "mythscreenstack.h"
20#include "mythscreentype.h"
21#include "mythuiimage.h"
22#include "mythuitext.h"
23#include "mythuiprogressbar.h"
25#include "mythuistatetype.h"
26
27// Forward declarations
30
31#define MIN_LIFE 1000
32
33class NCPrivate : public QObject
34{
35 Q_OBJECT
36
37public slots:
38 void ScreenDeleted(void);
39
40public:
41 NCPrivate(void);
42 ~NCPrivate() override;
43
49 bool Queue(const MythNotification &notification);
50
55
65 int Register(void *from);
72 void UnRegister(void *from, int id, bool closeimemdiately = false);
73
74 /*
75 * OSD drawing utilities
76 */
77
82 QDateTime ScreenExpiryTime(const MythScreenType *screen);
87 bool ScreenCreated(const MythScreenType *screen);
93 void GetNotificationScreens(QList<MythScreenType*> &screens);
102 int DisplayedNotifications(void) const;
106 int QueuedNotifications(void) const;
111 bool RemoveFirst(void);
117 void ProcessQueue(void);
118
119 void ScreenStackDeleted(void);
120
121private:
122
124 int id = -1);
125 void DeleteAllRegistrations(void);
126 void DeleteAllScreens(void);
127 void DeleteUnregistered(void);
130 void RefreshScreenPosition(int from = 0);
131
134 QList<MythNotification*> m_notifications;
135 QList<MythNotificationScreen*> m_screens;
136 QList<MythNotificationScreen*> m_deletedScreens;
137 QMap<int, MythNotificationScreen*> m_registrations;
138 QList<int> m_suspended;
139 QMap<int,bool> m_unregistered;
140 QMap<int, void*> m_clients;
141 QMutex m_lock;
142 int m_currentId {0};
143 QMap<MythNotificationScreen*, MythNotificationScreen*> m_converted;
144};
145
147{
148 Q_OBJECT
149
150public:
152 int id = -1);
154 MythNotification &notification);
156 const MythNotificationScreen &screen);
157
158 ~MythNotificationScreen() override;
159
160 bool keyPressEvent(QKeyEvent *event) override; // MythScreenType
161
162 // These two methods are declared by MythScreenType and their signatures
163 // should not be changed
164 bool Create(void) override; // MythScreenType
165 void Init(void) override; // MythScreenType
166
167 void SetNotification(MythNotification &notification);
168
169 void UpdateArtwork(const QImage &image);
170 void UpdateArtwork(const QString &image);
171 void UpdateMetaData(const DMAP &data);
172 void UpdatePlayback(float progress, const QString &text);
173 void UpdateFrom(const MythNotificationScreen &s);
174
175 void SetSingleShotTimer(std::chrono::seconds s, bool update = false);
176 void SetErrorState(void) const;
177
178 // UI methods
179 void AdjustYPosition(void);
180 void AdjustIndex(int by, bool set=false);
181 void SetIndex(int index);
182 int GetHeight(void);
183
184 enum Content {
185 kNone = 0,
186 kImage = 1 << 0,
187 kDuration = 1 << 1,
188 kMetaData = 1 << 2,
189 kStyle = 1 << 3,
190 kNoArtwork = 1 << 4,
191 kAll = ~kNone,
192 };
193
194signals:
196
197public slots:
198 void ProcessTimer(void);
199
200public:
201 int m_id;
202 QImage m_image;
203 QString m_imagePath;
204 QString m_title;
205 QString m_origin;
207 QString m_extra;
208 std::chrono::seconds m_duration {-1s};
209 float m_progress {-1.0F};
211 bool m_fullscreen {false};
212 bool m_added {false};
213 bool m_created {false};
214 uint32_t m_content {kNone};
215 uint32_t m_update {(uint32_t)kAll};
216 MythNotification::Type m_type {MythNotification::kNew};
226 QDateTime m_creation;
227 QDateTime m_expiry;
228 int m_index {0};
230 QTimer *m_timer {nullptr};
231 QString m_style;
234 bool m_refresh {true};
235};
236
238
240{
241public:
242 MythNotificationScreenStack(MythMainWindow *parent, const QString& name,
243 NCPrivate *owner)
244 : MythScreenStack(parent, name), m_owner(owner)
245 {
246 }
247
249 {
251 }
252
254 {
255 for (auto * screen : std::as_const(m_toDelete))
256 {
257 screen->SetAlpha(0);
258 screen->SetVisible(false);
259 screen->Close();
260 }
262 }
263
264 static const int kFadeVal = 20;
265
266 void PopScreen(MythScreenType *screen, bool allowFade = true,
267 bool deleteScreen = true) override; // MythScreenStack
268 MythScreenType *GetTopScreen(void) const override; // MythScreenStack
269private:
270 NCPrivate *m_owner {nullptr};
271
272};
273
274#endif
void PopScreen(MythScreenType *screen, bool allowFade=true, bool deleteScreen=true) override
MythScreenType * GetTopScreen(void) const override
MythNotificationScreenStack(MythMainWindow *parent, const QString &name, NCPrivate *owner)
void UpdatePlayback(float progress, const QString &text)
Update playback position information.
void UpdateArtwork(const QImage &image)
Update artwork image.
MythNotificationScreen(MythScreenStack *stack, int id=-1)
void UpdateFrom(const MythNotificationScreen &s)
Copy metadata from another notification.
void SetIndex(int index)
set index, without recalculating coordinates
void AdjustIndex(int by, bool set=false)
void SetSingleShotTimer(std::chrono::seconds s, bool update=false)
void SetNotification(MythNotification &notification)
void UpdateMetaData(const DMAP &data)
Read some DMAP tag to extract title, artist, album and file format.
void AdjustYPosition(void)
Update Y position of the screen All children elements will be relocated.
MythNotification::Priority m_priority
void Init(void) override
Update the various fields of a MythNotificationScreen.
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
static const Type kNew
Wrapper around QPoint allowing us to handle percentage and other relative values for positioning in m...
Definition: mythrect.h:89
void CheckDeletes(bool force=false)
QVector< MythScreenType * > m_toDelete
Screen in which all other widgets are contained and rendered.
Image widget, displays a single image or multiple images in sequence.
Definition: mythuiimage.h:98
Progress bar widget.
This widget is used for grouping other widgets for display when a particular named state is called.
All purpose text widget, displays a text string.
Definition: mythuitext.h:29
int DisplayedNotifications(void) const
Returns number of notifications currently displayed.
QMap< int, bool > m_unregistered
void RefreshScreenPosition(int from=0)
Re-position screens on display.
QList< MythNotificationScreen * > m_deletedScreens
int InsertScreen(MythNotificationScreen *screen)
Insert screen into list of screens.
MythNotificationScreenStack * m_screenStack
int RemoveScreen(MythNotificationScreen *screen)
Remove screen from list of screens.
QMap< int, void * > m_clients
void DeleteUnregistered(void)
QMap< MythNotificationScreen *, MythNotificationScreen * > m_converted
void ScreenStackDeleted(void)
bool ScreenCreated(const MythScreenType *screen)
Return true if ::Create() has been called on screen.
bool Queue(const MythNotification &notification)
Queue a notification Queue() is thread-safe and can be called from anywhere.
bool RemoveFirst(void)
Will remove the oldest notification from the stack return true if a screen was removed; or false if n...
MythNotificationScreen * CreateScreen(MythNotification *notification, int id=-1)
CreateScreen will create a MythNotificationScreen instance.
void DeleteAllRegistrations(void)
void DeleteAllScreens(void)
void GetNotificationScreens(QList< MythScreenType * > &screens)
Return the list of notification screens being currently displayed.
void ScreenDeleted(void)
Remove screen from screens list.
void ProcessQueue(void)
ProcessQueue will be called by the GUI event handler and will process all queued MythNotifications an...
int QueuedNotifications(void) const
Returns number of notifications currently queued.
static MythNotificationCenter * GetInstance(void)
returns the MythNotificationCenter singleton
MythNotificationScreenStack * m_originalScreenStack
void UnRegister(void *from, int id, bool closeimemdiately=false)
Unregister the client.
QDateTime ScreenExpiryTime(const MythScreenType *screen)
Return when the given screen is going to expire will return an invalid QDateTime if screen isn't a My...
QMap< int, MythNotificationScreen * > m_registrations
int Register(void *from)
An application can register in which case it will be assigned a reusable screen, which can be modifie...
void UpdateScreen(MythScreenType *screen)
Will call ::doInit() if the screen is a MythNotificationScreen and ::Create() has been called for it ...
QList< MythNotificationScreen * > m_screens
QList< MythNotification * > m_notifications
bool progress
unsigned int VNMask
QMap< QString, QString > DMAP