mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-11-06 19:12:30 +01:00
Add basic widget functionallity
This commit is contained in:
parent
055013f2d3
commit
db6cad839e
@ -1,16 +1,24 @@
|
||||
#include <QGuiApplication>
|
||||
#include <QQmlApplicationEngine>
|
||||
#include <QStringList>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
#include "src/spwidgetmainwindow.h"
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
QGuiApplication::setAttribute(Qt::AA_UseOpenGLES);
|
||||
|
||||
QGuiApplication app(argc, argv);
|
||||
|
||||
QQmlApplicationEngine engine;
|
||||
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
|
||||
if (engine.rootObjects().isEmpty())
|
||||
return -1;
|
||||
QStringList argumentList = app.arguments();
|
||||
|
||||
if (argumentList.length() != 3) {
|
||||
return -3;
|
||||
}
|
||||
|
||||
SPWidgetmainwindow spwmw(argumentList.at(1), argumentList.at(2));
|
||||
//SPWidgetmainwindow spwmw("asasasasd", "D:/672870/xkcd");
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
|
@ -13,7 +13,8 @@ DEFINES += QT_DEPRECATED_WARNINGS
|
||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||
|
||||
SOURCES += \
|
||||
SPWidgetmain.cpp
|
||||
SPWidgetmain.cpp \
|
||||
src/spwidgetmainwindow.cpp
|
||||
|
||||
RESOURCES += \
|
||||
SPWidgetResources.qrc
|
||||
@ -28,3 +29,6 @@ QML_DESIGNER_IMPORT_PATH =
|
||||
qnx: target.path = /tmp/$${TARGET}/bin
|
||||
else: unix:!android: target.path = /opt/$${TARGET}/bin
|
||||
!isEmpty(target.path): INSTALLS += target
|
||||
|
||||
HEADERS += \
|
||||
src/spwidgetmainwindow.h
|
||||
|
@ -10,11 +10,42 @@ Window {
|
||||
color: "transparent"
|
||||
flags: Qt.SplashScreen | Qt.ToolTip | Qt.WindowStaysOnBottomHint
|
||||
|
||||
Loader {
|
||||
id:loader
|
||||
anchors.fill: parent
|
||||
asynchronous: true
|
||||
ScreenPlaySDK {
|
||||
id: spSDK
|
||||
contentType: "ScreenPlayWindow"
|
||||
appID: mainwindow.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: {
|
||||
screenVideo.state = "destroy"
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: mainWindow
|
||||
|
||||
onSetWidgetSource: {
|
||||
loader.source = Qt.resolvedUrl("file:///" + source)
|
||||
print(loader.source)
|
||||
}
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: loader
|
||||
anchors.fill: parent
|
||||
asynchronous: true
|
||||
}
|
||||
}
|
||||
|
27
ScreenPlayWidget/src/spwidgetmainwindow.cpp
Normal file
27
ScreenPlayWidget/src/spwidgetmainwindow.cpp
Normal file
@ -0,0 +1,27 @@
|
||||
#include "spwidgetmainwindow.h"
|
||||
|
||||
SPWidgetmainwindow::SPWidgetmainwindow(QString projectPath, QString appid, QScreen* parent)
|
||||
: QWindow(parent)
|
||||
{
|
||||
m_appID = appid;
|
||||
|
||||
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 ");
|
||||
}
|
||||
|
||||
m_project = configJsonDocument.object();
|
||||
|
||||
emit setWidgetSource(projectPath + "/" + m_project.value("file").toString());
|
||||
|
||||
m_quickRenderer = QSharedPointer<QQuickView>(new QQuickView(this));
|
||||
m_quickRenderer.data()->rootContext()->setContextProperty("mainwindow", this);
|
||||
}
|
77
ScreenPlayWidget/src/spwidgetmainwindow.h
Normal file
77
ScreenPlayWidget/src/spwidgetmainwindow.h
Normal file
@ -0,0 +1,77 @@
|
||||
#pragma once
|
||||
|
||||
#include <QWindow>
|
||||
#include <QSharedPointer>
|
||||
#include <QQuickView>
|
||||
#include <QString>
|
||||
#include <QJsonParseError>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QQmlContext>
|
||||
|
||||
|
||||
class SPWidgetmainwindow : public QWindow {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SPWidgetmainwindow( QString projectPath, QString appid,QScreen* parent = nullptr);
|
||||
|
||||
Q_PROPERTY(QString appID READ appID WRITE setAppID NOTIFY appIDChanged)
|
||||
Q_PROPERTY(QString type READ type WRITE setType NOTIFY typeChanged)
|
||||
Q_PROPERTY(QString projectConfig READ projectConfig WRITE setProjectConfig NOTIFY projectConfigChanged)
|
||||
|
||||
QString appID() const
|
||||
{
|
||||
return m_appID;
|
||||
}
|
||||
|
||||
QString type() const
|
||||
{
|
||||
return m_type;
|
||||
}
|
||||
|
||||
QString projectConfig() const
|
||||
{
|
||||
return m_projectConfig;
|
||||
}
|
||||
|
||||
signals:
|
||||
void appIDChanged(QString appID);
|
||||
void typeChanged(QString type);
|
||||
void projectConfigChanged(QString projectConfig);
|
||||
void setWidgetSource(QString source);
|
||||
|
||||
public slots:
|
||||
void setAppID(QString appID)
|
||||
{
|
||||
if (m_appID == appID)
|
||||
return;
|
||||
|
||||
m_appID = appID;
|
||||
emit appIDChanged(m_appID);
|
||||
}
|
||||
void setType(QString type)
|
||||
{
|
||||
if (m_type == type)
|
||||
return;
|
||||
|
||||
m_type = type;
|
||||
emit typeChanged(m_type);
|
||||
}
|
||||
void setProjectConfig(QString projectConfig)
|
||||
{
|
||||
if (m_projectConfig == projectConfig)
|
||||
return;
|
||||
|
||||
m_projectConfig = projectConfig;
|
||||
emit projectConfigChanged(m_projectConfig);
|
||||
}
|
||||
|
||||
private:
|
||||
QString m_appID;
|
||||
QString m_type = "qmlWidget";
|
||||
QString m_projectConfig;
|
||||
QJsonObject m_project;
|
||||
|
||||
QSharedPointer<QQuickView> m_quickRenderer = nullptr;
|
||||
};
|
@ -6,6 +6,7 @@ int main(int argc, char* argv[])
|
||||
{
|
||||
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
QApplication::setAttribute(Qt::AA_UseOpenGLES);
|
||||
|
||||
QApplication a(argc, argv);
|
||||
|
||||
QStringList argumentList = a.arguments();
|
||||
|
@ -23,7 +23,7 @@ class MainWindow : public QWindow {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindow(int i, QString projectPath, QString id, QString decoder,QString volume, QString fillmode, QScreen* parent = 0);
|
||||
explicit MainWindow(int i, QString projectPath, QString id, QString decoder,QString volume, QString fillmode, QScreen* parent = nullptr);
|
||||
~MainWindow();
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user