diff --git a/ScreenPlayWidget/SPWidgetmain.cpp b/ScreenPlayWidget/SPWidgetmain.cpp index a577149d..da0e1f7e 100644 --- a/ScreenPlayWidget/SPWidgetmain.cpp +++ b/ScreenPlayWidget/SPWidgetmain.cpp @@ -3,12 +3,13 @@ #include #include "src/spwidgetmainwindow.h" +#include "../ScreenPlaySDK/screenplaysdk.h" int main(int argc, char* argv[]) { QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QGuiApplication::setAttribute(Qt::AA_UseOpenGLES); - + ScreenPlaySDK sdk; QGuiApplication app(argc, argv); @@ -21,5 +22,8 @@ int main(int argc, char* argv[]) SPWidgetmainwindow spwmw(argumentList.at(1), argumentList.at(2)); //SPWidgetmainwindow spwmw("D:/672870/xkcd","asasasasd" ); + QObject::connect(&sdk, &ScreenPlaySDK::sdkDisconnected, &spwmw, &SPWidgetmainwindow::destroyThis); + QObject::connect(&sdk, &ScreenPlaySDK::incommingMessage, &spwmw, &SPWidgetmainwindow::messageReceived); + return app.exec(); } diff --git a/ScreenPlayWidget/ScreenPlayWidget.pro b/ScreenPlayWidget/ScreenPlayWidget.pro index 349724be..3517fa1e 100644 --- a/ScreenPlayWidget/ScreenPlayWidget.pro +++ b/ScreenPlayWidget/ScreenPlayWidget.pro @@ -19,6 +19,24 @@ SOURCES += \ RESOURCES += \ SPWidgetResources.qrc +INCLUDEPATH += \ + $$PWD/../../ThirdParty/ \ + $$PWD/../../src/ \ + +include(../ScreenPlaySDK/Screenplaysdk.pri) + +CONFIG(debug, debug|release) { +LIBS += -lScreenplaysdkd + install_it.path = $${OUT_PWD}/debug/ + QMAKE_LIBDIR += $$OUT_PWD/../ScreenPlaySDK/debug + } else { +LIBS += -lScreenplaysdk + install_it.path = $${OUT_PWD}/release/ + QMAKE_LIBDIR += $$OUT_PWD/../ScreenPlaySDK/release + } +QMAKE_LIBDIR += $$OUT_PWD/../ScreenPlaySDK + + # Additional import path used to resolve QML modules just for Qt Quick Designer # QML_DESIGNER_IMPORT_PATH = QT_QUICK_CONTROLS_STYLE = "Material" diff --git a/ScreenPlayWidget/main.qml b/ScreenPlayWidget/main.qml index 731d0caf..5fab322f 100644 --- a/ScreenPlayWidget/main.qml +++ b/ScreenPlayWidget/main.qml @@ -8,7 +8,7 @@ Item { anchors.fill: parent Rectangle { - id:bgColor + id: bgColor anchors.fill: parent color: "white" //color: "#1A1F22" @@ -23,7 +23,6 @@ Item { fillMode: Image.Tile } - MouseArea { id: mouseArea anchors.fill: parent @@ -35,31 +34,6 @@ Item { onPositionChanged: { backend.setPos(mouse.x, mouse.y) } - - } - - ScreenPlaySDK { - id: spSDK - contentType: "ScreenPlayWindow" - appID: backend.appID - - onIncommingMessageError: { - - } - onIncommingMessage: { - var obj2 = 'import QtQuick 2.9; Item {Component.onCompleted: sceneLoader.item.' - + key + ' = ' + value + '; }' - var newObject = Qt.createQmlObject(obj2.toString(), root, "err") - newObject.destroy(10000) - } - - onSdkConnected: { - - } - - onSdkDisconnected: { - Qt.quit() - } } Connections { @@ -69,6 +43,13 @@ Item { loader.source = Qt.resolvedUrl("file:///" + source) print(loader.source) } + + onQmlSceneValueReceived: { + var obj2 = 'import QtQuick 2.9; Item {Component.onCompleted: loader.item.' + + key + ' = ' + value + '; }' + var newObject = Qt.createQmlObject(obj2.toString(), root, "err") + newObject.destroy(10000) + } } Loader { diff --git a/ScreenPlayWidget/src/spwidgetmainwindow.cpp b/ScreenPlayWidget/src/spwidgetmainwindow.cpp index 0338cc58..7d999fe3 100644 --- a/ScreenPlayWidget/src/spwidgetmainwindow.cpp +++ b/ScreenPlayWidget/src/spwidgetmainwindow.cpp @@ -1,5 +1,7 @@ #include "spwidgetmainwindow.h" +#include + SPWidgetmainwindow::SPWidgetmainwindow(QString projectPath, QString appid, QScreen* parent) : QWindow(parent) { @@ -52,6 +54,16 @@ void SPWidgetmainwindow::setSize(QSize size) m_quickRenderer.data()->setHeight(size.height()); } +void SPWidgetmainwindow::destroyThis() +{ + QCoreApplication::quit(); +} + +void SPWidgetmainwindow::messageReceived(QString key, QString value) +{ + emit qmlSceneValueReceived(key, value); +} + void SPWidgetmainwindow::setPos(int xPos, int yPos) { diff --git a/ScreenPlayWidget/src/spwidgetmainwindow.h b/ScreenPlayWidget/src/spwidgetmainwindow.h index 1872ff1b..7f5ddbf5 100644 --- a/ScreenPlayWidget/src/spwidgetmainwindow.h +++ b/ScreenPlayWidget/src/spwidgetmainwindow.h @@ -46,9 +46,12 @@ signals: void typeChanged(QString type); void projectConfigChanged(QString projectConfig); void setWidgetSource(QString source); + void qmlSceneValueReceived(QString key, QString value); public slots: void setSize(QSize size); + void destroyThis(); + void messageReceived(QString key, QString value); void setAppID(QString appID) { if (m_appID == appID)