MythTV  master
osd.h
Go to the documentation of this file.
1 #ifndef OSD_H
2 #define OSD_H
3 
4 // MythTV
10 
11 // Screen names are prepended with alphanumerics to force the correct ordering
12 // when displayed. This is slightly complicated by the default windows
13 // (e.g. osd_window) whose names are hard coded into existing themes.
14 
15 // menu dialogs should always be on top
16 static constexpr const char* OSD_DLG_VIDEOEXIT { "xx_OSD_VIDEO_EXIT" };
17 static constexpr const char* OSD_DLG_MENU { "xx_OSD_MENU" };
18 static constexpr const char* OSD_DLG_SLEEP { "xx_OSD_SLEEP" };
19 static constexpr const char* OSD_DLG_IDLE { "xx_OSD_IDLE" };
20 static constexpr const char* OSD_DLG_INFO { "xx_OSD_INFO" };
21 static constexpr const char* OSD_DLG_EDITING { "xx_OSD_EDITING" };
22 static constexpr const char* OSD_DLG_ASKALLOW { "xx_OSD_ASKALLOW" };
23 static constexpr const char* OSD_DLG_EDITOR { "xx_OSD_EDITOR" };
24 static constexpr const char* OSD_DLG_CUTPOINT { "xx_OSD_CUTPOINT" };
25 static constexpr const char* OSD_DLG_DELETE { "xx_OSD_DELETE" };
26 static constexpr const char* OSD_DLG_NAVIGATE { "xx_OSD_NAVIGATE" };
27 static constexpr const char* OSD_DLG_CONFIRM { "mythconfirmpopup" };
28 
29 static constexpr const char* OSD_WIN_MESSAGE { "osd_message" };
30 static constexpr const char* OSD_WIN_INPUT { "osd_input" };
31 static constexpr const char* OSD_WIN_PROGINFO { "program_info" };
32 static constexpr const char* OSD_WIN_STATUS { "osd_status" };
33 static constexpr const char* OSD_WIN_DEBUG { "osd_debug" };
34 static constexpr const char* OSD_WIN_BROWSE { "browse_info" };
35 static constexpr const char* OSD_WIN_PROGEDIT { "osd_program_editor" };
36 
37 static constexpr std::chrono::milliseconds kOSDFadeTime { 1s };
38 
39 class TV;
40 class MythMainWindow;
41 class MythPlayerUI;
42 
43 
44 enum OSDFunctionalType : std::uint8_t
45 {
53 };
54 
55 enum OSDTimeout : std::int8_t
56 {
57  kOSDTimeout_Ignore = -1, // Don't update existing timeout
58  kOSDTimeout_None = 0, // Don't timeout
62 };
63 
65 {
66  public:
68  {
69  public:
70  QString m_text;
71  QVariant m_data;
72  bool m_menu { false };
73  bool m_current { false };
74  };
75 
77  {
78  public:
79  QString m_text;
80  QVariant m_data { 0 };
81  bool m_exit { false };
82  };
83 
84  QString m_dialogName;
85  QString m_message { }; //NOLINT(readability-redundant-member-init)
86  std::chrono::milliseconds m_timeout { 0ms };
87  std::vector<MythOSDDialogButton> m_buttons { }; //NOLINT(readability-redundant-member-init)
89 };
90 
92 
93 class OSD : public MythMediaOverlay
94 {
95  Q_OBJECT
96 
97  signals:
98  void HideOSD(OSDFunctionalType Type);
99 
100  public slots:
101  void SetText(const QString& Window, const InfoMap& Map, OSDTimeout Timeout);
102  void DialogQuit();
103  void HideAll(bool KeepSubs = true, MythScreenType* Except = nullptr, bool DropNotification = false);
104  void Embed(bool Embedding);
105 
106  protected slots:
107  void ShowDialog(const MythOSDDialogData& Data);
108  void IsOSDVisible(bool& Visible);
109 
110  public:
111  OSD(MythMainWindow* MainWindow, TV* Tv, MythPlayerUI* Player, MythPainter* Painter);
112  ~OSD() override;
113 
114  bool Init(QRect Rect, float FontAspect) override;
115  void HideWindow(const QString &Window) override;
116  void SetFunctionalWindow(const QString &Window, enum OSDFunctionalType Type);
117 
118  void SetExpiry(const QString &Window, enum OSDTimeout Timeout, std::chrono::milliseconds CustomTimeout = 0ms);
119  void ResetWindow(const QString &Window);
120  void Draw();
121 
122  void SetValues(const QString &Window, const QHash<QString,int> &Map, OSDTimeout Timeout);
123  void SetValues(const QString &Window, const QHash<QString,float> &Map, OSDTimeout Timeout);
124  void SetRegions(const QString &Window, frm_dir_map_t &Map, long long Total);
125  void SetGraph(const QString &Window, const QString &Graph, std::chrono::milliseconds Timecode);
126  bool IsWindowVisible(const QString &Window);
127 
128  bool DialogVisible(const QString& Window = QString());
129  bool DialogHandleKeypress(QKeyEvent *Event);
130  bool DialogHandleGesture(MythGestureEvent *Event);
131  void DialogGetText(InfoMap &Map);
132 
133  private:
134  void PositionWindow(MythScreenType* Window);
135  void RemoveWindow(const QString& Window);
136  void DialogShow(const QString& Window, const QString& Text = "", std::chrono::milliseconds UpdateFor = 0ms);
137  void DialogAddButton(const QString& Text, QVariant Data, bool Menu = false, bool Current = false);
138  void DialogBack(const QString& Text = "", const QVariant& Data = 0, bool Exit = false);
139  void TearDown() override;
140  void LoadWindows();
141  void CheckExpiry();
142  void SetExpiryPriv(const QString &Window, enum OSDTimeout Timeout, std::chrono::milliseconds CustomTimeout);
143 
144  private:
145  bool m_embedded { false };
146  std::chrono::milliseconds m_fadeTime { kOSDFadeTime };
147  MythScreenType* m_dialog { nullptr };
149  QDateTime m_nextPulseUpdate;
150  std::array<std::chrono::milliseconds,4> m_timeouts { -1ms, 3s, 5s, 13s };
151  enum OSDFunctionalType m_functionalType { kOSDFunctionalType_Default };
153  QHash<MythScreenType*, QDateTime> m_expireTimes;
154 };
155 
156 #endif
OSD_DLG_MENU
static constexpr const char * OSD_DLG_MENU
Definition: osd.h:17
OSD::m_expireTimes
QHash< MythScreenType *, QDateTime > m_expireTimes
Definition: osd.h:153
mythplayerstate.h
OSD_WIN_BROWSE
static constexpr const char * OSD_WIN_BROWSE
Definition: osd.h:34
MythOSDDialogData::m_dialogName
QString m_dialogName
Definition: osd.h:84
MythOSDDialogData::MythOSDDialogButton::m_current
bool m_current
Definition: osd.h:73
OSD_DLG_CUTPOINT
static constexpr const char * OSD_DLG_CUTPOINT
Definition: osd.h:24
MythOSDDialogData::MythOSDBackButton::m_data
QVariant m_data
Definition: osd.h:80
MythOSDDialogData::MythOSDBackButton
Definition: osd.h:76
kOSDTimeout_Med
@ kOSDTimeout_Med
Definition: osd.h:60
OSD_DLG_SLEEP
static constexpr const char * OSD_DLG_SLEEP
Definition: osd.h:18
frm_dir_map_t
QMap< uint64_t, MarkTypes > frm_dir_map_t
Frame # -> Mark map.
Definition: programtypes.h:118
OSD_DLG_CONFIRM
static constexpr const char * OSD_DLG_CONFIRM
Definition: osd.h:27
OSD_DLG_INFO
static constexpr const char * OSD_DLG_INFO
Definition: osd.h:20
OSDTimeout
OSDTimeout
Definition: osd.h:55
MythScreenType
Screen in which all other widgets are contained and rendered.
Definition: mythscreentype.h:45
kOSDFunctionalType_PictureAdjust
@ kOSDFunctionalType_PictureAdjust
Definition: osd.h:47
MythOSDDialogData::MythOSDDialogButton
Definition: osd.h:67
OSD::m_functionalWindow
QString m_functionalWindow
Definition: osd.h:152
OSD_DLG_DELETE
static constexpr const char * OSD_DLG_DELETE
Definition: osd.h:25
OSD_WIN_MESSAGE
static constexpr const char * OSD_WIN_MESSAGE
Definition: osd.h:29
Visible
Definition: channelsettings.cpp:416
OSD_WIN_PROGEDIT
static constexpr const char * OSD_WIN_PROGEDIT
Definition: osd.h:35
OSDFunctionalType
OSDFunctionalType
Definition: osd.h:44
Q_DECLARE_METATYPE
Q_DECLARE_METATYPE(StandardSetting *)
programtypes.h
InfoMap
QHash< QString, QString > InfoMap
Definition: mythtypes.h:15
kOSDFadeTime
static constexpr std::chrono::milliseconds kOSDFadeTime
Definition: osd.h:37
MythPlayerUI
Definition: mythplayerui.h:12
OSD_WIN_STATUS
static constexpr const char * OSD_WIN_STATUS
Definition: osd.h:32
OSD_WIN_PROGINFO
static constexpr const char * OSD_WIN_PROGINFO
Definition: osd.h:31
kOSDTimeout_None
@ kOSDTimeout_None
Definition: osd.h:58
MythOSDDialogData
Definition: osd.h:64
kOSDTimeout_Ignore
@ kOSDTimeout_Ignore
Definition: osd.h:57
mythmediaoverlay.h
Event
Event details.
Definition: zmdefines.h:26
OSD_WIN_DEBUG
static constexpr const char * OSD_WIN_DEBUG
Definition: osd.h:33
kOSDFunctionalType_SubtitleZoomAdjust
@ kOSDFunctionalType_SubtitleZoomAdjust
Definition: osd.h:51
mythtypes.h
MythOSDDialogData::m_message
QString m_message
Definition: osd.h:85
OSD_DLG_IDLE
static constexpr const char * OSD_DLG_IDLE
Definition: osd.h:19
kOSDFunctionalType_TimeStretchAdjust
@ kOSDFunctionalType_TimeStretchAdjust
Definition: osd.h:49
MythOSDDialogData::m_timeout
std::chrono::milliseconds m_timeout
Definition: osd.h:86
OSD_DLG_VIDEOEXIT
static constexpr const char * OSD_DLG_VIDEOEXIT
Definition: osd.h:16
OSD_DLG_NAVIGATE
static constexpr const char * OSD_DLG_NAVIGATE
Definition: osd.h:26
kOSDFunctionalType_SubtitleDelayAdjust
@ kOSDFunctionalType_SubtitleDelayAdjust
Definition: osd.h:52
MythOSDDialogData::MythOSDDialogButton::m_data
QVariant m_data
Definition: osd.h:71
OSD_WIN_INPUT
static constexpr const char * OSD_WIN_INPUT
Definition: osd.h:30
OSD_DLG_EDITOR
static constexpr const char * OSD_DLG_EDITOR
Definition: osd.h:23
kOSDTimeout_Long
@ kOSDTimeout_Long
Definition: osd.h:61
MythOSDDialogData::MythOSDDialogButton::m_menu
bool m_menu
Definition: osd.h:72
MythOSDDialogData::MythOSDBackButton::m_text
QString m_text
Definition: osd.h:79
OSD::m_pulsedDialogText
QString m_pulsedDialogText
Definition: osd.h:148
MythOSDDialogData::m_buttons
std::vector< MythOSDDialogButton > m_buttons
Definition: osd.h:87
kOSDFunctionalType_SmartForward
@ kOSDFunctionalType_SmartForward
Definition: osd.h:48
MythMediaOverlay
Definition: mythmediaoverlay.h:30
MythPainter
Definition: mythpainter.h:34
kOSDFunctionalType_AudioSyncAdjust
@ kOSDFunctionalType_AudioSyncAdjust
Definition: osd.h:50
MythOSDDialogData::m_back
MythOSDBackButton m_back
Definition: osd.h:88
MythGestureEvent
A custom event that represents a mouse gesture.
Definition: mythgesture.h:39
MythOSDDialogData::MythOSDBackButton::m_exit
bool m_exit
Definition: osd.h:81
Player
Definition: zmliveplayer.h:34
OSD::m_nextPulseUpdate
QDateTime m_nextPulseUpdate
Definition: osd.h:149
MythOSDDialogData::MythOSDDialogButton::m_text
QString m_text
Definition: osd.h:70
OSD_DLG_EDITING
static constexpr const char * OSD_DLG_EDITING
Definition: osd.h:21
kOSDTimeout_Short
@ kOSDTimeout_Short
Definition: osd.h:59
OSD_DLG_ASKALLOW
static constexpr const char * OSD_DLG_ASKALLOW
Definition: osd.h:22
OSD
Definition: osd.h:93
MythMainWindow
Definition: mythmainwindow.h:28
kOSDFunctionalType_Default
@ kOSDFunctionalType_Default
Definition: osd.h:46
mythscreentype.h
TV
Control TV playback.
Definition: tv_play.h:152