MythTV master
mythnotification.h
Go to the documentation of this file.
1//
2// mythnotification.h
3// MythTV
4//
5// Created by Jean-Yves Avenard on 25/06/13.
6// Copyright (c) 2013 Bubblestuff Pty Ltd. All rights reserved.
7//
8
9#ifndef MYTHTV_MYTHNOTIFICATION_H
10#define MYTHTV_MYTHNOTIFICATION_H
11
12// Std
13#include <utility>
14
15// Qt
16#include <QImage>
17#include <QMap>
18#include <QMutex>
19
20// MythTV
22#include "libmythui/mythuiexp.h"
23
24using namespace std::chrono_literals;
25
26using DMAP = QMap<QString,QString>;
27using VNMask = unsigned int;
28
30{
31 public:
32 static const Type kNew;
33 static const Type kUpdate;
34 static const Type kInfo;
35 static const Type kError;
36 static const Type kWarning;
37 static const Type kCheck;
38 static const Type kBusy;
39
40 MythNotification(Type nType, void* Parent = nullptr);
41 MythNotification(int Id, void* Parent);
42 MythNotification(const QString& Title, const QString& Author,
43 const QString& Details = QString());
44 MythNotification(Type nType, const QString& Title, const QString& Author,
45 const QString& Details = QString(), const QString& Extra = QString());
46 MythNotification(Type nType, DMAP Metadata);
47 explicit MythNotification(const MythEvent& Event);
48 ~MythNotification() override = default;
49 MythEvent* clone() const override;
50 // No implicit copying.
53
58 enum Priority : std::uint8_t
59 {
60 kDefault = 0,
66 };
67
74 enum Visibility : std::uint8_t
75 {
76 kNone = 0,
77 kAll = 0xFF,
78 kPlayback = (1 << 0),
79 kSettings = (1 << 1),
80 kWizard = (1 << 2),
81 kVideos = (1 << 3),
82 kMusic = (1 << 4),
83 kRecordings = (1 << 5),
84 };
85
86 void SetId(int Id);
87 void SetParent(void* Parent);
88 void SetFullScreen(bool FullScreen);
89 void SetDescription(const QString& Description);
90 void SetMetaData(const DMAP& MetaData);
91 void SetDuration(std::chrono::seconds Duration);
92 void SetStyle(const QString& sStyle);
93 void SetVisibility(VNMask nVisibility);
94 void SetPriority(Priority nPriority);
95 static Type TypeFromString(const QString& Type);
96 void ToStringList();
97 bool FromStringList();
98
99 // Getter
100 int GetId() const { return m_id; }
101 void* GetParent() const { return m_parent; }
102 bool GetFullScreen() const { return m_fullScreen; }
103 QString GetDescription() const { return m_description; }
104 DMAP GetMetaData() const { return m_metadata; }
105 std::chrono::seconds GetDuration() const { return m_duration; }
106 QString GetStyle() const { return m_style; }
107 VNMask GetVisibility() const { return m_visibility; }
108 Priority GetPriority() const { return m_priority; }
109
110 protected:
111 MythNotification(const MythNotification& Notification);
112
113#ifndef _MSC_VER
115#else
116 MythNotification &operator=(const MythNotification &other) = default;
117#endif
118
119 protected:
120 int m_id { -1 };
121 void* m_parent { nullptr };
122 bool m_fullScreen { false };
124 std::chrono::seconds m_duration { 0s };
126 QString m_style;
127 VNMask m_visibility { static_cast<VNMask>(kAll) };
128 Priority m_priority { kDefault };
129};
130
132{
133 public:
134 MythImageNotification(Type nType, QImage Image);
135 MythImageNotification(Type nType, QString ImagePath);
136 MythImageNotification(Type nType, QImage Image, const DMAP& Metadata);
137 MythImageNotification(Type nType, QString ImagePath, const DMAP& Metadata);
138 MythEvent *clone() const override;
139
140 void SetImage(const QImage& Image) { m_image = Image; }
141 void SetImagePath(const QString& Image) { m_imagePath = Image; }
142 QImage GetImage() const { return m_image; }
143 QString GetImagePath() const { return m_imagePath; }
144
145 protected:
147
148 protected:
149 QImage m_image;
150 QString m_imagePath;
151};
152
154{
155 public:
156 MythPlaybackNotification(Type nType, float Progress, QString ProgressText);
157 MythPlaybackNotification(Type nType, float Progress, QString ProgressText,
158 const DMAP& Metadata);
159 MythPlaybackNotification(Type nType, std::chrono::seconds Duration, int Position);
160 MythEvent* clone() const override;
161
162 // Setter
167 void SetProgress(float progress) { m_progress = progress; }
168 void SetProgressText(const QString& text) { m_progressText = text; }
169 float GetProgress() const { return m_progress; }
170 QString GetProgressText() const { return m_progressText; }
171 static QString StringFromSeconds(std::chrono::seconds Time);
172
173 protected:
175
176 float m_progress { -1.0F };
178};
179
182{
183 public:
184 MythMediaNotification(Type nType, const QImage& Image, const DMAP& Metadata,
185 float Progress, const QString& DurationText);
186 MythMediaNotification(Type nType, const QImage& Image, const DMAP& Metadata,
187 std::chrono::seconds Duration, int Position);
188 MythMediaNotification(Type nType, const QString& Image, const DMAP& Metadata,
189 float Progress, const QString& DurationText);
190 MythMediaNotification(Type nType, const QString& Image, const DMAP& Metadata,
191 std::chrono::seconds Duration, int Position);
192 MythEvent* clone() const override;
193
194 protected:
195 MythMediaNotification(const MythMediaNotification& Notification);
196};
197
199{
200 public:
201 MythErrorNotification(const QString& Title, const QString& Author,
202 const QString& Details = QString());
203};
204
206{
207 public:
208 MythWarningNotification(const QString& Title, const QString& Author,
209 const QString& Details = QString());
210};
211
213{
214 public:
215 MythCheckNotification(const QString& Title, const QString& Author,
216 const QString& Details = QString());
217};
218
220{
221 public:
222 MythBusyNotification(const QString& Title, const QString& Author,
223 const QString& Details = QString());
224};
225
226#endif
Event details.
Definition: zmdefines.h:28
This class is used as a container for messages.
Definition: mythevent.h:17
MythEvent & operator=(const MythEvent &other)=default
MythEvent * clone() const override
Definition: mythevent.h:75
void SetImagePath(const QString &Image)
QString GetImagePath() const
MythImageNotification(const MythImageNotification &)=default
void SetImage(const QImage &Image)
static const Type kCheck
Priority GetPriority() const
~MythNotification() override=default
MythNotification(MythNotification &&)=delete
static const Type kNew
static const Type kUpdate
void * GetParent() const
static const Type kError
static const Type kInfo
bool GetFullScreen() const
MythNotification & operator=(const MythNotification &)
DMAP GetMetaData() const
MythNotification & operator=(MythNotification &&)=delete
static const Type kWarning
std::chrono::seconds GetDuration() const
static const Type kBusy
QString GetDescription() const
QString GetStyle() const
VNMask GetVisibility() const
void SetProgressText(const QString &text)
void SetProgress(float progress)
Set the current playback position to be displayed with the notification. Value to be between 0 <= x <...
QString GetProgressText() const
MythPlaybackNotification(const MythPlaybackNotification &)=default
bool progress
unsigned int VNMask
QMap< QString, QString > DMAP
#define MUI_PUBLIC
Definition: mythuiexp.h:9
MBASE_PUBLIC QStringList ToStringList(const FileSystemInfoList &fsInfos)
MBASE_PUBLIC FileSystemInfoList FromStringList(const QStringList &list)