MythTV  master
mythscreentype.h
Go to the documentation of this file.
1 #ifndef MYTHSCREEN_TYPE_H_
2 #define MYTHSCREEN_TYPE_H_
3 
4 #include <utility>
5 
6 // Qt headers
7 #include <QEvent>
8 #include <QSemaphore>
9 
10 // MythTV headers
11 #include "mythuicomposite.h"
12 #include "mythuiutils.h"
13 
14 class ScreenLoadTask;
15 class MythScreenStack;
16 class MythUIBusyDialog;
17 
25 {
26  public:
27  explicit ScreenLoadCompletionEvent(QString id) :
28  QEvent(kEventType), m_id(std::move(id)) { }
29 
30  QString GetId() { return m_id; }
31 
32  static Type kEventType;
33 
34  private:
35  QString m_id;
36 };
37 
45 {
46  Q_OBJECT
47 
48  friend class ScreenLoadTask;
49 
50  public:
51  MythScreenType(MythScreenStack *parent, const QString &name,
52  bool fullscreen = true);
53  ~MythScreenType() override;
54 
55  virtual bool Create(void); // do the actual work of making the screen.
56  bool keyPressEvent(QKeyEvent *event) override; // MythUIType
57  bool gestureEvent(MythGestureEvent *event) override; // MythUIType
58  virtual void ShowMenu(void);
59 
60  void doInit(void);
61  void LoadInForeground(void);
62  bool IsInitialized(void) const;
63 
64  // if the widget is full screen and obscures widgets below it
65  bool IsFullscreen(void) const;
66  void SetFullscreen(bool full);
67 
68  MythUIType *GetFocusWidget(void) const;
69  bool SetFocusWidget(MythUIType *widget = nullptr);
70  virtual bool NextPrevWidgetFocus(bool up_or_down);
71  void BuildFocusList(void);
72 
73  MythScreenStack *GetScreenStack() const;
74 
75  virtual void aboutToHide(void);
76  virtual void aboutToShow(void);
77 
78  bool IsDeleting(void) const;
79  void SetDeleting(bool deleting);
80 
81  bool IsLoading(void) const { return m_isLoading; }
82  bool IsLoaded(void) const { return m_isLoaded; }
83 
84  MythPainter *GetPainter(void) override; // MythUIType
85 
86  public slots:
87  virtual void Close();
88 
89  signals:
90  void Exiting();
91 
92  protected:
93  // for the global store..
94  MythScreenType(MythUIType *parent, const QString &name,
95  bool fullscreen = true);
96 
97  void CopyFrom(MythUIType *base) override; // MythUIType
98  void CreateCopy(MythUIType *parent) override; // MythUIType
99  bool ParseElement( const QString &filename,
100  QDomElement &element,
101  bool showWarnings) override; // MythUIType
102 
103  virtual void Load(void); // ONLY to be used for loading data, NO UI WORK or it will segfault
104  virtual void Init(void); // UI work to draw data loaded
105 
106  void LoadInBackground(const QString& message = "");
107  void ReloadInBackground(void);
108 
109  void OpenBusyPopup(const QString& message = "");
110  void CloseBusyPopup(void);
111  void SetBusyPopupMessage(const QString &message);
112  void ResetBusyPopup(void);
113 
114  bool m_fullScreen {false};
115  bool m_isDeleting {false};
116 
117  QSemaphore m_loadLock {1};
118  volatile bool m_isLoading {false};
119  volatile bool m_isLoaded {false};
120  bool m_isInitialized {false};
121 
122  MythUIType *m_currentFocusWidget {nullptr};
123  //TODO We are currently dependant on the internal sorting of QMap for
124  // entries to be iterated in the correct order, this should probably
125  // be changed.
126  QMap<int, MythUIType *> m_focusWidgetList;
127 
128  MythScreenStack *m_screenStack {nullptr};
129  MythUIBusyDialog *m_busyPopup {nullptr};
130 
131  QRegion m_savedMask;
132 
133  friend class XMLParseBase;
134 };
135 
136 #endif
MythUIType::keyPressEvent
virtual bool keyPressEvent(QKeyEvent *event)
Key event handler.
Definition: mythuitype.cpp:978
MythScreenType::IsLoading
bool IsLoading(void) const
Definition: mythscreentype.h:81
ScreenLoadCompletionEvent::GetId
QString GetId()
Definition: mythscreentype.h:30
slots
std::array< unsigned int, 4 > slots
Definition: element.cpp:38
MUI_PUBLIC
#define MUI_PUBLIC
Definition: mythuiexp.h:9
mythuicomposite.h
XMLParseBase
Definition: xmlparsebase.h:23
MythScreenStack
Definition: mythscreenstack.h:16
MythUIType::GetPainter
virtual MythPainter * GetPainter(void)
Definition: mythuitype.cpp:1400
MythScreenType
Screen in which all other widgets are contained and rendered.
Definition: mythscreentype.h:45
ScreenLoadCompletionEvent::kEventType
static Type kEventType
Definition: mythscreentype.h:32
MythUIType::CreateCopy
virtual void CreateCopy(MythUIType *parent)
Copy the state of this widget to the one given, it must be of the same type.
Definition: mythuitype.cpp:1210
mythuiutils.h
MythScreenType::IsLoaded
bool IsLoaded(void) const
Definition: mythscreentype.h:82
MythScreenType::m_focusWidgetList
QMap< int, MythUIType * > m_focusWidgetList
Definition: mythscreentype.h:126
filename
QString filename
Definition: mythplugins/mytharchive/mytharchivehelper/main.cpp:634
MythUIType::CopyFrom
virtual void CopyFrom(MythUIType *base)
Copy this widgets state from another.
Definition: mythuitype.cpp:1153
MythUIBusyDialog
Definition: mythprogressdialog.h:37
ScreenLoadCompletionEvent::ScreenLoadCompletionEvent
ScreenLoadCompletionEvent(QString id)
Definition: mythscreentype.h:27
MythUIType
The base class on which all widgets and screens are based.
Definition: mythuitype.h:64
ScreenLoadCompletionEvent::m_id
QString m_id
Definition: mythscreentype.h:35
ScreenLoadCompletionEvent
Event that can be dispatched from a MythScreenType when it has completed loading.
Definition: mythscreentype.h:25
MythPainter
Definition: mythpainter.h:33
MythUIType::gestureEvent
virtual bool gestureEvent(MythGestureEvent *event)
Mouse click/movement handler, receives mouse gesture events from the QCoreApplication event loop.
Definition: mythuitype.cpp:994
MythScreenType::Exiting
void Exiting()
MythScreenType::m_savedMask
QRegion m_savedMask
Definition: mythscreentype.h:131
MythGestureEvent
A custom event that represents a mouse gesture.
Definition: mythgesture.h:40
MythUIType::ParseElement
virtual bool ParseElement(const QString &filename, QDomElement &element, bool showWarnings)
Parse the xml definition of this widget setting the state of the object accordingly.
Definition: mythuitype.cpp:1219
ScreenLoadTask
Definition: mythscreentype.cpp:44
MythUIComposite
Definition: mythuicomposite.h:8