1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-11-07 03:22:33 +01:00

Fix workshop type not set resulting in not showing anything

This commit is contained in:
Elias Steurer 2020-07-18 20:48:24 +02:00
parent 0d7cb55643
commit 8bed32ae93
4 changed files with 27 additions and 26 deletions

View File

@ -15,7 +15,7 @@ Item {
animFadeOut.start()
}
function onQmlSceneValueReceived(key,value) {
function onQmlSceneValueReceived(key, value) {
var obj2 = 'import QtQuick 2.14; Item {Component.onCompleted: loader.item.'
+ key + ' = ' + value + '; }'
var newObject = Qt.createQmlObject(obj2.toString(), root, "err")
@ -67,26 +67,26 @@ Item {
anchors.fill: parent
asynchronous: true
Component.onCompleted: {
if (Widget.type === "qmlWidget") {
if (Widget.type === "QMLWidget") {
loader.source = Qt.resolvedUrl(Widget.sourcePath)
} else if (Widget.type === "htmlWidget") {
print("loader.source", loader.source)
} else if (Widget.type === "HTMLWidget") {
loader.sourceComponent = webViewComponent
}
}
onStatusChanged: {
if (loader.status == Loader.Ready) {
if(loader.item.widgetBackground !== undefined){
if (loader.item.widgetBackground !== undefined) {
bgColor.color = loader.item.widgetBackground
}
if(loader.item.widgetBackgroundOpacity !== undefined){
if (loader.item.widgetBackgroundOpacity !== undefined) {
bgColor.opacity = loader.item.widgetBackgroundOpacity
}
if(loader.item.widgetWidth !== undefined &&
loader.item.widgetHeight !== undefined){
if (loader.item.widgetWidth !== undefined
&& loader.item.widgetHeight !== undefined) {
Widget.setWidgetSize(loader.item.widgetWidth,
loader.item.widgetHeight)
}
}
}
}

View File

@ -37,8 +37,8 @@ int main(int argc, char* argv[])
positionY = 0;
}
// 0. App Path, 1. Project path, 2. AppID, 3. Type, 4. Posx, 5. PosY
WidgetWindow spwmw(argumentList.at(1), QPoint { positionX, positionY }, argumentList.at(2), argumentList.at(3));
// 1. Project path, 2. AppID, 3. Type, 4. Posx, 5. PosY
WidgetWindow spwmw(argumentList.at(1), argumentList.at(2), argumentList.at(3), QPoint { positionX, positionY });
return app.exec();
}

View File

@ -2,30 +2,33 @@
#include <QCoreApplication>
WidgetWindow::WidgetWindow(const QString& projectPath,
const QPoint& position,
const QString& appid,
const QString& type)
WidgetWindow::WidgetWindow(
const QString& projectPath,
const QString& appID,
const QString& type,
const QPoint& position)
: QObject(nullptr)
, m_appID { appid }
, m_appID { appID }
, m_type { type }
, m_position { position }
{
m_sdk = std::make_unique<ScreenPlaySDK>(appid, type);
m_sdk = std::make_unique<ScreenPlaySDK>(appID, type);
QObject::connect(m_sdk.get(), &ScreenPlaySDK::sdkDisconnected, this, &WidgetWindow::qmlExit);
QObject::connect(m_sdk.get(), &ScreenPlaySDK::incommingMessage, this, &WidgetWindow::messageReceived);
QStringList availableTypes {
"qmlWidget",
"htmlWidget"
"QMLWidget",
"HTMLWidget"
};
if (!availableTypes.contains(m_type)) {
if (!availableTypes.contains(m_type, Qt::CaseSensitivity::CaseInsensitive)) {
QApplication::exit(-4);
}
setType(type);
{
// We limit ourself to only update the position every 500ms!
auto sendPositionUpdate = [this]() {
@ -58,7 +61,9 @@ WidgetWindow::WidgetWindow(const QString& projectPath,
setWindowBlur();
#endif
if (projectPath != "test") {
if (projectPath == "test") {
setSourcePath("qrc:/test.qml");
} else {
QFile configTmp;
QJsonDocument configJsonDocument;
QJsonParseError parseError;
@ -75,11 +80,7 @@ WidgetWindow::WidgetWindow(const QString& projectPath,
m_project = configJsonDocument.object();
QString fullPath = "file:///" + projectPath + "/" + m_project.value("file").toString();
setSourcePath(fullPath);
} else {
setSourcePath("qrc:/test.qml");
}
// Instead of setting "renderType: Text.NativeRendering" every time
// we can set it here once :)
m_window.setTextRenderType(QQuickWindow::TextRenderType::NativeTextRendering);
m_window.setResizeMode(QQuickView::ResizeMode::SizeViewToRootObject);

View File

@ -65,9 +65,9 @@ class WidgetWindow : public QObject {
public:
explicit WidgetWindow(
const QString& projectPath,
const QPoint& position,
const QString& appid,
const QString& type);
const QString& type,
const QPoint& position);
Q_PROPERTY(QString appID READ appID WRITE setAppID NOTIFY appIDChanged)
Q_PROPERTY(QString type READ type WRITE setType NOTIFY typeChanged)