Overte C++ Documentation
QmlFragmentClass.h
1 //
2 // Created by Gabriel Calero & Cristian Duarte on Aug 25, 2017
3 // Copyright 2017 High Fidelity, Inc.
4 // Copyright 2023 Overte e.V.
5 //
6 // Distributed under the Apache License, Version 2.0.
7 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
8 // SPDX-License-Identifier: Apache-2.0
9 //
10 
11 #ifndef hifi_ui_QmlFragmentClass_h
12 #define hifi_ui_QmlFragmentClass_h
13 
14 #include "QmlWindowClass.h"
15 #include <ScriptValue.h>
16 
17 class ScriptContext;
18 class ScriptEngine;
19 
20 class QmlFragmentClass : public QmlWindowClass {
21  Q_OBJECT
22 
23 private:
24  static ScriptValue internal_constructor(ScriptContext* context, ScriptEngine* engine, bool restricted);
25 public:
26  static ScriptValue constructor(ScriptContext* context, ScriptEngine* engine) {
27  return internal_constructor(context, engine, false);
28  }
29 
30  static ScriptValue restricted_constructor(ScriptContext* context, ScriptEngine* engine ){
31  return internal_constructor(context, engine, true);
32  }
33 
34  QmlFragmentClass(bool restricted, QString id);
35 
36  /*@jsdoc
37  * Creates a new button, adds it to this and returns it.
38  * @function QmlFragmentClass#addButton
39  * @param properties {object} button properties
40  * @returns {TabletButtonProxy}
41  */
42  Q_INVOKABLE QObject* addButton(const QVariant& properties);
43 
44  /*
45  * TODO - not yet implemented
46  */
47  Q_INVOKABLE void removeButton(QObject* tabletButtonProxy);
48 public slots:
49  Q_INVOKABLE void close();
50 
51 protected:
52  QString qmlSource() const override { return qml; }
53 
54  static std::mutex _mutex;
55  static std::map<QString, ScriptValue> _fragments;
56 private:
57  QString qml;
58 
59 };
60 
61 #endif
[ScriptInterface] Provides an engine-independent interface for QScriptContext
Definition: ScriptContext.h:55
Provides an engine-independent interface for a scripting engine.
Definition: ScriptEngine.h:93
[ScriptInterface] Provides an engine-independent interface for QScriptValue
Definition: ScriptValue.h:40