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

Move everything inside the ScreenPlay namespace

This commit is contained in:
Elias 2019-06-11 15:44:17 +02:00
parent 1605b64250
commit c064952a2d
32 changed files with 174 additions and 91 deletions

View File

@ -26,7 +26,7 @@ SOURCES += main.cpp \
src/installedlistfilter.cpp \
src/sdkconnector.cpp \
src/projectsettingslistmodel.cpp \
src/screenplay.cpp \
src/screenplaymanager.cpp \
src/qmlutilities.cpp \
src/create.cpp
@ -48,7 +48,7 @@ HEADERS += \
src/sdkconnector.h \
src/projectsettingslistitem.h \
src/projectsettingslistmodel.h \
src/screenplay.h \
src/screenplaymanager.h \
src/qmlutilities.h \
src/create.h

View File

@ -17,12 +17,21 @@
#include "src/monitorlistmodel.h"
#include "src/profilelistmodel.h"
#include "src/qmlutilities.h"
#include "src/screenplay.h"
#include "src/screenplaymanager.h"
#include "src/sdkconnector.h"
#include "src/settings.h"
using std::shared_ptr,
std::make_shared;
std::make_shared,
ScreenPlay::QMLUtilities,
ScreenPlay::InstalledListModel,
ScreenPlay::ScreenPlayManager,
ScreenPlay::InstalledListFilter,
ScreenPlay::MonitorListModel,
ScreenPlay::ProfileListModel,
ScreenPlay::SDKConnector,
ScreenPlay::Settings,
ScreenPlay::Create;
int main(int argc, char* argv[])
{
@ -54,7 +63,7 @@ int main(int argc, char* argv[])
// such things as the profile list model to complete
// It will also set the m_absoluteStoragePath in profileListModel and installedListModel
auto settings = make_shared<Settings>(installedListModel, profileListModel, monitorListModel, sdkConnector);
ScreenPlay screenPlay(installedListModel, settings, monitorListModel, sdkConnector);
ScreenPlayManager screenPlay(installedListModel, settings, monitorListModel, sdkConnector);
Create create(settings);
// All the list need the default path from the settings

View File

@ -5,6 +5,6 @@
"sendStatistics" : false,
"absoluteStoragePath": "",
"profiles":[
{ "monitorID": "","profile": "" }
{ "monitorID": "","wallpaper": "" }
]
}

View File

@ -9,7 +9,7 @@
\todo
- This class would need to be refactored to be used in more creation types.
*/
namespace ScreenPlay {
Create::Create(const shared_ptr<Settings>& settings, QObject* parent)
: QObject(parent)
, m_settings(settings)
@ -145,3 +145,4 @@ void Create::abortAndCleanup()
});
m_createImportVideoThread->requestInterruption();
}
}

View File

@ -26,6 +26,10 @@
#include "qmlutilities.h"
#include "settings.h"
namespace ScreenPlay {
using std::shared_ptr,
std::make_shared;
@ -90,3 +94,4 @@ private:
float m_progress = 0.0f;
QString m_workingDir;
};
}

View File

