MythTV  master
osd.h
Go to the documentation of this file.
1 #ifndef OSD_H
2 #define OSD_H
3 
4 // MythTV
5 #include "libmyth/programtypes.h"
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 #define OSD_DLG_VIDEOEXIT "xx_OSD_VIDEO_EXIT"
17 #define OSD_DLG_MENU "xx_OSD_MENU"
18 #define OSD_DLG_SLEEP "xx_OSD_SLEEP"
19 #define OSD_DLG_IDLE "xx_OSD_IDLE"
20 #define OSD_DLG_INFO "xx_OSD_INFO"
21 #define OSD_DLG_EDITING "xx_OSD_EDITING"
22 #define OSD_DLG_ASKALLOW "xx_OSD_ASKALLOW"
23 #define OSD_DLG_EDITOR "xx_OSD_EDITOR"
24 #define OSD_DLG_CUTPOINT "xx_OSD_CUTPOINT"
25 #define OSD_DLG_DELETE "xx_OSD_DELETE"
26 #define OSD_DLG_NAVIGATE "xx_OSD_NAVIGATE"
27 #define OSD_DLG_CONFIRM "mythconfirmpopup"
28 
29 #define OSD_WIN_MESSAGE "osd_message"
30 #define OSD_WIN_INPUT "osd_input"
31 #define OSD_WIN_PROGINFO "program_info"
32 #define OSD_WIN_STATUS "osd_status"
33 #define OSD_WIN_DEBUG "osd_debug"
34 #define OSD_WIN_BROWSE "browse_info"
35 #define 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 
45 {
53 };
54 
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 { };
86  std::chrono::milliseconds m_timeout { 0ms };
87  std::vector<MythOSDDialogButton> m_buttons { };
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 };
148  QString m_pulsedDialogText { };
149  QDateTime m_nextPulseUpdate { };
150  std::array<std::chrono::milliseconds,4> m_timeouts { -1ms, 3s, 5s, 13s };
151  enum OSDFunctionalType m_functionalType { kOSDFunctionalType_Default };
152  QString m_functionalWindow { };
153  QHash<MythScreenType*, QDateTime> m_expireTimes { };
154 };
155 
156 #endif
Q_DECLARE_METATYPE
Q_DECLARE_METATYPE(GrabberScript *)
mythplayerstate.h
MythOSDDialogData::m_dialogName
QString m_dialogName
Definition: osd.h:84
MythOSDDialogData::MythOSDDialogButton::m_current
bool m_current
Definition: osd.h:73
MythOSDDialogData::MythOSDBackButton::m_data
QVariant m_data
Definition: osd.h:80
MythOSDDialogData::MythOSDBackButton
Definition: osd.h:76
frm_dir_map_t
QMap< uint64_t, MarkTypes > frm_dir_map_t
Frame # -> Mark map.
Definition: programtypes.h:119
MythScreenType
Screen in which all other widgets are contained and rendered.
Definition: mythscreentype.h:45
MythOSDDialogData::MythOSDDialogButton
Definition: osd.h:67
kOSDTimeout_None
@ kOSDTimeout_None
Definition: osd.h:58
Visible
Definition: channelsettings.cpp:392
kOSDFunctionalType_TimeStretchAdjust
@ kOSDFunctionalType_TimeStretchAdjust
Definition: osd.h:49
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:10
OSDTimeout
OSDTimeout
Definition: osd.h:55
MythOSDDialogData
Definition: osd.h:64
kOSDFunctionalType_Default
@ kOSDFunctionalType_Default
Definition: osd.h:46
mythmediaoverlay.h
Event
Event details.
Definition: zmdefines.h:26
kOSDFunctionalType_SmartForward
@ kOSDFunctionalType_SmartForward
Definition: osd.h:48
kOSDFunctionalType_SubtitleDelayAdjust
@ kOSDFunctionalType_SubtitleDelayAdjust
Definition: osd.h:52
mythtypes.h
kOSDTimeout_Short
@ kOSDTimeout_Short
Definition: osd.h:59
MythOSDDialogData::m_message
QString m_message
Definition: osd.h:85
kOSDTimeout_Long
@ kOSDTimeout_Long
Definition: osd.h:61
MythOSDDialogData::m_timeout
std::chrono::milliseconds m_timeout
Definition: osd.h:86
kOSDTimeout_Ignore
@ kOSDTimeout_Ignore
Definition: osd.h:57
MythOSDDialogData::MythOSDDialogButton::m_data
QVariant m_data
Definition: osd.h:71
kOSDFunctionalType_SubtitleZoomAdjust
@ kOSDFunctionalType_SubtitleZoomAdjust
Definition: osd.h:51
MythOSDDialogData::MythOSDDialogButton::m_menu
bool m_menu
Definition: osd.h:72
MythOSDDialogData::MythOSDBackButton::m_text
QString m_text
Definition: osd.h:79
MythOSDDialogData::m_buttons
std::vector< MythOSDDialogButton > m_buttons
Definition: osd.h:87
kOSDFunctionalType_AudioSyncAdjust
@ kOSDFunctionalType_AudioSyncAdjust
Definition: osd.h:50
MythMediaOverlay
Definition: mythmediaoverlay.h:30
MythPainter
Definition: mythpainter.h:34
kOSDFunctionalType_PictureAdjust
@ kOSDFunctionalType_PictureAdjust
Definition: osd.h:47
MythOSDDialogData::m_back
MythOSDBackButton m_back
Definition: osd.h:88
OSDFunctionalType
OSDFunctionalType
Definition: osd.h:44
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
MythOSDDialogData::MythOSDDialogButton::m_text
QString m_text
Definition: osd.h:70
kOSDTimeout_Med
@ kOSDTimeout_Med
Definition: osd.h:60
OSD
Definition: osd.h:93
MythMainWindow
Definition: mythmainwindow.h:35
mythscreentype.h
TV
Control TV playback.
Definition: tv_play.h:154