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