MythTV  master
frontend.h
Go to the documentation of this file.
1 #ifndef FRONTEND_H
2 #define FRONTEND_H
3 
4 #include "libmythbase/mythconfig.h"
5 #if CONFIG_QTSCRIPT
6 #include <QScriptEngine>
7 #endif
10 
11 class Frontend : public FrontendServices
12 {
13  friend class MythFEXML;
14 
15  Q_OBJECT
16 
17  public:
18  Q_INVOKABLE explicit Frontend(QObject *parent = nullptr) : FrontendServices(parent) { }
19 
20  public:
21  DTC::FrontendStatus* GetStatus(void) override; // FrontendServices
22  bool SendMessage(const QString &Message,
23  uint TimeoutInt) override; // FrontendServices
24  bool SendNotification(bool Error,
25  const QString &Type,
26  const QString &Message,
27  const QString &Origin,
28  const QString &Description,
29  const QString &Image,
30  const QString &Extra,
31  const QString &ProgressText,
32  float Progress,
33  int Timeout,
34  bool Fullscreen,
35  uint Visibility, uint Priority) override; // FrontendServices
36 
37  bool SendAction(const QString &Action,
38  const QString &Value,
39  uint Width, uint Height) override; // FrontendServices
40  bool PlayRecording(int RecordedId, int ChanId,
41  const QDateTime &StartTime) override; // FrontendServices
42  bool PlayVideo(const QString &Id, bool UseBookmark) override; // FrontendServices
43  QStringList GetContextList(void) override; // FrontendServices
44  DTC::FrontendActionList* GetActionList(const QString &Context) override; // FrontendServices
45 
46 
47  static bool IsValidAction(const QString &action);
48  static void InitialiseActions(void);
49  bool SendKey(const QString &Key) override; // FrontendServices
50 
51  protected:
52  static QStringList gActionList;
53  static QHash<QString,QStringList> gActionDescriptions;
54 };
55 
56 // --------------------------------------------------------------------------
57 // The following class wrapper is due to a limitation in Qt Script Engine. It
58 // requires all methods that return pointers to user classes that are derived from
59 // QObject actually return QObject* (not the user class *). If the user class pointer
60 // is returned, the script engine treats it as a QVariant and doesn't create a
61 // javascript prototype wrapper for it.
62 //
63 // This class allows us to keep the rich return types in the main API class while
64 // offering the script engine a class it can work with.
65 //
66 // Only API Classes that return custom classes needs to implement these wrappers.
67 //
68 // We should continue to look for a cleaning solution to this problem.
69 // --------------------------------------------------------------------------
70 
71 #if CONFIG_QTSCRIPT
72 class ScriptableFrontend : public QObject
73 {
74  Q_OBJECT
75 
76  private:
77  Frontend m_obj;
78  QScriptEngine *m_pEngine;
79 
80  public:
81  Q_INVOKABLE explicit ScriptableFrontend( QScriptEngine *pEngine, QObject *parent = nullptr )
82  : QObject( parent ), m_pEngine(pEngine)
83  {
84  }
85  public slots:
86  QObject* GetStatus(void) { SCRIPT_CATCH_EXCEPTION( nullptr,
87  return m_obj.GetStatus(); ) }
88 };
89 
90 // NOLINTNEXTLINE(modernize-use-auto)
91 Q_SCRIPT_DECLARE_QMETAOBJECT_MYTHTV(ScriptableFrontend, QObject*);
92 #endif
93 
94 #endif // FRONTEND_H
Frontend::GetStatus
DTC::FrontendStatus * GetStatus(void) override
Definition: frontend.cpp:35
Frontend::SendMessage
bool SendMessage(const QString &Message, uint TimeoutInt) override
Definition: frontend.cpp:47
Frontend::PlayVideo
bool PlayVideo(const QString &Id, bool UseBookmark) override
Definition: frontend.cpp:197
service.h
FrontendServices
Definition: frontendServices.h:9
MythFEXML
Definition: mythfexml.h:24
Frontend::SendNotification
bool SendNotification(bool Error, const QString &Type, const QString &Message, const QString &Origin, const QString &Description, const QString &Image, const QString &Extra, const QString &ProgressText, float Progress, int Timeout, bool Fullscreen, uint Visibility, uint Priority) override
Definition: frontend.cpp:62
Image
Definition: image.h:33
Action
An action (for this plugin) consists of a description, and a set of key sequences.
Definition: action.h:40
frontendServices.h
Frontend::GetActionList
DTC::FrontendActionList * GetActionList(const QString &Context) override
Definition: frontend.cpp:259
Q_SCRIPT_DECLARE_QMETAOBJECT_MYTHTV
#define Q_SCRIPT_DECLARE_QMETAOBJECT_MYTHTV(T, _Arg1)
Definition: service.h:113
Frontend
Definition: backendcontext.h:19
Frontend::SendKey
bool SendKey(const QString &Key) override
Definition: frontend.cpp:340
uint
unsigned int uint
Definition: compat.h:81
SCRIPT_CATCH_EXCEPTION
#define SCRIPT_CATCH_EXCEPTION(default, code)
Definition: service.h:85
DTC::FrontendStatus
Definition: frontendStatus.h:9
Frontend::gActionList
static QStringList gActionList
Definition: frontend.h:52
Frontend::GetContextList
QStringList GetContextList(void) override
Definition: frontend.cpp:253
DTC::FrontendActionList
Definition: frontendActionList.h:9
Frontend::PlayRecording
bool PlayRecording(int RecordedId, int ChanId, const QDateTime &StartTime) override
Definition: frontend.cpp:134
Frontend::gActionDescriptions
static QHash< QString, QStringList > gActionDescriptions
Definition: frontend.h:53
build_compdb.action
action
Definition: build_compdb.py:9
Frontend::Frontend
Q_INVOKABLE Frontend(QObject *parent=nullptr)
Definition: frontend.h:18
Frontend::SendAction
bool SendAction(const QString &Action, const QString &Value, uint Width, uint Height) override
Definition: frontend.cpp:91
Frontend::IsValidAction
static bool IsValidAction(const QString &action)
Definition: frontend.cpp:284
Frontend::InitialiseActions
static void InitialiseActions(void)
Definition: frontend.cpp:306
Priority
Definition: channelsettings.cpp:216