1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-11-22 10:42:29 +01:00

Refactor project to use Util functions

This commit is contained in:
Elias Steurer 2021-05-12 17:33:17 +02:00
parent 1e1dd057e6
commit e73ac98fc9
2 changed files with 10 additions and 19 deletions

View File

@ -31,4 +31,4 @@ if(APPLE)
set_target_properties(${PROJECT_NAME} PROPERTIES MACOSX_BUNDLE true)
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)

View File

@ -2,6 +2,9 @@
#include <QCoreApplication>
#include "ScreenPlayUtil/contenttypes.h"
#include "ScreenPlayUtil/util.h"
WidgetWindow::WidgetWindow(
const QString& projectPath,
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::incommingMessage, this, &WidgetWindow::messageReceived);
QStringList availableTypes {
"qmlWidget",
"htmlWidget"
};
if (!availableTypes.contains(m_type, Qt::CaseSensitivity::CaseInsensitive)) {
if (!ScreenPlayUtil::getAvailableWidgets().contains(m_type, Qt::CaseSensitivity::CaseInsensitive)) {
QApplication::exit(-4);
}
@ -44,20 +42,13 @@ WidgetWindow::WidgetWindow(
if (projectPath == "test") {
setSourcePath("qrc:/test.qml");
} else {
QFile configTmp;
QJsonDocument configJsonDocument;
QJsonParseError parseError {};
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();
auto projectOpt = ScreenPlayUtil::openJsonFileToObject(projectPath + "/project.json");
if (projectOpt.has_value()) {
qWarning() << "Unable to parse project file!";
QApplication::exit(-1);
}
m_project = configJsonDocument.object();
m_project = projectOpt.value();
QString fullPath = "file:///" + projectPath + "/" + m_project.value("file").toString();
setSourcePath(fullPath);
}