mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-11-25 20:22:39 +01:00
Refactor project to use Util functions
This commit is contained in:
parent
1e1dd057e6
commit
e73ac98fc9
@ -31,4 +31,4 @@ if(APPLE)
|
|||||||
set_target_properties(${PROJECT_NAME} PROPERTIES MACOSX_BUNDLE true)
|
set_target_properties(${PROJECT_NAME} PROPERTIES MACOSX_BUNDLE true)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::Quick Qt5::Gui Qt5::Widgets Qt5::Core ScreenPlaySDK)
|
target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::Quick Qt5::Gui Qt5::Widgets Qt5::Core ScreenPlaySDK ScreenPlayUtil)
|
||||||
|
@ -2,6 +2,9 @@
|
|||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
|
||||||
|
#include "ScreenPlayUtil/contenttypes.h"
|
||||||
|
#include "ScreenPlayUtil/util.h"
|
||||||
|
|
||||||
WidgetWindow::WidgetWindow(
|
WidgetWindow::WidgetWindow(
|
||||||
const QString& projectPath,
|
const QString& projectPath,
|
||||||
const QString& appID,
|
const QString& appID,
|
||||||
@ -18,12 +21,7 @@ WidgetWindow::WidgetWindow(
|
|||||||
QObject::connect(m_sdk.get(), &ScreenPlaySDK::sdkDisconnected, this, &WidgetWindow::qmlExit);
|
QObject::connect(m_sdk.get(), &ScreenPlaySDK::sdkDisconnected, this, &WidgetWindow::qmlExit);
|
||||||
QObject::connect(m_sdk.get(), &ScreenPlaySDK::incommingMessage, this, &WidgetWindow::messageReceived);
|
QObject::connect(m_sdk.get(), &ScreenPlaySDK::incommingMessage, this, &WidgetWindow::messageReceived);
|
||||||
|
|
||||||
QStringList availableTypes {
|
if (!ScreenPlayUtil::getAvailableWidgets().contains(m_type, Qt::CaseSensitivity::CaseInsensitive)) {
|
||||||
"qmlWidget",
|
|
||||||
"htmlWidget"
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!availableTypes.contains(m_type, Qt::CaseSensitivity::CaseInsensitive)) {
|
|
||||||
QApplication::exit(-4);
|
QApplication::exit(-4);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,20 +42,13 @@ WidgetWindow::WidgetWindow(
|
|||||||
if (projectPath == "test") {
|
if (projectPath == "test") {
|
||||||
setSourcePath("qrc:/test.qml");
|
setSourcePath("qrc:/test.qml");
|
||||||
} else {
|
} else {
|
||||||
QFile configTmp;
|
auto projectOpt = ScreenPlayUtil::openJsonFileToObject(projectPath + "/project.json");
|
||||||
QJsonDocument configJsonDocument;
|
if (projectOpt.has_value()) {
|
||||||
QJsonParseError parseError {};
|
qWarning() << "Unable to parse project file!";
|
||||||
|
QApplication::exit(-1);
|
||||||
configTmp.setFileName(projectPath + "/project.json");
|
|
||||||
configTmp.open(QIODevice::ReadOnly | QIODevice::Text);
|
|
||||||
m_projectConfig = configTmp.readAll();
|
|
||||||
configJsonDocument = QJsonDocument::fromJson(m_projectConfig.toUtf8(), &parseError);
|
|
||||||
|
|
||||||
if (!(parseError.error == QJsonParseError::NoError)) {
|
|
||||||
qWarning() << "Settings Json Parse Error " << parseError.errorString() << configTmp.fileName();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_project = configJsonDocument.object();
|
m_project = projectOpt.value();
|
||||||
QString fullPath = "file:///" + projectPath + "/" + m_project.value("file").toString();
|
QString fullPath = "file:///" + projectPath + "/" + m_project.value("file").toString();
|
||||||
setSourcePath(fullPath);
|
setSourcePath(fullPath);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user