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 // Qt
13 #include <QImage>
14 #include <QMap>
15 #include <QMutex>
16 
17 // MythTV
18 #include "mythevent.h"
19 #include "mythuiexp.h"
20 
21 // Std
22 #include <utility>
23 
24 using namespace std::chrono_literals;
25 
26 using DMAP = QMap<QString,QString>;
27 using VNMask = unsigned int;
28 
30 {
31  public:
32  static inline Type New = static_cast<QEvent::Type>(QEvent::registerEventType());
33  static inline Type Update = static_cast<QEvent::Type>(QEvent::registerEventType());
34  static inline Type Info = static_cast<QEvent::Type>(QEvent::registerEventType());
35  static inline Type Error = static_cast<QEvent::Type>(QEvent::registerEventType());
36  static inline Type Warning = static_cast<QEvent::Type>(QEvent::registerEventType());
37  static inline Type Check = static_cast<QEvent::Type>(QEvent::registerEventType());
38  static inline Type Busy = static_cast<QEvent::Type>(QEvent::registerEventType());
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.
52  MythNotification &operator=(MythNotification &&) = delete;
53 
58  enum Priority
59  {
60  kDefault = 0,
66  };
67 
75  {
76  kNone = 0,
77  kAll = ~0,
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
114  MythNotification &operator=(const MythNotification&);
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 };
123  QString m_description;
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 };
177  QString m_progressText;
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
mythevent.h
MUI_PUBLIC
#define MUI_PUBLIC
Definition: mythuiexp.h:9
MythImageNotification::GetImagePath
QString GetImagePath() const
Definition: mythnotification.h:143
MythImageNotification::GetImage
QImage GetImage() const
Definition: mythnotification.h:142
MythCheckNotification
Definition: mythnotification.h:212
MythNotification::kLow
@ kLow
Definition: mythnotification.h:61
MythBusyNotification
Definition: mythnotification.h:219
progress
bool progress
Definition: mythtv/programs/mythcommflag/main.cpp:71
MythEvent
This class is used as a container for messages.
Definition: mythevent.h:16
MythNotification::GetDuration
std::chrono::seconds GetDuration() const
Definition: mythnotification.h:105
MythWarningNotification
Definition: mythnotification.h:205
MythImageNotification::m_imagePath
QString m_imagePath
Definition: mythnotification.h:150
MythNotification
Definition: mythnotification.h:29
MythNotification::GetDescription
QString GetDescription() const
Definition: mythnotification.h:103
MythNotification::GetFullScreen
bool GetFullScreen() const
Definition: mythnotification.h:102
MythImageNotification
Definition: mythnotification.h:131
MythNotification::m_description
QString m_description
Definition: mythnotification.h:123
MythNotification::m_style
QString m_style
Definition: mythnotification.h:126
MythNotification::Visibility
Visibility
Definition: mythnotification.h:74
Event
Event details.
Definition: zmdefines.h:26
MythNotification::GetPriority
Priority GetPriority() const
Definition: mythnotification.h:108
VNMask
unsigned int VNMask
Definition: mythnotification.h:27
MythImageNotification::m_image
QImage m_image
Definition: mythnotification.h:149
MythNotification::kHigh
@ kHigh
Definition: mythnotification.h:63
MythErrorNotification
Definition: mythnotification.h:198
MythPlaybackNotification::SetProgress
void SetProgress(float progress)
Set the current playback position to be displayed with the notification. Value to be between 0 <= x <...
Definition: mythnotification.h:167
MythImageNotification::SetImage
void SetImage(const QImage &Image)
Definition: mythnotification.h:140
MythPlaybackNotification::SetProgressText
void SetProgressText(const QString &text)
Definition: mythnotification.h:168
MythNotification::GetParent
void * GetParent() const
Definition: mythnotification.h:101
MythMediaNotification
Definition: mythnotification.h:180
MythPlaybackNotification::m_progressText
QString m_progressText
Definition: mythnotification.h:177
MythPlaybackNotification::GetProgress
float GetProgress() const
Definition: mythnotification.h:169
MythNotification::GetMetaData
DMAP GetMetaData() const
Definition: mythnotification.h:104
MythNotification::GetStyle
QString GetStyle() const
Definition: mythnotification.h:106
MythPlaybackNotification::GetProgressText
QString GetProgressText() const
Definition: mythnotification.h:170
MythNotification::kHighest
@ kHighest
Definition: mythnotification.h:65
MythNotification::GetId
int GetId() const
Definition: mythnotification.h:100
MythNotification::m_metadata
DMAP m_metadata
Definition: mythnotification.h:125
MythNotification::kMedium
@ kMedium
Definition: mythnotification.h:62
DMAP
QMap< QString, QString > DMAP
Definition: mythnotification.h:26
MythNotification::kHigher
@ kHigher
Definition: mythnotification.h:64
Priority
Definition: channelsettings.cpp:191
mythuiexp.h
MythNotification::GetVisibility
VNMask GetVisibility() const
Definition: mythnotification.h:107
MythImageNotification::SetImagePath
void SetImagePath(const QString &Image)
Definition: mythnotification.h:141
MythPlaybackNotification
Definition: mythnotification.h:153