1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-11-25 12:13:00 +01:00

Fix sdk connection not sending appID with the "appID=" in the beginning of the string

This commit is contained in:
Elias Steurer 2020-01-10 15:26:25 +01:00
parent ad886d6e84
commit dbe1135708
6 changed files with 78 additions and 43 deletions

View File

@ -25,7 +25,11 @@ ScreenPlayWidget::ScreenPlayWidget(
, m_position { 0, 0 }
, m_type { type }
{
const QStringList proArgs { m_projectPath, m_appID, m_type };
const QStringList proArgs {
m_projectPath,
QString { "appID=" + m_appID },
m_type
};
m_process.setArguments(proArgs);
if (fullPath.endsWith(".exe")) {

View File

@ -140,13 +140,12 @@ public slots:
void close()
{
if ((m_socket->state()) == QLocalSocket::UnconnectedState || (m_socket->state()) == QLocalSocket::ClosingState)
return;
if (m_socket->state() == QLocalSocket::ConnectedState) {
m_socket->disconnectFromServer();
m_socket->close();
m_socket->disconnectFromServer();
m_socket->close();
qDebug() << "### Destroy APPID:\t " << m_appID << " State: " << m_socket->state();
qDebug() << "### Destroy APPID:\t " << m_appID << " State: " << m_socket->state();
}
}
void setAppID(QString appID)

View File

@ -2,22 +2,22 @@
#include <QQmlApplicationEngine>
#include <QStringList>
#include "src/widgetwindow.h"
#include "../ScreenPlaySDK/screenplaysdk.h"
#include "src/widgetwindow.h"
int main(int argc, char* argv[])
{
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
ScreenPlaySDK sdk;
QGuiApplication app(argc, argv);
QStringList argumentList = app.arguments();
// If we start with only one argument (app, path, type),
// If we start with only one argument (path, appID, type),
// it means we want to test a single widget
if (argumentList.length() == 1) {
WidgetWindow spwmw("test","appid", "qmlWidget");
WidgetWindow spwmw("test", "appid", "qmlWidget");
return app.exec();
}
@ -25,6 +25,7 @@ int main(int argc, char* argv[])
return -3;
}
ScreenPlaySDK sdk(argumentList.at(2), argumentList.at(3));
WidgetWindow spwmw(argumentList.at(1), argumentList.at(2), argumentList.at(3));
QObject::connect(&sdk, &ScreenPlaySDK::sdkDisconnected, &spwmw, &WidgetWindow::destroyThis);

View File

@ -1,10 +1,23 @@
import QtQuick 2.12
import QtQuick.Controls 2.3
import QtWebEngine 1.8
import ScreenPlayWidget 1.0
Item {
id: mainWindow
anchors.fill: parent
Connections {
target: Widget
onQmlSceneValueReceived: {
var obj2 = 'import QtQuick 2.14; Item {Component.onCompleted: loader.item.'
+ key + ' = ' + value + '; }'
var newObject = Qt.createQmlObject(obj2.toString(), root, "err")
newObject.destroy(10000)
}
}
OpacityAnimator {
id: animFadeOut
from: 1
@ -12,7 +25,7 @@ Item {
target: parent
duration: 800
easing.type: Easing.InOutQuad
onFinished: window.destroyThis()
onFinished: Widget.destroyThis()
}
Rectangle {
@ -29,19 +42,36 @@ Item {
opacity: .05
fillMode: Image.Tile
}
Loader {
id: loader
anchors.fill: parent
asynchronous: true
source: {
Qt.resolvedUrl(window.sourcePath)
Component.onCompleted: {
if (Widget.type === "qmlWidget") {
loader.source = Qt.resolvedUrl(Widget.sourcePath)
} else if (Widget.type === "htmlWidget") {
loader.sourceComponent = webViewComponent
}
}
Connections {
target: loader.item
onSizeChanged: {
mainWindow.width = size.width
mainWindow.height = size.height
ignoreUnknownSignals: true
onWidthChanged: mainWindow.width = loader.item.width
onHeightChanged: mainWindow.height = loader.item.height
}
}
Component {
id: webViewComponent
WebEngineView {
id: webView
backgroundColor: "transparent"
anchors.fill: parent
onJavaScriptConsoleMessage: print(lineNumber, message)
Component.onCompleted: {
webView.url = Qt.resolvedUrl(Widget.sourcePath)
}
}
}
@ -51,23 +81,12 @@ Item {
anchors.fill: parent
hoverEnabled: true
onPressed: {
window.setClickPos(Qt.point(mouse.x, mouse.y))
Widget.setClickPos(Qt.point(mouse.x, mouse.y))
}
onPositionChanged: {
if (mouseArea.pressed)
window.setPos(mouse.x, mouse.y)
}
}
Connections {
target: window
onQmlSceneValueReceived: {
var obj2 = 'import QtQuick 2.12; Item {Component.onCompleted: loader.item.'
+ key + ' = ' + value + '; }'
var newObject = Qt.createQmlObject(obj2.toString(), root, "err")
newObject.destroy(10000)
Widget.setPos(mouse.x, mouse.y)
}
}
@ -81,15 +100,25 @@ Item {
}
cursorShape: Qt.PointingHandCursor
onClicked: {
window.setWindowBlur(0)
Widget.setWindowBlur(0)
animFadeOut.start()
}
hoverEnabled: true
onEntered: imgClose.opacity = 1
onExited: imgClose.opacity = .15
Image {
id: imgClose
source: "qrc:/assets/icons/baseline-close-24px.svg"
anchors.centerIn: parent
opacity: .15
OpacityAnimator {
target: parent
duration: 300
}
}
}
MouseArea {
id: mouseAreaResize
width: 20
@ -107,7 +136,7 @@ Item {
onPositionChanged: {
if (mouseAreaResize.pressed) {
window.setWidgetSize(clickPosition.x + mouseX,
Widget.setWidgetSize(clickPosition.x + mouseX,
clickPosition.y + mouseY)
}
}

View File

@ -9,8 +9,7 @@ WidgetWindow::WidgetWindow(const QString projectPath, const QString appid, const
{
QStringList availableTypes {
"qmlWidget",
"htmlWidget",
"standaloneWidget"
"htmlWidget"
};
if (!availableTypes.contains(m_type)) {

View File

@ -2,6 +2,7 @@
#include <QDebug>
#include <QFile>
#include <QGuiApplication>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonParseError>
@ -15,7 +16,6 @@
#include <QWindow>
#include <QtQuick/QQuickView>
#include <QtQuick/QQuickWindow>
#include <QGuiApplication>
#ifdef Q_OS_WIN
#include <qt_windows.h>
@ -53,6 +53,8 @@ public:
}
signals:
void qmlExit();
void appIDChanged(QString appID);
void typeChanged(QString type);
void projectConfigChanged(QString projectConfig);
@ -66,9 +68,6 @@ public slots:
void setPos(int xPos, int yPos);
void setClickPos(const QPoint& clickPos);
void setWidgetSize(const int with, const int height);
#ifdef Q_OS_WIN
void setWindowBlur(unsigned int style = 3);
#endif
void setAppID(QString appID)
{
@ -94,7 +93,6 @@ public slots:
m_projectConfig = projectConfig;
emit projectConfigChanged(m_projectConfig);
}
void setSourcePath(QString sourcePath)
{
if (m_sourcePath == sourcePath)
@ -104,16 +102,21 @@ public slots:
emit sourcePathChanged(m_sourcePath);
}
#ifdef Q_OS_WIN
void setWindowBlur(unsigned int style = 3);
#endif
private:
QString m_appID { "" };
QString m_type { "qmlWidget" };
QString m_projectConfig { "" };
QString m_sourcePath { "" };
QJsonObject m_project;
QPoint m_clickPos = { 0, 0 };
QQuickView m_window;
#ifdef Q_OS_WIN
HWND m_hwnd;
#endif
QPoint m_clickPos = { 0, 0 };
QQuickView m_window;
QString m_sourcePath { "" };
};