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);
113
114 protected:
115 int m_id { -1 };
116 void* m_parent { nullptr };
117 bool m_fullScreen { false };
119 std::chrono::seconds m_duration { 0s };
121 QString m_style;
122 VNMask m_visibility { static_cast<VNMask>(kAll) };
123 Priority m_priority { kDefault };
124};
125
127{
128 public:
129 MythImageNotification(Type nType, QImage Image);
130 MythImageNotification(Type nType, QString ImagePath);
131 MythImageNotification(Type nType, QImage Image, const DMAP& Metadata);
132 MythImageNotification(Type nType, QString ImagePath, const DMAP& Metadata);
133 MythEvent *clone() const override;
134
135 void SetImage(const QImage& Image) { m_image = Image; }
136 void SetImagePath(const QString& Image) { m_imagePath = Image; }
137 QImage GetImage() const { return m_image; }
138 QString GetImagePath() const { return m_imagePath; }
139
140 protected:
142
143 protected:
144 QImage m_image;
145 QString m_imagePath;
146};
147
149{
150 public:
151 MythPlaybackNotification(Type nType, float Progress, QString ProgressText);
152 MythPlaybackNotification(Type nType, float Progress, QString ProgressText,
153 const DMAP& Metadata);
154 MythPlaybackNotification(Type nType, std::chrono::seconds Duration, int Position);
155 MythEvent* clone() const override;
156
157 // Setter
162 void SetProgress(float progress) { m_progress = progress; }
163 void SetProgressText(const QString& text) { m_progressText = text; }
164 float GetProgress() const { return m_progress; }
165 QString GetProgressText() const { return m_progressText; }
166 static QString StringFromSeconds(std::chrono::seconds Time);
167
168 protected:
170
171 float m_progress { -1.0F };
173};
174
177{
178 public:
179 MythMediaNotification(Type nType, const QImage& Image, const DMAP& Metadata,
180 float Progress, const QString& DurationText);
181 MythMediaNotification(Type nType, const QImage& Image, const DMAP& Metadata,
182 std::chrono::seconds Duration, int Position);
183 MythMediaNotification(Type nType, const QString& Image, const DMAP& Metadata,
184 float Progress, const QString& DurationText);
185 MythMediaNotification(Type nType, const QString& Image, const DMAP& Metadata,
186 std::chrono::seconds Duration, int Position);
187 MythEvent* clone() const override;
188
189 protected:
190 MythMediaNotification(const MythMediaNotification& Notification);
191};
192
194{
195 public:
196 MythErrorNotification(const QString& Title, const QString& Author,
197 const QString& Details = QString());
198};
199
201{
202 public:
203 MythWarningNotification(const QString& Title, const QString& Author,
204 const QString& Details = QString());
205};
206
208{
209 public:
210 MythCheckNotification(const QString& Title, const QString& Author,
211 const QString& Details = QString());
212};
213
215{
216 public:
217 MythBusyNotification(const QString& Title, const QString& Author,
218 const QString& Details = QString());
219};
220
221#endif
Event details.
Definition: zmdefines.h:28
This class is used as a container for messages.
Definition: mythevent.h:17
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
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)