-
-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[js] Implement ability to create custom QML UIs that can control the …
…score
- Loading branch information
Showing
22 changed files
with
796 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#include "ApplicationPlugin.hpp" | ||
|
||
#include <JS/Qml/DeviceContext.hpp> | ||
#include <JS/Qml/EditContext.hpp> | ||
#include <JS/Qml/Utils.hpp> | ||
|
||
namespace JS | ||
{ | ||
ApplicationPlugin::ApplicationPlugin(const score::GUIApplicationContext& ctx) | ||
: score::GUIApplicationPlugin{ctx} | ||
{ | ||
m_engine.globalObject().setProperty("Score", m_engine.newQObject(new EditJsContext)); | ||
m_engine.globalObject().setProperty("Util", m_engine.newQObject(new JsUtils)); | ||
m_engine.globalObject().setProperty("Device", m_engine.newQObject(new DeviceContext)); | ||
} | ||
|
||
ApplicationPlugin::~ApplicationPlugin() { } | ||
|
||
bool ApplicationPlugin::handleStartup() | ||
{ | ||
if(QFileInfo f{context.applicationSettings.ui}; f.isFile()) | ||
{ | ||
m_comp = new QQmlComponent{&m_engine, f.absoluteFilePath(), this}; | ||
|
||
if(auto obj = m_comp->create()) | ||
{ | ||
if(auto item = qobject_cast<QQuickItem*>(obj)) | ||
{ | ||
m_window = new QQuickWindow{}; | ||
m_window->setWidth(640); | ||
m_window->setHeight(480); | ||
item->setParentItem(m_window->contentItem()); | ||
m_window->show(); | ||
return true; | ||
} | ||
} | ||
else | ||
{ | ||
qDebug() << m_comp->errorString(); | ||
qGuiApp->exit(1); | ||
} | ||
delete m_comp; | ||
} | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#pragma once | ||
#include <score/plugins/application/GUIApplicationPlugin.hpp> | ||
|
||
#include <core/application/ApplicationSettings.hpp> | ||
|
||
#include <QFileInfo> | ||
#include <QQmlComponent> | ||
#include <QQmlContext> | ||
#include <QQmlEngine> | ||
#include <QQuickView> | ||
|
||
namespace JS | ||
{ | ||
class ApplicationPlugin final | ||
: public QObject | ||
, public score::GUIApplicationPlugin | ||
{ | ||
public: | ||
explicit ApplicationPlugin(const score::GUIApplicationContext& ctx); | ||
|
||
~ApplicationPlugin() override; | ||
bool handleStartup() override; | ||
|
||
QQmlEngine m_engine; | ||
QQmlComponent* m_comp{}; | ||
QQuickWindow* m_window{}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.