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 DMAP = QMap<QString,QString>;
25 using VNMask = unsigned int;
26 
28 {
29  public:
30  static inline Type New = static_cast<QEvent::Type>(QEvent::registerEventType());
31  static inline Type Update = static_cast<QEvent::Type>(QEvent::registerEventType());
32  static inline Type Info = static_cast<QEvent::Type>(QEvent::registerEventType());
33  static inline Type Error = static_cast<QEvent::Type>(QEvent::registerEventType());
34  static inline Type Warning = static_cast<QEvent::Type>(QEvent::registerEventType());
35  static inline Type Check = static_cast<QEvent::Type>(QEvent::registerEventType());
36  static inline Type Busy = static_cast<QEvent::Type>(QEvent::registerEventType());
37 
38  MythNotification(Type nType, void* Parent = nullptr);
39  MythNotification(int Id, void* Parent);
40  MythNotification(const QString& Title, const QString& Author,
41  const QString& Details = QString());
42  MythNotification(Type nType, const QString& Title, const QString& Author,
43  const QString& Details = QString(), const QString& Extra = QString());
44  MythNotification(Type nType, DMAP Metadata);
45  explicit MythNotification(const MythEvent& Event);
46  ~MythNotification() override = default;
47  MythEvent* clone() const override;
48 
53  enum Priority
54  {
55  kDefault = 0,
61  };
62 
70  {
71  kNone = 0,
72  kAll = ~0,
73  kPlayback = (1 << 0),
74  kSettings = (1 << 1),
75  kWizard = (1 << 2),
76  kVideos = (1 << 3),
77  kMusic = (1 << 4),
78  kRecordings = (1 << 5),
79  };
80 
81  void SetId(int Id);
82  void SetParent(void* Parent);
83  void SetFullScreen(bool FullScreen);
84  void SetDescription(const QString& Description);
85  void SetMetaData(const DMAP& MetaData);
86  void SetDuration(int Duration);
87  void SetStyle(const QString& Style);
88  void SetVisibility(VNMask Visibility);
89  void SetPriority(Priority nPriority);
90  static Type TypeFromString(const QString& Type);
91  void ToStringList();
92  bool FromStringList();
93 
94  // Getter
95  int GetId() const { return m_id; }
96  void* GetParent() const { return m_parent; }
97  bool GetFullScreen() const { return m_fullScreen; }
98  QString GetDescription() const { return m_description; }
99  DMAP GetMetaData() const { return m_metadata; }
100  int GetDuration() const { return m_duration; }
101  QString GetStyle() const { return m_style; }
102  VNMask GetVisibility() const { return m_visibility; }
103  Priority GetPriority() const { return m_priority; }
104 
105  protected:
106  MythNotification(const MythNotification& Notification);
107 
108 #ifndef _MSC_VER
109  MythNotification &operator=(const MythNotification&);
110 #endif
111 
112  protected:
113  int m_id { -1 };
114  void* m_parent { nullptr };
115  bool m_fullScreen { false };
116  QString m_description;
117  int m_duration { 0 };
119  QString m_style;
120  VNMask m_visibility { static_cast<VNMask>(kAll) };
121  Priority m_priority { kDefault };
122 };
123 
125 {
126  public:
127  MythImageNotification(Type nType, QImage Image);
128  MythImageNotification(Type nType, QString ImagePath);
129  MythImageNotification(Type nType, QImage Image, const DMAP& Metadata);
130  MythImageNotification(Type nType, QString ImagePath, const DMAP& Metadata);
131  MythEvent *clone() const override;
132 
133  void SetImage(const QImage& Image) { m_image = Image; }
134  void SetImagePath(const QString& Image) { m_imagePath = Image; }
135  QImage GetImage() const { return m_image; }
136  QString GetImagePath() const { return m_imagePath; }
137 
138  protected:
140 
141  protected:
142  QImage m_image;
143  QString m_imagePath;
144 };
145 
147 {
148  public:
149  MythPlaybackNotification(Type nType, float Progress, QString ProgressText);
150  MythPlaybackNotification(Type nType, float Progress, QString ProgressText,
151  const DMAP& Metadata);
152  MythPlaybackNotification(Type nType, int Duration, int Position);
153  MythEvent* clone() const override;
154 
155  // Setter
160  void SetProgress(float progress) { m_progress = progress; }
161  void SetProgressText(const QString& text) { m_progressText = text; }
162  float GetProgress() const { return m_progress; }
163  QString GetProgressText() const { return m_progressText; }
164  static QString StringFromSeconds(int Time);
165 
166  protected:
168 
169  float m_progress { -1.0F };
170  QString m_progressText;
171 };
172 
175 {
176  public:
177  MythMediaNotification(Type nType, const QImage& Image, const DMAP& Metadata,
178  float Progress, const QString& DurationText);
179  MythMediaNotification(Type nType, const QImage& Image, const DMAP& Metadata,
180  int Duration, int Position);
181  MythMediaNotification(Type nType, const QString& Image, const DMAP& Metadata,
182  float Progress, const QString& DurationText);
183  MythMediaNotification(Type nType, const QString& Image, const DMAP& Metadata,
184  int Duration, int Position);
185  MythEvent* clone() const override;
186 
187  protected:
188  MythMediaNotification(const MythMediaNotification& Notification);
189 };
190 
192 {
193  public:
194  MythErrorNotification(const QString& Title, const QString& Author,
195  const QString& Details = QString());
196 };
197 
199 {
200  public:
201  MythWarningNotification(const QString& Title, const QString& Author,
202  const QString& Details = QString());
203 };
204 
206 {
207  public:
208  MythCheckNotification(const QString& Title, const QString& Author,
209  const QString& Details = QString());
210 };
211 
213 {
214  public:
215  MythBusyNotification(const QString& Title, const QString& Author,
216  const QString& Details = QString());
217 };
218 
219 #endif
mythevent.h
MUI_PUBLIC
#define MUI_PUBLIC
Definition: mythuiexp.h:9
MythImageNotification::GetImagePath
QString GetImagePath() const
Definition: mythnotification.h:136
MythImageNotification::GetImage
QImage GetImage() const
Definition: mythnotification.h:135
MythCheckNotification
Definition: mythnotification.h:205
MythNotification::kLow
@ kLow
Definition: mythnotification.h:56
MythBusyNotification
Definition: mythnotification.h:212
progress
bool progress
Definition: mythtv/programs/mythcommflag/main.cpp:73
MythEvent
This class is used as a container for messages.
Definition: mythevent.h:16
MythWarningNotification
Definition: mythnotification.h:198
MythImageNotification::m_imagePath
QString m_imagePath
Definition: mythnotification.h:143
MythNotification
Definition: mythnotification.h:27
MythImageNotification::clone
MythEvent * clone() const override
Definition: mythnotification.cpp:261
MythNotification::GetDescription
QString GetDescription() const
Definition: mythnotification.h:98
MythNotification::GetFullScreen
bool GetFullScreen() const
Definition: mythnotification.h:97
Image
Definition: image.h:30
MythImageNotification
Definition: mythnotification.h:124
MythNotification::m_description
QString m_description
Definition: mythnotification.h:116
MythNotification::m_style
QString m_style
Definition: mythnotification.h:119
MythNotification::Visibility
Visibility
Definition: mythnotification.h:69
Event
Event details.
Definition: zmdefines.h:26
MythNotification::GetPriority
Priority GetPriority() const
Definition: mythnotification.h:103
VNMask
unsigned int VNMask
Definition: mythnotification.h:25
MythImageNotification::m_image
QImage m_image
Definition: mythnotification.h:142
MythNotification::GetDuration
int GetDuration() const
Definition: mythnotification.h:100
MythNotification::kHigh
@ kHigh
Definition: mythnotification.h:58
MythNotification::clone
MythEvent * clone() const override
Definition: mythnotification.cpp:76
MythErrorNotification
Definition: mythnotification.h:191
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:160
MythImageNotification::SetImage
void SetImage(const QImage &Image)
Definition: mythnotification.h:133
MythPlaybackNotification::SetProgressText
void SetProgressText(const QString &text)
Definition: mythnotification.h:161
MythNotification::GetParent
void * GetParent() const
Definition: mythnotification.h:96
MythMediaNotification
Definition: mythnotification.h:173
MythPlaybackNotification::m_progressText
QString m_progressText
Definition: mythnotification.h:170
MythEvent::clone
virtual MythEvent * clone() const
Definition: mythevent.h:70
MythPlaybackNotification::GetProgress
float GetProgress() const
Definition: mythnotification.h:162
MythNotification::GetMetaData
DMAP GetMetaData() const
Definition: mythnotification.h:99
MythNotification::GetStyle
QString GetStyle() const
Definition: mythnotification.h:101
MythPlaybackNotification::GetProgressText
QString GetProgressText() const
Definition: mythnotification.h:163
MythNotification::kHighest
@ kHighest
Definition: mythnotification.h:60
MythNotification::GetId
int GetId() const
Definition: mythnotification.h:95
MythNotification::m_metadata
DMAP m_metadata
Definition: mythnotification.h:118
MythNotification::kMedium
@ kMedium
Definition: mythnotification.h:57
DMAP
QMap< QString, QString > DMAP
Definition: mythnotification.h:24
MythNotification::kHigher
@ kHigher
Definition: mythnotification.h:59
Priority
Definition: channelsettings.cpp:191
mythuiexp.h
MythNotification::GetVisibility
VNMask GetVisibility() const
Definition: mythnotification.h:102
MythImageNotification::SetImagePath
void SetImagePath(const QString &Image)
Definition: mythnotification.h:134
MythPlaybackNotification
Definition: mythnotification.h:146