mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-11-07 03:22:33 +01:00
Change screenplay widget and wallpaper creation from settings to screenplay class
This commit is contained in:
parent
26fd3651b9
commit
fc79180aaa
@ -254,13 +254,14 @@ Item {
|
||||
|
||||
onClicked: {
|
||||
if (type === "video" || type === "qmlScene") {
|
||||
screenPlaySettings.setWallpaper(
|
||||
screenPlay.createWallpaper(
|
||||
monitorSelection.activeMonitorIndex,
|
||||
installedListModel.absoluteStoragePath + "/" + activeScreen,
|
||||
installedListModel.get(activeScreen).screenPreview)
|
||||
} else if (type === "widget") {
|
||||
screenPlaySettings.setWidget(
|
||||
installedListModel.absoluteStoragePath + "/" + activeScreen)
|
||||
screenPlay.createWidget(
|
||||
installedListModel.absoluteStoragePath + "/" + activeScreen,
|
||||
installedListModel.get(activeScreen).screenPreview)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ Rectangle {
|
||||
}
|
||||
}
|
||||
Connections {
|
||||
target: screenPlaySettings
|
||||
target: screenPlay
|
||||
onAllWallpaperRemoved:{
|
||||
for(var i = 0; i < rp.count; i++){
|
||||
rp.itemAt(i).isSelected = false
|
||||
|
@ -86,8 +86,7 @@ Item {
|
||||
text: qsTr("Remove all wallpaper")
|
||||
Material.background: Material.Orange
|
||||
Material.foreground: "white"
|
||||
enabled: screenPlaySettings.activeWallpaperCounterChanged === 0 ? false : true
|
||||
onClicked: screenPlaySettings.removeAll()
|
||||
onClicked: screenPlay.removeAllWallpaper()
|
||||
anchors {
|
||||
horizontalCenter: parent.horizontalCenter
|
||||
bottom: parent.bottom
|
||||
|
@ -1,6 +1,58 @@
|
||||
#include "screenplay.h"
|
||||
|
||||
ScreenPlay::ScreenPlay(QObject *parent) : QObject(parent)
|
||||
ScreenPlay::ScreenPlay(InstalledListModel* ilm, Settings* set, MonitorListModel* mlm, QGuiApplication* qGuiApplication, SDKConnector* sdkc, QObject* parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
m_ilm = ilm;
|
||||
m_settings = set;
|
||||
m_mlm = mlm;
|
||||
m_qGuiApplication = qGuiApplication;
|
||||
m_sdkc = sdkc;
|
||||
}
|
||||
|
||||
void ScreenPlay::createWallpaper(int monitorIndex, QUrl absoluteStoragePath, QString previewImage)
|
||||
{
|
||||
ProjectFile project;
|
||||
|
||||
if (!m_ilm->getProjectByAbsoluteStoragePath(&absoluteStoragePath, &project)) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_settings->increaseActiveWallpaperCounter();
|
||||
QVector<int> tmpMonitorIndex;
|
||||
tmpMonitorIndex.append(monitorIndex);
|
||||
m_screenPlayWallpaperList.append(QSharedPointer<ScreenPlayWallpaper>(new ScreenPlayWallpaper(tmpMonitorIndex, absoluteStoragePath.toString(), previewImage, this)));
|
||||
|
||||
m_mlm->setWallpaperActiveMonitor(m_qGuiApplication->screens().at(monitorIndex), absoluteStoragePath.toString() + "/" + previewImage);
|
||||
|
||||
}
|
||||
|
||||
void ScreenPlay::createWidget(QUrl absoluteStoragePath, QString previewImage)
|
||||
{
|
||||
ProjectFile project;
|
||||
if (!m_ilm->getProjectByAbsoluteStoragePath(&absoluteStoragePath, &project)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (project.m_file.toString().endsWith(".exe")) {
|
||||
|
||||
} else if (project.m_file.toString().endsWith(".qml")) {
|
||||
}
|
||||
|
||||
QString fullPath = absoluteStoragePath.toString() + "/" + project.m_file.toString();
|
||||
|
||||
m_screenPlayWidgetList.append(QSharedPointer<ScreenPlayWidget>(new ScreenPlayWidget(absoluteStoragePath.toString(), previewImage, fullPath, this)));
|
||||
|
||||
}
|
||||
|
||||
void ScreenPlay::removeAllWallpaper()
|
||||
{
|
||||
m_sdkc->closeAllWallpapers();
|
||||
m_settings->setActiveWallpaperCounter(0);
|
||||
emit allWallpaperRemoved();
|
||||
}
|
||||
|
||||
Settings* ScreenPlay::settings() const
|
||||
{
|
||||
return m_settings;
|
||||
}
|
||||
|
@ -1,17 +1,220 @@
|
||||
#ifndef SCREENPLAY_H
|
||||
#define SCREENPLAY_H
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <QPoint>
|
||||
#include <QProcess>
|
||||
#include <QSharedPointer>
|
||||
#include <QVector>
|
||||
|
||||
class ScreenPlay : public QObject
|
||||
{
|
||||
#include "installedlistmodel.h"
|
||||
#include "monitorlistmodel.h"
|
||||
#include "projectfile.h"
|
||||
#include "sdkconnector.h"
|
||||
#include "settings.h"
|
||||
|
||||
class ScreenPlayWallpaper;
|
||||
class ScreenPlayWidget;
|
||||
|
||||
class ScreenPlay : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ScreenPlay(QObject *parent = nullptr);
|
||||
explicit ScreenPlay(InstalledListModel* ilm, Settings* set, MonitorListModel* mlm, QGuiApplication* qGuiApplication, SDKConnector* sdkc, QObject* parent = nullptr);
|
||||
|
||||
Settings* settings() const;
|
||||
|
||||
signals:
|
||||
void allWallpaperRemoved();
|
||||
|
||||
public slots:
|
||||
void createWallpaper(int monitorIndex, QUrl absoluteStoragePath, QString previewImage);
|
||||
void createWidget(QUrl absoluteStoragePath, QString previewImage);
|
||||
void removeAllWallpaper();
|
||||
|
||||
private:
|
||||
QVector<QSharedPointer<ScreenPlayWallpaper>> m_screenPlayWallpaperList;
|
||||
QVector<QSharedPointer<ScreenPlayWidget>> m_screenPlayWidgetList;
|
||||
InstalledListModel* m_ilm;
|
||||
Settings* m_settings;
|
||||
MonitorListModel* m_mlm;
|
||||
QGuiApplication* m_qGuiApplication;
|
||||
SDKConnector* m_sdkc;
|
||||
};
|
||||
|
||||
class ScreenPlayWallpaper : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QVector<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)
|
||||
|
||||
public:
|
||||
explicit ScreenPlayWallpaper(QVector<int> screenNumber, QString projectPath, QString previewImage, ScreenPlay* parent)
|
||||
{
|
||||
m_screenNumber = screenNumber;
|
||||
m_projectPath = projectPath;
|
||||
m_previewImage = previewImage;
|
||||
|
||||
// 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();
|
||||
|
||||
QStringList proArgs;
|
||||
proArgs.append(QString::number(m_screenNumber.at(0)));
|
||||
proArgs.append(m_projectPath);
|
||||
m_process->setArguments(proArgs);
|
||||
m_process->setProgram(parent->settings()->screenPlayWindowPath().toString());
|
||||
m_process->start();
|
||||
}
|
||||
|
||||
QVector<int> screenNumber() const
|
||||
{
|
||||
return m_screenNumber;
|
||||
}
|
||||
|
||||
QString projectPath() const
|
||||
{
|
||||
return m_projectPath;
|
||||
}
|
||||
|
||||
QString previewImage() const
|
||||
{
|
||||
return m_previewImage;
|
||||
}
|
||||
|
||||
signals:
|
||||
|
||||
void screenNumberChanged(QVector<int> screenNumber);
|
||||
|
||||
void projectPathChanged(QString projectPath);
|
||||
|
||||
void previewImageChanged(QString previewImage);
|
||||
|
||||
public slots:
|
||||
|
||||
void setScreenNumber(QVector<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);
|
||||
}
|
||||
|
||||
private:
|
||||
QVector<int> m_screenNumber;
|
||||
QString m_projectPath;
|
||||
QString m_previewImage;
|
||||
QProcess* m_process;
|
||||
};
|
||||
|
||||
#endif // SCREENPLAY_H
|
||||
class ScreenPlayWidget : 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)
|
||||
|
||||
public:
|
||||
explicit ScreenPlayWidget(QString projectPath, QString previewImage, QString fullPath, ScreenPlay* parent)
|
||||
{
|
||||
m_process = new QProcess(this);
|
||||
|
||||
m_process->setProgram(fullPath);
|
||||
m_process->start();
|
||||
}
|
||||
|
||||
QString projectPath() const
|
||||
{
|
||||
return m_projectPath;
|
||||
}
|
||||
|
||||
QString previewImage() const
|
||||
{
|
||||
return m_previewImage;
|
||||
}
|
||||
|
||||
QPoint position() const
|
||||
{
|
||||
return m_position;
|
||||
}
|
||||
|
||||
QString fullPath() const
|
||||
{
|
||||
return m_fullPath;
|
||||
}
|
||||
|
||||
signals:
|
||||
|
||||
void projectPathChanged(QString projectPath);
|
||||
|
||||
void previewImageChanged(QString previewImage);
|
||||
|
||||
void positionChanged(QPoint position);
|
||||
|
||||
void fullPathChanged(QString fullPath);
|
||||
|
||||
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 setFullPath(QString fullPath)
|
||||
{
|
||||
if (m_fullPath == fullPath)
|
||||
return;
|
||||
|
||||
m_fullPath = fullPath;
|
||||
emit fullPathChanged(m_fullPath);
|
||||
}
|
||||
|
||||
private:
|
||||
QString m_projectPath;
|
||||
QString m_previewImage;
|
||||
QPoint m_position;
|
||||
QProcess* m_process;
|
||||
QString m_fullPath;
|
||||
};
|
||||
|
@ -90,56 +90,6 @@ Settings::~Settings()
|
||||
{
|
||||
}
|
||||
|
||||
void Settings::setWallpaper(int monitorIndex, QUrl absoluteStoragePath, QString previewImage)
|
||||
{
|
||||
|
||||
ProjectFile project;
|
||||
Monitor monitor;
|
||||
|
||||
// Replace wallpaper
|
||||
// if (!m_mlm->getMonitorListItemAt(monitorIndex, &monitor)) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (!m_ilm->getProjectByAbsoluteStoragePath(&absoluteStoragePath, &project)) {
|
||||
return;
|
||||
}
|
||||
|
||||
increaseActiveWallpaperCounter();
|
||||
|
||||
m_activeProfiles.append(QSharedPointer<ActiveProfile>(new ActiveProfile(monitorIndex,absoluteStoragePath.toString())));
|
||||
|
||||
// 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* pro = new QProcess();
|
||||
m_windows.append(pro);
|
||||
|
||||
QStringList proArgs;
|
||||
proArgs.append(QString::number(monitorIndex));
|
||||
proArgs.append(absoluteStoragePath.toString());
|
||||
pro->setArguments(proArgs);
|
||||
pro->setProgram(m_screenPlayWindowPath.toString());
|
||||
pro->start();
|
||||
|
||||
|
||||
m_mlm->setWallpaperActiveMonitor(m_qGuiApplication->screens().at(monitorIndex), absoluteStoragePath.toString() + "/" + previewImage);
|
||||
}
|
||||
|
||||
void Settings::setWidget(QUrl absoluteStoragePath)
|
||||
{
|
||||
ProjectFile project;
|
||||
if (!m_ilm->getProjectByAbsoluteStoragePath(&absoluteStoragePath, &project)) {
|
||||
return;
|
||||
}
|
||||
QProcess* pro = new QProcess(this);
|
||||
m_widgets.append(pro);
|
||||
QString fullPath = absoluteStoragePath.toString() + "/" + project.m_file.toString();
|
||||
|
||||
m_widgets.last()->setProgram(fullPath);
|
||||
m_widgets.last()->start();
|
||||
}
|
||||
|
||||
QString Settings::loadProject(QString file)
|
||||
{
|
||||
QFile configTmp;
|
||||
@ -227,13 +177,6 @@ void Settings::writeSingleSettingConfig(QString name, QVariant value)
|
||||
configTmp.close();
|
||||
}
|
||||
|
||||
void Settings::removeAll()
|
||||
{
|
||||
m_sdkc->closeAllWallpapers();
|
||||
setActiveWallpaperCounter(0);
|
||||
emit allWallpaperRemoved();
|
||||
}
|
||||
|
||||
void Settings::setMuteAll(bool isMuted)
|
||||
{
|
||||
|
||||
@ -261,22 +204,6 @@ void Settings::setPlayAll(bool isPlaying)
|
||||
// }
|
||||
}
|
||||
|
||||
QUrl Settings::getPreviewImageByMonitorID(QString id)
|
||||
{
|
||||
// for (int i = 0; i < m_mlm->m_monitorList.size(); ++i) {
|
||||
// if(m_mlm->m_monitorList.at(i).m_id == id){
|
||||
// //return m_mlm->m_monitorList.at(i).m_
|
||||
// }
|
||||
// }
|
||||
return QUrl();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Settings::removeWallpaperAt(int pos)
|
||||
{
|
||||
}
|
||||
|
||||
void Settings::createDefaultConfig()
|
||||
{
|
||||
|
||||
@ -305,7 +232,6 @@ void Settings::setScreenPlayWindowPath(const QUrl& screenPlayWindowPath)
|
||||
m_screenPlayWindowPath = screenPlayWindowPath;
|
||||
}
|
||||
|
||||
|
||||
void Settings::checkForOtherFullscreenApplication()
|
||||
{
|
||||
HWND hWnd = GetForegroundWindow();
|
||||
@ -320,25 +246,3 @@ void Settings::checkForOtherFullscreenApplication()
|
||||
// }
|
||||
}
|
||||
|
||||
ActiveProfile::ActiveProfile()
|
||||
{
|
||||
}
|
||||
|
||||
ActiveProfile::ActiveProfile(QString wallpaperId, Profile profile)
|
||||
{
|
||||
m_monitorId = wallpaperId;
|
||||
m_profile = profile;
|
||||
}
|
||||
|
||||
ActiveProfile::ActiveProfile(int monitorIndex, QString absoluteStoragePath)
|
||||
{
|
||||
m_monitorIndex = monitorIndex;
|
||||
m_absoluteStoragePath = absoluteStoragePath;
|
||||
m_proSettingsListModel.init(absoluteStoragePath +"/project.json");
|
||||
|
||||
}
|
||||
|
||||
QString ActiveProfile::monitorId() const
|
||||
{
|
||||
return m_monitorId;
|
||||
}
|
||||
|
@ -83,6 +83,11 @@ public:
|
||||
return m_version;
|
||||
}
|
||||
|
||||
QUrl screenPlayWindowPath() const
|
||||
{
|
||||
return m_screenPlayWindowPath;
|
||||
}
|
||||
|
||||
QUrl localStoragePath() const
|
||||
{
|
||||
return m_localStoragePath;
|
||||
@ -122,11 +127,10 @@ signals:
|
||||
void setMainWindowVisible(bool visible);
|
||||
void activeWallpaperCounterChanged(int activeWallpaperCounter);
|
||||
void pauseWallpaperWhenIngameChanged(bool pauseWallpaperWhenIngame);
|
||||
void allWallpaperRemoved();
|
||||
|
||||
void offlineModeChanged(bool offlineMode);
|
||||
|
||||
public slots:
|
||||
void removeAll();
|
||||
void setMuteAll(bool isMuted);
|
||||
void setPlayAll(bool isPlaying);
|
||||
void checkForOtherFullscreenApplication();
|
||||
@ -134,8 +138,6 @@ public slots:
|
||||
void setGlobalFillMode(QString fillMode);
|
||||
void writeSingleSettingConfig(QString name, QVariant value);
|
||||
|
||||
QUrl getPreviewImageByMonitorID(QString id);
|
||||
|
||||
bool autostart() const
|
||||
{
|
||||
return m_autostart;
|
||||
@ -196,12 +198,6 @@ public slots:
|
||||
emit sendStatisticsChanged(m_sendStatistics);
|
||||
}
|
||||
|
||||
void removeWallpaperAt(int pos);
|
||||
|
||||
void setWallpaper(int monitorIndex, QUrl absoluteStoragePath, QString previewImage);
|
||||
|
||||
void setWidget(QUrl absoluteStoragePath);
|
||||
|
||||
QString loadProject(QString file);
|
||||
|
||||
void setLocalStoragePath(QUrl localStoragePath)
|
||||
@ -310,10 +306,6 @@ private:
|
||||
|
||||
QTimer* m_checkForOtherFullscreenApplicationTimer;
|
||||
|
||||
QVector<QProcess*> m_widgets;
|
||||
QVector<QProcess*> m_windows;
|
||||
QVector<QSharedPointer<ActiveProfile>> m_activeProfiles;
|
||||
|
||||
QUrl m_localStoragePath;
|
||||
QUrl m_localSettingsPath;
|
||||
QUrl m_screenPlayWindowPath;
|
||||
@ -332,23 +324,3 @@ private:
|
||||
bool m_offlineMode = false;
|
||||
};
|
||||
|
||||
class ActiveProfile {
|
||||
public:
|
||||
ActiveProfile();
|
||||
ActiveProfile(QString monitorId, Profile profile);
|
||||
ActiveProfile(int monitorIndex, QString absoluteStoragePath);
|
||||
QString monitorId() const;
|
||||
|
||||
private:
|
||||
QString m_monitorId, m_absoluteStoragePath;
|
||||
int m_monitorIndex;
|
||||
Profile m_profile;
|
||||
QProcess* m_process;
|
||||
ProjectSettingsListModel m_proSettingsListModel;
|
||||
};
|
||||
|
||||
enum FillMode {
|
||||
Stretch,
|
||||
PreserveAspectFit,
|
||||
PreserveAspectCrop,
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user