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

Add initial wallpaper start on startup

This commit is contained in:
Elias 2019-08-02 13:11:31 +02:00
parent 0b7676ab17
commit 17729a590f
25 changed files with 250 additions and 221 deletions

View File

@ -126,5 +126,6 @@
<file>qml/Create/FFMPEGPopup.qml</file>
<file>assets/images/FFmpeg_Logo_new.svg</file>
<file>assets/icons/baseline-done-24px.svg</file>
<file>profiles.json</file>
</qresource>
</RCC>

View File

@ -63,9 +63,6 @@ CONFIG(debug, debug|release) {
install_it.path = $${OUT_PWD}/release/
}
install_it.files += assets/templates/config.json \
assets/icons/favicon.ico
INCLUDEPATH += $$PWD/../Common/vcpkg/installed/x64-windows/include
DEPENDPATH += $$PWD/../Common/vcpkg/installed/x64-windows/include

View File

@ -1,21 +0,0 @@
{
"Version" : "0.0.1",
"Settings" : {
"Autostart" : true,
"Renderer": {
"Value": 0,
"Enum" : ["OpenGL","Vulkan", "DirectX11", "DirectX12", "Software"]
}
},
"Screens":
[
{ "ScreenName1": {"id": "abc", "fillmode": "stretch"} },
{ "ScreenName2": {"id": "xyz"} }
],
"Widgets":
[
{ "WidgetName1": {"id": "abc"} },
{ "WidgetName2": {"id": "aaa"} }
],
"Plays": []
}

View File

@ -62,14 +62,10 @@ int main(int argc, char* argv[])
// such things as the profile list model to complete
// It will also set the m_absoluteStoragePath in profileListModel and installedListModel
auto settings = make_shared<Settings>(installedListModel, profileListModel, monitorListModel, sdkConnector);
ScreenPlayManager screenPlay(installedListModel, settings, monitorListModel, sdkConnector);
installedListModel->loadInstalledContent();
ScreenPlayManager screenPlay(installedListModel, settings, monitorListModel, sdkConnector, profileListModel);
Create create(settings);
// All the list need the default path from the settings
// to know where to look for the files
profileListModel->loadProfiles();
settings->loadActiveProfiles();
QQmlApplicationEngine mainWindowEngine;
QMLUtilities qmlUtil { mainWindowEngine.networkAccessManager() };
@ -83,7 +79,6 @@ int main(int argc, char* argv[])
mainWindowEngine.rootContext()->setContextProperty("screenPlaySettings", settings.get());
mainWindowEngine.load(QUrl(QStringLiteral("qrc:/main.qml")));
installedListModel->loadInstalledContent();
// Instead of setting "renderType: Text.NativeRendering" every time
// we can set it here once :)

View File

@ -17,8 +17,9 @@ ApplicationWindow {
// Set visible if the -silent parameter was not set (see main.cpp:87).
visible: false
width: 1400
height: 788
title: "ScreenPlay 0.2"
minimumHeight: 788
minimumHeight: 450
minimumWidth: 1050
Component.onCompleted: {
@ -147,11 +148,11 @@ ApplicationWindow {
if (miMuteAll.isMuted) {
isMuted = false
miMuteAll.text = qsTr("Mute all")
screenPlay.setAllWallpaperValue("volume", "1")
screenPlay.setAllWallpaperValue("muted", "true")
} else {
isMuted = true
miMuteAll.text = qsTr("Unmute all")
screenPlay.setAllWallpaperValue("volume", "0")
screenPlay.setAllWallpaperValue("muted", "false")
}
}
}
@ -163,11 +164,11 @@ ApplicationWindow {
if (miStopAll.isPlaying) {
isPlaying = false
miStopAll.text = qsTr("Pause all")
screenPlay.setAllWallpaperValue("isPlaying", "false")
screenPlay.setAllWallpaperValue("isPlaying", "true")
} else {
isPlaying = true
miStopAll.text = qsTr("Play all")
screenPlay.setAllWallpaperValue("isPlaying", "true")
screenPlay.setAllWallpaperValue("isPlaying", "false")
}
}
}

16
ScreenPlay/profiles.json Normal file
View File

@ -0,0 +1,16 @@
{
"version":"1.0.0",
"profilesWallpaper":[
],
"profilesWidgets":[
{
}
],
"profilesAppDrawer":[
{
}
]
}

View File

