1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-11-07 03:22:33 +01:00

Very big code cleanup to match the naming convention. Change projectfile comparison from a id to a path so we can have multiple projects with the same name in different dirs for later features

This commit is contained in:
kelteseth 2017-10-24 15:02:46 +02:00
parent 35c7ad47e9
commit 4694ebc407
20 changed files with 283 additions and 174 deletions

View File

@ -1,10 +1,11 @@
import QtQuick 2.7
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Dialogs 1.2
import Qt.labs.platform 1.0
CustomPage {
id: page
id: create
pageName: ""
Connections {
@ -19,17 +20,23 @@ CustomPage {
busyIndicator.running = false
}
}
onLocalFileCopyCompleted:{
create.state = ""
}
}
Connections {
target: leftArea
onHasEmptyField:{
if(fieldNumber === 0){
onHasEmptyField: {
if (fieldNumber === 0) {
fileDropperVideo.state = "error"
} else if (fieldNumber === 1) {
fileDropperPreview.state = "error"
}
}
onCreateLocalWallpaperStarted: {
create.state = "createLocalWallpaper"
}
}
FontLoader {
@ -54,7 +61,6 @@ CustomPage {
left: parent.left
margins: 10
}
}
Item {
@ -78,14 +84,15 @@ CustomPage {
width: parent.width * .48
height: parent.height
FileDropperSingleFile {
id:fileDropperVideo
id: fileDropperVideo
anchors.fill: parent
z: 99
descriptionTitle: "Drop your video here"
helpText: "Supportet Video formats: mp4 for older devices and VP9 for newer like NVidia 1000 or AMD VEGA"
isVideo: true
imagePath: "qrc:/assets/icons/icon_tv.svg"
onExternalFilePathChanged: leftArea.videoPath = fileDropperVideo.externalFilePath
onExternalFilePathChanged: leftArea.videoPath
= fileDropperVideo.externalFilePath
}
}
Item {
@ -94,13 +101,14 @@ CustomPage {
height: parent.height
FileDropperSingleFile {
id:fileDropperPreview
id: fileDropperPreview
anchors.fill: parent
z: 99
descriptionTitle: "Set Preview Image"
helpText: "Use PNG for best results. The image ratio should be 21:9. Preffered resulution 123x123."
imagePath: "qrc:/assets/icons/icon_single_image.svg"
onExternalFilePathChanged: leftArea.previewPath = fileDropperPreview.externalFilePath
onExternalFilePathChanged: leftArea.previewPath
= fileDropperPreview.externalFilePath
}
}
@ -118,7 +126,6 @@ CustomPage {
z: 99
descriptionTitle: "Add additional images"
imagePath: "qrc:/assets/icons/icon_multiple_images.svg"
}
}
}
@ -156,8 +163,9 @@ CustomPage {
Transition {
from: "*"
to: "*"
PropertyAnimation{
properties: "opacity"; easing.type: Easing.InOutQuad
PropertyAnimation {
properties: "opacity"
easing.type: Easing.InOutQuad
}
}
]

View File

@ -14,6 +14,7 @@ Rectangle {
property url previewPath
//Todo 5.10 ENUM
signal hasEmptyField(int fieldNumber)
signal createLocalWallpaperStarted()
Row {
id: rowUseSteamWorkshop
@ -125,6 +126,7 @@ Rectangle {
}
}
}
Button {
id: btnSubmit
anchors {
@ -157,7 +159,7 @@ Rectangle {
previewPath)
tiItemUpdate.start()
} else {
createLocalWallpaperStarted()
steamWorkshop.createLocalWorkshopItem(
txtTitle.text.toString(), videoPath,
previewPath)

View File

@ -1,53 +1,50 @@
import QtQuick 2.7
import QtQuick.Controls 1.4
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import QtQuick.Controls.Material 2.0
Item {
id: headline
property string name: ""
property string name: "TEXT"
width: parent.width
height: 80
height: 50
Item {
height: 70
anchors {
top: parent.top
right: parent.right
left: parent.left
}
Item {
height: parent.height
anchors {
top: parent.top
right: parent.right
left: parent.left
}
Text {
id: txtName
text: headline.name
font.italic: true
renderType: Text.NativeRendering
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignLeft
anchors.bottom: line.top
anchors.bottomMargin: 5
anchors.left: parent.left
anchors.leftMargin: 10
font.pixelSize: 18
color: "#818181"
anchors.margins: 10
font.family: font_LibreBaskerville_Italic.name
Text {
id:txtName
text: headline.name
font.italic: true
renderType: Text.NativeRendering
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignLeft
anchors.bottom: line.top
anchors.bottomMargin: 5
anchors.left: parent.left
anchors.leftMargin: 10
font.pixelSize: 18
color: "#818181"
anchors.margins: 10
font.family: font_LibreBaskerville_Italic.name
FontLoader {
id: font_LibreBaskerville_Italic
source: "qrc:/assets/fonts/LibreBaskerville-Italic.ttf"
}
}
FontLoader {
id: font_LibreBaskerville_Italic
source: "qrc:/assets/fonts/LibreBaskerville-Italic.ttf"
Rectangle {
id: line
height: 1
width: parent.width
color: "#BBBBBB"
anchors.bottom: parent.bottom
}
}
Rectangle {
id:line
height: 1
width: parent.width
color: "#BBBBBB"
anchors.bottom: parent.bottom
}
}
}

View File

@ -1,6 +1,6 @@
import QtQuick 2.7
import QtGraphicalEffects 1.0
import QtQuick.Controls 2.0
import QtQuick.Controls 2.2
import QtQuick.Extras 1.4
Item {
@ -101,16 +101,14 @@ Item {
anchors.bottom: parent.bottom
anchors.bottomMargin: 18
onClicked: {
installedListModel.setScreenToVideoFromQml(
Qt.resolvedUrl(
"file:///" + installedListModel._screensPath
+ activeScreen + "/" + installedListModel.get(
activeScreen).screenFile))
screenPlaySettings.constructWallpaper(
activeScreen,
monitorSelection.activeMonitorIndex)
}
}
Rectangle {
id:monitorSelectionWrapper
id: monitorSelectionWrapper
color: "gray"
height: 200
anchors {
@ -121,6 +119,7 @@ Item {
anchors.bottomMargin: 100
MonitorSelection {
id: monitorSelection
anchors.centerIn: parent
anchors.fill: parent
availableWidth: sidebar.width

View File

@ -25,6 +25,8 @@ QVariant InstalledListModel::data(const QModelIndex& index, int role) const
return m_screenPlayFiles.at(index.row()).m_folderId;
case FileIdRole:
return m_screenPlayFiles.at(index.row()).m_file;
case AbsoluteFilePathRole:
return m_screenPlayFiles.at(index.row()).m_absolutePath;
default:
return QVariant();
}
@ -38,18 +40,21 @@ QHash<int, QByteArray> InstalledListModel::roleNames() const
{ PreviewRole, "screenPreview" },
{ FolderIdRole, "screenFolderId" },
{ FileIdRole, "screenFile" },
{ AbsoluteFilePathRole, "absoluteFilePath" },
};
return roles;
}
bool InstalledListModel::getProjectByName(QString profileName, ProjectFile *spf)
bool InstalledListModel::getProjectByAbsoluteStoragePath(QUrl* path, ProjectFile* spf)
{
for (int i = 0; i < m_screenPlayFiles.size(); i++) {
if (m_screenPlayFiles.at(i).m_folderId == profileName) {
for (int i = 0; i < m_screenPlayFiles.count(); ++i) {
if (m_screenPlayFiles.at(i).m_absolutePath == *path) {
*spf = m_screenPlayFiles.at(i);
return true;
}
}
return false;
}
@ -59,7 +64,7 @@ void InstalledListModel::append(const QJsonObject obj, const QString folderName)
beginInsertRows(QModelIndex(), row, row);
ProjectFile tmpFile(obj, folderName);
ProjectFile tmpFile(obj, folderName, m_absoluteStoragePath);
m_screenPlayFiles.append(tmpFile);
endInsertRows();
@ -74,7 +79,7 @@ void InstalledListModel::loadScreens()
QString tmpPath;
for (auto&& item : list) {
tmpPath = m_absoluteStoragePath.toString() +"/" +item.baseName() + "/project.json";
tmpPath = m_absoluteStoragePath.toString() + "/" + item.baseName() + "/project.json";
if (!QFile(tmpPath).exists())
continue;
@ -109,5 +114,3 @@ QVariantMap InstalledListModel::get(QString folderId)
return map;
}

View File

@ -12,7 +12,7 @@
#include <QJsonArray>
#include <QJsonDocument>
#include <QJsonObject>
#include <QList>
#include <QVector>
#include <QStandardPaths>
#include <QString>
#include <QUrl>
@ -29,7 +29,8 @@ public:
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
void append(const QJsonObject, const QString);
QHash<int, QByteArray> roleNames() const override;
bool getProjectByName(QString profileName, ProjectFile* spf);
bool getProjectByAbsoluteStoragePath(QUrl *path, ProjectFile* spf);
Q_INVOKABLE void loadScreens();
Q_INVOKABLE QVariantMap get(QString folderId);
@ -40,6 +41,7 @@ public:
PreviewRole,
FolderIdRole,
FileIdRole,
AbsoluteFilePathRole,
};
Q_ENUM(InstalledRole)
@ -65,7 +67,7 @@ signals:
void absoluteStoragePathChanged(QUrl absoluteStoragePath);
private:
QList<ProjectFile> m_screenPlayFiles;
QVector<ProjectFile> m_screenPlayFiles;
QUrl m_absoluteStoragePath;
};

View File

@ -20,7 +20,7 @@ QHash<int, QByteArray> MonitorListModel::roleNames() const
QRect MonitorListModel::getAbsoluteDesktopSize()
{
return _monitorList.at(0)._availableVirtualGeometry;
return m_monitorList.at(0).m_availableVirtualGeometry;
}
QVariant MonitorListModel::headerData(int section, Qt::Orientation orientation, int role) const
@ -45,7 +45,7 @@ int MonitorListModel::rowCount(const QModelIndex& parent) const
if (parent.isValid())
return 0;
return _monitorList.count();
return m_monitorList.count();
}
QVariant MonitorListModel::data(const QModelIndex& index, int role) const
@ -56,15 +56,15 @@ QVariant MonitorListModel::data(const QModelIndex& index, int role) const
if (index.row() < rowCount())
switch (role) {
case NameRole:
return _monitorList.at(index.row())._name;
return m_monitorList.at(index.row()).m_name;
case SizeRole:
return _monitorList.at(index.row())._size;
return m_monitorList.at(index.row()).m_size;
case AvailableGeometryRole:
return _monitorList.at(index.row())._availableGeometry;
return m_monitorList.at(index.row()).m_availableGeometry;
case AvailableVirtualGeometryRole:
return _monitorList.at(index.row())._availableVirtualGeometry;
return m_monitorList.at(index.row()).m_availableVirtualGeometry;
case NumberRole:
return _monitorList.at(index.row())._number;
return m_monitorList.at(index.row()).m_number;
default:
return QVariant();
}
@ -109,7 +109,7 @@ void MonitorListModel::loadMonitors()
for (int i = 0; i < QApplication::screens().count(); i++) {
QScreen* screen = QApplication::screens().at(i);
_monitorList.append(Monitor(screen->manufacturer(),
m_monitorList.append(Monitor(screen->manufacturer(),
screen->model(),
screen->name(),
screen->size(),
@ -120,14 +120,30 @@ void MonitorListModel::loadMonitors()
}
}
int MonitorListModel::size()
{
return m_monitorList.size();
}
bool MonitorListModel::getMonitorListItemAt(int position, Monitor* monitor)
{
if (position < 0 && position > m_monitorList.size()) {
return false;
} else {
*monitor = m_monitorList.at(position);
return true;
}
}
float MonitorListModel::GetHighestMonitorYValue()
{
/*for (int i = 0; i < vector.size(); ++i)
{
_monitorList.at(i).screen->availableVirtualGeometry().x();
_monitorList.at(i).screen->availableGeometry().y();
m_monitorList.at(i).screen->availableVirtualGeometry().x();
m_monitorList.at(i).screen->availableGeometry().y();
}*/
// _monitorList.
// m_monitorList.
return 0.0f;
}
@ -138,13 +154,13 @@ Monitor::Monitor()
Monitor::Monitor(QString manufacturer, QString model, QString name, QSize size, QRect availableGeometry, int number, QRect availableVirtualGeometry)
{
_name = name;
_size = size;
_availableGeometry = availableGeometry;
m_name = name;
m_size = size;
m_availableGeometry = availableGeometry;
_availableVirtualGeometry = availableVirtualGeometry;
_number = number;
m_availableVirtualGeometry = availableVirtualGeometry;
m_number = number;
// FIXME: Use a better way to create an id
// because name and manufacturer are allways empty
_id = /*name + "_" +*/ QString::number(size.width()) + "x" + QString::number(size.height()) + "_" + QString::number(availableGeometry.x()) + "x" + QString::number(availableGeometry.y());
m_id = /*name + "_" +*/ QString::number(size.width()) + "x" + QString::number(size.height()) + "_" + QString::number(availableGeometry.x()) + "x" + QString::number(availableGeometry.y());
}

View File

@ -57,10 +57,13 @@ public:
void loadMonitors();
int size();
bool getMonitorListItemAt(int position, Monitor *monitor);
float GetHighestMonitorYValue();
private:
QVector<Monitor> _monitorList;
QVector<Monitor> m_monitorList;
};
class Monitor {
@ -69,13 +72,13 @@ public:
Monitor();
Monitor(QString manufacturer, QString model, QString name, QSize size, QRect availableGeometry, int number, QRect availableVirtualGeometry);
QString _id;
QString _name;
QSize _size;
QRect _availableGeometry;
QRect _availableVirtualGeometry;
int _number;
bool _isVirtualDesktop;
QString m_id;
QString m_name;
QSize m_size;
QRect m_availableGeometry;
QRect m_availableVirtualGeometry;
int m_number;
bool m_isVirtualDesktop;
};
#endif // MONITORLISTMODEL_H

View File

@ -7,7 +7,7 @@ PackageFileHandler::PackageFileHandler(QObject* parent)
qmlRegisterType<PackageFileHandler>("PackageFileHandler", 1, 0, "LoaderStatus");
}
int PackageFileHandler::loadPackageFromLocalZip(QList<QUrl> url, QString extractDir)
int PackageFileHandler::loadPackageFromLocalZip(QVector<QUrl> url, QString extractDir)
{
setCurrentLoaderStatus(LoaderStatus::Extracting);
for(int i = 0; i < url.length(); i++) {

View File

@ -2,7 +2,7 @@
#define PACKAGEFILEHANDLER_H
#include <QFile>
#include <QList>
#include <QVector>
#include <QObject>
#include <QString>
#include <QUrl>
@ -15,7 +15,7 @@ class PackageFileHandler : public QObject {
public:
explicit PackageFileHandler(QObject* parent = nullptr);
Q_INVOKABLE int loadPackageFromLocalZip(QList<QUrl> url, QString extractDir);
Q_INVOKABLE int loadPackageFromLocalZip(QVector<QUrl> url, QString extractDir);
enum LoaderStatus {
Idle,

View File

@ -48,14 +48,14 @@ void ProfileListModel::loadProfiles()
{
QFileInfoList list = QDir(m_absoluteStoragePath.toString()+ "/Profiles/").entryInfoList(QDir::NoDotAndDotDot | QDir::AllDirs);
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_absoluteStoragePath.toString() + "/Profiles/" + item.baseName() + "/profile.json";
tmpPath = m_localStoragePath.toString() + "/Profiles/" + item.baseName() + "/profile.json";
QFile settings;
settings.setFileName(tmpPath);
@ -94,7 +94,7 @@ void ProfileListModel::loadProfiles()
if (profileObj.contains("isLooping"))
tmpProfile.m_isLooping = profileObj.value("isLooping").toBool();
tmpProfile.m_absolutePath = m_absoluteStoragePath;
tmpProfile.m_absolutePath = m_localStoragePath;
m_profileList.append(tmpProfile);
}

View File

@ -30,7 +30,7 @@ public:
virtual QHash<int, QByteArray> roleNames() const override;
void loadProfiles();
bool getProfileByName(QString id, Profile* profile);
QUrl m_absoluteStoragePath;
QUrl m_localStoragePath;
private:
QHash<int, QByteArray> m_roleNames;

View File

@ -4,7 +4,7 @@ ProjectFile::ProjectFile()
{
}
ProjectFile::ProjectFile(QJsonObject obj, QString folderName)
ProjectFile::ProjectFile(QJsonObject obj, QString folderName, QUrl absolutePath)
{
if (obj.contains("description"))
m_description = obj.value("description");
@ -18,5 +18,7 @@ ProjectFile::ProjectFile(QJsonObject obj, QString folderName)
if (obj.contains("title"))
m_title = obj.value("title");
m_absolutePath = absolutePath;
m_folderId = folderName;
}

View File

@ -10,7 +10,7 @@ class ProjectFile
{
public:
ProjectFile();
ProjectFile(QJsonObject obj, QString folderName);
ProjectFile(QJsonObject obj, QString folderName, QUrl absolutePath);
QVariant m_description;
QVariant m_file;

View File

@ -12,7 +12,6 @@ Settings::Settings(ProfileListModel* plm, MonitorListModel* mlm, InstalledListMo
QFile configTmp;
QString appConfigLocation = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation);
if (!QDir(appConfigLocation).exists()) {
if (!QDir().mkdir(appConfigLocation)) {
qWarning("ERROR: Cloud not create install dir");
@ -59,7 +58,7 @@ Settings::Settings(ProfileListModel* plm, MonitorListModel* mlm, InstalledListMo
if (QString(configObj.value("absoluteStoragePath").toString()).isEmpty()) {
uint32 size = 5000;
char folder[size];
SteamApps()->GetAppInstallDir(m_steamID,folder,5000);
SteamApps()->GetAppInstallDir(m_steamID, folder, 5000);
QDir steamTmpUrl = QDir(QString(QByteArray(folder).data()));
steamTmpUrl.cdUp();
steamTmpUrl.cdUp();
@ -75,32 +74,7 @@ Settings::Settings(ProfileListModel* plm, MonitorListModel* mlm, InstalledListMo
m_ilm->setabsoluteStoragePath(m_localStoragePath);
m_plm->m_localStoragePath = m_localStoragePath;
/*
//Create default folders
if (!QDir(m_absoluteStoragePath.toString() + "/ProfilePackages").exists()) {
if (!QDir().mkdir(appConfigLocation + "/ProfilePackages")) {
qWarning("ERROR: Cloud not create ProfilePackages dir");
return;
}
}
if (!QDir(m_absoluteStoragePath.toString() + "/Profiles").exists()) {
if (!QDir().mkdir(appConfigLocation + "/Profiles")) {
qWarning("ERROR: Cloud not create Profiles dir");
return;
}
}
if (!QDir(m_absoluteStoragePath.toString() + "/Wallpaper").exists()) {
if (!QDir().mkdir(appConfigLocation + "/Wallpaper")) {
qWarning("ERROR: Cloud not create Wallpaper dir");
return;
}
}
if (!QDir(m_absoluteStoragePath.toString() + "/Widgets").exists()) {
if (!QDir().mkdir(appConfigLocation + "/Widgets")) {
qWarning("ERROR: Cloud not create Widgets dir");
return;
}
}*/
m_autostart = configObj.value("autostart").toBool();
m_highPriorityStart = configObj.value("highPriorityStart").toBool();
@ -112,19 +86,61 @@ Settings::~Settings()
{
}
void Settings::createNewProfile(int screenNumber)
{
}
void Settings::constructWallpaper(Profile profile, QString monitorID, ProjectFile pf)
{
m_wallpapers.append(QSharedPointer<Wallpaper>(new Wallpaper(profile,pf)));
//m_wallpapers.append(QSharedPointer<Wallpaper>(new Wallpaper(profile, pf)));
}
void Settings::setWallpaper(int monitorIndex, QString wallpaperID)
void Settings::constructWallpaper(QString folder, int monitorListAt)
{
}
void Settings::setWallpaper(int monitorIndex, QString wallpaperID, QUrl absoluteStoragePath)
{
ProjectFile project;
Monitor monitor;
if (!m_mlm->getMonitorListItemAt(monitorIndex, &monitor)) {
return;
}
if(!m_ilm->getProjectByAbsoluteStoragePath(&absoluteStoragePath,&project)){
return;
}
// Search for active Wallpapers on the same monitor and delte it
for (int i = 0; i < m_wallpapers.length(); ++i) {
if (m_wallpapers.at(i).data()->monitor().m_id == monitor.m_id) {
removeWallpaperAt(i);
}
}
/*
* Profile profile;
//Does the targeted monitor has a profile ?
// 1. Get the requested monitor
if(m_mlm->getMonitorListItemAt(monitorIndex,&monitor)){
// 2. When found search for
for (int i = 0; i < m_mlm->size(); ++i) {
if(m_mlm->getMonitorListItemAt(i,&tmpMonitor)){
for(int i = 0; i < m_activeProfiles.size(); ++i){
if(tmpMonitor._id == m_activeProfiles.at(i).data()->monitorId()) {
}
}
}
}
}
if (m_ilm->getProjectByName(wallpaperID, &project)) {
if(m_mlm->getMonitorListItemAt(monitorIndex,&monitor)){
m_wallpapers.append(QSharedPointer<Wallpaper>(new Wallpaper(profile, monitor)));
}
}*/
}
void Settings::loadActiveProfiles()
@ -152,10 +168,9 @@ void Settings::loadActiveProfiles()
if (!m_plm->getProfileByName(profileName, &profile))
continue;
if (!m_ilm->getProjectByName(profile.m_wallpaperId, &spf))
if(!m_ilm->getProjectByAbsoluteStoragePath(&profile.m_absolutePath, &spf))
continue;
constructWallpaper(profile, monitorID, spf);
}
}
@ -166,9 +181,14 @@ void Settings::removeAll()
m_wallpapers.clear();
}
void Settings::updateSettinsValue(QString newValue)
void Settings::createNewWallpaper(int monitorListPosition, Profile profile, ProjectFile projectFile)
{
}
void Settings::removeWallpaperAt(int pos)
{
//Todo is this a memory leak?
m_wallpapers.removeAt(pos);
}
void Settings::createDefaultConfig()
@ -189,11 +209,6 @@ void Settings::createDefaultConfig()
defaultSettings.close();
}
void Settings::updateSettingsLocalPath(QUrl newPath)
{
}
ActiveProfiles::ActiveProfiles()
{
}
@ -203,3 +218,8 @@ ActiveProfiles::ActiveProfiles(QString wallpaperId, Profile profile)
m_monitorId = wallpaperId;
m_profile = profile;
}
QString ActiveProfiles::monitorId() const
{
return m_monitorId;
}

View File

@ -1,5 +1,4 @@
#ifndef SCREENPLAYSETTINGS_H
#define SCREENPLAYSETTINGS_H
#pragma once
#include <QDebug>
#include <QDir>
@ -28,6 +27,9 @@
class ActiveProfiles;
class Settings : public QObject {
Q_OBJECT
public:
@ -43,7 +45,13 @@ public:
void loadActiveProfiles();
void removeAll();
void updateSettinsValue(QString newValue);
enum LocalCopyResult {
NoError,
CopyError,
NotEnoughDiskSpace,
NameCollision,
};
Q_ENUM(LocalCopyResult)
enum Renderer {
OpenGL,
@ -87,6 +95,7 @@ public:
return m_localStoragePath;
}
signals:
void autostartChanged(bool autostart);
@ -95,7 +104,7 @@ signals:
void rendererChanged(Renderer renderer);
void sendStatisticsChanged(bool sendStatistics);
void sendStatisticsChanged(bool status);
void localStoragePathChanged(QUrl localStoragePath);
@ -128,15 +137,6 @@ public slots:
emit rendererChanged(m_renderer);
}
void setsendStatistics(bool sendStatistics)
{
if (m_sendStatistics == sendStatistics)
return;
m_sendStatistics = sendStatistics;
emit sendStatisticsChanged(m_sendStatistics);
}
void setSendStatistics(bool sendStatistics)
{
if (m_sendStatistics == sendStatistics)
@ -146,18 +146,22 @@ public slots:
emit sendStatisticsChanged(m_sendStatistics);
}
void createNewProfile(int screenNumber);
void createNewWallpaper(int monitorListPosition, Profile profile, ProjectFile projectFile);
void removeWallpaperAt(int pos);
void constructWallpaper(Profile profile, QString monitorID, ProjectFile spf);
void setWallpaper(int monitorIndex, QString wallpaperID);
void constructWallpaper(QString folder, int monitorListAt);
void setWallpaper(int monitorIndex, QString wallpaperID, QUrl absoluteStoragePath);
void setLocalStoragePath(QUrl localStoragePath)
{
if (m_localStoragePath == localStoragePath)
return;
QJsonValue cleanedPath = QJsonValue(QString(localStoragePath.toString()).remove(0,8));
QJsonValue cleanedPath = QJsonValue(QString(localStoragePath.toString()).remove(0, 8));
m_localStoragePath = cleanedPath.toString();
@ -186,13 +190,11 @@ public slots:
private:
void createDefaultConfig();
void createProfileConfig();
void updateSettingsLocalPath(QUrl newPath);
bool m_autostart = true;
bool m_highPriorityStart = true;
bool m_sendStatistics;
AppId_t m_steamID;
Renderer m_renderer = Renderer::OpenGL;
@ -202,8 +204,9 @@ private:
MonitorListModel* m_mlm;
QThread m_thread;
QVector<QSharedPointer<Wallpaper>> m_wallpapers;
QVector<QSharedPointer<ActiveProfiles>> m_activeProfiles;
QUrl m_localStoragePath;
};
@ -212,6 +215,8 @@ public:
ActiveProfiles();
ActiveProfiles(QString monitorId, Profile profile);
QString monitorId() const;
private:
QString m_monitorId;
Profile m_profile;
@ -222,4 +227,4 @@ enum FillMode {
PreserveAspectFit,
PreserveAspectCrop,
};
#endif // SCREENPLAYSETTINGS_H

View File

@ -5,10 +5,11 @@ SteamWorkshop::SteamWorkshop(QObject* parent)
{
}
SteamWorkshop::SteamWorkshop(AppId_t nConsumerAppId, SteamWorkshopListModel* wlm)
SteamWorkshop::SteamWorkshop(AppId_t nConsumerAppId, SteamWorkshopListModel* wlm, Settings *s)
{
m_AppId = nConsumerAppId;
m_workshopListModel = wlm;
m_settings = s;
}
void SteamWorkshop::createWorkshopItem()
@ -51,6 +52,23 @@ void SteamWorkshop::getAPICallInfo()
void SteamWorkshop::createLocalWorkshopItem(QString title, QUrl videoPath, QUrl previewPath)
{
QFuture<void> future = QtConcurrent::run([&]() {
if(QDir(m_settings->localStoragePath().toString() + title ).exists()){
//emit localFileCopyCompleted()
return;
}
// bool copyResult = QFile::copy();
// if(copyResult){
// emit localFileCopyCompleted(true);
// } else {
// emit localFileCopyCompleted(false);
// }
});
}
void SteamWorkshop::onWorkshopItemCreated(CreateItemResult_t* pCallback, bool bIOFailure)
@ -94,7 +112,7 @@ void SteamWorkshop::onWorkshopSearched(SteamUGCQueryCompleted_t* pCallback, bool
QByteArray urlData(url);
previews = SteamUGC()->GetQueryUGCNumAdditionalPreviews(pCallback->m_handle, i);
m_workshopListModel->append(QString(details.m_rgchTitle),QUrl(urlData));
m_workshopListModel->append(QString(details.m_rgchTitle), QUrl(urlData));
}
}
}

View File

@ -6,15 +6,19 @@
#include <QFileInfo>
#include <QObject>
#include <QUrl>
#include <QFuture>
#include <QtConcurrent/QtConcurrent>
#include "steam/steam_api.h"
#include "steamworkshoplistmodel.h"
#include "settings.h"
class SteamWorkshop : public QObject {
Q_OBJECT
public:
explicit SteamWorkshop(QObject* parent = nullptr);
SteamWorkshop(AppId_t nConsumerAppId, SteamWorkshopListModel* wlm);
SteamWorkshop(AppId_t nConsumerAppId, SteamWorkshopListModel* wlm, Settings* s);
public slots:
void searchWorkshop();
@ -22,10 +26,12 @@ public slots:
void submitWorkshopItem(QString title, QString description, QString language, int remoteStoragePublishedFileVisibility, QUrl absoluteContentPath, QUrl absolutePreviewPath);
int getItemUpdateProcess();
void getAPICallInfo();
void createLocalWorkshopItem(QString title, QUrl videoPath, QUrl previewPath);
signals:
void workshopItemCreated(bool userNeedsToAcceptWorkshopLegalAgreement, int eResult, int publishedFileId);
void workshopSearched();
void localFileCopyCompleted(bool successful);
private:
void onWorkshopItemCreated(CreateItemResult_t* pCallback, bool bIOFailure);
@ -39,4 +45,5 @@ private:
UGCQueryHandle_t m_UGCSearchHandle;
SteamAPICall_t m_searchCall;
SteamWorkshopListModel* m_workshopListModel;
Settings* m_settings;
};

View File

@ -18,12 +18,13 @@ Wallpaper::Wallpaper(QWindow* parent)
{
}
Wallpaper::Wallpaper(Profile profile, ProjectFile projf)
Wallpaper::Wallpaper(Profile profile, ProjectFile project, Monitor monitor)
{
m_profile = profile;
m_project = projf;
QString tmp = profile.m_absolutePath.toString() + "/Wallpaper/" + profile.m_wallpaperId + "/" + projf.m_file.toString();
m_monitor = monitor;
m_project = project;
QString tmp = profile.m_absolutePath.toString() + "/Wallpaper/" + profile.m_wallpaperId + "/" + m_project.m_file.toString();
tmp.replace("/","\\\\");
setAbsoluteFilePath(tmp);
@ -70,3 +71,8 @@ Wallpaper::~Wallpaper()
{
ShowWindow(m_hwnd, SW_HIDE);
}
Monitor Wallpaper::monitor() const
{
return m_monitor;
}

View File

@ -12,15 +12,16 @@
#include "profile.h"
#include "projectfile.h"
#include "monitorlistmodel.h"
class Wallpaper : public QWindow {
Q_OBJECT
public:
explicit Wallpaper(QWindow* parent = 0);
Wallpaper(Profile profile, ProjectFile projf);
Wallpaper(Profile profile, ProjectFile project, Monitor monitor);
~Wallpaper();
Q_PROPERTY(QString absoluteFilePath READ absoluteFilePath WRITE setAbsoluteFilePath NOTIFY absoluteFilePathChanged)
Q_PROPERTY(bool isPlaying READ isPlaying WRITE setIsPlaying NOTIFY isPlayingChanged)
@ -29,6 +30,13 @@ public:
return m_absoluteFilePath;
}
bool isPlaying() const
{
return m_isPlaying;
}
Monitor monitor() const;
public slots:
void setAbsoluteFilePath(QString absoluteFilePath)
{
@ -39,9 +47,20 @@ public slots:
emit absoluteFilePathChanged(m_absoluteFilePath);
}
void setIsPlaying(bool isPlaying)
{
if (m_isPlaying == isPlaying)
return;
m_isPlaying = isPlaying;
emit isPlayingChanged(m_isPlaying);
}
signals:
void absoluteFilePathChanged(QString absoluteFilePath);
void isPlayingChanged(bool isPlaying);
private:
HWND m_hwnd;
HWND m_worker_hwnd;
@ -50,7 +69,9 @@ private:
Profile m_profile;
ProjectFile m_project;
Monitor m_monitor;
QString m_absoluteFilePath;
bool m_isPlaying;
};
#endif // WALLPAPER_H