mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-11-06 02:52:29 +01:00
Add widget type to the ScreenPlayWidget executable as an argument. This can be ether qmlWidget or htmlWidget for now.
This commit is contained in:
parent
57001e500a
commit
04705a5ec3
@ -337,14 +337,14 @@ Item {
|
|||||||
+ "/" + activeScreen,
|
+ "/" + activeScreen,
|
||||||
ScreenPlay.installedListModel.get(activeScreen).screenPreview,
|
ScreenPlay.installedListModel.get(activeScreen).screenPreview,
|
||||||
(Math.round(sliderVolume.value * 100) / 100),
|
(Math.round(sliderVolume.value * 100) / 100),
|
||||||
settingsComboBox.model.get(settingsComboBox.currentIndex).text.toString(
|
settingsComboBox.model.get(settingsComboBox.currentIndex).text.toString(),
|
||||||
), type)
|
type)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
ScreenPlay.screenPlayManager.createWidget(
|
ScreenPlay.screenPlayManager.createWidget(
|
||||||
ScreenPlay.globalVariables.localStoragePath + "/" + activeScreen,
|
ScreenPlay.globalVariables.localStoragePath + "/" + activeScreen,
|
||||||
ScreenPlay.installedListModel.get(
|
ScreenPlay.installedListModel.get(activeScreen).screenPreview,
|
||||||
activeScreen).screenPreview)
|
type)
|
||||||
}
|
}
|
||||||
sidebar.state = "inactive"
|
sidebar.state = "inactive"
|
||||||
monitorSelection.deselectAll()
|
monitorSelection.deselectAll()
|
||||||
|
@ -36,11 +36,13 @@ Create::Create()
|
|||||||
|
|
||||||
void Create::createWidget(const QString& localStoragePath, const QString& title, const QString& previewThumbnail, const QString& createdBy, const QString& license, const QString& type, const QVector<QString>& tags)
|
void Create::createWidget(const QString& localStoragePath, const QString& title, const QString& previewThumbnail, const QString& createdBy, const QString& license, const QString& type, const QVector<QString>& tags)
|
||||||
{
|
{
|
||||||
|
QtConcurrent::run([=]() {
|
||||||
QUrl localStoragePathUrl { localStoragePath };
|
QUrl localStoragePathUrl { localStoragePath };
|
||||||
QDir dir;
|
QDir dir;
|
||||||
dir.cd(localStoragePathUrl.toLocalFile());
|
dir.cd(localStoragePathUrl.toLocalFile());
|
||||||
// Create a temp dir so we can later alter it to the workshop id
|
// Create a temp dir so we can later alter it to the workshop id
|
||||||
auto folderName = QString("_tmp_" + QTime::currentTime().toString()).replace(":", "");
|
auto folderName = QString("_tmp_" + QTime::currentTime().toString()).replace(":", "");
|
||||||
|
QString workingPath = dir.path() + "/" + folderName;
|
||||||
|
|
||||||
if (!dir.mkdir(folderName)) {
|
if (!dir.mkdir(folderName)) {
|
||||||
qDebug() << "Could create folder: " << folderName;
|
qDebug() << "Could create folder: " << folderName;
|
||||||
@ -55,9 +57,32 @@ void Create::createWidget(const QString& localStoragePath, const QString& title,
|
|||||||
if (type == "QML") {
|
if (type == "QML") {
|
||||||
obj.insert("type", "qmlWidget");
|
obj.insert("type", "qmlWidget");
|
||||||
obj.insert("file", "main.qml");
|
obj.insert("file", "main.qml");
|
||||||
|
|
||||||
|
QFile fileMainQML(workingPath + "/main.qml");
|
||||||
|
if (!fileMainQML.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||||
|
qDebug() << "Could not open /main.qml";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QTextStream outMainQML(&fileMainQML);
|
||||||
|
outMainQML.setCodec("UTF-8");
|
||||||
|
outMainQML << "import QtQuick 2.14 \n\n Item {\n id:root \n}";
|
||||||
|
fileMainQML.close();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
obj.insert("type", "htmlWidget");
|
obj.insert("type", "htmlWidget");
|
||||||
obj.insert("file", "index.html");
|
obj.insert("file", "index.html");
|
||||||
|
|
||||||
|
QFile fileMainHTML(workingPath + "/index.html");
|
||||||
|
if (!fileMainHTML.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||||
|
qDebug() << "Could not open /index.html";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QTextStream outMainHTML(&fileMainHTML);
|
||||||
|
outMainHTML.setCodec("UTF-8");
|
||||||
|
outMainHTML << "<html>\n<head></head>\n<body></body>\n</html>";
|
||||||
|
fileMainHTML.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonArray tagsJsonArray;
|
QJsonArray tagsJsonArray;
|
||||||
@ -65,7 +90,6 @@ void Create::createWidget(const QString& localStoragePath, const QString& title,
|
|||||||
tagsJsonArray.append(tmp);
|
tagsJsonArray.append(tmp);
|
||||||
}
|
}
|
||||||
obj.insert("tags", tagsJsonArray);
|
obj.insert("tags", tagsJsonArray);
|
||||||
QString workingPath = dir.path() + "/" + folderName;
|
|
||||||
|
|
||||||
QFile file(workingPath + "/project.json");
|
QFile file(workingPath + "/project.json");
|
||||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||||
@ -91,18 +115,8 @@ void Create::createWidget(const QString& localStoragePath, const QString& title,
|
|||||||
out << doc.toJson();
|
out << doc.toJson();
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
QFile fileMainQML(workingPath + "/main.qml");
|
|
||||||
if (!fileMainQML.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
|
||||||
qDebug() << "Could not open /main.qml";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QTextStream outMainQML(&fileMainQML);
|
|
||||||
outMainQML.setCodec("UTF-8");
|
|
||||||
outMainQML << "import QtQuick 2.14 \n\n Item {\n id:root \n}";
|
|
||||||
fileMainQML.close();
|
|
||||||
|
|
||||||
emit widgetCreatedSuccessful(workingPath);
|
emit widgetCreatedSuccessful(workingPath);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -41,7 +41,7 @@ void ScreenPlayManager::createWallpaper(
|
|||||||
const bool saveToProfilesConfigFile)
|
const bool saveToProfilesConfigFile)
|
||||||
{
|
{
|
||||||
|
|
||||||
m_tracker->sendEvent("wallpaper","start");
|
m_tracker->sendEvent("wallpaper", "start");
|
||||||
QString path = absoluteStoragePath;
|
QString path = absoluteStoragePath;
|
||||||
|
|
||||||
if (absoluteStoragePath.contains("file:///"))
|
if (absoluteStoragePath.contains("file:///"))
|
||||||
@ -105,9 +105,9 @@ void ScreenPlayManager::createWallpaper(
|
|||||||
/*!
|
/*!
|
||||||
Creates a ScreenPlayWidget object via a \a absoluteStoragePath and a \a preview image (relative path).
|
Creates a ScreenPlayWidget object via a \a absoluteStoragePath and a \a preview image (relative path).
|
||||||
*/
|
*/
|
||||||
void ScreenPlayManager::createWidget(const QUrl& absoluteStoragePath, const QString& previewImage)
|
void ScreenPlayManager::createWidget(const QUrl& absoluteStoragePath, const QString& previewImage, const QString& type)
|
||||||
{
|
{
|
||||||
m_tracker->sendEvent("widget","start");
|
m_tracker->sendEvent("widget", "start");
|
||||||
increaseActiveWidgetsCounter();
|
increaseActiveWidgetsCounter();
|
||||||
|
|
||||||
m_screenPlayWidgets.append(
|
m_screenPlayWidgets.append(
|
||||||
@ -117,7 +117,7 @@ void ScreenPlayManager::createWidget(const QUrl& absoluteStoragePath, const QStr
|
|||||||
absoluteStoragePath.toLocalFile(),
|
absoluteStoragePath.toLocalFile(),
|
||||||
previewImage,
|
previewImage,
|
||||||
absoluteStoragePath.toString(),
|
absoluteStoragePath.toString(),
|
||||||
this));
|
type));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -127,7 +127,7 @@ void ScreenPlayManager::createWidget(const QUrl& absoluteStoragePath, const QStr
|
|||||||
void ScreenPlayManager::removeAllWallpapers()
|
void ScreenPlayManager::removeAllWallpapers()
|
||||||
{
|
{
|
||||||
if (!m_screenPlayWallpapers.empty()) {
|
if (!m_screenPlayWallpapers.empty()) {
|
||||||
m_tracker->sendEvent("wallpaper","stopAll");
|
m_tracker->sendEvent("wallpaper", "stopAll");
|
||||||
m_sdkconnector->closeAllWallpapers();
|
m_sdkconnector->closeAllWallpapers();
|
||||||
m_screenPlayWallpapers.clear();
|
m_screenPlayWallpapers.clear();
|
||||||
m_monitorListModel->clearActiveWallpaper();
|
m_monitorListModel->clearActiveWallpaper();
|
||||||
@ -168,7 +168,7 @@ void ScreenPlayManager::removeAllWallpapers()
|
|||||||
*/
|
*/
|
||||||
bool ScreenPlayManager::removeWallpaperAt(int at)
|
bool ScreenPlayManager::removeWallpaperAt(int at)
|
||||||
{
|
{
|
||||||
m_tracker->sendEvent("wallpaper","removeSingleWallpaper");
|
m_tracker->sendEvent("wallpaper", "removeSingleWallpaper");
|
||||||
if (auto appID = m_monitorListModel->getAppIDByMonitorIndex(at)) {
|
if (auto appID = m_monitorListModel->getAppIDByMonitorIndex(at)) {
|
||||||
|
|
||||||
m_sdkconnector->closeWallpaper(appID.value());
|
m_sdkconnector->closeWallpaper(appID.value());
|
||||||
|
@ -95,7 +95,7 @@ public slots:
|
|||||||
const QString& fillMode,
|
const QString& fillMode,
|
||||||
const QString& type, const bool saveToProfilesConfigFile = true);
|
const QString& type, const bool saveToProfilesConfigFile = true);
|
||||||
|
|
||||||
void createWidget(const QUrl& absoluteStoragePath, const QString& previewImage);
|
void createWidget(const QUrl& absoluteStoragePath, const QString& previewImage, const QString &type);
|
||||||
|
|
||||||
void removeAllWallpapers();
|
void removeAllWallpapers();
|
||||||
bool removeWallpaperAt(const int at = 0);
|
bool removeWallpaperAt(const int at = 0);
|
||||||
|
@ -16,20 +16,21 @@ ScreenPlayWidget::ScreenPlayWidget(
|
|||||||
const QString& projectPath,
|
const QString& projectPath,
|
||||||
const QString& previewImage,
|
const QString& previewImage,
|
||||||
const QString& fullPath,
|
const QString& fullPath,
|
||||||
QObject* parent)
|
const QString& type)
|
||||||
: QObject { parent }
|
: QObject { nullptr }
|
||||||
, m_globalVariables { globalVariables }
|
, m_globalVariables { globalVariables }
|
||||||
, m_projectPath { projectPath }
|
, m_projectPath { projectPath }
|
||||||
, m_previewImage { previewImage }
|
, m_previewImage { previewImage }
|
||||||
, m_appID { appID }
|
, m_appID { appID }
|
||||||
, m_position { 0, 0 }
|
, m_position { 0, 0 }
|
||||||
|
, m_type { type }
|
||||||
{
|
{
|
||||||
const QStringList proArgs { m_projectPath, m_appID };
|
const QStringList proArgs { m_projectPath, m_appID, m_type };
|
||||||
m_process.setArguments(proArgs);
|
m_process.setArguments(proArgs);
|
||||||
|
|
||||||
if (fullPath.endsWith(".exe")) {
|
if (fullPath.endsWith(".exe")) {
|
||||||
m_process.setProgram(fullPath);
|
m_process.setProgram(fullPath);
|
||||||
} else if (fullPath.endsWith(".qml")) {
|
} else {
|
||||||
m_process.setProgram(m_globalVariables->widgetExecutablePath().path());
|
m_process.setProgram(m_globalVariables->widgetExecutablePath().path());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@ class ScreenPlayWidget : public QObject {
|
|||||||
Q_PROPERTY(QString previewImage READ previewImage WRITE setPreviewImage NOTIFY previewImageChanged)
|
Q_PROPERTY(QString previewImage READ previewImage WRITE setPreviewImage NOTIFY previewImageChanged)
|
||||||
Q_PROPERTY(QPoint position READ position WRITE setPosition NOTIFY positionChanged)
|
Q_PROPERTY(QPoint position READ position WRITE setPosition NOTIFY positionChanged)
|
||||||
Q_PROPERTY(QString appID READ appID WRITE setAppID NOTIFY appIDChanged)
|
Q_PROPERTY(QString appID READ appID WRITE setAppID NOTIFY appIDChanged)
|
||||||
|
Q_PROPERTY(QString type READ type WRITE setType NOTIFY typeChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ScreenPlayWidget(
|
explicit ScreenPlayWidget(
|
||||||
@ -30,7 +31,7 @@ public:
|
|||||||
const QString& projectPath,
|
const QString& projectPath,
|
||||||
const QString& previewImage,
|
const QString& previewImage,
|
||||||
const QString& fullPath,
|
const QString& fullPath,
|
||||||
QObject* parent = nullptr);
|
const QString& type);
|
||||||
|
|
||||||
~ScreenPlayWidget() {}
|
~ScreenPlayWidget() {}
|
||||||
|
|
||||||
@ -54,6 +55,11 @@ public:
|
|||||||
return m_appID;
|
return m_appID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString type() const
|
||||||
|
{
|
||||||
|
return m_type;
|
||||||
|
}
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setProjectPath(QString projectPath)
|
void setProjectPath(QString projectPath)
|
||||||
{
|
{
|
||||||
@ -91,12 +97,23 @@ public slots:
|
|||||||
emit appIDChanged(m_appID);
|
emit appIDChanged(m_appID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setType(QString type)
|
||||||
|
{
|
||||||
|
if (m_type == type)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_type = type;
|
||||||
|
emit typeChanged(m_type);
|
||||||
|
}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void projectPathChanged(QString projectPath);
|
void projectPathChanged(QString projectPath);
|
||||||
void previewImageChanged(QString previewImage);
|
void previewImageChanged(QString previewImage);
|
||||||
void positionChanged(QPoint position);
|
void positionChanged(QPoint position);
|
||||||
void appIDChanged(QString appID);
|
void appIDChanged(QString appID);
|
||||||
|
|
||||||
|
void typeChanged(QString type);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QProcess m_process;
|
QProcess m_process;
|
||||||
const shared_ptr<GlobalVariables>& m_globalVariables;
|
const shared_ptr<GlobalVariables>& m_globalVariables;
|
||||||
@ -105,5 +122,6 @@ private:
|
|||||||
QString m_previewImage;
|
QString m_previewImage;
|
||||||
QString m_appID;
|
QString m_appID;
|
||||||
QPoint m_position;
|
QPoint m_position;
|
||||||
|
QString m_type;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -14,18 +14,18 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
QStringList argumentList = app.arguments();
|
QStringList argumentList = app.arguments();
|
||||||
|
|
||||||
// If we start with only one argument (app path),
|
// If we start with only one argument (app, path, type),
|
||||||
// it means we want to test a single widget
|
// it means we want to test a single widget
|
||||||
if (argumentList.length() == 1) {
|
if (argumentList.length() == 1) {
|
||||||
WidgetWindow spwmw("test","appid" );
|
WidgetWindow spwmw("test","appid", "qmlWidget");
|
||||||
return app.exec();
|
return app.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argumentList.length() != 3) {
|
if (argumentList.length() != 4) {
|
||||||
return -3;
|
return -3;
|
||||||
}
|
}
|
||||||
|
|
||||||
WidgetWindow spwmw(argumentList.at(1), argumentList.at(2));
|
WidgetWindow spwmw(argumentList.at(1), argumentList.at(2), argumentList.at(3));
|
||||||
|
|
||||||
QObject::connect(&sdk, &ScreenPlaySDK::sdkDisconnected, &spwmw, &WidgetWindow::destroyThis);
|
QObject::connect(&sdk, &ScreenPlaySDK::sdkDisconnected, &spwmw, &WidgetWindow::destroyThis);
|
||||||
QObject::connect(&sdk, &ScreenPlaySDK::incommingMessage, &spwmw, &WidgetWindow::messageReceived);
|
QObject::connect(&sdk, &ScreenPlaySDK::incommingMessage, &spwmw, &WidgetWindow::messageReceived);
|
||||||
|
@ -2,10 +2,20 @@
|
|||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
|
||||||
WidgetWindow::WidgetWindow(QString projectPath, QString appid, QObject* parent)
|
WidgetWindow::WidgetWindow(const QString projectPath, const QString appid, const QString type)
|
||||||
: QObject(parent)
|
: QObject(nullptr)
|
||||||
, m_appID { appid }
|
, m_appID { appid }
|
||||||
|
, m_type { type }
|
||||||
{
|
{
|
||||||
|
QStringList availableTypes {
|
||||||
|
"qmlWidget",
|
||||||
|
"htmlWidget",
|
||||||
|
"standaloneWidget"
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!availableTypes.contains(m_type)) {
|
||||||
|
QGuiApplication::exit(-4);
|
||||||
|
}
|
||||||
|
|
||||||
Qt::WindowFlags flags = m_window.flags();
|
Qt::WindowFlags flags = m_window.flags();
|
||||||
m_window.setWidth(300);
|
m_window.setWidth(300);
|
||||||
@ -41,6 +51,7 @@ WidgetWindow::WidgetWindow(QString projectPath, QString appid, QObject* parent)
|
|||||||
}
|
}
|
||||||
// Instead of setting "renderType: Text.NativeRendering" every time
|
// Instead of setting "renderType: Text.NativeRendering" every time
|
||||||
// we can set it here once :)
|
// we can set it here once :)
|
||||||
|
|
||||||
m_window.setTextRenderType(QQuickWindow::TextRenderType::NativeTextRendering);
|
m_window.setTextRenderType(QQuickWindow::TextRenderType::NativeTextRendering);
|
||||||
// m_window.setResizeMode(QQuickView::ResizeMode::SizeViewToRootObject);
|
// m_window.setResizeMode(QQuickView::ResizeMode::SizeViewToRootObject);
|
||||||
m_window.setSource(QUrl("qrc:/mainWidget.qml"));
|
m_window.setSource(QUrl("qrc:/mainWidget.qml"));
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#include <QWindow>
|
#include <QWindow>
|
||||||
#include <QtQuick/QQuickView>
|
#include <QtQuick/QQuickView>
|
||||||
#include <QtQuick/QQuickWindow>
|
#include <QtQuick/QQuickWindow>
|
||||||
|
#include <QGuiApplication>
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
#include <qt_windows.h>
|
#include <qt_windows.h>
|
||||||
@ -24,7 +25,7 @@ class WidgetWindow : public QObject {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit WidgetWindow(QString projectPath, QString appid, QObject* parent = nullptr);
|
explicit WidgetWindow(const QString projectPath, const QString appid, const QString type);
|
||||||
|
|
||||||
Q_PROPERTY(QString appID READ appID WRITE setAppID NOTIFY appIDChanged)
|
Q_PROPERTY(QString appID READ appID WRITE setAppID NOTIFY appIDChanged)
|
||||||
Q_PROPERTY(QString type READ type WRITE setType NOTIFY typeChanged)
|
Q_PROPERTY(QString type READ type WRITE setType NOTIFY typeChanged)
|
||||||
|
Loading…
Reference in New Issue
Block a user