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 #define kOSDFadeTime 1000
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 { };
88  std::vector<MythOSDDialogButton> m_buttons { };
90 };
91 
93 
94 class OSD : public MythMediaOverlay
95 {
96  Q_OBJECT
97 
98  signals:
100 
101  public slots:
102  void SetText(const QString& Window, const InfoMap& Map, OSDTimeout Timeout);
103 
104  protected slots:
105  void ShowDialog(const MythOSDDialogData& Data);
106  void IsOSDVisible(bool& Visible);
107 
108  public:
109  OSD(MythMainWindow* MainWindow, TV* Tv, MythPlayerUI* Player, MythPainter* Painter);
110  ~OSD() override;
111 
112  bool Init(QRect Rect, float FontAspect) override;
113  void HideWindow(const QString &Window) override;
114  void SetFunctionalWindow(const QString &Window, enum OSDFunctionalType Type);
115  void HideAll(bool KeepSubs = true, MythScreenType *Except = nullptr, bool DropNotification = false);
116  void SetExpiry(const QString &Window, enum OSDTimeout Timeout, int CustomTimeout = 0);
117  void ResetWindow(const QString &Window);
118  void Draw(QRect Rect);
119 
120  void SetValues(const QString &Window, const QHash<QString,int> &Map, OSDTimeout Timeout);
121  void SetValues(const QString &Window, const QHash<QString,float> &Map, OSDTimeout Timeout);
122  void SetRegions(const QString &Window, frm_dir_map_t &Map, long long Total);
123  void SetGraph(const QString &Window, const QString &Graph, int64_t Timecode);
124  bool IsWindowVisible(const QString &Window);
125 
126  bool DialogVisible(const QString& Window = QString());
127  bool DialogHandleKeypress(QKeyEvent *Event);
128  bool DialogHandleGesture(MythGestureEvent *Event);
129  void DialogQuit();
130  void DialogGetText(InfoMap &Map);
131 
132  private:
133  void PositionWindow(MythScreenType* Window);
134  void RemoveWindow(const QString& Window);
135  void DialogShow(const QString& Window, const QString& Text = "", int UpdateFor = 0);
136  void DialogAddButton(const QString& Text, QVariant Data, bool Menu = false, bool Current = false);
137  void DialogBack(const QString& Text = "", const QVariant& Data = 0, bool Exit = false);
138  void TearDown() override;
139  void LoadWindows();
140  void CheckExpiry();
141  void SetExpiryPriv(const QString &Window, enum OSDTimeout Timeout, int CustomTimeout);
142 
143  private:
144  int m_fadeTime { kOSDFadeTime };
145  MythScreenType* m_dialog { nullptr };
146  QString m_pulsedDialogText { };
147  QDateTime m_nextPulseUpdate { };
148  std::array<int,4> m_timeouts { -1, 3000, 5000, 13000 };
149  enum OSDFunctionalType m_functionalType { kOSDFunctionalType_Default };
150  QString m_functionalWindow { };
151  QHash<MythScreenType*, QDateTime> m_expireTimes { };
152 };
153 
154 #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:78
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:45
MythOSDDialogData::MythOSDDialogButton
Definition: osd.h:69
kOSDTimeout_None
@ kOSDTimeout_None
Definition: osd.h:59
Visible
Definition: channelsettings.cpp:392
kOSDFunctionalType_TimeStretchAdjust
@ kOSDFunctionalType_TimeStretchAdjust
Definition: osd.h:50
programtypes.h
InfoMap
QHash< QString, QString > InfoMap
Definition: mythtypes.h:15
kOSDFadeTime
#define kOSDFadeTime
Definition: osd.h:38
MythPlayerUI
Definition: mythplayerui.h:11
OSDTimeout
OSDTimeout
Definition: osd.h:57
MythOSDDialogData
Definition: osd.h:66
kOSDFunctionalType_Default
@ kOSDFunctionalType_Default
Definition: osd.h:47
mythmediaoverlay.h
MythOSDDialogData::m_timeout
int m_timeout
Definition: osd.h:87
OSD::HideOSD
void HideOSD(OSDFunctionalType Type)
Event
Event details.
Definition: zmdefines.h:27
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
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:31
MythPainter
Definition: mythpainter.h:33
kOSDFunctionalType_PictureAdjust
@ kOSDFunctionalType_PictureAdjust
Definition: osd.h:48
MythOSDDialogData::m_back
MythOSDBackButton m_back
Definition: osd.h:89
OSDFunctionalType
OSDFunctionalType
Definition: osd.h:46
MythGestureEvent
A custom event that represents a mouse gesture.
Definition: mythgesture.h:40
MythOSDDialogData::MythOSDBackButton::m_exit
bool m_exit
Definition: osd.h:82
Player
Definition: zmliveplayer.h:35
MythOSDDialogData::MythOSDDialogButton::m_text
QString m_text
Definition: osd.h:71
kOSDTimeout_Med
@ kOSDTimeout_Med
Definition: osd.h:61
OSD
Definition: osd.h:95
MythMainWindow
Definition: mythmainwindow.h:35
mythscreentype.h
TV
Control TV playback.
Definition: tv_play.h:153