mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-11-06 19:12:30 +01:00
Refactor Widget and Wallpaper to use same project properties
- projectPath - C:\Program Files (x86)\Steam\steamapps\workshop\content\672870\_tmp_171806 - projectSourceFile - main.qml - projectSourceFileAbsolute - C:\Program Files (x86)\Steam\steamapps\workshop\content\672870\_tmp_171806\main.qml
This commit is contained in:
parent
f01e713d11
commit
ebfe616460
@ -48,7 +48,7 @@ Rectangle {
|
|||||||
loader.source = ""
|
loader.source = ""
|
||||||
Wallpaper.clearComponentCache()
|
Wallpaper.clearComponentCache()
|
||||||
|
|
||||||
loader.source = Qt.resolvedUrl(Wallpaper.fullContentPath)
|
loader.source = Qt.resolvedUrl(Wallpaper.projectSourceFileAbsolute)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replace wallpaper with GIF
|
// Replace wallpaper with GIF
|
||||||
@ -78,23 +78,23 @@ Rectangle {
|
|||||||
case InstalledType.HTMLWallpaper:
|
case InstalledType.HTMLWallpaper:
|
||||||
loader.setSource("qrc:/WebView.qml", {
|
loader.setSource("qrc:/WebView.qml", {
|
||||||
"url": Qt.resolvedUrl(
|
"url": Qt.resolvedUrl(
|
||||||
Wallpaper.fullContentPath)
|
Wallpaper.projectSourceFileAbsolute)
|
||||||
})
|
})
|
||||||
break
|
break
|
||||||
case InstalledType.QMLWallpaper:
|
case InstalledType.QMLWallpaper:
|
||||||
loader.source = Qt.resolvedUrl(Wallpaper.fullContentPath)
|
loader.source = Qt.resolvedUrl(Wallpaper.projectSourceFileAbsolute)
|
||||||
fadeIn()
|
fadeIn()
|
||||||
break
|
break
|
||||||
case InstalledType.WebsiteWallpaper:
|
case InstalledType.WebsiteWallpaper:
|
||||||
loader.setSource("qrc:/WebsiteWallpaper.qml", {
|
loader.setSource("qrc:/WebsiteWallpaper.qml", {
|
||||||
"url": Wallpaper.fullContentPath
|
"url": Wallpaper.projectSourceFileAbsolute
|
||||||
})
|
})
|
||||||
fadeIn()
|
fadeIn()
|
||||||
break
|
break
|
||||||
case InstalledType.GifWallpaper:
|
case InstalledType.GifWallpaper:
|
||||||
loader.setSource("qrc:/GifWallpaper.qml", {
|
loader.setSource("qrc:/GifWallpaper.qml", {
|
||||||
"source": Qt.resolvedUrl(
|
"source": Qt.resolvedUrl(
|
||||||
Wallpaper.fullContentPath)
|
Wallpaper.projectSourceFileAbsolute)
|
||||||
})
|
})
|
||||||
fadeIn()
|
fadeIn()
|
||||||
break
|
break
|
||||||
@ -261,11 +261,11 @@ Rectangle {
|
|||||||
font.pointSize: 14
|
font.pointSize: 14
|
||||||
}
|
}
|
||||||
Text {
|
Text {
|
||||||
text: "basePath " + Wallpaper.basePath
|
text: "projectPath " + Wallpaper.projectPath
|
||||||
font.pointSize: 14
|
font.pointSize: 14
|
||||||
}
|
}
|
||||||
Text {
|
Text {
|
||||||
text: "fullContentPath " + Wallpaper.fullContentPath
|
text: "projectSourceFileAbsolute " + Wallpaper.projectSourceFileAbsolute
|
||||||
font.pointSize: 14
|
font.pointSize: 14
|
||||||
}
|
}
|
||||||
Text {
|
Text {
|
||||||
|
@ -26,7 +26,7 @@ Item {
|
|||||||
var src = ""
|
var src = ""
|
||||||
src += "var videoPlayer = document.getElementById('videoPlayer');"
|
src += "var videoPlayer = document.getElementById('videoPlayer');"
|
||||||
src += "var videoSource = document.getElementById('videoSource');"
|
src += "var videoSource = document.getElementById('videoSource');"
|
||||||
src += "videoSource.src = '" + Wallpaper.fullContentPath + "';"
|
src += "videoSource.src = '" + Wallpaper.projectSourceFileAbsolute + "';"
|
||||||
src += "videoPlayer.load();"
|
src += "videoPlayer.load();"
|
||||||
src += "videoPlayer.volume = " + Wallpaper.volume + ";"
|
src += "videoPlayer.volume = " + Wallpaper.volume + ";"
|
||||||
src += "videoPlayer.setAttribute('style', 'object-fit :" + Wallpaper.fillMode + ";');"
|
src += "videoPlayer.setAttribute('style', 'object-fit :" + Wallpaper.fillMode + ";');"
|
||||||
|
@ -49,12 +49,12 @@ BaseWindow::BaseWindow(
|
|||||||
}
|
}
|
||||||
|
|
||||||
setAppID(appID);
|
setAppID(appID);
|
||||||
setContentBasePath(projectFilePath);
|
setProjectPath(projectFilePath);
|
||||||
setOSVersion(QSysInfo::productVersion());
|
setOSVersion(QSysInfo::productVersion());
|
||||||
|
|
||||||
if (projectFilePath == "test") {
|
if (projectFilePath == "test") {
|
||||||
setType(ScreenPlay::InstalledType::InstalledType::QMLWallpaper);
|
setType(ScreenPlay::InstalledType::InstalledType::QMLWallpaper);
|
||||||
setFullContentPath("qrc:/Test.qml");
|
setProjectSourceFileAbsolute({ "qrc:/Test.qml" });
|
||||||
setupLiveReloading();
|
setupLiveReloading();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -82,16 +82,15 @@ BaseWindow::BaseWindow(
|
|||||||
qCritical() << "Cannot parse Wallpaper type from value" << project.value("type");
|
qCritical() << "Cannot parse Wallpaper type from value" << project.value("type");
|
||||||
}
|
}
|
||||||
|
|
||||||
setBasePath(QUrl::fromUserInput(projectFilePath).toLocalFile());
|
|
||||||
|
|
||||||
if (m_type == ScreenPlay::InstalledType::InstalledType::WebsiteWallpaper) {
|
if (m_type == ScreenPlay::InstalledType::InstalledType::WebsiteWallpaper) {
|
||||||
if (!project.contains("url")) {
|
if (!project.contains("url")) {
|
||||||
qFatal("No url was specified for a websiteWallpaper!");
|
qFatal("No url was specified for a websiteWallpaper!");
|
||||||
QApplication::exit(-5);
|
QApplication::exit(-5);
|
||||||
}
|
}
|
||||||
setFullContentPath(project.value("url").toString());
|
setProjectSourceFileAbsolute(project.value("url").toString());
|
||||||
} else {
|
} else {
|
||||||
setFullContentPath("file:///" + projectFilePath + "/" + project.value("file").toString());
|
setProjectSourceFile(project.value("file").toString());
|
||||||
|
setProjectSourceFileAbsolute(QUrl::fromLocalFile(projectFilePath + "/" + projectSourceFile()));
|
||||||
}
|
}
|
||||||
|
|
||||||
setupLiveReloading();
|
setupLiveReloading();
|
||||||
@ -181,9 +180,9 @@ void BaseWindow::replaceWallpaper(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (type.contains("websiteWallpaper", Qt::CaseInsensitive)) {
|
if (type.contains("websiteWallpaper", Qt::CaseInsensitive)) {
|
||||||
setFullContentPath(file);
|
setProjectSourceFileAbsolute(file);
|
||||||
} else {
|
} else {
|
||||||
setFullContentPath("file:///" + absolutePath + "/" + file);
|
setProjectSourceFileAbsolute(QUrl::fromLocalFile(absolutePath + "/" + file));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_type == ScreenPlay::InstalledType::InstalledType::QMLWallpaper || m_type == ScreenPlay::InstalledType::InstalledType::HTMLWallpaper)
|
if (m_type == ScreenPlay::InstalledType::InstalledType::QMLWallpaper || m_type == ScreenPlay::InstalledType::InstalledType::HTMLWallpaper)
|
||||||
@ -201,7 +200,7 @@ void BaseWindow::replaceWallpaper(
|
|||||||
*/
|
*/
|
||||||
QString BaseWindow::loadFromFile(const QString& filename)
|
QString BaseWindow::loadFromFile(const QString& filename)
|
||||||
{
|
{
|
||||||
QFile file(basePath() + "/" + filename);
|
QFile file(projectPath() + "/" + filename);
|
||||||
if (!file.open(QIODevice::ReadOnly)) {
|
if (!file.open(QIODevice::ReadOnly)) {
|
||||||
qWarning() << "Could not loadFromFile: " << file.fileName();
|
qWarning() << "Could not loadFromFile: " << file.fileName();
|
||||||
file.close();
|
file.close();
|
||||||
@ -238,5 +237,5 @@ void BaseWindow::setupLiveReloading()
|
|||||||
QObject::connect(&m_fileSystemWatcher, &QFileSystemWatcher::directoryChanged, this, timeoutLambda);
|
QObject::connect(&m_fileSystemWatcher, &QFileSystemWatcher::directoryChanged, this, timeoutLambda);
|
||||||
QObject::connect(&m_fileSystemWatcher, &QFileSystemWatcher::fileChanged, this, timeoutLambda);
|
QObject::connect(&m_fileSystemWatcher, &QFileSystemWatcher::fileChanged, this, timeoutLambda);
|
||||||
QObject::connect(&m_liveReloadLimiter, &QTimer::timeout, this, reloadQMLLambda);
|
QObject::connect(&m_liveReloadLimiter, &QTimer::timeout, this, reloadQMLLambda);
|
||||||
m_fileSystemWatcher.addPaths({ m_contentBasePath });
|
m_fileSystemWatcher.addPaths({ projectPath() });
|
||||||
}
|
}
|
||||||
|
@ -70,11 +70,12 @@ public:
|
|||||||
Q_PROPERTY(QVector<int> activeScreensList READ activeScreensList WRITE setActiveScreensList NOTIFY activeScreensListChanged)
|
Q_PROPERTY(QVector<int> activeScreensList READ activeScreensList WRITE setActiveScreensList NOTIFY activeScreensListChanged)
|
||||||
|
|
||||||
Q_PROPERTY(QString appID READ appID WRITE setAppID NOTIFY appIDChanged)
|
Q_PROPERTY(QString appID READ appID WRITE setAppID NOTIFY appIDChanged)
|
||||||
Q_PROPERTY(QString basePath READ basePath WRITE setBasePath NOTIFY basePathChanged)
|
|
||||||
Q_PROPERTY(QString fullContentPath READ fullContentPath WRITE setFullContentPath NOTIFY fullContentPathChanged)
|
|
||||||
Q_PROPERTY(QString contentBasePath READ contentBasePath WRITE setContentBasePath NOTIFY contentBasePathChanged)
|
|
||||||
Q_PROPERTY(QString fillMode READ fillMode WRITE setFillMode NOTIFY fillModeChanged)
|
Q_PROPERTY(QString fillMode READ fillMode WRITE setFillMode NOTIFY fillModeChanged)
|
||||||
|
|
||||||
|
Q_PROPERTY(QString projectPath READ projectPath WRITE setProjectPath NOTIFY projectPathChanged)
|
||||||
|
Q_PROPERTY(QString projectSourceFile READ projectSourceFile WRITE setProjectSourceFile NOTIFY projectSourceFileChanged)
|
||||||
|
Q_PROPERTY(QUrl projectSourceFileAbsolute READ projectSourceFileAbsolute WRITE setProjectSourceFileAbsolute NOTIFY projectSourceFileAbsoluteChanged)
|
||||||
|
|
||||||
Q_PROPERTY(bool loops READ loops WRITE setLoops NOTIFY loopsChanged)
|
Q_PROPERTY(bool loops READ loops WRITE setLoops NOTIFY loopsChanged)
|
||||||
Q_PROPERTY(bool isPlaying READ isPlaying WRITE setIsPlaying NOTIFY isPlayingChanged)
|
Q_PROPERTY(bool isPlaying READ isPlaying WRITE setIsPlaying NOTIFY isPlayingChanged)
|
||||||
Q_PROPERTY(bool muted READ muted WRITE setMuted NOTIFY mutedChanged)
|
Q_PROPERTY(bool muted READ muted WRITE setMuted NOTIFY mutedChanged)
|
||||||
@ -99,7 +100,6 @@ public:
|
|||||||
bool isPlaying() const { return m_isPlaying; }
|
bool isPlaying() const { return m_isPlaying; }
|
||||||
float playbackRate() const { return m_playbackRate; }
|
float playbackRate() const { return m_playbackRate; }
|
||||||
ScreenPlay::InstalledType::InstalledType type() const { return m_type; }
|
ScreenPlay::InstalledType::InstalledType type() const { return m_type; }
|
||||||
QString fullContentPath() const { return m_fullContentPath; }
|
|
||||||
QString appID() const { return m_appID; }
|
QString appID() const { return m_appID; }
|
||||||
QString OSVersion() const { return m_OSVersion; }
|
QString OSVersion() const { return m_OSVersion; }
|
||||||
bool muted() const { return m_muted; }
|
bool muted() const { return m_muted; }
|
||||||
@ -111,10 +111,11 @@ public:
|
|||||||
QVector<int> activeScreensList() const { return m_activeScreensList; }
|
QVector<int> activeScreensList() const { return m_activeScreensList; }
|
||||||
bool checkWallpaperVisible() const { return m_checkWallpaperVisible; }
|
bool checkWallpaperVisible() const { return m_checkWallpaperVisible; }
|
||||||
bool visualsPaused() const { return m_visualsPaused; }
|
bool visualsPaused() const { return m_visualsPaused; }
|
||||||
QString basePath() const { return m_basePath; }
|
|
||||||
bool debugMode() const { return m_debugMode; }
|
bool debugMode() const { return m_debugMode; }
|
||||||
ScreenPlaySDK* sdk() const { return m_sdk.get(); }
|
ScreenPlaySDK* sdk() const { return m_sdk.get(); }
|
||||||
const QString& contentBasePath() const { return m_contentBasePath; }
|
const QString& projectPath() const { return m_projectPath; }
|
||||||
|
const QString& projectSourceFile() const { return m_projectSourceFile; }
|
||||||
|
const QUrl& projectSourceFileAbsolute() const { return m_projectSourceFileAbsolute; }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void qmlExit();
|
void qmlExit();
|
||||||
@ -127,7 +128,6 @@ signals:
|
|||||||
void isPlayingChanged(bool isPlaying);
|
void isPlayingChanged(bool isPlaying);
|
||||||
void playbackRateChanged(float playbackRate);
|
void playbackRateChanged(float playbackRate);
|
||||||
void typeChanged(ScreenPlay::InstalledType::InstalledType type);
|
void typeChanged(ScreenPlay::InstalledType::InstalledType type);
|
||||||
void fullContentPathChanged(QString fullContentPath);
|
|
||||||
void appIDChanged(QString appID);
|
void appIDChanged(QString appID);
|
||||||
void qmlSceneValueReceived(QString key, QString value);
|
void qmlSceneValueReceived(QString key, QString value);
|
||||||
void OSVersionChanged(QString OSVersion);
|
void OSVersionChanged(QString OSVersion);
|
||||||
@ -140,11 +140,11 @@ signals:
|
|||||||
void activeScreensListChanged(QVector<int> activeScreensList);
|
void activeScreensListChanged(QVector<int> activeScreensList);
|
||||||
void checkWallpaperVisibleChanged(bool checkWallpaperVisible);
|
void checkWallpaperVisibleChanged(bool checkWallpaperVisible);
|
||||||
void visualsPausedChanged(bool visualsPaused);
|
void visualsPausedChanged(bool visualsPaused);
|
||||||
void basePathChanged(QString basePath);
|
|
||||||
void debugModeChanged(bool debugMode);
|
void debugModeChanged(bool debugMode);
|
||||||
void sdkChanged(ScreenPlaySDK* sdk);
|
void sdkChanged(ScreenPlaySDK* sdk);
|
||||||
|
void projectPathChanged(const QString& rojectPath);
|
||||||
void contentBasePathChanged(const QString&);
|
void projectSourceFileChanged(const QString& projectSourceFile);
|
||||||
|
void projectSourceFileAbsoluteChanged(const QUrl& rojectSourceFileAbsolute);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void destroyThis() { }
|
virtual void destroyThis() { }
|
||||||
@ -207,14 +207,6 @@ public slots:
|
|||||||
m_type = type;
|
m_type = type;
|
||||||
emit typeChanged(m_type);
|
emit typeChanged(m_type);
|
||||||
}
|
}
|
||||||
void setFullContentPath(QString fullContentPath)
|
|
||||||
{
|
|
||||||
if (m_fullContentPath == fullContentPath)
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_fullContentPath = fullContentPath;
|
|
||||||
emit fullContentPathChanged(m_fullContentPath);
|
|
||||||
}
|
|
||||||
void setAppID(QString appID)
|
void setAppID(QString appID)
|
||||||
{
|
{
|
||||||
if (m_appID == appID)
|
if (m_appID == appID)
|
||||||
@ -319,15 +311,6 @@ public slots:
|
|||||||
m_visualsPaused = visualsPaused;
|
m_visualsPaused = visualsPaused;
|
||||||
emit visualsPausedChanged(m_visualsPaused);
|
emit visualsPausedChanged(m_visualsPaused);
|
||||||
}
|
}
|
||||||
void setBasePath(QString basePath)
|
|
||||||
{
|
|
||||||
if (m_basePath == basePath)
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_basePath = basePath;
|
|
||||||
emit basePathChanged(m_basePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setDebugMode(bool debugMode)
|
void setDebugMode(bool debugMode)
|
||||||
{
|
{
|
||||||
if (m_debugMode == debugMode)
|
if (m_debugMode == debugMode)
|
||||||
@ -344,12 +327,28 @@ public slots:
|
|||||||
emit sdkChanged(sdk);
|
emit sdkChanged(sdk);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setContentBasePath(const QString& contentBasePath)
|
void setProjectPath(const QString& projectPath)
|
||||||
{
|
{
|
||||||
if (m_contentBasePath == contentBasePath)
|
if (m_projectPath == projectPath)
|
||||||
return;
|
return;
|
||||||
m_contentBasePath = contentBasePath;
|
m_projectPath = projectPath;
|
||||||
emit contentBasePathChanged(m_contentBasePath);
|
emit projectPathChanged(m_projectPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setProjectSourceFile(const QString& projectSourceFile)
|
||||||
|
{
|
||||||
|
if (m_projectSourceFile == projectSourceFile)
|
||||||
|
return;
|
||||||
|
m_projectSourceFile = projectSourceFile;
|
||||||
|
emit projectSourceFileChanged(m_projectSourceFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setProjectSourceFileAbsolute(const QUrl& projectSourceFileAbsolute)
|
||||||
|
{
|
||||||
|
if (m_projectSourceFileAbsolute == projectSourceFileAbsolute)
|
||||||
|
return;
|
||||||
|
m_projectSourceFileAbsolute = projectSourceFileAbsolute;
|
||||||
|
emit projectSourceFileAbsoluteChanged(m_projectSourceFileAbsolute);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -368,7 +367,6 @@ private:
|
|||||||
float m_playbackRate { 1.0f };
|
float m_playbackRate { 1.0f };
|
||||||
float m_currentTime { 0.0f };
|
float m_currentTime { 0.0f };
|
||||||
|
|
||||||
QString m_fullContentPath;
|
|
||||||
QString m_appID;
|
QString m_appID;
|
||||||
|
|
||||||
ScreenPlay::InstalledType::InstalledType m_type = ScreenPlay::InstalledType::InstalledType::Unknown;
|
ScreenPlay::InstalledType::InstalledType m_type = ScreenPlay::InstalledType::InstalledType::Unknown;
|
||||||
@ -379,9 +377,11 @@ private:
|
|||||||
QVector<int> m_activeScreensList;
|
QVector<int> m_activeScreensList;
|
||||||
QFileSystemWatcher m_fileSystemWatcher;
|
QFileSystemWatcher m_fileSystemWatcher;
|
||||||
QSysInfo m_sysinfo;
|
QSysInfo m_sysinfo;
|
||||||
QString m_basePath;
|
|
||||||
bool m_debugMode = false;
|
bool m_debugMode = false;
|
||||||
std::unique_ptr<ScreenPlaySDK> m_sdk;
|
std::unique_ptr<ScreenPlaySDK> m_sdk;
|
||||||
QString m_contentBasePath;
|
QString m_contentBasePath;
|
||||||
QTimer m_liveReloadLimiter;
|
QTimer m_liveReloadLimiter;
|
||||||
|
QString m_projectPath;
|
||||||
|
QString m_projectSourceFile;
|
||||||
|
QUrl m_projectSourceFileAbsolute;
|
||||||
};
|
};
|
||||||
|
@ -2,6 +2,7 @@ import QtQuick 2.12
|
|||||||
import QtQuick.Controls 2.3
|
import QtQuick.Controls 2.3
|
||||||
import QtWebEngine 1.8
|
import QtWebEngine 1.8
|
||||||
import ScreenPlayWidget 1.0
|
import ScreenPlayWidget 1.0
|
||||||
|
import ScreenPlay.Enums.InstalledType 1.0
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: mainWindow
|
id: mainWindow
|
||||||
@ -67,11 +68,13 @@ Item {
|
|||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
asynchronous: true
|
asynchronous: true
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
if (Widget.type === "QMLWidget") {
|
switch (Widget.type) {
|
||||||
loader.source = Qt.resolvedUrl(Widget.sourcePath)
|
case InstalledType.QMLWidget:
|
||||||
print("loader.source", loader.source)
|
loader.source = Qt.resolvedUrl( Widget.projectSourceFileAbsolute)
|
||||||
} else if (Widget.type === "HTMLWidget") {
|
break
|
||||||
|
case InstalledType.HTMLWidget:
|
||||||
loader.sourceComponent = webViewComponent
|
loader.sourceComponent = webViewComponent
|
||||||
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onStatusChanged: {
|
onStatusChanged: {
|
||||||
|
@ -11,13 +11,12 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
|
|
||||||
QStringList argumentList = app.arguments();
|
const QStringList argumentList = app.arguments();
|
||||||
|
|
||||||
// If we start with only one argument (path, appID, type),
|
// If we start with only one argument (path, appID, 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", { 0, 0 }, "appid", "qmlWidget");
|
//WidgetWindow spwmw("test", "appid", "qmlWidget", { 0, 0 });
|
||||||
//WidgetWindow spwmw("C:\\Program Files (x86)\\Steam\\steamapps\\workshop\\content\\672870\\2136442401", "appid", "qmlWidget", { 0, 0 });
|
|
||||||
WidgetWindow spwmw("C:/Program Files (x86)/Steam/steamapps/workshop/content/672870/2136442401", "appid", "qmlWidget", { 0, 0 });
|
WidgetWindow spwmw("C:/Program Files (x86)/Steam/steamapps/workshop/content/672870/2136442401", "appid", "qmlWidget", { 0, 0 });
|
||||||
return app.exec();
|
return app.exec();
|
||||||
}
|
}
|
||||||
@ -39,8 +38,11 @@ int main(int argc, char* argv[])
|
|||||||
positionY = 0;
|
positionY = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1. Project path, 2. AppID, 3. Type, 4. Posx, 5. PosY
|
WidgetWindow spwmw(
|
||||||
WidgetWindow spwmw(argumentList.at(1), argumentList.at(2), argumentList.at(3), QPoint { positionX, positionY });
|
argumentList.at(1), // Project path,
|
||||||
|
argumentList.at(2), // AppID
|
||||||
|
argumentList.at(3), // Type
|
||||||
|
QPoint { positionX, positionY });
|
||||||
|
|
||||||
return app.exec();
|
return app.exec();
|
||||||
}
|
}
|
||||||
|
@ -24,21 +24,22 @@ WidgetWindow::WidgetWindow(
|
|||||||
const QPoint& position)
|
const QPoint& position)
|
||||||
: QObject(nullptr)
|
: QObject(nullptr)
|
||||||
, m_appID { appID }
|
, m_appID { appID }
|
||||||
, m_type { type }
|
|
||||||
, m_position { position }
|
, m_position { position }
|
||||||
|
, m_sdk { std::make_unique<ScreenPlaySDK>(appID, type) }
|
||||||
{
|
{
|
||||||
|
|
||||||
|
qRegisterMetaType<ScreenPlay::InstalledType::InstalledType>();
|
||||||
|
qmlRegisterUncreatableMetaObject(ScreenPlay::InstalledType::staticMetaObject,
|
||||||
|
"ScreenPlay.Enums.InstalledType",
|
||||||
|
1, 0,
|
||||||
|
"InstalledType",
|
||||||
|
"Error: only enums");
|
||||||
|
|
||||||
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::sdkDisconnected, this, &WidgetWindow::qmlExit);
|
||||||
QObject::connect(m_sdk.get(), &ScreenPlaySDK::incommingMessage, this, &WidgetWindow::messageReceived);
|
QObject::connect(m_sdk.get(), &ScreenPlaySDK::incommingMessage, this, &WidgetWindow::messageReceived);
|
||||||
|
|
||||||
if (!ScreenPlayUtil::getAvailableWidgets().contains(m_type, Qt::CaseSensitivity::CaseInsensitive)) {
|
|
||||||
QApplication::exit(-4);
|
|
||||||
}
|
|
||||||
|
|
||||||
setType(type);
|
|
||||||
|
|
||||||
Qt::WindowFlags flags = m_window.flags();
|
Qt::WindowFlags flags = m_window.flags();
|
||||||
|
|
||||||
m_window.setFlags(flags | Qt::FramelessWindowHint | Qt::NoDropShadowWindowHint | Qt::BypassWindowManagerHint | Qt::SplashScreen);
|
m_window.setFlags(flags | Qt::FramelessWindowHint | Qt::NoDropShadowWindowHint | Qt::BypassWindowManagerHint | Qt::SplashScreen);
|
||||||
@ -52,17 +53,23 @@ WidgetWindow::WidgetWindow(
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (projectPath == "test") {
|
if (projectPath == "test") {
|
||||||
setSourcePath("qrc:/test.qml");
|
setProjectSourceFileAbsolute({ "qrc:/test.qml" });
|
||||||
|
setType(ScreenPlay::InstalledType::InstalledType::QMLWidget);
|
||||||
} else {
|
} else {
|
||||||
auto projectOpt = ScreenPlayUtil::openJsonFileToObject(projectPath + "/project.json");
|
auto projectOpt = ScreenPlayUtil::openJsonFileToObject(projectPath + "/project.json");
|
||||||
if (projectOpt.has_value()) {
|
if (!projectOpt.has_value()) {
|
||||||
qWarning() << "Unable to parse project file!";
|
qWarning() << "Unable to parse project file!";
|
||||||
QApplication::exit(-1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_project = projectOpt.value();
|
m_project = projectOpt.value();
|
||||||
QString fullPath = "file:///" + projectPath + "/" + m_project.value("file").toString();
|
setProjectSourceFile(m_project.value("file").toString());
|
||||||
setSourcePath(fullPath);
|
setProjectSourceFileAbsolute(QUrl::fromLocalFile(projectPath + "/" + projectSourceFile()));
|
||||||
|
|
||||||
|
if (auto typeOpt = ScreenPlayUtil::getInstalledTypeFromString(m_project.value("type").toString())) {
|
||||||
|
setType(typeOpt.value());
|
||||||
|
} else {
|
||||||
|
qWarning() << "Cannot parse Wallpaper type from value" << m_project.value("type");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_window.setTextRenderType(QQuickWindow::TextRenderType::NativeTextRendering);
|
m_window.setTextRenderType(QQuickWindow::TextRenderType::NativeTextRendering);
|
||||||
@ -72,6 +79,7 @@ WidgetWindow::WidgetWindow(
|
|||||||
m_window.show();
|
m_window.show();
|
||||||
|
|
||||||
// Do not trigger position changed save reuqest on startup
|
// Do not trigger position changed save reuqest on startup
|
||||||
|
sdk()->start();
|
||||||
QTimer::singleShot(1000, this, [=, this]() {
|
QTimer::singleShot(1000, this, [=, this]() {
|
||||||
// We limit ourself to only update the position every 500ms!
|
// We limit ourself to only update the position every 500ms!
|
||||||
auto sendPositionUpdate = [this]() {
|
auto sendPositionUpdate = [this]() {
|
||||||
|
@ -55,9 +55,9 @@
|
|||||||
#include <qt_windows.h>
|
#include <qt_windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <memory>
|
#include "ScreenPlayUtil/util.h"
|
||||||
|
|
||||||
#include "screenplaysdk.h"
|
#include "screenplaysdk.h"
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
class WidgetWindow : public QObject {
|
class WidgetWindow : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -70,46 +70,33 @@ public:
|
|||||||
const QPoint& position);
|
const QPoint& position);
|
||||||
|
|
||||||
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 projectPath READ projectPath WRITE setProjectPath NOTIFY projectPathChanged)
|
||||||
Q_PROPERTY(QString projectConfig READ projectConfig WRITE setProjectConfig NOTIFY projectConfigChanged)
|
Q_PROPERTY(QString projectSourceFile READ projectSourceFile WRITE setProjectSourceFile NOTIFY projectSourceFileChanged)
|
||||||
Q_PROPERTY(QString sourcePath READ sourcePath WRITE setSourcePath NOTIFY sourcePathChanged)
|
Q_PROPERTY(QUrl projectSourceFileAbsolute READ projectSourceFileAbsolute WRITE setProjectSourceFileAbsolute NOTIFY projectSourceFileAbsoluteChanged)
|
||||||
Q_PROPERTY(QPoint position READ position WRITE setPosition NOTIFY positionChanged)
|
Q_PROPERTY(QPoint position READ position WRITE setPosition NOTIFY positionChanged)
|
||||||
|
Q_PROPERTY(ScreenPlay::InstalledType::InstalledType type READ type WRITE setType NOTIFY typeChanged)
|
||||||
|
Q_PROPERTY(ScreenPlaySDK* sdk READ sdk WRITE setSdk NOTIFY sdkChanged)
|
||||||
|
|
||||||
QString appID() const
|
QString appID() const { return m_appID; }
|
||||||
{
|
QPoint position() const { return m_position; }
|
||||||
return m_appID;
|
const QString& projectPath() const { return m_projectPath; }
|
||||||
}
|
ScreenPlay::InstalledType::InstalledType type() const { return m_type; }
|
||||||
|
const QString& projectSourceFile() const { return m_projectSourceFile; }
|
||||||
QString type() const
|
const QUrl& projectSourceFileAbsolute() const { return m_projectSourceFileAbsolute; }
|
||||||
{
|
ScreenPlaySDK* sdk() const { return m_sdk.get(); }
|
||||||
return m_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString projectConfig() const
|
|
||||||
{
|
|
||||||
return m_projectConfig;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString sourcePath() const
|
|
||||||
{
|
|
||||||
return m_sourcePath;
|
|
||||||
}
|
|
||||||
|
|
||||||
QPoint position() const
|
|
||||||
{
|
|
||||||
return m_position;
|
|
||||||
}
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void qmlExit();
|
void qmlExit();
|
||||||
|
|
||||||
void appIDChanged(QString appID);
|
void appIDChanged(QString appID);
|
||||||
void typeChanged(QString type);
|
|
||||||
void projectConfigChanged(QString projectConfig);
|
|
||||||
void sourcePathChanged(QString sourcePath);
|
|
||||||
void qmlSceneValueReceived(QString key, QString value);
|
void qmlSceneValueReceived(QString key, QString value);
|
||||||
|
|
||||||
void positionChanged(QPoint position);
|
void positionChanged(QPoint position);
|
||||||
|
void projectPathChanged(const QString& projectPath);
|
||||||
|
void typeChanged(ScreenPlay::InstalledType::InstalledType);
|
||||||
|
void projectSourceFileChanged(const QString& projectSourceFile);
|
||||||
|
void projectSourceFileAbsoluteChanged(const QUrl& projectSourceFileAbsolute);
|
||||||
|
|
||||||
|
void sdkChanged(ScreenPlaySDK*);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setSize(QSize size);
|
void setSize(QSize size);
|
||||||
@ -128,30 +115,6 @@ public slots:
|
|||||||
m_appID = appID;
|
m_appID = appID;
|
||||||
emit appIDChanged(m_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);
|
|
||||||
}
|
|
||||||
void setSourcePath(QString sourcePath)
|
|
||||||
{
|
|
||||||
if (m_sourcePath == sourcePath)
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_sourcePath = sourcePath;
|
|
||||||
emit sourcePathChanged(m_sourcePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
QPointF cursorPos() { return QCursor::pos(); }
|
QPointF cursorPos() { return QCursor::pos(); }
|
||||||
|
|
||||||
@ -168,21 +131,61 @@ public slots:
|
|||||||
emit positionChanged(m_position);
|
emit positionChanged(m_position);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
void setProjectPath(const QString& projectPath)
|
||||||
QString m_appID { "" };
|
{
|
||||||
QString m_type { "qmlWidget" };
|
if (m_projectPath == projectPath)
|
||||||
QString m_projectConfig { "" };
|
return;
|
||||||
QString m_sourcePath { "" };
|
m_projectPath = projectPath;
|
||||||
|
emit projectPathChanged(m_projectPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setType(ScreenPlay::InstalledType::InstalledType Type)
|
||||||
|
{
|
||||||
|
if (m_type == Type)
|
||||||
|
return;
|
||||||
|
m_type = Type;
|
||||||
|
emit typeChanged(m_type);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setProjectSourceFile(const QString& ProjectSourceFile)
|
||||||
|
{
|
||||||
|
if (m_projectSourceFile == ProjectSourceFile)
|
||||||
|
return;
|
||||||
|
m_projectSourceFile = ProjectSourceFile;
|
||||||
|
emit projectSourceFileChanged(m_projectSourceFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setProjectSourceFileAbsolute(const QUrl& projectSourceFileAbsolute)
|
||||||
|
{
|
||||||
|
if (m_projectSourceFileAbsolute == projectSourceFileAbsolute)
|
||||||
|
return;
|
||||||
|
m_projectSourceFileAbsolute = projectSourceFileAbsolute;
|
||||||
|
emit projectSourceFileAbsoluteChanged(m_projectSourceFileAbsolute);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setSdk(ScreenPlaySDK* sdk)
|
||||||
|
{
|
||||||
|
if (m_sdk.get() == sdk)
|
||||||
|
return;
|
||||||
|
m_sdk.reset(sdk);
|
||||||
|
emit sdkChanged(sdk);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString m_appID;
|
||||||
|
QString m_projectPath;
|
||||||
QJsonObject m_project;
|
QJsonObject m_project;
|
||||||
QPoint m_clickPos = { 0, 0 };
|
QPoint m_clickPos = { 0, 0 };
|
||||||
QPoint m_lastPos = { 0, 0 };
|
QPoint m_lastPos = { 0, 0 };
|
||||||
|
QPoint m_position = { 0, 0 };
|
||||||
QQuickView m_window;
|
QQuickView m_window;
|
||||||
|
std::unique_ptr<ScreenPlaySDK> m_sdk;
|
||||||
|
QTimer m_positionMessageLimiter;
|
||||||
|
ScreenPlay::InstalledType::InstalledType m_type;
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
HWND m_hwnd;
|
HWND m_hwnd;
|
||||||
#endif
|
#endif
|
||||||
QPoint m_position;
|
QString m_projectSourceFile;
|
||||||
std::unique_ptr<ScreenPlaySDK> m_sdk;
|
QUrl m_projectSourceFileAbsolute;
|
||||||
QTimer m_positionMessageLimiter;
|
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user