@ -1,12 +1,25 @@
#include "createimportvideo.h"
#include <QScopeGuard>
namespace ScreenPlay {
/*!
\class CreateImportVideo
\brief This class imports (copies) and creates wallaper previews. This
class only exsits as long as the user creates a wallpaper and gets
destroyed if the creation was successful or not.
The state get propagated via createWallpaperStateChanged(CreateImportVideo::State state);
\todo
- Maybe: Replace with QThread to avoid running QCoreApplication::processEvents();?
*/
CreateImportVideo::CreateImportVideo(QObject* parent)
: QObject(parent)
{
}
CreateImportVideo::CreateImportVideo(QString videoPath, QString exportPath, QObject* parent)
CreateImportVideo::CreateImportVideo(const QString& videoPath, const QString& exportPath, QObject* parent)
: QObject(parent)
{
m_videoPath = videoPath;
@ -101,7 +114,7 @@ bool CreateImportVideo::createWallpaperInfo()
// Get framerate
QJsonArray arrSteams = obj.value("streams").toArray();
if (arrSteams.size() < 1) {
if (arrSteams.empty()) {
qDebug() << "Error container does not have any video streams";
return false;
}
@ -359,4 +372,4 @@ bool CreateImportVideo::extractWallpaperAudio()
return true;
}
}

View File

@ -14,26 +14,16 @@
#include <QString>
#include <QThread>
#include <QtMath>
#include <QScopeGuard>
/*!
\class CreateImportVideo
\brief This class imports (copies) and creates wallaper previews. This
class only exsits as long as the user creates a wallpaper and gets
destroyed if the creation was successful or not.
The state get propagated via createWallpaperStateChanged(CreateImportVideo::State state);
\todo
- Maybe: Replace with QThread to avoid running QCoreApplication::processEvents();?
*/
namespace ScreenPlay {
class CreateImportVideo : public QObject {
Q_OBJECT
public:
CreateImportVideo(QObject* parent = nullptr);
explicit CreateImportVideo(QString videoPath, QString exportPath, QObject* parent = nullptr);
explicit CreateImportVideo(const QString& videoPath, const QString& exportPath, QObject* parent = nullptr);
enum class State {
Idle,
@ -91,3 +81,4 @@ public slots:
bool createWallpaperImagePreview();
bool extractWallpaperAudio();
};
}

View File

@ -9,7 +9,7 @@
- Expand filter functionality
*/
namespace ScreenPlay {
InstalledListFilter::InstalledListFilter(const shared_ptr<InstalledListModel>& ilm)
: QSortFilterProxyModel()
, m_ilm(ilm)
@ -53,3 +53,4 @@ void InstalledListFilter::resetFilter()
setFilterWildcard("*");
sort(0);
}
}

View File

@ -4,7 +4,7 @@
#include <QSortFilterProxyModel>
#include <memory>
#include "installedlistmodel.h"
namespace ScreenPlay {
using std::shared_ptr;
class InstalledListFilter : public QSortFilterProxyModel {
@ -20,3 +20,4 @@ public slots:
private:
const shared_ptr<InstalledListModel> m_ilm;
};
}

View File

@ -1,5 +1,15 @@
#include "installedlistmodel.h"
/*!
\class Installed List Model
\brief Lists all installed wallpapers, widgets etc. from a given Path
*/
namespace ScreenPlay {
InstalledListModel::InstalledListModel(QObject* parent)
: QAbstractListModel(parent)
{
@ -177,3 +187,4 @@ void InstalledListModel::reset()
m_screenPlayFiles.squeeze();
endResetModel();
}
}

View File

@ -1,7 +1,5 @@
#pragma once
#include "profilelistmodel.h"
#include "projectfile.h"
#include <QAbstractListModel>
#include <QByteArray>
#include <QDebug>
@ -19,11 +17,11 @@
#include <QVector>
#include <QtConcurrent/QtConcurrent>
/*!
\class Installed List Model
\brief Lists all installed wallpapers, widgets etc. from a given Path
*/
#include "profilelistmodel.h"
#include "projectfile.h"
namespace ScreenPlay {
class InstalledListModel : public QAbstractListModel {
Q_OBJECT
@ -65,7 +63,7 @@ public slots:
QVariantMap get(QString folderId);
void setabsoluteStoragePath(QUrl absoluteStoragePath)
void setabsoluteStoragePath(const QUrl& absoluteStoragePath)
{
if (m_absoluteStoragePath == absoluteStoragePath)
return;
@ -85,3 +83,4 @@ private:
QVector<ProjectFile> m_screenPlayFiles;
QUrl m_absoluteStoragePath;
};
}

View File

@ -1,5 +1,5 @@
#include "monitorlistmodel.h"
namespace ScreenPlay {
MonitorListModel::MonitorListModel(QObject* parent)
: QAbstractListModel(parent)
, m_qGuiApplication(static_cast<QGuiApplication*>(QGuiApplication::instance()))
@ -192,3 +192,4 @@ Monitor::Monitor(QString manufacturer, QString model, QString name, QSize size,
// because name and manufacturer are allways empty
m_id = name + "_" + QString::number(size.width()) + "x" + QString::number(size.height()) + "_" + QString::number(availableGeometry.x()) + "x" + QString::number(availableGeometry.y());
}
}

View File

@ -20,7 +20,7 @@
- Add event when monitor count changed.
*/
namespace ScreenPlay {
struct Monitor;
class MonitorListModel : public QAbstractListModel {
@ -93,3 +93,4 @@ struct Monitor {
QScreen* m_screen = nullptr;
};
}

View File

@ -9,11 +9,16 @@
See Profile List Model for more details
*/
namespace ScreenPlay {
struct Profile {
Profile() {}
Profile(QUrl absolutePath, QString id, QString version, QString wallpaperId, QRect rect, bool isLooping)
Profile(const QUrl& absolutePath,
const QString& id,
const QString& version,
const QString& wallpaperId,
const QRect& rect,
const bool isLooping)
{
m_absolutePath = absolutePath;
m_id = id;
@ -30,3 +35,4 @@ struct Profile {
QRect m_rect;
bool m_isLooping = true;
};
}

View File

@ -6,6 +6,8 @@
#include <QJsonObject>
#include <QPair>
namespace ScreenPlay {
ProfileListModel::ProfileListModel(QObject* parent)
: QAbstractListModel(parent)
{
@ -112,3 +114,4 @@ bool ProfileListModel::getProfileByName(QString id, Profile* profile)
}
return false;
}
}

View File

@ -17,7 +17,7 @@
- Add a profile for a combination of active wallpaper and widgets!
*/
namespace ScreenPlay {
struct Profile;
class ProfileListModel : public QAbstractListModel {
@ -42,3 +42,4 @@ private:
QHash<int, QByteArray> m_roleNames;
QVector<Profile> m_profileList;
};
}

View File

@ -11,10 +11,14 @@
\brief In ScreenPlay every Wallpaper, Scene or Widget has an project.json to store its configuration
*/
namespace ScreenPlay {
struct ProjectFile {
ProjectFile(QJsonObject obj, QString folderName, QUrl absolutePath)
ProjectFile(const QJsonObject& obj,
const QString& folderName,
const QUrl& absolutePath)
{
if (obj.contains("description"))
@ -72,3 +76,4 @@ struct ProjectFile {
QVariantList m_tags; //TODO: Implement me!
};
}

View File

@ -9,10 +9,14 @@
*/
namespace ScreenPlay {
struct ProjectSettingsListItem {
ProjectSettingsListItem(QString name, bool isHeadline, QVariant value)
ProjectSettingsListItem(
const QString& name,
const bool isHeadline,
const QVariant& value)
{
m_name = name;
m_isHeadline = isHeadline;
@ -24,3 +28,4 @@ struct ProjectSettingsListItem {
bool m_isHeadline;
QVariant m_value;
};
}

View File

@ -1,5 +1,5 @@
#include "projectsettingslistmodel.h"
namespace ScreenPlay {
ProjectSettingsListModel::ProjectSettingsListModel(QString file, QObject* parent)
: QAbstractListModel(parent)
{
@ -98,3 +98,4 @@ void ProjectSettingsListModel::append(QString name, bool isHeadline, QVariant va
endInsertRows();
}
}

View File

@ -17,7 +17,7 @@
\brief Reads the project.json for every Wallpaper, Scene or Widget "general" object and displays it for the user to modify
*/
namespace ScreenPlay {
class ProjectSettingsListModel : public QAbstractListModel {
Q_OBJECT
@ -43,3 +43,4 @@ public slots:
private:
QVector<ProjectSettingsListItem> m_projectSettings;
};
}

View File

@ -2,6 +2,17 @@
#include <QProcess>
namespace ScreenPlay {
/*!
\class Global QML Utilities
\brief Easy to use global object to use to:
\list
\i Navigate the main menu
\i Open Explorer at a given path
\endlist
*/
QMLUtilities::QMLUtilities(QObject* parent)
: QObject(parent)
{
@ -29,11 +40,11 @@ QString QMLUtilities::fixWindowsPath(QString url)
void QMLUtilities::openFolderInExplorer(QString url)
{
QProcess explorer;
#ifdef Q_OS_WIN
#ifdef Q_OS_WIN
explorer.setProgram("explorer.exe");
#elif defined(Q_OS_OSX)
#elif defined(Q_OS_OSX)
explorer.setProgram("open");
#endif
#endif
QStringList args;
args.append(QDir::toNativeSeparators(url));
explorer.setArguments(args);
@ -98,3 +109,4 @@ void QMLUtilities::QMLUtilities::requestAllLDataProtection()
});
}
}

View File

@ -8,14 +8,7 @@
#include <QString>
#include <QtConcurrent/QtConcurrent>
/*!
\class Global QML Utilities
\brief Easy to use global object to use to:
\list
\i Navigate the main menu
\i Open Explorer at a given path
\endlist
*/
namespace ScreenPlay {
class QMLUtilities : public QObject {
Q_OBJECT
@ -41,3 +34,4 @@ public slots:
QString fixWindowsPath(QString url);
};
}

View File

@ -1,6 +1,8 @@
#include "screenplay.h"
#include "screenplaymanager.h"
ScreenPlay::ScreenPlay(const shared_ptr<InstalledListModel>& ilm,
namespace ScreenPlay {
ScreenPlayManager::ScreenPlayManager(const shared_ptr<InstalledListModel>& ilm,
const shared_ptr<Settings>& settings,
const shared_ptr<MonitorListModel>& mlm,
const shared_ptr<SDKConnector>& sdkc,
@ -14,7 +16,7 @@ ScreenPlay::ScreenPlay(const shared_ptr<InstalledListModel>& ilm,
{
}
void ScreenPlay::createWallpaper(
void ScreenPlayManager::createWallpaper(
const int monitorIndex, QUrl absoluteStoragePath,
const QString& previewImage, const float volume,
const QString& fillMode, const QString& type)
@ -44,7 +46,7 @@ void ScreenPlay::createWallpaper(
m_settings->saveWallpaperToConfig(monitorIndex, absoluteStoragePath, type);
}
void ScreenPlay::createWidget(QUrl absoluteStoragePath, const QString& previewImage)
void ScreenPlayManager::createWidget(QUrl absoluteStoragePath, const QString& previewImage)
{
ProjectFile project {};
@ -62,7 +64,7 @@ void ScreenPlay::createWidget(QUrl absoluteStoragePath, const QString& previewIm
this));
}
void ScreenPlay::removeAllWallpaper()
void ScreenPlayManager::removeAllWallpaper()
{
if (m_settings && !m_screenPlayWallpapers.empty()) {
m_sdkconnector->closeAllWallpapers();
@ -73,7 +75,7 @@ void ScreenPlay::removeAllWallpaper()
return;
}
void ScreenPlay::requestProjectSettingsListModelAt(const int index)
void ScreenPlayManager::requestProjectSettingsListModelAt(const int index)
{
for (const unique_ptr<ScreenPlayWallpaper>& uPtrWallpaper : m_screenPlayWallpapers) {
if (!uPtrWallpaper->screenNumber().empty() && uPtrWallpaper->screenNumber()[0] == index) { // ??? only at index == 0
@ -86,7 +88,7 @@ void ScreenPlay::requestProjectSettingsListModelAt(const int index)
emit projectSettingsListModelNotFound();
}
void ScreenPlay::setWallpaperValue(const int at, const QString& key, const QString& value)
void ScreenPlayManager::setWallpaperValue(const int at, const QString& key, const QString& value)
{
Q_ASSERT(static_cast<size_t>(at) < m_screenPlayWallpapers.size() && m_sdkconnector);
for (const unique_ptr<ScreenPlayWallpaper>& uPtrWallpaper : m_screenPlayWallpapers) {
@ -97,14 +99,14 @@ void ScreenPlay::setWallpaperValue(const int at, const QString& key, const QStri
}
}
void ScreenPlay::setAllWallpaperValue(const QString& key, const QString& value)
void ScreenPlayManager::setAllWallpaperValue(const QString& key, const QString& value)
{
for (const unique_ptr<ScreenPlayWallpaper>& uPtrWallpaper : m_screenPlayWallpapers) {
m_sdkconnector->setWallpaperValue(uPtrWallpaper->appID(), key, value);
}
}
void ScreenPlay::removeWallpaperAt(const int at)
void ScreenPlayManager::removeWallpaperAt(const int at)
{
if (m_screenPlayWallpapers.empty())
return;
@ -124,7 +126,7 @@ void ScreenPlay::removeWallpaperAt(const int at)
m_screenPlayWallpapers.erase(wallsToRemove, m_screenPlayWallpapers.end());
}
QString ScreenPlay::generateID() const
QString ScreenPlayManager::generateID() const
{
const QString possibleCharacters {
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
@ -140,3 +142,4 @@ QString ScreenPlay::generateID() const
}
return randomString;
}
}

View File

@ -22,6 +22,9 @@
\brief Used for Creation of Wallpaper, Scenes and Widgets
*/
namespace ScreenPlay {
using std::shared_ptr,
std::unique_ptr,
std::make_shared,
@ -30,18 +33,18 @@ using std::shared_ptr,
std::size_t,
std::remove_if;
class ScreenPlay final : public QObject {
class ScreenPlayManager final : public QObject {
Q_OBJECT
public:
explicit ScreenPlay(
explicit ScreenPlayManager(
const shared_ptr<InstalledListModel>& ilm,
const shared_ptr<Settings>& settings,
const shared_ptr<MonitorListModel>& mlm,
const shared_ptr<SDKConnector>& sdkc,
QObject* parent = nullptr);
~ScreenPlay() {}
~ScreenPlayManager() {}
signals:
void allWallpaperRemoved();
@ -71,3 +74,5 @@ private:
vector<unique_ptr<ScreenPlayWallpaper>> m_screenPlayWallpapers;
vector<unique_ptr<ScreenPlayWidget>> m_screenPlayWidgets;
};
}

View File

@ -4,6 +4,7 @@
\class ScreenPlayWallpaper
\brief Used for ...
*/
namespace ScreenPlay {
ScreenPlayWallpaper::ScreenPlayWallpaper(const vector<int>& screenNumber,
const shared_ptr<Settings>& settings,
@ -44,9 +45,10 @@ ScreenPlayWallpaper::ScreenPlayWallpaper(const vector<int>& screenNumber,
fillMode
};
qDebug() << "Creating ScreenPlayWallpaper " << proArgs;
//qDebug() << "Creating ScreenPlayWallpaper " << proArgs;
m_process.setArguments(proArgs);
m_process.setProgram(m_settings->screenPlayWindowPath().toString());
m_process.startDetached();
}
}

View File

@ -7,7 +7,7 @@
#include "projectsettingslistmodel.h"
#include "settings.h"
namespace ScreenPlay {
using std::shared_ptr,
std::make_shared,
std::vector,
@ -128,3 +128,4 @@ private:
QString m_type;
const shared_ptr<Settings> m_settings;
};
}

View File

@ -4,6 +4,7 @@
\class ScreenPlayWidget
\brief Used for ...
*/
namespace ScreenPlay {
ScreenPlayWidget::ScreenPlayWidget(const QString& appID, const shared_ptr<Settings>& settings,
const QString& projectPath,
@ -33,3 +34,4 @@ ScreenPlayWidget::ScreenPlayWidget(const QString& appID, const shared_ptr<Settin
});
m_process.startDetached();
}
}

View File

@ -8,7 +8,7 @@
#include <memory>
#include "settings.h"
namespace ScreenPlay {
using std::shared_ptr,
std::make_shared;
@ -97,3 +97,4 @@ private:
QProcess m_process;
const shared_ptr<Settings> m_settings;
};
}

View File

@ -2,7 +2,7 @@
#include <QJsonDocument>
#include <QJsonObject>
namespace ScreenPlay {
SDKConnector::SDKConnector(QObject* parent)
: QObject(parent)
{
@ -84,3 +84,4 @@ QLocalSocket* SDKConnection::socket() const
{
return m_socket;
}
}

View File

@ -13,6 +13,8 @@
\brief Used for every Wallpaper, Scene or Widget communication via Windows pipes/QLocalSocket
*/
namespace ScreenPlay {
class SDKConnection;
class SDKConnector : public QObject {
@ -20,8 +22,6 @@ class SDKConnector : public QObject {
public:
explicit SDKConnector(QObject* parent = nullptr);
signals:
public slots:
void readyRead();
void newConnection();
@ -130,3 +130,4 @@ private:
QString m_appID;
QVector<int> m_monitor;
};
}

View File

@ -10,6 +10,8 @@
*/
namespace ScreenPlay {
Settings::Settings(const shared_ptr<InstalledListModel>& ilm,
const shared_ptr<ProfileListModel>& plm,
const shared_ptr<MonitorListModel>& mlm,
@ -285,3 +287,4 @@ void Settings::setupWidgetAndWindowPaths()
}
#endif
}
}

View File

@ -38,7 +38,7 @@
#ifdef Q_OS_WIN
#include <qt_windows.h>
#endif
namespace ScreenPlay {
class ActiveProfile;
using std::shared_ptr,
@ -47,7 +47,7 @@ using std::shared_ptr,
class Settings : public QObject {
Q_OBJECT
Q_PROPERTY(QVersionNumber version READ version)
Q_PROPERTY(QVersionNumber version READ version )
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)
@ -131,23 +131,6 @@ public:
return m_offlineMode;
}
signals:
void autostartChanged(bool autostart);
void highPriorityStartChanged(bool highPriorityStart);
void sendStatisticsChanged(bool status);
void localStoragePathChanged(QUrl localStoragePath);
void hasWorkshopBannerSeenChanged(bool hasWorkshopBannerSeen);
void decoderChanged(QString decoder);
void setMainWindowVisible(bool visible);
void activeWallpaperCounterChanged(int activeWallpaperCounter);
void pauseWallpaperWhenIngameChanged(bool pauseWallpaperWhenIngame);
void offlineModeChanged(bool offlineMode);
public slots:
void writeSingleSettingConfig(QString name, QVariant value);
void saveWallpaperToConfig(const int monitorIndex, const QUrl& absoluteStoragePath, const QString& type);
void removeWallpaperFromConfig(const int monitorIndex);
void setqSetting(const QString& key, const QString& value);
bool autostart() const
{
@ -169,6 +152,25 @@ public slots:
return m_decoder;
}
signals:
void autostartChanged(bool autostart);
void highPriorityStartChanged(bool highPriorityStart);
void sendStatisticsChanged(bool status);
void localStoragePathChanged(QUrl localStoragePath);
void hasWorkshopBannerSeenChanged(bool hasWorkshopBannerSeen);
void decoderChanged(QString decoder);
void setMainWindowVisible(bool visible);
void activeWallpaperCounterChanged(int activeWallpaperCounter);
void pauseWallpaperWhenIngameChanged(bool pauseWallpaperWhenIngame);
void offlineModeChanged(bool offlineMode);
public slots:
void writeSingleSettingConfig(QString name, QVariant value);
void saveWallpaperToConfig(const int monitorIndex, const QUrl& absoluteStoragePath, const QString& type);
void removeWallpaperFromConfig(const int monitorIndex);
void setqSetting(const QString& key, const QString& value);
void setAutostart(bool autostart)
{
if (m_autostart == autostart)
@ -313,3 +315,4 @@ private:
QString m_decoder = "";
int m_activeWallpaperCounter = 0;
};
}