@ -36,6 +36,7 @@ Item {
onCreateWallpaperStateChanged: {
if (state === CreateImportVideo.AnalyseVideoError || state
=== CreateImportVideo.ConvertingVideoError || state
=== CreateImportVideo.AnalyseVideoHasNoVideoStreamError || state
=== CreateImportVideo.ConvertingPreviewGifError || state
=== CreateImportVideo.ConvertingPreviewImageError || state
=== CreateImportVideo.ConvertingAudioError || state
@ -100,11 +101,6 @@ Item {
}
}
CreateWallpaperResult {
id: wrapperResult
anchors.fill: parent
}
MouseArea {
anchors {
top: parent.top
@ -157,10 +153,6 @@ Item {
target: effect
opacity: 0
}
PropertyChanges {
target: wrapperResult
opacity: 0
}
},
State {
name: "in"
@ -173,10 +165,6 @@ Item {
target: effect
opacity: .4
}
PropertyChanges {
target: wrapperResult
opacity: 0
}
},
State {
name: "error"
@ -194,10 +182,6 @@ Item {
opacity: 0
z: 0
}
PropertyChanges {
target: wrapperResult
opacity: 1
}
},
State {
name: "success"
@ -300,12 +284,6 @@ Item {
PauseAnimation {
duration: 50
}
PropertyAnimation {
target: wrapperResult
duration: 200
property: "opacity"
easing.type: Easing.OutQuart
}
}
}
]

View File

@ -1,10 +1,7 @@
{
"version" : "0.0.1",
"autostart" : true,
"highPriorityStart" : false,
"sendStatistics" : false,
"absoluteStoragePath": "",
"profiles":[
{ "monitorID": "","wallpaper": "" }
]
"version":"1.0.0",
"autostart":true,
"highPriorityStart":false,
"sendStatistics":false,
"absoluteStoragePath":""
}

View File

@ -29,23 +29,26 @@ CreateImportVideo::CreateImportVideo(const QString& videoPath, const QString& ex
void CreateImportVideo::process()
{
if (!createWallpaperInfo())
if (!createWallpaperInfo() || QThread::currentThread()->isInterruptionRequested())
return;
if (!createWallpaperVideoPreview())
if (!createWallpaperImagePreview() || QThread::currentThread()->isInterruptionRequested())
return;
if (!createWallpaperImagePreview())
if (!createWallpaperVideoPreview() || QThread::currentThread()->isInterruptionRequested())
return;
if (!createWallpaperGifPreview())
if (!createWallpaperGifPreview() || QThread::currentThread()->isInterruptionRequested())
return;
if (!createWallpaperVideo())
if (!createWallpaperVideo() || QThread::currentThread()->isInterruptionRequested())
return;
if (!extractWallpaperAudio())
return;
// If the video has no audio we can skip the extraction
if (!m_skipAudio) {
if (!extractWallpaperAudio() || QThread::currentThread()->isInterruptionRequested())
return;
}
emit createWallpaperStateChanged(ImportVideoState::Finished);
}
@ -93,10 +96,41 @@ bool CreateImportVideo::createWallpaperInfo()
}
obj = doc.object();
if (obj.empty()) {
emit createWallpaperStateChanged(ImportVideoState::AnalyseVideoError);
pro.data()->close();
return false;
}
pro.data()->close();
// Get video length
// Check for audio and video streams
QJsonArray arrayStream = obj.value("streams").toArray();
bool hasAudioStream { false };
bool hasVideoStream { false };
for (const auto stream : arrayStream) {
QString codec_type = stream.toObject().value("codec_type").toString();
if (codec_type == "video") {
hasVideoStream = true;
} else if (codec_type == "audio") {
hasAudioStream = true;
}
}
// Display error if wallpaper has no video
if (!hasVideoStream) {
emit createWallpaperStateChanged(ImportVideoState::AnalyseVideoHasNoVideoStreamError);
return false;
}
if (!hasAudioStream)
m_skipAudio = true;
QJsonObject objFormat = obj.value("format").toObject();
// Get video length
qDebug() << objFormat;
bool okParseDuration = false;
auto tmpLength = objFormat.value("duration").toVariant().toFloat(&okParseDuration);
@ -317,20 +351,13 @@ bool CreateImportVideo::createWallpaperImagePreview()
bool CreateImportVideo::createWallpaperVideo()
{
emit createWallpaperStateChanged(ImportVideoState::ConvertingVideo);
if(m_videoPath.endsWith(".webm")){
emit createWallpaperStateChanged(ImportVideoState::ConvertingVideoFinished);
if (!QFile::copy(m_videoPath, m_exportPath + "/video.webm")) {
qDebug() << "Could not copy" << m_videoPath << " to " << m_exportPath + "/video.webm";
emit createWallpaperStateChanged(ImportVideoState::CopyFilesError);
return false;
}
if (m_videoPath.endsWith(".webm")) {
return true;
}
emit createWallpaperStateChanged(ImportVideoState::ConvertingVideo);
QStringList args;
args.clear();
args.append("-hide_banner");
@ -354,7 +381,7 @@ bool CreateImportVideo::createWallpaperVideo()
args.append("0");
QFileInfo file(m_videoPath);
QString convertedFileAbsolutePath {m_exportPath +"/"+ file.baseName() +".webm"};
QString convertedFileAbsolutePath { m_exportPath + "/" + file.baseName() + ".webm" };
args.append(convertedFileAbsolutePath);
QScopedPointer<QProcess> proConvertVideo(new QProcess());
@ -441,6 +468,8 @@ bool CreateImportVideo::extractWallpaperAudio()
if (!tmpErrImg.isEmpty()) {
QFile previewImg(m_exportPath + "/audio.mp3");
if (!previewImg.exists() && !(previewImg.size() > 0)) {
qDebug() << args;
qDebug() << proConvertAudio.data()->readAll();
emit createWallpaperStateChanged(ImportVideoState::ConvertingAudioError);
return false;
}

View File

@ -38,6 +38,7 @@ public:
AnalyseVideo,
AnalyseVideoFinished,
AnalyseVideoError,
AnalyseVideoHasNoVideoStreamError,
ConvertingPreviewVideo,
ConvertingPreviewVideoFinished,
ConvertingPreviewVideoError,
@ -82,6 +83,9 @@ public slots:
bool createWallpaperVideo();
bool extractWallpaperAudio();
private:
bool m_skipAudio {false};
};
}
Q_DECLARE_METATYPE(ScreenPlay::CreateImportVideo::ImportVideoState)

View File

@ -13,6 +13,7 @@ InstalledListModel::InstalledListModel(QObject* parent)
{
QObject::connect(this, &InstalledListModel::addInstalledItem,
this, &InstalledListModel::append, Qt::QueuedConnection);
}
int InstalledListModel::rowCount(const QModelIndex& parent) const
@ -70,19 +71,6 @@ QHash<int, QByteArray> InstalledListModel::roleNames() const
return roles;
}
bool InstalledListModel::getProjectByAbsoluteStoragePath(QUrl* path, ProjectFile* spf)
{
for (int i = 0; i < m_screenPlayFiles.count(); ++i) {
if (m_screenPlayFiles.at(i).m_absoluteStoragePath == *path) {
*spf = m_screenPlayFiles.at(i);
return true;
}
}
return false;
}
void InstalledListModel::append(const QJsonObject& obj, const QString& folderName)
{

View File

@ -35,7 +35,6 @@ public:
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
QHash<int, QByteArray> roleNames() const override;
bool getProjectByAbsoluteStoragePath(QUrl* path, ProjectFile* spf);
enum InstalledRole {
TitleRole = Qt::UserRole,

View File

@ -34,5 +34,6 @@ struct Profile {
QString m_wallpaperId = "";
QRect m_rect;
bool m_isLooping = true;
QVector<QString> m_monitorList;
};
}

View File

@ -46,64 +46,10 @@ QVariant ProfileListModel::data(const QModelIndex& index, int role) const
QHash<int, QByteArray> ProfileListModel::roleNames() const
{
QHash<int, QByteArray> m_roleNames;
return m_roleNames;
}
void ProfileListModel::loadProfiles()
{
QFileInfoList list = QDir(m_localStoragePath.toString() + "/Profiles/").entryInfoList(QDir::NoDotAndDotDot | QDir::AllDirs);
QString tmpPath;
QJsonDocument profileDoc;
QJsonParseError parseError;
QJsonObject profileObj;
for (auto&& item : list) {
tmpPath = m_localStoragePath.toString() + "/Profiles/" + item.baseName() + "/profile.json";
QFile settings;
settings.setFileName(tmpPath);
settings.open(QIODevice::ReadOnly | QIODevice::Text);
QString projectConfigData = settings.readAll();
profileDoc = QJsonDocument::fromJson(projectConfigData.toUtf8(), &parseError);
if (!(parseError.error == QJsonParseError::NoError))
continue;
profileObj = profileDoc.object();
Profile tmpProfile;
tmpProfile.m_id = item.baseName();
if (profileObj.contains("version"))
tmpProfile.m_version = profileObj.value("version").toString();
if (profileObj.contains("wallpaperId"))
tmpProfile.m_wallpaperId = profileObj.value("wallpaperId").toString();
if (profileObj.contains("width") && profileObj.contains("height") && profileObj.contains("xPos") && profileObj.contains("yPos")) {
//Check for inpossible values
if (profileObj.value("width").toInt() == 0 || profileObj.value("height").toInt() == 0) {
continue;
}
tmpProfile.m_rect.setX(profileObj.value("xPos").toInt());
tmpProfile.m_rect.setY(profileObj.value("yPos").toInt());
tmpProfile.m_rect.setWidth(profileObj.value("width").toInt());
tmpProfile.m_rect.setHeight(profileObj.value("height").toInt());
} else {
qWarning("Parsing error");
}
if (profileObj.contains("isLooping"))
tmpProfile.m_isLooping = profileObj.value("isLooping").toBool();
tmpProfile.m_absolutePath = m_localStoragePath;
m_profileList.append(tmpProfile);
}
}
bool ProfileListModel::getProfileByName(QString id, Profile* profile)
{
for (int i = 0; i < m_profileList.size(); i++) {
@ -114,4 +60,8 @@ bool ProfileListModel::getProfileByName(QString id, Profile* profile)
}
return false;
}
void ProfileListModel::append(const Profile& profile)
{
}
}

View File

@ -34,12 +34,11 @@ public:
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
virtual QHash<int, QByteArray> roleNames() const override;
void loadProfiles();
bool getProfileByName(QString id, Profile* profile);
QUrl m_localStoragePath;
void append(const Profile& profile);
private:
QHash<int, QByteArray> m_roleNames;
QVector<Profile> m_profileList;
};
}

