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