Loading...
Searching...
No Matches
score-plugin-js/JS/ApplicationPlugin.hpp
1#pragma once
2#include <score/plugins/application/GUIApplicationPlugin.hpp>
3
4#include <score_plugin_js_export.h>
5
6#include <core/application/ApplicationSettings.hpp>
7
8#include <QFileInfo>
9#include <QJSValue>
10#include <QQmlComponent>
11#include <QQmlContext>
12#include <QQmlEngine>
13
14#include <thread>
15#include <vector>
16
17namespace ossia::net
18{
19struct network_context;
20using network_context_ptr = std::shared_ptr<network_context>;
21}
22class QQuickWindow;
23namespace JS
24{
25// Exported like the other plugins' ApplicationPlugin: guiApplicationPlugin<T>()
26// dynamic_casts across the plugin boundary and needs the typeinfo visible.
27class SCORE_PLUGIN_JS_EXPORT ApplicationPlugin final
28 : public QObject
30{
31public:
33
34 void on_createdDocument(score::Document& doc) override;
35
36 ~ApplicationPlugin() override;
37 void afterStartup() override;
38 void on_newDocument(score::Document& doc) override;
39
53 static QJSValue importModule(QQmlEngine& engine, const QString& path);
54
55 // Used for processing whatever comes from the console
56 QQmlEngine m_consoleEngine;
57
58 // Used for instantiating JS::Script* to verify that the script is valid
59 // before updating, as well as for running JS UI scripts.
60 QQmlEngine m_scriptProcessUIEngine;
61 QQmlComponent* m_comp{};
62 QQuickWindow* m_window{};
63
64 std::atomic_bool m_processMessages{};
65 std::thread m_asioThread;
66 ossia::net::network_context_ptr m_asioContext;
67
70 {
71 QString source;
72 QString name;
73 QString file;
74 QString dir;
75 bool module{};
76 };
77
80 std::vector<StartScript> m_start_scripts;
81 bool m_start_script_failed{};
82};
83}
Definition score-plugin-js/JS/ApplicationPlugin.hpp:30
std::vector< StartScript > m_start_scripts
Definition score-plugin-js/JS/ApplicationPlugin.hpp:80
The Document class is the central part of the software.
Definition Document.hpp:51
Used to extend the software with application-wide data.
Definition GUIApplicationPlugin.hpp:89
One –script argument.
Definition score-plugin-js/JS/ApplicationPlugin.hpp:70
QString source
inline source or file contents; empty for a module
Definition score-plugin-js/JS/ApplicationPlugin.hpp:71
QString name
path as given, for diagnostics; empty when inline
Definition score-plugin-js/JS/ApplicationPlugin.hpp:72
QString dir
the script's folder, added as a QML import path
Definition score-plugin-js/JS/ApplicationPlugin.hpp:74
QString file
canonical path, what importModule() is given
Definition score-plugin-js/JS/ApplicationPlugin.hpp:73
Specializes ApplicationContext with the QMainWindow.
Definition GUIApplicationContext.hpp:15