View File

@ -5,31 +5,27 @@ namespace ScreenPlay {
ScreenPlayManager::ScreenPlayManager(const shared_ptr<InstalledListModel>& ilm,
const shared_ptr<Settings>& settings,
const shared_ptr<MonitorListModel>& mlm,
const shared_ptr<SDKConnector>& sdkc,
const shared_ptr<SDKConnector>& sdkc, const shared_ptr<ProfileListModel>& plm,
QObject* parent)
: QObject { parent }
, m_installedListModel { ilm }
, m_settings { settings }
, m_monitorListModel { mlm }
, m_sdkconnector { sdkc }
, m_profileListModel { plm }
, m_qGuiApplication { static_cast<QGuiApplication*>(QGuiApplication::instance()) }
{
// loadActiveProfiles();
}
void ScreenPlayManager::createWallpaper(
const int monitorIndex, QUrl absoluteStoragePath,
const int monitorIndex, const QUrl& absoluteStoragePath,
const QString& previewImage, const float volume,
const QString& fillMode, const QString& type)
{
removeWallpaperAt(monitorIndex);
ProjectFile project {};
if (!m_installedListModel->getProjectByAbsoluteStoragePath(&absoluteStoragePath, &project)) {
qWarning() << "Failed to receive getProjectByAbsoluteStoragePath";
return;
}
m_settings->increaseActiveWallpaperCounter();
m_screenPlayWallpapers.emplace_back(
@ -54,10 +50,6 @@ void ScreenPlayManager::createWidget(QUrl absoluteStoragePath, const QString& pr
{
ProjectFile project {};
if (!m_installedListModel->getProjectByAbsoluteStoragePath(&absoluteStoragePath, &project)) {
return;
}
m_settings->increaseActiveWidgetsCounter();
m_screenPlayWidgets.emplace_back(
@ -66,7 +58,7 @@ void ScreenPlayManager::createWidget(QUrl absoluteStoragePath, const QString& pr
m_settings,
absoluteStoragePath.toLocalFile(),
previewImage,
QString { absoluteStoragePath.toLocalFile() + "/" + project.m_file.toString() },
absoluteStoragePath.toString(),
this));
}
@ -150,4 +142,65 @@ QString ScreenPlayManager::generateID() const
}
return randomString;
}
void ScreenPlayManager::loadActiveProfiles()
{
QJsonDocument configJsonDocument;
QJsonObject configObj;
QJsonArray activeProfilesTmp;
QFile configTmp;
configTmp.setFileName(m_settings->localSettingsPath().toLocalFile() + "/profiles.json");
configTmp.open(QIODevice::ReadOnly | QIODevice::Text);
QString config = configTmp.readAll();
configJsonDocument = QJsonDocument::fromJson(config.toUtf8());
configObj = configJsonDocument.object();
activeProfilesTmp = configObj.value("profilesWallpaper").toArray();
for (const QJsonValueRef wallpaper : activeProfilesTmp) {
QJsonObject wallpaperObj = wallpaper.toObject();
if (wallpaperObj.empty())
continue;
bool parsing = true;
bool isLooping = wallpaperObj.value("isLooping").toBool(parsing);
if (!parsing)
continue;
float volume = static_cast<float>(wallpaperObj.value("volume").toDouble(parsing));
if (!parsing)
continue;
QString absolutePath = wallpaperObj.value("absolutePath").toString();
QString fillMode = wallpaperObj.value("fillMode").toString();
QString previewImage = wallpaperObj.value("previewImage").toString();
QString file = wallpaperObj.value("file").toString();
QString type = wallpaperObj.value("type").toString();
QJsonArray monitorsArray = wallpaper.toObject().value("monitors").toArray();
if (monitorsArray.empty())
continue;
QMap<QString, int> monitorMap;
// A wallpaper can span across multiple monitors
for (const QJsonValueRef monitor : monitorsArray) {
QJsonObject obj = monitor.toObject();
int parseMonitorIndexDefaultValue { -1 };
int monitorIndex = obj.value("index").toInt(parseMonitorIndexDefaultValue);
if (monitorIndex == -1)
continue;
monitorMap.insert(obj.value("name").toString(), monitorIndex);
}
createWallpaper(0, absolutePath, previewImage, volume, fillMode, type);
}
}
}

View File

@ -10,6 +10,7 @@
#include "installedlistmodel.h"
#include "monitorlistmodel.h"
#include "profilelistmodel.h"
#include "projectfile.h"
#include "projectsettingslistmodel.h"
#include "screenplaywallpaper.h"
@ -22,7 +23,6 @@
\brief Used for Creation of Wallpaper, Scenes and Widgets
*/
namespace ScreenPlay {
using std::shared_ptr,
@ -42,6 +42,7 @@ public:
const shared_ptr<Settings>& settings,
const shared_ptr<MonitorListModel>& mlm,
const shared_ptr<SDKConnector>& sdkc,
const shared_ptr<ProfileListModel>& plm,
QObject* parent = nullptr);
~ScreenPlayManager() {}
@ -52,8 +53,7 @@ signals:
void projectSettingsListModelNotFound();
public slots:
void createWallpaper(
const int monitorIndex, QUrl absoluteStoragePath,
void createWallpaper(const int monitorIndex, const QUrl &absoluteStoragePath,
const QString& previewImage, const float volume,
const QString& fillMode, const QString& type);
void createWidget(QUrl absoluteStoragePath, const QString& previewImage);
@ -64,11 +64,15 @@ public slots:
void removeWallpaperAt(const int at = 0);
QString generateID() const;
private:
void loadActiveProfiles();
private:
const shared_ptr<InstalledListModel> m_installedListModel;
const shared_ptr<Settings> m_settings;
const shared_ptr<MonitorListModel> m_monitorListModel;
const shared_ptr<SDKConnector> m_sdkconnector;
const shared_ptr<ProfileListModel> m_profileListModel;
const QGuiApplication* const m_qGuiApplication;
vector<unique_ptr<ScreenPlayWallpaper>> m_screenPlayWallpapers;

View File

@ -64,7 +64,7 @@ Settings::Settings(const shared_ptr<InstalledListModel>& ilm,
m_localSettingsPath = QUrl::fromUserInput(appConfigLocation);
if (!QDir(appConfigLocation).exists()) {
if (!QDir().mkpath(appConfigLocation)) {
qWarning("ERROR: Cloud not create install dir");
qWarning("ERROR: Cloud not create appConfigLocation dir");
return;
}
}
@ -77,6 +77,13 @@ Settings::Settings(const shared_ptr<InstalledListModel>& ilm,
createDefaultConfig();
}
QFile profiles;
profiles.setFileName(appConfigLocation + "/profiles.json");
if (!profiles.exists()) {
qWarning("No profiles.json found, creating default settings");
createDefaultProfiles();
}
QJsonDocument configJsonDocument;
QJsonParseError parseError {};
QJsonObject configObj;
@ -136,40 +143,6 @@ Settings::Settings(const shared_ptr<InstalledListModel>& ilm,
setupWidgetAndWindowPaths();
}
void Settings::loadActiveProfiles()
{
QJsonDocument configJsonDocument;
QJsonObject configObj;
QJsonArray activeProfilesTmp;
QFile configTmp;
configTmp.setFileName(m_localSettingsPath.toLocalFile() + "/settings.json");
configTmp.open(QIODevice::ReadOnly | QIODevice::Text);
QString config = configTmp.readAll();
configJsonDocument = QJsonDocument::fromJson(config.toUtf8());
configObj = configJsonDocument.object();
activeProfilesTmp = configObj.value("profiles").toArray();
int size = activeProfilesTmp.size();
// Only load profiles if we have any
if (size > 0) {
for (int i = 0; i < size; i++) {
QString profileName = activeProfilesTmp.at(i).toObject().value("profile").toString();
QString monitorID = activeProfilesTmp.at(i).toObject().value("monitorID").toString();
Profile profile;
// auto spf = new QSharedPointer<ProjectFile>(new ProjectFile());
// if (!m_plm->getProfileByName(profileName, &profile))
// continue;
// if (!m_ilm->getProjectByAbsoluteStoragePath(&profile.m_absolutePath, spf))
// continue;
// constructWallpaper(profile, monitorID, spf);
}
}
}
void Settings::writeSingleSettingConfig(QString name, QVariant value)
{
@ -232,6 +205,24 @@ void Settings::createDefaultConfig()
defaultSettings.close();
}
void Settings::createDefaultProfiles()
{
QFile file(m_localSettingsPath.toLocalFile() + "/profiles.json");
QFile defaultSettings(":/profiles.json");
file.open(QIODevice::WriteOnly | QIODevice::Text);
defaultSettings.open(QIODevice::ReadOnly | QIODevice::Text);
QTextStream out(&file);
QTextStream defaultOut(&defaultSettings);
out << defaultOut.readAll();
file.close();
defaultSettings.close();
}
void Settings::setupWidgetAndWindowPaths()
{
QDir SPWorkingDir(QDir::currentPath());
@ -287,4 +278,6 @@ void Settings::setupWidgetAndWindowPaths()
}
#endif
}
}

View File

@ -67,6 +67,7 @@ public:
QObject* parent = nullptr);
~Settings() {}
QVersionNumber version() const
{
return m_version;
@ -157,6 +158,11 @@ public:
return m_activeWidgetsCounter;
}
QUrl localSettingsPath() const
{
return m_localSettingsPath;
}
signals:
void autostartChanged(bool autostart);
void highPriorityStartChanged(bool highPriorityStart);
@ -302,8 +308,6 @@ public slots:
emit offlineModeChanged(m_offlineMode);
}
void loadActiveProfiles();
void setActiveWidgetsCounter(int activeWidgetsCounter)
{
if (m_activeWidgetsCounter == activeWidgetsCounter)
@ -341,5 +345,6 @@ private:
QString m_decoder { "" };
int m_activeWallpaperCounter { 0 };
int m_activeWidgetsCounter { 0 };
void createDefaultProfiles();
};
}

