mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-11-07 03:22:33 +01:00
Merge remote-tracking branch 'origin/team/john' into feature/vcpkg
# Conflicts: # ScreenPlay/src/screenplay.cpp # ScreenPlay/src/screenplay.h
This commit is contained in:
commit
aed40a3633
@ -19,6 +19,8 @@ SOURCES += main.cpp \
|
||||
src/createimportvideo.cpp \
|
||||
src/installedlistmodel.cpp \
|
||||
src/monitorlistmodel.cpp \
|
||||
src/screenplaywallpaper.cpp \
|
||||
src/screenplaywidget.cpp \
|
||||
src/settings.cpp \
|
||||
src/profilelistmodel.cpp \
|
||||
src/profile.cpp \
|
||||
@ -39,6 +41,8 @@ HEADERS += \
|
||||
src/createimportvideo.h \
|
||||
src/installedlistmodel.h \
|
||||
src/monitorlistmodel.h \
|
||||
src/screenplaywallpaper.h \
|
||||
src/screenplaywidget.h \
|
||||
src/settings.h \
|
||||
src/profilelistmodel.h \
|
||||
src/profile.h \
|
||||
|
@ -1,5 +1,4 @@
|
||||
#include <QDir>
|
||||
#include <QFontDatabase>
|
||||
#include <QGuiApplication>
|
||||
#include <QIcon>
|
||||
#include <QObject>
|
||||
@ -10,6 +9,8 @@
|
||||
#include <QUrl>
|
||||
#include <QtWebEngine>
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "src/create.h"
|
||||
#include "src/installedlistfilter.h"
|
||||
#include "src/installedlistmodel.h"
|
||||
@ -20,6 +21,9 @@
|
||||
#include "src/sdkconnector.h"
|
||||
#include "src/settings.h"
|
||||
|
||||
using std::shared_ptr,
|
||||
std::make_shared;
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
|
||||
@ -39,45 +43,37 @@ int main(int argc, char* argv[])
|
||||
// Qt < 6.0 needs this init QtWebEngine
|
||||
QtWebEngine::initialize();
|
||||
|
||||
QFontDatabase::addApplicationFont(":/assets/fonts/LibreBaskerville-Italic.ttf");
|
||||
QFontDatabase::addApplicationFont(":/assets/fonts/Roboto-Light.ttf");
|
||||
QFontDatabase::addApplicationFont(":/assets/fonts/Roboto-Regular.ttf");
|
||||
QFontDatabase::addApplicationFont(":/assets/fonts/Roboto-Thin.ttf");
|
||||
QFontDatabase::addApplicationFont(":/assets/fonts/RobotoMono-Light.ttf");
|
||||
QFontDatabase::addApplicationFont(":/assets/fonts/RobotoMono-Thin.ttf");
|
||||
|
||||
QMLUtilities qmlUtil;
|
||||
InstalledListModel installedListModel;
|
||||
InstalledListFilter installedListFilter(&installedListModel);
|
||||
MonitorListModel monitorListModel;
|
||||
ProfileListModel profileListModel;
|
||||
SDKConnector sdkConnector;
|
||||
|
||||
auto installedListModel = make_shared<InstalledListModel>();
|
||||
auto installedListFilter = make_shared<InstalledListFilter>(installedListModel);
|
||||
auto monitorListModel = make_shared<MonitorListModel>();
|
||||
auto profileListModel = make_shared<ProfileListModel>();
|
||||
auto sdkConnector = make_shared<SDKConnector>();
|
||||
|
||||
// Create settings in the end because for now it depends on
|
||||
// such things as the profile list model to complete
|
||||
// It will also set the m_absoluteStoragePath in profileListModel and installedListModel
|
||||
Settings settings(&profileListModel, &monitorListModel, &installedListModel, &sdkConnector);
|
||||
ScreenPlay screenPlay(&installedListModel, &settings, &monitorListModel, &sdkConnector);
|
||||
Create create(&settings, &qmlUtil);
|
||||
auto settings = make_shared<Settings>(installedListModel, profileListModel, monitorListModel, sdkConnector);
|
||||
ScreenPlay screenPlay(installedListModel, settings, monitorListModel, sdkConnector);
|
||||
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();
|
||||
profileListModel->loadProfiles();
|
||||
settings->loadActiveProfiles();
|
||||
|
||||
QQmlApplicationEngine mainWindowEngine;
|
||||
mainWindowEngine.rootContext()->setContextProperty("screenPlay", &screenPlay);
|
||||
mainWindowEngine.rootContext()->setContextProperty("screenPlayCreate", &create);
|
||||
mainWindowEngine.rootContext()->setContextProperty("utility", &qmlUtil);
|
||||
mainWindowEngine.rootContext()->setContextProperty("installedListFilter", &installedListFilter);
|
||||
mainWindowEngine.rootContext()->setContextProperty("monitorListModel", &monitorListModel);
|
||||
mainWindowEngine.rootContext()->setContextProperty("installedListModel", &installedListModel);
|
||||
mainWindowEngine.rootContext()->setContextProperty("profileListModel", &profileListModel);
|
||||
mainWindowEngine.rootContext()->setContextProperty("screenPlaySettings", &settings);
|
||||
mainWindowEngine.rootContext()->setContextProperty("installedListFilter", installedListFilter.get());
|
||||
mainWindowEngine.rootContext()->setContextProperty("monitorListModel", monitorListModel.get());
|
||||
mainWindowEngine.rootContext()->setContextProperty("installedListModel", installedListModel.get());
|
||||
mainWindowEngine.rootContext()->setContextProperty("profileListModel", profileListModel.get());
|
||||
mainWindowEngine.rootContext()->setContextProperty("screenPlaySettings", settings.get());
|
||||
mainWindowEngine.load(QUrl(QStringLiteral("qrc:/main.qml")));
|
||||
|
||||
installedListModel.loadInstalledContent();
|
||||
installedListModel->loadInstalledContent();
|
||||
|
||||
// Instead of setting "renderType: Text.NativeRendering" every time
|
||||
// we can set it here once :)
|
||||
@ -87,7 +83,7 @@ int main(int argc, char* argv[])
|
||||
// Set visible if the -silent parameter was not set
|
||||
QStringList argumentList = app.arguments();
|
||||
if (!argumentList.contains("-silent")) {
|
||||
settings.setMainWindowVisible(true);
|
||||
settings->setMainWindowVisible(true);
|
||||
}
|
||||
|
||||
return app.exec();
|
||||
|
@ -1,12 +1,30 @@
|
||||
#include "create.h"
|
||||
|
||||
Create::Create(Settings* st, QMLUtilities* util, QObject* parent)
|
||||
/*!
|
||||
\class Create
|
||||
\since 1.0
|
||||
\brief Baseclass for creating wallapers, widgets and the corresponding
|
||||
wizards. As for this writing (April 2019) it is solely used to
|
||||
import webm wallpaper and create the gif/web 5 second previews.
|
||||
\todo
|
||||
- This class would need to be refactored to be used in more creation types.
|
||||
*/
|
||||
|
||||
Create::Create(const shared_ptr<Settings>& settings, QObject* parent)
|
||||
: QObject(parent)
|
||||
, m_settings(settings)
|
||||
|
||||
{
|
||||
qRegisterMetaType<CreateImportVideo::State>();
|
||||
qmlRegisterType<Create>("net.aimber.create", 1, 0, "Create");
|
||||
qmlRegisterType<CreateImportVideo>("net.aimber.create", 1, 0, "CreateImportVideo");
|
||||
}
|
||||
|
||||
m_settings = st;
|
||||
m_utils = util;
|
||||
|
||||
// Constructor for the QMLEngine
|
||||
Create::Create()
|
||||
: QObject(nullptr)
|
||||
, m_settings(nullptr)
|
||||
{
|
||||
qRegisterMetaType<CreateImportVideo::State>();
|
||||
qmlRegisterType<Create>("net.aimber.create", 1, 0, "Create");
|
||||
qmlRegisterType<CreateImportVideo>("net.aimber.create", 1, 0, "CreateImportVideo");
|
||||
|
@ -26,15 +26,8 @@
|
||||
#include "qmlutilities.h"
|
||||
#include "settings.h"
|
||||
|
||||
/*!
|
||||
\class Create
|
||||
\since 1.0
|
||||
\brief Baseclass for creating wallapers, widgets and the corresponding
|
||||
wizards. As for this writing (April 2019) it is solely used to
|
||||
import webm wallpaper and create the gif/web 5 second previews.
|
||||
\todo
|
||||
- This class would need to be refactored to be used in more creation types.
|
||||
*/
|
||||
using std::shared_ptr,
|
||||
std::make_shared;
|
||||
|
||||
class Create : public QObject {
|
||||
Q_OBJECT
|
||||
@ -43,9 +36,9 @@ class Create : public QObject {
|
||||
Q_PROPERTY(float progress READ progress WRITE setProgress NOTIFY progressChanged)
|
||||
|
||||
public:
|
||||
explicit Create(Settings* st, QMLUtilities* util, QObject* parent = nullptr);
|
||||
|
||||
Create() {}
|
||||
explicit Create(const shared_ptr<Settings>& settings,
|
||||
QObject* parent = nullptr);
|
||||
Create();
|
||||
~Create() {}
|
||||
|
||||
float progress() const
|
||||
@ -90,9 +83,9 @@ public slots:
|
||||
|
||||
private:
|
||||
CreateImportVideo* m_createImportVideo;
|
||||
Settings* m_settings;
|
||||
QThread* m_createImportVideoThread;
|
||||
QMLUtilities* m_utils;
|
||||
|
||||
const shared_ptr<Settings> m_settings;
|
||||
|
||||
float m_progress = 0.0f;
|
||||
QString m_workingDir;
|
||||
|
@ -1,9 +1,20 @@
|
||||
#include "installedlistfilter.h"
|
||||
|
||||
InstalledListFilter::InstalledListFilter(InstalledListModel* ilm)
|
||||
{
|
||||
/*!
|
||||
\class Installed List Filder
|
||||
\brief Proxy between Installed List Model and QML view to filter items.
|
||||
Maybe this class could be merged with the InstalledListModel...
|
||||
|
||||
setSourceModel(ilm);
|
||||
\todo
|
||||
- Expand filter functionality
|
||||
|
||||
*/
|
||||
|
||||
InstalledListFilter::InstalledListFilter(const shared_ptr<InstalledListModel>& ilm)
|
||||
: QSortFilterProxyModel()
|
||||
, m_ilm(ilm)
|
||||
{
|
||||
setSourceModel(m_ilm.get());
|
||||
setFilterRole(InstalledListModel::InstalledRole::TitleRole);
|
||||
sortByRoleType("All");
|
||||
}
|
||||
@ -19,7 +30,8 @@ void InstalledListFilter::sortByRoleType(QString type)
|
||||
} else if (type == "Widgets") {
|
||||
setFilterRole(InstalledListModel::InstalledRole::TypeRole);
|
||||
setFilterFixedString("widget");
|
||||
} if (type == "Scenes") {
|
||||
}
|
||||
if (type == "Scenes") {
|
||||
setFilterRole(InstalledListModel::InstalledRole::TypeRole);
|
||||
setFilterFixedString("qmlScene");
|
||||
}
|
||||
|
@ -2,27 +2,21 @@
|
||||
|
||||
#include <QRegExp>
|
||||
#include <QSortFilterProxyModel>
|
||||
|
||||
#include <memory>
|
||||
#include "installedlistmodel.h"
|
||||
|
||||
/*!
|
||||
\class Installed List Filder
|
||||
\brief Proxy between Installed List Model and QML view to filter items.
|
||||
Maybe this class could be merged with the InstalledListModel...
|
||||
|
||||
\todo
|
||||
- Expand filter functionality
|
||||
|
||||
*/
|
||||
using std::shared_ptr;
|
||||
|
||||
class InstalledListFilter : public QSortFilterProxyModel {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
InstalledListFilter(InstalledListModel* ilm);
|
||||
InstalledListFilter(const shared_ptr<InstalledListModel>& ilm);
|
||||
|
||||
public slots:
|
||||
void sortByRoleType(QString type);
|
||||
void sortByName(QString name);
|
||||
void resetFilter();
|
||||
private:
|
||||
const shared_ptr<InstalledListModel> m_ilm;
|
||||
};
|
||||
|
@ -1,32 +1,19 @@
|
||||
#include "screenplay.h"
|
||||
|
||||
ScreenPlay::ScreenPlay(InstalledListModel* ilm, Settings* set, MonitorListModel* mlm, SDKConnector* sdkc, QObject* parent)
|
||||
ScreenPlay::ScreenPlay(const shared_ptr<InstalledListModel> &ilm,
|
||||
const shared_ptr<Settings>& settings,
|
||||
const shared_ptr<MonitorListModel> &mlm,
|
||||
const shared_ptr<SDKConnector>& sdkc,
|
||||
QObject* parent)
|
||||
: QObject { parent }
|
||||
, m_ilm { ilm }
|
||||
, m_settings { set }
|
||||
, m_settings { settings }
|
||||
, m_mlm { mlm }
|
||||
, m_qGuiApplication { static_cast<QGuiApplication*>(QGuiApplication::instance()) }
|
||||
, m_sdkc { sdkc }
|
||||
, m_qGuiApplication { static_cast<QGuiApplication*>(QGuiApplication::instance()) }
|
||||
{
|
||||
}
|
||||
|
||||
ScreenPlay::~ScreenPlay()
|
||||
{
|
||||
if (m_ilm)
|
||||
delete m_ilm;
|
||||
if (m_settings)
|
||||
delete m_settings;
|
||||
if (m_mlm)
|
||||
delete m_mlm;
|
||||
if (m_qGuiApplication)
|
||||
delete m_qGuiApplication;
|
||||
if (m_sdkc)
|
||||
delete m_sdkc;
|
||||
}
|
||||
|
||||
const Settings* ScreenPlay::settings() const noexcept { return m_settings; }
|
||||
|
||||
|
||||
void ScreenPlay::createWallpaper(
|
||||
const int monitorIndex, QUrl absoluteStoragePath,
|
||||
const QString& previewImage, const float volume,
|
||||
@ -36,15 +23,22 @@ void ScreenPlay::createWallpaper(
|
||||
if (!m_ilm->getProjectByAbsoluteStoragePath(&absoluteStoragePath, &project)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Remove previous wallpaper, if any
|
||||
//this->removeAllWallpaper();
|
||||
this->removeWallpaperAt(0);
|
||||
m_settings->increaseActiveWallpaperCounter();
|
||||
|
||||
m_screenPlayWallpaperList.emplace_back(
|
||||
RefSPWall::create(
|
||||
std::vector<int> { monitorIndex }, absoluteStoragePath.toLocalFile(),
|
||||
previewImage, volume, fillMode, type, this));
|
||||
m_screenPlayWallpapers.emplace_back(
|
||||
make_unique<ScreenPlayWallpaper>(
|
||||
vector<int> { monitorIndex },
|
||||
m_settings,
|
||||
generateID(),
|
||||
absoluteStoragePath.toLocalFile(),
|
||||
previewImage,
|
||||
volume,
|
||||
fillMode,
|
||||
type,
|
||||
this));
|
||||
|
||||
m_mlm->setWallpaperActiveMonitor(m_qGuiApplication->screens().at(monitorIndex),
|
||||
QString { absoluteStoragePath.toLocalFile() + "/" + previewImage });
|
||||
@ -53,34 +47,39 @@ void ScreenPlay::createWallpaper(
|
||||
void ScreenPlay::createWidget(QUrl absoluteStoragePath, const QString& previewImage)
|
||||
{
|
||||
ProjectFile project {};
|
||||
|
||||
if (!m_ilm->getProjectByAbsoluteStoragePath(&absoluteStoragePath, &project)) {
|
||||
return;
|
||||
}
|
||||
m_screenPlayWidgetList.emplace_back(
|
||||
RefSPWidget::create(
|
||||
absoluteStoragePath.toLocalFile(), previewImage,
|
||||
|
||||
m_screenPlayWidgets.emplace_back(
|
||||
make_unique<ScreenPlayWidget>(
|
||||
generateID(),
|
||||
m_settings,
|
||||
absoluteStoragePath.toLocalFile(),
|
||||
previewImage,
|
||||
QString { absoluteStoragePath.toLocalFile() + "/" + project.m_file.toString() },
|
||||
this));
|
||||
}
|
||||
|
||||
void ScreenPlay::removeAllWallpaper() noexcept
|
||||
{
|
||||
if (m_sdkc && m_settings && !m_screenPlayWallpaperList.empty()) {
|
||||
if (m_sdkc && m_settings && !m_screenPlayWallpapers.empty()) {
|
||||
m_sdkc->closeAllWallpapers();
|
||||
m_settings->setActiveWallpaperCounter(0);
|
||||
m_screenPlayWallpaperList.clear();
|
||||
m_screenPlayWallpapers.clear();
|
||||
emit allWallpaperRemoved();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void ScreenPlay::requestProjectSettingsListModelAt(const int index) const noexcept
|
||||
void ScreenPlay::requestProjectSettingsListModelAt(const int index) noexcept
|
||||
{
|
||||
for (const RefSPWall& refSPWallpaper : m_screenPlayWallpaperList) {
|
||||
if (!refSPWallpaper.data()->screenNumber().empty() && refSPWallpaper.data()->screenNumber()[0] == index) { // ??? only at index == 0
|
||||
for (const unique_ptr<ScreenPlayWallpaper>& uPtrWallpaper : m_screenPlayWallpapers) {
|
||||
if (!uPtrWallpaper->screenNumber().empty() && uPtrWallpaper->screenNumber()[0] == index) { // ??? only at index == 0
|
||||
emit projectSettingsListModelFound(
|
||||
refSPWallpaper.data()->projectSettingsListModel().data(),
|
||||
refSPWallpaper.data()->type());
|
||||
uPtrWallpaper->projectSettingsListModel().data(),
|
||||
uPtrWallpaper->type());
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -89,10 +88,10 @@ void ScreenPlay::requestProjectSettingsListModelAt(const int index) const noexce
|
||||
|
||||
void ScreenPlay::setWallpaperValue(const int at, const QString& key, const QString& value) noexcept
|
||||
{
|
||||
Q_ASSERT(static_cast<std::size_t>(at) < m_screenPlayWallpaperList.size() && m_sdkc);
|
||||
for (const RefSPWall& refSPWallpaper : m_screenPlayWallpaperList) {
|
||||
if (!refSPWallpaper.data()->screenNumber().empty() && m_sdkc && refSPWallpaper.data()->screenNumber()[0] == at) { // ??? only at index == 0
|
||||
m_sdkc->setWallpaperValue(refSPWallpaper.data()->appID(), key, value);
|
||||
Q_ASSERT(static_cast<size_t>(at) < m_screenPlayWallpapers.size() && m_sdkc);
|
||||
for (const unique_ptr<ScreenPlayWallpaper>& uPtrWallpaper : m_screenPlayWallpapers) {
|
||||
if (!uPtrWallpaper->screenNumber().empty() && m_sdkc && uPtrWallpaper->screenNumber()[0] == at) { // ??? only at index == 0
|
||||
m_sdkc->setWallpaperValue(uPtrWallpaper->appID(), key, value);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -101,45 +100,45 @@ void ScreenPlay::setWallpaperValue(const int at, const QString& key, const QStri
|
||||
void ScreenPlay::setAllWallpaperValue(const QString& key, const QString& value) noexcept
|
||||
{
|
||||
Q_ASSERT(m_sdkc);
|
||||
for (const RefSPWall& refSPWallpaper : m_screenPlayWallpaperList) {
|
||||
for (const unique_ptr<ScreenPlayWallpaper>& uPtrWallpaper : m_screenPlayWallpapers) {
|
||||
if (m_sdkc)
|
||||
m_sdkc->setWallpaperValue(refSPWallpaper.data()->appID(), key, value);
|
||||
m_sdkc->setWallpaperValue(uPtrWallpaper->appID(), key, value);
|
||||
}
|
||||
}
|
||||
|
||||
void ScreenPlay::removeWallpaperAt(const int at)
|
||||
{
|
||||
// Q_ASSERT(at < m_screenPlayWallpaperList.size() && m_sdkc);
|
||||
qDebug() << "No of walls in list: " << m_screenPlayWallpaperList.size();
|
||||
if (m_screenPlayWallpaperList.empty())
|
||||
Q_ASSERT(m_sdkc);
|
||||
qDebug() << "No of walls in list: " << m_screenPlayWallpapers.size();
|
||||
if (m_screenPlayWallpapers.empty())
|
||||
return; // done here;
|
||||
|
||||
const auto toRemove = std::remove_if(
|
||||
m_screenPlayWallpaperList.begin(), m_screenPlayWallpaperList.end(),
|
||||
[&](const RefSPWall& refSPWallpaper) noexcept->bool {
|
||||
const std::vector<int>& screenNumber = refSPWallpaper->screenNumber();
|
||||
qDebug() << "Screen No. :" << screenNumber.size();
|
||||
const bool isFound = !screenNumber.empty(); // && screenNumber[0] == at;
|
||||
const auto wallsToRemove = remove_if(
|
||||
m_screenPlayWallpapers.begin(), m_screenPlayWallpapers.end(),
|
||||
[&](const unique_ptr<ScreenPlayWallpaper>& uPtrWallpaper) noexcept->bool {
|
||||
const vector<int>& screenNumber = uPtrWallpaper->screenNumber();
|
||||
qDebug() << "Screen No. or vector size :" << screenNumber.size();
|
||||
const bool isFound = !screenNumber.empty() && screenNumber[0] == at;
|
||||
if (isFound) {
|
||||
// m_mlm
|
||||
m_sdkc->closeWallpapersAt(at); // for waht ???
|
||||
m_sdkc->closeWallpapersAt(at);
|
||||
m_settings->decreaseActiveWallpaperCounter();
|
||||
qDebug() << "current wall count... " << m_settings->activeWallpaperCounter();
|
||||
}
|
||||
return isFound;
|
||||
});
|
||||
m_screenPlayWallpaperList.erase(toRemove, m_screenPlayWallpaperList.end());
|
||||
qDebug() << "After removing: No of walls in list: " << m_screenPlayWallpaperList.size();
|
||||
m_screenPlayWallpapers.erase(wallsToRemove, m_screenPlayWallpapers.end());
|
||||
qDebug() << "After removing: No of walls in list: " << m_screenPlayWallpapers.size();
|
||||
}
|
||||
|
||||
std::vector<int> ScreenPlay::getMonitorByAppID(const QString& appID) const
|
||||
vector<int> ScreenPlay::getMonitorByAppID(const QString& appID) const
|
||||
{
|
||||
for (const RefSPWall& refSPWallpaper : m_screenPlayWallpaperList) {
|
||||
if (refSPWallpaper.data()->appID() == appID) {
|
||||
return refSPWallpaper.data()->screenNumber();
|
||||
for (const unique_ptr<ScreenPlayWallpaper>& uPtrWallpaper : m_screenPlayWallpapers) {
|
||||
if (uPtrWallpaper->appID() == appID) {
|
||||
return uPtrWallpaper->screenNumber();
|
||||
}
|
||||
}
|
||||
return std::vector<int> {};
|
||||
return vector<int> {};
|
||||
}
|
||||
|
||||
QString ScreenPlay::generateID() const
|
||||
@ -158,230 +157,3 @@ QString ScreenPlay::generateID() const
|
||||
}
|
||||
return randomString;
|
||||
}
|
||||
|
||||
ScreenPlayWallpaper::ScreenPlayWallpaper(const std::vector<int>& screenNumber, const QString& projectPath,
|
||||
const QString& previewImage, const float volume,
|
||||
const QString& fillMode, const QString& type, ScreenPlay* parent)
|
||||
: QObject { parent }
|
||||
, m_screenNumber { std::move(screenNumber) }
|
||||
, m_projectPath { projectPath }
|
||||
, m_previewImage { previewImage }
|
||||
, m_type { type }
|
||||
, m_appID { parent ? parent->generateID() : QString {} }
|
||||
, m_process { nullptr }
|
||||
, m_projectSettingsListModel { QSharedPointer<ProjectSettingsListModel>::create(projectPath + "/project.json") }
|
||||
{
|
||||
QStringList proArgs;
|
||||
proArgs.append(QString::number(m_screenNumber.empty() ? 0 : m_screenNumber[0]));
|
||||
proArgs.append(m_projectPath);
|
||||
proArgs.append("appID=" + m_appID);
|
||||
proArgs.append(parent ? parent->settings()->decoder() : QString {});
|
||||
proArgs.append(QString::number(static_cast<double>(volume)));
|
||||
proArgs.append(fillMode);
|
||||
|
||||
qDebug() << proArgs;
|
||||
|
||||
// We do not want to parent the QProcess because the
|
||||
// Process manages its lifetime and destructing (animation) itself
|
||||
// via a disconnection from the ScreenPlay SDK
|
||||
QProcess* m_process = new QProcess();
|
||||
|
||||
QObject::connect(m_process, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
|
||||
[=](int exitCode, QProcess::ExitStatus exitStatus) {
|
||||
if (exitCode != 0)
|
||||
qDebug() << "WARNING EXIT CODE: " << exitCode;
|
||||
});
|
||||
QObject::connect(m_process, &QProcess::errorOccurred, [=](QProcess::ProcessError error) {
|
||||
qDebug() << "EX: " << error;
|
||||
});
|
||||
|
||||
m_process->setArguments(proArgs);
|
||||
m_process->setProgram(parent->settings()->screenPlayWindowPath().toString());
|
||||
m_process->start();
|
||||
}
|
||||
|
||||
ScreenPlayWallpaper::~ScreenPlayWallpaper()
|
||||
{
|
||||
if (m_process)
|
||||
delete m_process;
|
||||
}
|
||||
|
||||
const std::vector<int>& ScreenPlayWallpaper::screenNumber() const noexcept
|
||||
{
|
||||
return m_screenNumber;
|
||||
}
|
||||
|
||||
const QString& ScreenPlayWallpaper::projectPath() const noexcept
|
||||
{
|
||||
return m_projectPath;
|
||||
}
|
||||
|
||||
const QString& ScreenPlayWallpaper::previewImage() const noexcept
|
||||
{
|
||||
return m_previewImage;
|
||||
}
|
||||
|
||||
const QString& ScreenPlayWallpaper::type() const noexcept
|
||||
{
|
||||
return m_type;
|
||||
}
|
||||
|
||||
const QString& ScreenPlayWallpaper::appID() const noexcept
|
||||
{
|
||||
return m_appID;
|
||||
}
|
||||
|
||||
const QSharedPointer<ProjectSettingsListModel>& ScreenPlayWallpaper::projectSettingsListModel() const noexcept
|
||||
{
|
||||
return m_projectSettingsListModel;
|
||||
}
|
||||
|
||||
void ScreenPlayWallpaper::setScreenNumber(const std::vector<int>& screenNumber) noexcept
|
||||
{
|
||||
if (m_screenNumber == screenNumber)
|
||||
return;
|
||||
m_screenNumber = screenNumber;
|
||||
emit screenNumberChanged(m_screenNumber);
|
||||
}
|
||||
|
||||
void ScreenPlayWallpaper::setProjectPath(const QString& projectPath) noexcept
|
||||
{
|
||||
if (m_projectPath == projectPath)
|
||||
return;
|
||||
|
||||
m_projectPath = projectPath;
|
||||
emit projectPathChanged(m_projectPath);
|
||||
}
|
||||
|
||||
void ScreenPlayWallpaper::setPreviewImage(const QString& previewImage) noexcept
|
||||
{
|
||||
if (m_previewImage == previewImage)
|
||||
return;
|
||||
|
||||
m_previewImage = previewImage;
|
||||
emit previewImageChanged(m_previewImage);
|
||||
}
|
||||
|
||||
void ScreenPlayWallpaper::setType(const QString& type) noexcept
|
||||
{
|
||||
if (m_type == type)
|
||||
return;
|
||||
|
||||
m_type = type;
|
||||
emit typeChanged(m_type);
|
||||
}
|
||||
|
||||
void ScreenPlayWallpaper::setAppID(const QString& appID) noexcept
|
||||
{
|
||||
if (m_appID == appID)
|
||||
return;
|
||||
|
||||
m_appID = appID;
|
||||
emit appIDChanged(m_appID);
|
||||
}
|
||||
|
||||
ScreenPlayWidget::ScreenPlayWidget(const QString& projectPath, const QString& previewImage,
|
||||
const QString& fullPath, ScreenPlay* parent)
|
||||
: m_projectPath { projectPath }
|
||||
, m_previewImage { previewImage }
|
||||
, m_fullPath { fullPath }
|
||||
, m_appID { parent ? parent->generateID() : QString {} }
|
||||
, m_position { 0, 0 }
|
||||
, m_process { nullptr }
|
||||
{
|
||||
QStringList proArgs;
|
||||
proArgs.append(m_projectPath);
|
||||
proArgs.append(m_appID);
|
||||
|
||||
m_process = new QProcess(this); //PLS LESS BEHINDERT @Elias
|
||||
m_process->setArguments(proArgs);
|
||||
|
||||
if (fullPath.endsWith(".exe")) {
|
||||
m_process->setProgram(fullPath);
|
||||
} else if (fullPath.endsWith(".qml")) {
|
||||
m_process->setProgram(parent->settings()->getScreenPlayWidgetPath().path());
|
||||
}
|
||||
|
||||
qDebug() << m_process->program();
|
||||
|
||||
QObject::connect(m_process, &QProcess::errorOccurred, this, [](QProcess::ProcessError error) {
|
||||
qDebug() << "error: " << error;
|
||||
});
|
||||
m_process->start();
|
||||
}
|
||||
|
||||
ScreenPlayWidget::~ScreenPlayWidget()
|
||||
{
|
||||
if (m_process)
|
||||
delete m_process;
|
||||
}
|
||||
|
||||
const QString& ScreenPlayWidget::projectPath() const noexcept
|
||||
{
|
||||
return m_projectPath;
|
||||
}
|
||||
|
||||
const QString& ScreenPlayWidget::previewImage() const noexcept
|
||||
{
|
||||
return m_previewImage;
|
||||
}
|
||||
|
||||
const QString& ScreenPlayWidget::fullPath() const noexcept
|
||||
{
|
||||
return m_fullPath;
|
||||
}
|
||||
|
||||
const QString& ScreenPlayWidget::appID() const noexcept
|
||||
{
|
||||
return m_appID;
|
||||
}
|
||||
|
||||
const QPoint& ScreenPlayWidget::position() const noexcept
|
||||
{
|
||||
return m_position;
|
||||
}
|
||||
|
||||
void ScreenPlayWidget::setProjectPath(const QString& projectPath) noexcept
|
||||
{
|
||||
if (m_projectPath == projectPath)
|
||||
return;
|
||||
|
||||
m_projectPath = projectPath;
|
||||
emit projectPathChanged(m_projectPath);
|
||||
}
|
||||
|
||||
void ScreenPlayWidget::setPreviewImage(const QString& previewImage) noexcept
|
||||
{
|
||||
if (m_previewImage == previewImage)
|
||||
return;
|
||||
|
||||
m_previewImage = previewImage;
|
||||
emit previewImageChanged(m_previewImage);
|
||||
}
|
||||
|
||||
void ScreenPlayWidget::setFullPath(const QString& fullPath) noexcept
|
||||
{
|
||||
if (m_fullPath == fullPath)
|
||||
return;
|
||||
|
||||
m_fullPath = fullPath;
|
||||
emit fullPathChanged(m_fullPath);
|
||||
}
|
||||
|
||||
void ScreenPlayWidget::setAppID(const QString& appID) noexcept
|
||||
{
|
||||
if (m_appID == appID)
|
||||
return;
|
||||
|
||||
m_appID = appID;
|
||||
emit appIDChanged(m_appID);
|
||||
}
|
||||
|
||||
void ScreenPlayWidget::setPosition(const QPoint& position) noexcept
|
||||
{
|
||||
if (m_position == position)
|
||||
return;
|
||||
|
||||
m_position = position;
|
||||
emit positionChanged(m_position);
|
||||
}
|
||||
|
@ -12,6 +12,8 @@
|
||||
#include "monitorlistmodel.h"
|
||||
#include "projectfile.h"
|
||||
#include "projectsettingslistmodel.h"
|
||||
#include "screenplaywallpaper.h"
|
||||
#include "screenplaywidget.h"
|
||||
#include "sdkconnector.h"
|
||||
#include "settings.h"
|
||||
|
||||
@ -20,43 +22,31 @@
|
||||
\brief Used for Creation of Wallpaper, Scenes and Widgets
|
||||
*/
|
||||
|
||||
class ScreenPlayWallpaper;
|
||||
class ScreenPlayWidget;
|
||||
|
||||
// convenience types
|
||||
using RefSPWall = QSharedPointer<ScreenPlayWallpaper>;
|
||||
using RefSPWidget = QSharedPointer<ScreenPlayWidget>;
|
||||
using std::shared_ptr,
|
||||
std::unique_ptr,
|
||||
std::make_shared,
|
||||
std::make_unique,
|
||||
std::vector,
|
||||
std::size_t,
|
||||
std::remove_if;
|
||||
|
||||
class ScreenPlay final : public QObject {
|
||||
Q_OBJECT
|
||||
private:
|
||||
InstalledListModel* const m_ilm { nullptr };
|
||||
Settings* const m_settings { nullptr };
|
||||
MonitorListModel* const m_mlm { nullptr };
|
||||
QGuiApplication* const m_qGuiApplication { nullptr };
|
||||
SDKConnector* const m_sdkc { nullptr };
|
||||
std::vector<RefSPWall> m_screenPlayWallpaperList;
|
||||
std::vector<RefSPWidget> m_screenPlayWidgetList;
|
||||
|
||||
public:
|
||||
// constructor(s)
|
||||
explicit ScreenPlay(
|
||||
InstalledListModel* ilm, Settings* set,
|
||||
MonitorListModel* mlm, SDKConnector* sdkc,
|
||||
const shared_ptr<InstalledListModel>& ilm,
|
||||
const shared_ptr<Settings>& settings,
|
||||
const shared_ptr<MonitorListModel>& mlm,
|
||||
const shared_ptr<SDKConnector>& sdkc,
|
||||
QObject* parent = nullptr);
|
||||
~ScreenPlay();
|
||||
|
||||
// copy and move disable(for now) : remember rule of 1/3/5
|
||||
//Q_DISABLE_COPY_MOVE(ScreenPlay)
|
||||
|
||||
const Settings* settings() const noexcept;
|
||||
const std::vector<RefSPWall>& spWallList() const noexcept;
|
||||
const std::vector<RefSPWidget>& spWidgetList() const noexcept;
|
||||
~ScreenPlay() {}
|
||||
|
||||
signals:
|
||||
void allWallpaperRemoved() const;
|
||||
void projectSettingsListModelFound(ProjectSettingsListModel* li, const QString& type) const;
|
||||
void projectSettingsListModelNotFound() const;
|
||||
void allWallpaperRemoved();
|
||||
void projectSettingsListModelFound(ProjectSettingsListModel* li, const QString& type);
|
||||
void projectSettingsListModelNotFound();
|
||||
|
||||
public slots:
|
||||
void createWallpaper(
|
||||
@ -65,120 +55,20 @@ public slots:
|
||||
const QString& fillMode, const QString& type);
|
||||
void createWidget(QUrl absoluteStoragePath, const QString& previewImage);
|
||||
void removeAllWallpaper() noexcept;
|
||||
void requestProjectSettingsListModelAt(const int index) const noexcept;
|
||||
void requestProjectSettingsListModelAt(const int index) noexcept;
|
||||
void setWallpaperValue(const int at, const QString& key, const QString& value) noexcept;
|
||||
void setAllWallpaperValue(const QString& key, const QString& value) noexcept;
|
||||
void removeWallpaperAt(const int at = 0);
|
||||
std::vector<int> getMonitorByAppID(const QString& appID) const;
|
||||
vector<int> getMonitorByAppID(const QString& appID) const;
|
||||
QString generateID() const;
|
||||
};
|
||||
|
||||
/*!
|
||||
\class ScreenPlayWallpaper
|
||||
\brief Used for ...
|
||||
*/
|
||||
|
||||
class ScreenPlayWallpaper final : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(std::vector<int> screenNumber READ screenNumber WRITE setScreenNumber NOTIFY screenNumberChanged)
|
||||
Q_PROPERTY(QString projectPath READ projectPath WRITE setProjectPath NOTIFY projectPathChanged)
|
||||
Q_PROPERTY(QString previewImage READ previewImage WRITE setPreviewImage NOTIFY previewImageChanged)
|
||||
Q_PROPERTY(QString appID READ appID WRITE setAppID NOTIFY appIDChanged)
|
||||
Q_PROPERTY(QString type READ type WRITE setType NOTIFY typeChanged)
|
||||
|
||||
private:
|
||||
std::vector<int> m_screenNumber;
|
||||
QString m_projectPath;
|
||||
QString m_previewImage;
|
||||
QString m_type;
|
||||
QString m_appID;
|
||||
QProcess* m_process;
|
||||
QSharedPointer<ProjectSettingsListModel> m_projectSettingsListModel;
|
||||
const shared_ptr<InstalledListModel> m_ilm;
|
||||
const shared_ptr<Settings> m_settings;
|
||||
const shared_ptr<MonitorListModel> m_mlm;
|
||||
const shared_ptr<SDKConnector> m_sdkc;
|
||||
|
||||
public:
|
||||
// constructor(s)
|
||||
explicit ScreenPlayWallpaper(const std::vector<int>& screenNumber, const QString& projectPath,
|
||||
const QString& previewImage, const float volume, const QString& fillMode,
|
||||
const QString& type, ScreenPlay* parent = nullptr);
|
||||
|
||||
// copy and move disable(for now) : remember rule of 1/3/5
|
||||
//Q_DISABLE_COPY_MOVE(ScreenPlayWallpaper)
|
||||
|
||||
~ScreenPlayWallpaper();
|
||||
|
||||
const std::vector<int>& screenNumber() const noexcept;
|
||||
const QString& projectPath() const noexcept;
|
||||
const QString& previewImage() const noexcept;
|
||||
const QString& type() const noexcept;
|
||||
const QString& appID() const noexcept;
|
||||
const QSharedPointer<ProjectSettingsListModel>& projectSettingsListModel() const noexcept;
|
||||
|
||||
signals:
|
||||
void screenNumberChanged(std::vector<int> screenNumber) const;
|
||||
void projectPathChanged(QString projectPath) const;
|
||||
void previewImageChanged(QString previewImage) const;
|
||||
void typeChanged(QString type) const;
|
||||
void appIDChanged(QString appID) const;
|
||||
//void projectSettingsListModelAt(ProjectSettingsListModel* li); ??? not used
|
||||
|
||||
public slots:
|
||||
void setScreenNumber(const std::vector<int>& screenNumber) noexcept;
|
||||
void setProjectPath(const QString& projectPath) noexcept;
|
||||
void setPreviewImage(const QString& previewImage) noexcept;
|
||||
void setType(const QString& type) noexcept;
|
||||
void setAppID(const QString& appID) noexcept;
|
||||
};
|
||||
|
||||
/*!
|
||||
\class ScreenPlayWidget
|
||||
\brief Used for ...
|
||||
*/
|
||||
|
||||
class ScreenPlayWidget final : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QString projectPath READ projectPath WRITE setProjectPath NOTIFY projectPathChanged)
|
||||
Q_PROPERTY(QString fullPath READ fullPath WRITE setFullPath NOTIFY fullPathChanged)
|
||||
Q_PROPERTY(QString previewImage READ previewImage WRITE setPreviewImage NOTIFY previewImageChanged)
|
||||
Q_PROPERTY(QPoint position READ position WRITE setPosition NOTIFY positionChanged)
|
||||
Q_PROPERTY(QString appID READ appID WRITE setAppID NOTIFY appIDChanged)
|
||||
|
||||
private:
|
||||
QString m_projectPath;
|
||||
QString m_previewImage;
|
||||
QString m_fullPath;
|
||||
QString m_appID;
|
||||
QPoint m_position;
|
||||
QProcess* m_process;
|
||||
|
||||
public:
|
||||
// constructor(s)
|
||||
explicit ScreenPlayWidget(const QString& projectPath, const QString& previewImage,
|
||||
const QString& fullPath, ScreenPlay* parent = nullptr);
|
||||
|
||||
// copy and move disable(for now) : remember rule of 1/3/5
|
||||
//Q_DISABLE_COPY_MOVE(ScreenPlayWidget)
|
||||
|
||||
~ScreenPlayWidget();
|
||||
|
||||
const QString& projectPath() const noexcept;
|
||||
const QString& previewImage() const noexcept;
|
||||
const QString& fullPath() const noexcept;
|
||||
const QString& appID() const noexcept;
|
||||
const QPoint& position() const noexcept;
|
||||
|
||||
signals:
|
||||
void projectPathChanged(QString projectPath) const;
|
||||
void previewImageChanged(QString previewImage) const;
|
||||
void fullPathChanged(QString fullPath) const;
|
||||
void appIDChanged(QString appID) const;
|
||||
void positionChanged(QPoint position) const;
|
||||
|
||||
public slots:
|
||||
void setProjectPath(const QString& projectPath) noexcept;
|
||||
void setPreviewImage(const QString& previewImage) noexcept;
|
||||
void setFullPath(const QString& fullPath) noexcept;
|
||||
void setAppID(const QString& appID) noexcept;
|
||||
void setPosition(const QPoint& position) noexcept;
|
||||
QGuiApplication* const m_qGuiApplication;
|
||||
vector<unique_ptr<ScreenPlayWallpaper>> m_screenPlayWallpapers;
|
||||
vector<unique_ptr<ScreenPlayWidget>> m_screenPlayWidgets;
|
||||
};
|
||||
|
52
ScreenPlay/src/screenplaywallpaper.cpp
Normal file
52
ScreenPlay/src/screenplaywallpaper.cpp
Normal file
@ -0,0 +1,52 @@
|
||||
#include "screenplaywallpaper.h"
|
||||
|
||||
/*!
|
||||
\class ScreenPlayWallpaper
|
||||
\brief Used for ...
|
||||
*/
|
||||
|
||||
ScreenPlayWallpaper::ScreenPlayWallpaper(const vector<int>& screenNumber,
|
||||
const shared_ptr<Settings>& settings,
|
||||
const QString& appID,
|
||||
const QString& projectPath,
|
||||
const QString& previewImage,
|
||||
const float volume,
|
||||
const QString& fillMode,
|
||||
const QString& type,
|
||||
QObject* parent)
|
||||
: QObject(parent)
|
||||
, m_projectSettingsListModel { QSharedPointer<ProjectSettingsListModel>::create(projectPath + "/project.json") }
|
||||
, m_screenNumber { move(screenNumber) }
|
||||
, m_projectPath { projectPath }
|
||||
, m_previewImage { previewImage }
|
||||
, m_appID { appID }
|
||||
, m_type { type }
|
||||
, m_settings { settings }
|
||||
{
|
||||
|
||||
QObject::connect(&m_process, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
|
||||
[=](int exitCode, QProcess::ExitStatus exitStatus) {
|
||||
Q_UNUSED(exitStatus)
|
||||
if (exitCode != 0)
|
||||
qDebug() << "WARNING EXIT CODE: " << exitCode;
|
||||
});
|
||||
|
||||
QObject::connect(&m_process, &QProcess::errorOccurred, [=](QProcess::ProcessError error) {
|
||||
qDebug() << "EX: " << error;
|
||||
});
|
||||
|
||||
const QStringList proArgs {
|
||||
QString::number(m_screenNumber.empty() ? 0 : m_screenNumber[0]),
|
||||
m_projectPath,
|
||||
QString { "appID=" + m_appID },
|
||||
"",
|
||||
QString::number(static_cast<double>(volume)),
|
||||
fillMode
|
||||
};
|
||||
|
||||
qDebug() << "Creating ScreenPlayWallpaper " << proArgs;
|
||||
|
||||
m_process.setArguments(proArgs);
|
||||
m_process.setProgram(m_settings->screenPlayWindowPath().toString());
|
||||
m_process.startDetached();
|
||||
}
|
130
ScreenPlay/src/screenplaywallpaper.h
Normal file
130
ScreenPlay/src/screenplaywallpaper.h
Normal file
@ -0,0 +1,130 @@
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <QProcess>
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "projectsettingslistmodel.h"
|
||||
#include "settings.h"
|
||||
|
||||
using std::shared_ptr,
|
||||
std::make_shared,
|
||||
std::vector,
|
||||
std::move;
|
||||
|
||||
class ScreenPlayWallpaper final : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(vector<int> screenNumber READ screenNumber WRITE setScreenNumber NOTIFY screenNumberChanged)
|
||||
Q_PROPERTY(QString projectPath READ projectPath WRITE setProjectPath NOTIFY projectPathChanged)
|
||||
Q_PROPERTY(QString previewImage READ previewImage WRITE setPreviewImage NOTIFY previewImageChanged)
|
||||
Q_PROPERTY(QString appID READ appID WRITE setAppID NOTIFY appIDChanged)
|
||||
Q_PROPERTY(QString type READ type WRITE setType NOTIFY typeChanged)
|
||||
|
||||
public:
|
||||
explicit ScreenPlayWallpaper(const vector<int>& screenNumber,
|
||||
const shared_ptr<Settings>& settings,
|
||||
const QString& appID,
|
||||
const QString& projectPath,
|
||||
const QString& previewImage,
|
||||
const float volume,
|
||||
const QString& fillMode,
|
||||
const QString& type,
|
||||
QObject* parent = nullptr);
|
||||
|
||||
~ScreenPlayWallpaper() {}
|
||||
|
||||
const QSharedPointer<ProjectSettingsListModel>& projectSettingsListModel() const noexcept
|
||||
{
|
||||
return m_projectSettingsListModel;
|
||||
}
|
||||
|
||||
vector<int> screenNumber() const
|
||||
{
|
||||
return m_screenNumber;
|
||||
}
|
||||
|
||||
QString projectPath() const
|
||||
{
|
||||
return m_projectPath;
|
||||
}
|
||||
|
||||
QString previewImage() const
|
||||
{
|
||||
return m_previewImage;
|
||||
}
|
||||
|
||||
QString appID() const
|
||||
{
|
||||
return m_appID;
|
||||
}
|
||||
|
||||
QString type() const
|
||||
{
|
||||
return m_type;
|
||||
}
|
||||
|
||||
signals:
|
||||
void screenNumberChanged(vector<int> screenNumber);
|
||||
void projectPathChanged(QString projectPath);
|
||||
void previewImageChanged(QString previewImage);
|
||||
void appIDChanged(QString appID);
|
||||
void typeChanged(QString type);
|
||||
|
||||
public slots:
|
||||
void setScreenNumber(vector<int> screenNumber)
|
||||
{
|
||||
if (m_screenNumber == screenNumber)
|
||||
return;
|
||||
|
||||
m_screenNumber = screenNumber;
|
||||
emit screenNumberChanged(m_screenNumber);
|
||||
}
|
||||
|
||||
void setProjectPath(QString projectPath)
|
||||
{
|
||||
if (m_projectPath == projectPath)
|
||||
return;
|
||||
|
||||
m_projectPath = projectPath;
|
||||
emit projectPathChanged(m_projectPath);
|
||||
}
|
||||
|
||||
void setPreviewImage(QString previewImage)
|
||||
{
|
||||
if (m_previewImage == previewImage)
|
||||
return;
|
||||
|
||||
m_previewImage = previewImage;
|
||||
emit previewImageChanged(m_previewImage);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
private:
|
||||
QProcess m_process;
|
||||
QSharedPointer<ProjectSettingsListModel> m_projectSettingsListModel;
|
||||
vector<int> m_screenNumber;
|
||||
QString m_projectPath;
|
||||
QString m_previewImage;
|
||||
QString m_appID;
|
||||
QString m_type;
|
||||
const shared_ptr<Settings> m_settings;
|
||||
};
|
35
ScreenPlay/src/screenplaywidget.cpp
Normal file
35
ScreenPlay/src/screenplaywidget.cpp
Normal file
@ -0,0 +1,35 @@
|
||||
#include "screenplaywidget.h"
|
||||
|
||||
/*!
|
||||
\class ScreenPlayWidget
|
||||
\brief Used for ...
|
||||
*/
|
||||
|
||||
ScreenPlayWidget::ScreenPlayWidget(const QString& appID, const shared_ptr<Settings>& settings,
|
||||
const QString& projectPath,
|
||||
const QString& previewImage,
|
||||
const QString& fullPath,
|
||||
QObject* parent)
|
||||
: QObject { parent }
|
||||
, m_projectPath { projectPath }
|
||||
, m_previewImage { previewImage }
|
||||
, m_appID { appID }
|
||||
, m_position { 0, 0 }
|
||||
, m_settings(settings)
|
||||
{
|
||||
const QStringList proArgs { m_projectPath, m_appID };
|
||||
m_process.setArguments(proArgs);
|
||||
|
||||
if (fullPath.endsWith(".exe")) {
|
||||
m_process.setProgram(fullPath);
|
||||
} else if (fullPath.endsWith(".qml")) {
|
||||
m_process.setProgram(m_settings->getScreenPlayWidgetPath().path());
|
||||
}
|
||||
|
||||
qDebug() << m_process.program();
|
||||
|
||||
QObject::connect(&m_process, &QProcess::errorOccurred, this, [](QProcess::ProcessError error) {
|
||||
qDebug() << "error: " << error;
|
||||
});
|
||||
m_process.startDetached();
|
||||
}
|
99
ScreenPlay/src/screenplaywidget.h
Normal file
99
ScreenPlay/src/screenplaywidget.h
Normal file
@ -0,0 +1,99 @@
|
||||
#pragma once
|
||||
|
||||
#include <QDebug>
|
||||
#include <QObject>
|
||||
#include <QPoint>
|
||||
#include <QProcess>
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "settings.h"
|
||||
|
||||
using std::shared_ptr,
|
||||
std::make_shared;
|
||||
|
||||
class ScreenPlayWidget final : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QString projectPath READ projectPath WRITE setProjectPath NOTIFY projectPathChanged)
|
||||
Q_PROPERTY(QString previewImage READ previewImage WRITE setPreviewImage NOTIFY previewImageChanged)
|
||||
Q_PROPERTY(QPoint position READ position WRITE setPosition NOTIFY positionChanged)
|
||||
Q_PROPERTY(QString appID READ appID WRITE setAppID NOTIFY appIDChanged)
|
||||
|
||||
public:
|
||||
explicit ScreenPlayWidget(const QString& appID, const shared_ptr<Settings>& settings, const QString& projectPath, const QString& previewImage,
|
||||
const QString& fullPath, QObject* parent = nullptr);
|
||||
|
||||
~ScreenPlayWidget() {}
|
||||
|
||||
QString projectPath() const
|
||||
{
|
||||
return m_projectPath;
|
||||
}
|
||||
|
||||
QString previewImage() const
|
||||
{
|
||||
return m_previewImage;
|
||||
}
|
||||
|
||||
QPoint position() const
|
||||
{
|
||||
return m_position;
|
||||
}
|
||||
|
||||
QString appID() const
|
||||
{
|
||||
return m_appID;
|
||||
}
|
||||
|
||||
public slots:
|
||||
void setProjectPath(QString projectPath)
|
||||
{
|
||||
if (m_projectPath == projectPath)
|
||||
return;
|
||||
|
||||
m_projectPath = projectPath;
|
||||
emit projectPathChanged(m_projectPath);
|
||||
}
|
||||
|
||||
void setPreviewImage(QString previewImage)
|
||||
{
|
||||
if (m_previewImage == previewImage)
|
||||
return;
|
||||
|
||||
m_previewImage = previewImage;
|
||||
emit previewImageChanged(m_previewImage);
|
||||
}
|
||||
|
||||
void setPosition(QPoint position)
|
||||
{
|
||||
if (m_position == position)
|
||||
return;
|
||||
|
||||
m_position = position;
|
||||
emit positionChanged(m_position);
|
||||
}
|
||||
|
||||
void setAppID(QString appID)
|
||||
{
|
||||
if (m_appID == appID)
|
||||
return;
|
||||
|
||||
m_appID = appID;
|
||||
emit appIDChanged(m_appID);
|
||||
}
|
||||
|
||||
signals:
|
||||
void projectPathChanged(QString projectPath);
|
||||
void previewImageChanged(QString previewImage);
|
||||
void positionChanged(QPoint position);
|
||||
void appIDChanged(QString appID);
|
||||
|
||||
private:
|
||||
QString m_projectPath;
|
||||
QString m_previewImage;
|
||||
QString m_appID;
|
||||
QPoint m_position;
|
||||
QProcess m_process;
|
||||
const shared_ptr<Settings> m_settings;
|
||||
};
|
@ -1,17 +1,35 @@
|
||||
#include "settings.h"
|
||||
#include <QGuiApplication>
|
||||
#include <QStandardPaths>
|
||||
|
||||
Settings::Settings(ProfileListModel* plm, MonitorListModel* mlm, InstalledListModel* ilm, SDKConnector* sdkc, QObject* parent)
|
||||
/*!
|
||||
\class Settings
|
||||
\brief Used for:
|
||||
\list
|
||||
\i User configuration
|
||||
\i Communication via the SDK Connector
|
||||
\endlist
|
||||
|
||||
*/
|
||||
|
||||
Settings::Settings(const shared_ptr<InstalledListModel>& ilm,
|
||||
const shared_ptr<ProfileListModel>& plm,
|
||||
const shared_ptr<MonitorListModel>& mlm,
|
||||
const shared_ptr<SDKConnector>& sdkc,
|
||||
QObject* parent)
|
||||
: QObject(parent)
|
||||
, m_version(QVersionNumber(0, 0, 1))
|
||||
, m_plm(plm)
|
||||
, m_ilm(ilm)
|
||||
, m_mlm(mlm)
|
||||
, m_sdkc(sdkc)
|
||||
{
|
||||
auto* app = static_cast<QGuiApplication*>(QGuiApplication::instance());
|
||||
|
||||
m_plm = plm;
|
||||
m_mlm = mlm;
|
||||
m_ilm = ilm;
|
||||
m_sdkc = sdkc;
|
||||
m_app = static_cast<QGuiApplication*>(QGuiApplication::instance());
|
||||
QFontDatabase::addApplicationFont(":/assets/fonts/LibreBaskerville-Italic.ttf");
|
||||
QFontDatabase::addApplicationFont(":/assets/fonts/Roboto-Light.ttf");
|
||||
QFontDatabase::addApplicationFont(":/assets/fonts/Roboto-Regular.ttf");
|
||||
QFontDatabase::addApplicationFont(":/assets/fonts/Roboto-Thin.ttf");
|
||||
QFontDatabase::addApplicationFont(":/assets/fonts/RobotoMono-Light.ttf");
|
||||
QFontDatabase::addApplicationFont(":/assets/fonts/RobotoMono-Thin.ttf");
|
||||
|
||||
if (m_qSettings.value("language").isNull()) {
|
||||
auto locale = QLocale::system().uiLanguages();
|
||||
@ -24,13 +42,13 @@ Settings::Settings(ProfileListModel* plm, MonitorListModel* mlm, InstalledListMo
|
||||
m_translator.load(":/translations/ScreenPlay_" + localeSplits.at(0) + ".qm");
|
||||
m_qSettings.setValue("language", QVariant(localeSplits.at(0)));
|
||||
m_qSettings.sync();
|
||||
m_app->installTranslator(&m_translator);
|
||||
app->installTranslator(&m_translator);
|
||||
}
|
||||
} else {
|
||||
QFile tsFile;
|
||||
if (tsFile.exists(":/translations/ScreenPlay_" + m_qSettings.value("language").toString() + ".qm")) {
|
||||
m_translator.load(":/translations/ScreenPlay_" + m_qSettings.value("language").toString() + ".qm");
|
||||
m_app->installTranslator(&m_translator);
|
||||
app->installTranslator(&m_translator);
|
||||
}
|
||||
}
|
||||
|
||||
@ -101,32 +119,21 @@ Settings::Settings(ProfileListModel* plm, MonitorListModel* mlm, InstalledListMo
|
||||
m_localStoragePath = QUrl::fromUserInput(configObj.value("absoluteStoragePath").toString());
|
||||
}
|
||||
|
||||
|
||||
if (m_qSettings.value("ScreenPlayInstalledPath").isNull()) {
|
||||
m_qSettings.setValue("ScreenPlayInstalledPath", QDir::toNativeSeparators(m_localStoragePath.toString().remove("file:///")));
|
||||
m_qSettings.sync();
|
||||
}
|
||||
|
||||
|
||||
m_ilm->setabsoluteStoragePath(m_localStoragePath);
|
||||
m_plm->m_localStoragePath = m_localStoragePath;
|
||||
|
||||
m_autostart = configObj.value("autostart").toBool();
|
||||
m_highPriorityStart = configObj.value("highPriorityStart").toBool();
|
||||
m_sendStatistics = configObj.value("sendStatistics").toBool();
|
||||
int renderer = static_cast<int>(configObj.value("renderer-value").toInt());
|
||||
|
||||
m_checkForOtherFullscreenApplicationTimer = new QTimer(this);
|
||||
connect(m_checkForOtherFullscreenApplicationTimer, &QTimer::timeout, this, &Settings::checkForOtherFullscreenApplication);
|
||||
m_checkForOtherFullscreenApplicationTimer->start(1500);
|
||||
|
||||
setupWidgetAndWindowPaths();
|
||||
}
|
||||
|
||||
Settings::~Settings()
|
||||
{
|
||||
}
|
||||
|
||||
QString Settings::loadProject(QString file)
|
||||
{
|
||||
QFile configTmp;
|
||||
@ -171,20 +178,6 @@ void Settings::loadActiveProfiles()
|
||||
}
|
||||
}
|
||||
|
||||
void Settings::setGlobalVolume(float volume)
|
||||
{
|
||||
// for (int i = 0; i < m_wallpapers.size(); ++i) {
|
||||
// m_wallpapers.at(i).data()->setVolume(volume);
|
||||
// }
|
||||
}
|
||||
|
||||
void Settings::setGlobalFillMode(QString fillMode)
|
||||
{
|
||||
// for (int i = 0; i < m_wallpapers.size(); ++i) {
|
||||
// m_wallpapers.at(i).data()->setFillMode(fillMode);
|
||||
// }
|
||||
}
|
||||
|
||||
void Settings::writeSingleSettingConfig(QString name, QVariant value)
|
||||
{
|
||||
|
||||
@ -282,33 +275,6 @@ void Settings::setqSetting(const QString& key, const QString& value)
|
||||
m_qSettings.sync();
|
||||
}
|
||||
|
||||
void Settings::setMuteAll(bool isMuted)
|
||||
{
|
||||
|
||||
// if (isMuted) {
|
||||
// for (int i = 0; i < m_wallpapers.size(); ++i) {
|
||||
// m_wallpapers.at(i).data()->setVolume(0.0f);
|
||||
// }
|
||||
// } else {
|
||||
// for (int i = 0; i < m_wallpapers.size(); ++i) {
|
||||
// m_wallpapers.at(i).data()->setVolume(1.0f);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
void Settings::setPlayAll(bool isPlaying)
|
||||
{
|
||||
// if (isPlaying) {
|
||||
// for (int i = 0; i < m_wallpapers.size(); ++i) {
|
||||
// m_wallpapers.at(i).data()->setIsPlaying(true);
|
||||
// }
|
||||
// } else {
|
||||
// for (int i = 0; i < m_wallpapers.size(); ++i) {
|
||||
// m_wallpapers.at(i).data()->setIsPlaying(false);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
void Settings::createDefaultConfig()
|
||||
{
|
||||
|
||||
@ -418,20 +384,3 @@ void Settings::setScreenPlayWindowPath(const QUrl& screenPlayWindowPath)
|
||||
{
|
||||
m_screenPlayWindowPath = screenPlayWindowPath;
|
||||
}
|
||||
|
||||
void Settings::checkForOtherFullscreenApplication()
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
|
||||
HWND hWnd = GetForegroundWindow();
|
||||
RECT appBounds;
|
||||
RECT rc;
|
||||
GetWindowRect(GetDesktopWindow(), &rc);
|
||||
#endif
|
||||
// if(hWnd =! (HWND)GetDesktopWindow() && hWnd != (HWND)GetShellWindow())
|
||||
// {
|
||||
// GetWindowRect(hWnd, &appBounds);
|
||||
// } else {
|
||||
|
||||
// }
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QFontDatabase>
|
||||
#include <QGuiApplication>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
@ -25,6 +26,8 @@
|
||||
#include <QtConcurrent/QtConcurrent>
|
||||
#include <QtGlobal>
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "installedlistmodel.h"
|
||||
#include "monitorlistmodel.h"
|
||||
#include "profile.h"
|
||||
@ -36,23 +39,15 @@
|
||||
#include <qt_windows.h>
|
||||
#endif
|
||||
|
||||
/*!
|
||||
\class Settings
|
||||
\brief Used for:
|
||||
\list
|
||||
\i User configuration
|
||||
\i Communication via the SDK Connector
|
||||
\endlist
|
||||
|
||||
*/
|
||||
|
||||
class ActiveProfile;
|
||||
|
||||
using std::shared_ptr,
|
||||
std::make_shared;
|
||||
|
||||
class Settings : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QVersionNumber version READ version)
|
||||
Q_PROPERTY(bool hasWorkshopBannerSeen READ hasWorkshopBannerSeen WRITE setHasWorkshopBannerSeen NOTIFY hasWorkshopBannerSeenChanged)
|
||||
Q_PROPERTY(bool autostart READ autostart WRITE setAutostart NOTIFY autostartChanged)
|
||||
Q_PROPERTY(bool highPriorityStart READ highPriorityStart WRITE setHighPriorityStart NOTIFY highPriorityStartChanged)
|
||||
Q_PROPERTY(bool sendStatistics READ sendStatistics WRITE setSendStatistics NOTIFY sendStatisticsChanged)
|
||||
@ -63,8 +58,13 @@ class Settings : public QObject {
|
||||
Q_PROPERTY(int activeWallpaperCounter READ activeWallpaperCounter WRITE setActiveWallpaperCounter NOTIFY activeWallpaperCounterChanged)
|
||||
|
||||
public:
|
||||
explicit Settings(ProfileListModel* plm, MonitorListModel* mlm, InstalledListModel* ilm, SDKConnector* sdkc, QObject* parent = nullptr);
|
||||
~Settings();
|
||||
explicit Settings(
|
||||
const shared_ptr<InstalledListModel>& ilm,
|
||||
const shared_ptr<ProfileListModel>& plm,
|
||||
const shared_ptr<MonitorListModel>& mlm,
|
||||
const shared_ptr<SDKConnector>& sdkc,
|
||||
QObject* parent = nullptr);
|
||||
~Settings() {}
|
||||
|
||||
enum LocalCopyResult {
|
||||
NoError,
|
||||
@ -89,11 +89,6 @@ public:
|
||||
return m_localStoragePath;
|
||||
}
|
||||
|
||||
bool hasWorkshopBannerSeen() const
|
||||
{
|
||||
return m_hasWorkshopBannerSeen;
|
||||
}
|
||||
|
||||
int activeWallpaperCounter() const
|
||||
{
|
||||
return m_activeWallpaperCounter;
|
||||
@ -119,7 +114,6 @@ public:
|
||||
void setScreenPlayWidgetPath(const QUrl& screenPlayWidgetPath);
|
||||
|
||||
bool getOfflineMode() const;
|
||||
void loadActiveProfiles();
|
||||
|
||||
signals:
|
||||
void autostartChanged(bool autostart);
|
||||
@ -136,11 +130,6 @@ signals:
|
||||
void allDataProtectionLoaded(QString dataProtectionText);
|
||||
|
||||
public slots:
|
||||
void setMuteAll(bool isMuted);
|
||||
void setPlayAll(bool isPlaying);
|
||||
void checkForOtherFullscreenApplication();
|
||||
void setGlobalVolume(float volume);
|
||||
void setGlobalFillMode(QString fillMode);
|
||||
void writeSingleSettingConfig(QString name, QVariant value);
|
||||
void requestAllLicenses();
|
||||
void requestAllLDataProtection();
|
||||
@ -241,15 +230,6 @@ public slots:
|
||||
emit decoderChanged(m_decoder);
|
||||
}
|
||||
|
||||
void setHasWorkshopBannerSeen(bool hasWorkshopBannerSeen)
|
||||
{
|
||||
if (m_hasWorkshopBannerSeen == hasWorkshopBannerSeen)
|
||||
return;
|
||||
|
||||
m_hasWorkshopBannerSeen = hasWorkshopBannerSeen;
|
||||
emit hasWorkshopBannerSeenChanged(m_hasWorkshopBannerSeen);
|
||||
}
|
||||
|
||||
void setActiveWallpaperCounter(int activeWallpaperCounter)
|
||||
{
|
||||
if (m_activeWallpaperCounter == activeWallpaperCounter)
|
||||
@ -292,6 +272,8 @@ public slots:
|
||||
emit offlineModeChanged(m_offlineMode);
|
||||
}
|
||||
|
||||
void loadActiveProfiles();
|
||||
|
||||
private:
|
||||
void createDefaultConfig();
|
||||
void setupWidgetAndWindowPaths();
|
||||
@ -299,12 +281,11 @@ private:
|
||||
QVersionNumber m_version;
|
||||
QSettings m_qSettings;
|
||||
QTranslator m_translator;
|
||||
ProfileListModel* m_plm;
|
||||
InstalledListModel* m_ilm;
|
||||
MonitorListModel* m_mlm;
|
||||
SDKConnector* m_sdkc;
|
||||
|
||||
QTimer* m_checkForOtherFullscreenApplicationTimer;
|
||||
const shared_ptr<ProfileListModel> m_plm;
|
||||
const shared_ptr<InstalledListModel> m_ilm;
|
||||
const shared_ptr<MonitorListModel> m_mlm;
|
||||
const shared_ptr<SDKConnector> m_sdkc;
|
||||
|
||||
QUrl m_localStoragePath;
|
||||
QUrl m_localSettingsPath;
|
||||
@ -312,15 +293,12 @@ private:
|
||||
QUrl m_screenPlayWidgetPath;
|
||||
QUrl m_screenPlayBasePath;
|
||||
|
||||
bool m_hasWorkshopBannerSeen = false;
|
||||
bool m_pauseWallpaperWhenIngame = true;
|
||||
bool m_autostart = true;
|
||||
bool m_highPriorityStart = true;
|
||||
bool m_sendStatistics;
|
||||
|
||||
QString m_decoder;
|
||||
int m_activeWallpaperCounter = 0;
|
||||
QGuiApplication* m_app;
|
||||
|
||||
bool m_sendStatistics = false;
|
||||
bool m_offlineMode = true;
|
||||
|
||||
QString m_decoder = "";
|
||||
int m_activeWallpaperCounter = 0;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user