View File

@ -3,7 +3,7 @@ TARGET = ScreenPlaySDK
TARGET = $$qtLibraryTarget($$TARGET)
QT += qml quick
CONFIG += plugin c++11
CONFIG += plugin c++17
uri = ScreenPlay.screenplaysdk

View File

@ -1,7 +1,7 @@
TEMPLATE = lib
TARGET = ScreenPlaySysInfo
QT += qml quick
CONFIG += plugin c++11
CONFIG += plugin c++17
TARGET = $$qtLibraryTarget($$TARGET)
uri = ScreenPlay.Sysinfo

View File

@ -116,7 +116,7 @@ Rectangle {
top: parent.top
topMargin: {
if(desktopProperties.windowsVersion >= 1903){
return -(1080 / 9)
return -((1080 / 9) / 3)
} else {
return 0;
}
@ -162,6 +162,16 @@ Rectangle {
Connections {
target: window
onMutedChanged:{
if(muted){
webView.runJavaScript(
"var videoPlayer = document.getElementById('videoPlayer'); videoPlayer.volume = 0;")
} else {
webView.runJavaScript(
"var videoPlayer = document.getElementById('videoPlayer'); videoPlayer.volume = " + window.volume + ";")
}
}
onQmlExit: {
webView.runJavaScript(
"var videoPlayer = document.getElementById('videoPlayer'); videoPlayer.volume = 0;")
@ -199,7 +209,7 @@ Rectangle {
onIsPlayingChanged: {
if (webView.loadProgress === 100) {
if (isPlaying === "false") {
if (isPlaying) {
webView.runJavaScript(
"var videoPlayer = document.getElementById('videoPlayer'); videoPlayer.play();")
} else {

View File

@ -24,6 +24,9 @@ BaseWindow::BaseWindow(QString projectFilePath, QObject* parent)
QJsonDocument configJsonDocument;
QJsonParseError parseError;
if(projectFilePath.contains("file:\\\\\\"))
projectFilePath = projectFilePath.remove("file:\\\\\\");
projectFile.setFileName(projectFilePath + "/project.json");
projectFile.open(QIODevice::ReadOnly | QIODevice::Text);
QString projectConfig = projectFile.readAll();
@ -112,5 +115,11 @@ void BaseWindow::messageReceived(QString key, QString value)
return;
}
if (key == "muted") {
bool tmp = QVariant(value).toBool();
setMuted(tmp);
return;
}
emit qmlSceneValueReceived(key, value);
}

View File

@ -8,8 +8,8 @@
#include <QJsonParseError>
#include <QObject>
#include <QString>
#include <QtQml>
#include <QSysInfo>
#include <QtQml>
class BaseWindow : public QObject {
Q_OBJECT
@ -23,6 +23,7 @@ public:
Q_PROPERTY(bool loops READ loops WRITE setLoops NOTIFY loopsChanged)
Q_PROPERTY(bool isPlaying READ isPlaying WRITE setIsPlaying NOTIFY isPlayingChanged)
Q_PROPERTY(float volume READ volume WRITE setVolume NOTIFY volumeChanged)
Q_PROPERTY(bool muted READ muted WRITE setMuted NOTIFY mutedChanged)
Q_PROPERTY(float playbackRate READ playbackRate WRITE setPlaybackRate NOTIFY playbackRateChanged)
Q_PROPERTY(WallpaperType type READ type WRITE setType NOTIFY typeChanged)
Q_PROPERTY(QString OSVersion READ OSVersion WRITE setOSVersion NOTIFY OSVersionChanged)
@ -76,6 +77,11 @@ public:
return m_OSVersion;
}
bool muted() const
{
return m_muted;
}
signals:
void loopsChanged(bool loops);
void volumeChanged(float volume);
@ -89,6 +95,8 @@ signals:
void OSVersionChanged(QString OSVersion);
void mutedChanged(bool muted);
public slots:
virtual void destroyThis() {}
virtual void setVisible(bool show) { Q_UNUSED(show) }
@ -170,12 +178,22 @@ public slots:
emit OSVersionChanged(m_OSVersion);
}
private:
bool m_loops = true;
bool m_isPlaying = true;
void setMuted(bool muted)
{
if (m_muted == muted)
return;
float m_volume = 1.0f;
float m_playbackRate = 1.0f;
m_muted = muted;
emit mutedChanged(m_muted);
}
private:
bool m_loops { true };
bool m_isPlaying { true };
bool m_muted { false };
float m_volume { 1.0f };
float m_playbackRate { 1.0f };
QString m_fullContentPath;
QString m_appID;

View File

@ -30,11 +30,14 @@ WindowsDesktopProperties::WindowsDesktopProperties(QObject* parent)
QSettings settingsWindowsVersion("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", QSettings::NativeFormat);
// Only Windows > 10 has this variable
if(!settingsWindowsVersion.contains("ReleaseID"))
return;
bool canParse {false};
int value = settingsWindowsVersion.value("ReleaseId").toInt(&canParse);
if(canParse)
setWindowsVersion(value);
qDebug() << settingsWindowsVersion.value("ReleaseId").toInt();
}