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

Formatting

This commit is contained in:
Elias Steurer 2024-10-25 17:48:43 +02:00
parent 48dac9001e
commit a46bf9a2e0
9 changed files with 96 additions and 98 deletions

View File

@ -39,8 +39,8 @@ public:
Q_INVOKABLE bool removeAllRunningWidgets(bool saveToProfile = false); Q_INVOKABLE bool removeAllRunningWidgets(bool saveToProfile = false);
Q_INVOKABLE QCoro::QmlTask removeWallpaperAt(const int timelineIndex, const QString sectionIdentifier, const int monitorIndex); Q_INVOKABLE QCoro::QmlTask removeWallpaperAt(const int timelineIndex, const QString sectionIdentifier, const int monitorIndex);
Q_INVOKABLE WallpaperData getWallpaperData(const int monitorIndex, Q_INVOKABLE WallpaperData getWallpaperData(const int monitorIndex,
const int timelineIndex, const int timelineIndex,
const QString sectionIdentifier); const QString sectionIdentifier);
Q_INVOKABLE bool moveTimelineAt( Q_INVOKABLE bool moveTimelineAt(
const int timelineIndex, const int timelineIndex,
@ -57,13 +57,13 @@ public:
Q_INVOKABLE QCoro::QmlTask setWallpaperAtTimelineIndex( Q_INVOKABLE QCoro::QmlTask setWallpaperAtTimelineIndex(
const ScreenPlay::ContentTypes::InstalledType type, const ScreenPlay::ContentTypes::InstalledType type,
const QString &absolutePath, const QString& absolutePath,
const QString &previewImage, const QString& previewImage,
const QString &file, const QString& file,
const QString &title, const QString& title,
const QVector<int> &monitorIndex, const QVector<int>& monitorIndex,
const int timelineIndex, const int timelineIndex,
const QString &identifier, const QString& identifier,
const bool saveToProfilesConfigFile); const bool saveToProfilesConfigFile);
Q_INVOKABLE bool startWidget( Q_INVOKABLE bool startWidget(
@ -76,7 +76,7 @@ public:
const bool saveToProfilesConfigFile); const bool saveToProfilesConfigFile);
Q_INVOKABLE bool requestProjectSettingsAtMonitorIndex(const int index); Q_INVOKABLE bool requestProjectSettingsAtMonitorIndex(const int index);
Q_INVOKABLE QCoro::QmlTask setValueAtMonitorTimelineIndex( Q_INVOKABLE QCoro::QmlTask setValueAtMonitorTimelineIndex(
const int monitorIndex, const int monitorIndex,
const int timelineIndex, const int timelineIndex,
const QString sectionIdentifier, const QString sectionIdentifier,

View File

@ -16,13 +16,13 @@ class ScreenPlayTimelineManager : public QObject {
Q_PROPERTY(int selectedTimelineIndex READ selectedTimelineIndex WRITE setSelectedTimelineIndex NOTIFY selectedTimelineIndexChanged FINAL) Q_PROPERTY(int selectedTimelineIndex READ selectedTimelineIndex WRITE setSelectedTimelineIndex NOTIFY selectedTimelineIndexChanged FINAL)
public: public:
explicit ScreenPlayTimelineManager(QObject *parent = nullptr); explicit ScreenPlayTimelineManager(QObject* parent = nullptr);
std::shared_ptr<WallpaperTimelineSection> findActiveWallpaperTimelineSection(); std::shared_ptr<WallpaperTimelineSection> findActiveWallpaperTimelineSection();
std::shared_ptr<WallpaperTimelineSection> findTimelineSectionForCurrentTime(); std::shared_ptr<WallpaperTimelineSection> findTimelineSectionForCurrentTime();
std::shared_ptr<WallpaperTimelineSection> findTimelineSection(const int monitorIndex, std::shared_ptr<WallpaperTimelineSection> findTimelineSection(const int monitorIndex,
const int timelineIndex, const int timelineIndex,
const QString sectionIdentifier); const QString sectionIdentifier);
void startup(); void startup();
bool addTimelineFromSettings(const QJsonObject& timelineObj); bool addTimelineFromSettings(const QJsonObject& timelineObj);
@ -44,10 +44,10 @@ public:
const int timelineIndex, const int timelineIndex,
const QString& sectionIdentifier); const QString& sectionIdentifier);
QCoro::Task<bool> setValueAtMonitorTimelineIndex(const int monitorIndex, QCoro::Task<bool> setValueAtMonitorTimelineIndex(const int monitorIndex,
const int timelineIndex, const int timelineIndex,
const QString sectionIdentifier, const QString sectionIdentifier,
const QString &key, const QString& key,
const QString &value); const QString& value);
QJsonArray timelineSections(); QJsonArray timelineSections();
QJsonArray timelineWallpaperList(); QJsonArray timelineWallpaperList();
void setGlobalVariables(const std::shared_ptr<GlobalVariables>& globalVariables); void setGlobalVariables(const std::shared_ptr<GlobalVariables>& globalVariables);

View File

@ -47,16 +47,16 @@ public:
// Setters // Setters
void setIsLooping(bool value) { m_isLooping = value; } void setIsLooping(bool value) { m_isLooping = value; }
void setAbsolutePath(const QString &value) { m_absolutePath = value; } void setAbsolutePath(const QString& value) { m_absolutePath = value; }
void setPreviewImage(const QString &value) { m_previewImage = value; } void setPreviewImage(const QString& value) { m_previewImage = value; }
void setPlaybackRate(float value) { m_playbackRate = value; } void setPlaybackRate(float value) { m_playbackRate = value; }
void setVolume(float value) { m_volume = value; } void setVolume(float value) { m_volume = value; }
void setFile(const QString &value) { m_file = value; } void setFile(const QString& value) { m_file = value; }
void setProperties(const QJsonObject &value) { m_properties = value; } void setProperties(const QJsonObject& value) { m_properties = value; }
void setType(ContentTypes::InstalledType value) { m_type = value; } void setType(ContentTypes::InstalledType value) { m_type = value; }
void setFillMode(Video::FillMode value) { m_fillMode = value; } void setFillMode(Video::FillMode value) { m_fillMode = value; }
void setMonitors(const QVector<int> &value) { m_monitors = value; } void setMonitors(const QVector<int>& value) { m_monitors = value; }
void setTitle(const QString &title) { m_title = title; } void setTitle(const QString& title) { m_title = title; }
Q_INVOKABLE QString toString() const; Q_INVOKABLE QString toString() const;

View File

@ -240,8 +240,6 @@ QRect MonitorListModel::absoluteDesktopSize() const
return totalRect; return totalRect;
} }
/*! /*!
\brief Removes all items and loads them vida loadMonitors() again. \brief Removes all items and loads them vida loadMonitors() again.
*/ */

View File

@ -74,13 +74,13 @@ void ScreenPlayManager::init(
*/ */
QCoro::QmlTask ScreenPlayManager::setWallpaperAtTimelineIndex( QCoro::QmlTask ScreenPlayManager::setWallpaperAtTimelineIndex(
const ScreenPlay::ContentTypes::InstalledType type, const ScreenPlay::ContentTypes::InstalledType type,
const QString &absolutePath, const QString& absolutePath,
const QString &previewImage, const QString& previewImage,
const QString &file, const QString& file,
const QString &title, const QString& title,
const QVector<int> &monitorIndex, const QVector<int>& monitorIndex,
const int timelineIndex, const int timelineIndex,
const QString &identifier, const QString& identifier,
const bool saveToProfilesConfigFile) const bool saveToProfilesConfigFile)
{ {
WallpaperData wallpaperData; WallpaperData wallpaperData;
@ -130,7 +130,7 @@ QCoro::QmlTask ScreenPlayManager::setWallpaperAtTimelineIndex(
// ScreenPlayTimelineManager::checkActiveWallpaperTimeline decide // ScreenPlayTimelineManager::checkActiveWallpaperTimeline decide
// if the wallpaper // if the wallpaper
requestSaveProfiles(); requestSaveProfiles();
co_return Result{success}; co_return Result { success };
}); });
co_return result; co_return result;
}()); }());
@ -282,10 +282,10 @@ QCoro::QmlTask ScreenPlayManager::setValueAtMonitorTimelineIndex(
[this, monitorIndex, timelineIndex, sectionIdentifier, key, value]() -> QCoro::Task<Result> { [this, monitorIndex, timelineIndex, sectionIdentifier, key, value]() -> QCoro::Task<Result> {
auto result = co_await m_screenPlayTimelineManager auto result = co_await m_screenPlayTimelineManager
.setValueAtMonitorTimelineIndex(monitorIndex, .setValueAtMonitorTimelineIndex(monitorIndex,
timelineIndex, timelineIndex,
sectionIdentifier, sectionIdentifier,
key, key,
value) value)
.then([this](bool success) -> QCoro::Task<Result> { .then([this](bool success) -> QCoro::Task<Result> {
qDebug() << "Task: setValueAtMonitorTimelineIndex" << success; qDebug() << "Task: setValueAtMonitorTimelineIndex" << success;
if (success) { if (success) {
@ -293,7 +293,7 @@ QCoro::QmlTask ScreenPlayManager::setValueAtMonitorTimelineIndex(
selectedTimelineIndex()); selectedTimelineIndex());
emit requestSaveProfiles(); emit requestSaveProfiles();
} }
co_return Result{success}; co_return Result { success };
}); });
co_return result; co_return result;
}()); }());
@ -318,10 +318,10 @@ QCoro::QmlTask ScreenPlayManager::setWallpaperFillModeAtMonitorIndex(
[this, monitorIndex, timelineIndex, sectionIdentifier, key, value]() -> QCoro::Task<Result> { [this, monitorIndex, timelineIndex, sectionIdentifier, key, value]() -> QCoro::Task<Result> {
auto result = co_await m_screenPlayTimelineManager auto result = co_await m_screenPlayTimelineManager
.setValueAtMonitorTimelineIndex(monitorIndex, .setValueAtMonitorTimelineIndex(monitorIndex,
timelineIndex, timelineIndex,
sectionIdentifier, sectionIdentifier,
key, key,
value) value)
.then([this](bool success) -> QCoro::Task<Result> { .then([this](bool success) -> QCoro::Task<Result> {
qDebug() << "Task: setValueAtMonitorTimelineIndex" << success; qDebug() << "Task: setValueAtMonitorTimelineIndex" << success;
if (success) { if (success) {
@ -329,7 +329,7 @@ QCoro::QmlTask ScreenPlayManager::setWallpaperFillModeAtMonitorIndex(
selectedTimelineIndex()); selectedTimelineIndex());
emit requestSaveProfiles(); emit requestSaveProfiles();
} }
co_return Result{success}; co_return Result { success };
}); });
co_return result; co_return result;
}()); }());
@ -356,16 +356,16 @@ bool ScreenPlayManager::setAllWallpaperValue(const QString& key, const QString&
This function is only used in QML. This function is only used in QML.
*/ */
WallpaperData ScreenPlayManager::getWallpaperData(const int monitorIndex, WallpaperData ScreenPlayManager::getWallpaperData(const int monitorIndex,
const int timelineIndex, const int timelineIndex,
const QString sectionIdentifier) const QString sectionIdentifier)
{ {
auto timelineSection = m_screenPlayTimelineManager.findTimelineSection(monitorIndex, auto timelineSection = m_screenPlayTimelineManager.findTimelineSection(monitorIndex,
timelineIndex, timelineIndex,
sectionIdentifier); sectionIdentifier);
if (!timelineSection) { if (!timelineSection) {
return {}; return {};
} }
for (auto &wallpaperData : timelineSection->wallpaperDataList) { for (auto& wallpaperData : timelineSection->wallpaperDataList) {
if (wallpaperData.monitors().first() == monitorIndex) { if (wallpaperData.monitors().first() == monitorIndex) {
// TODO COPY? // TODO COPY?
return wallpaperData; return wallpaperData;

View File

@ -69,7 +69,7 @@ ScreenPlayTimelineManager::findTimelineSectionForCurrentTime()
std::shared_ptr<WallpaperTimelineSection> ScreenPlayTimelineManager::findTimelineSection( std::shared_ptr<WallpaperTimelineSection> ScreenPlayTimelineManager::findTimelineSection(
const int monitorIndex, const int timelineIndex, const QString sectionIdentifier) const int monitorIndex, const int timelineIndex, const QString sectionIdentifier)
{ {
for (const auto &section : m_wallpaperTimelineSectionsList) { for (const auto& section : m_wallpaperTimelineSectionsList) {
if (section->identifier == sectionIdentifier && section->index == timelineIndex) { if (section->identifier == sectionIdentifier && section->index == timelineIndex) {
return section; return section;
} }
@ -196,13 +196,13 @@ void ScreenPlayTimelineManager::checkActiveWallpaperTimeline()
} }
} }
std::optional<std::shared_ptr<WallpaperTimelineSection>> ScreenPlayTimelineManager::wallpaperSection(const int timelineIndex, const QString &sectionIdentifier) std::optional<std::shared_ptr<WallpaperTimelineSection>> ScreenPlayTimelineManager::wallpaperSection(const int timelineIndex, const QString& sectionIdentifier)
{ {
for (const auto& section : m_wallpaperTimelineSectionsList) { for (const auto& section : m_wallpaperTimelineSectionsList) {
const bool indexMatches = section->index == timelineIndex; const bool indexMatches = section->index == timelineIndex;
const bool sectionIdentifierMatches = section->identifier == sectionIdentifier; const bool sectionIdentifierMatches = section->identifier == sectionIdentifier;
if (indexMatches && sectionIdentifierMatches) { if (indexMatches && sectionIdentifierMatches) {
return {section}; return { section };
} }
} }
qCritical() << "No matching timeline for index:" << timelineIndex << "sectionIdentifier: " << sectionIdentifier; qCritical() << "No matching timeline for index:" << timelineIndex << "sectionIdentifier: " << sectionIdentifier;
@ -311,13 +311,13 @@ void ScreenPlayTimelineManager::updateMonitorListModelData(const int selectedTim
if (wallpaper->monitors().contains(monitorIndex)) { if (wallpaper->monitors().contains(monitorIndex)) {
const auto& wallpaperData = wallpaper->wallpaperData(); const auto& wallpaperData = wallpaper->wallpaperData();
const auto previewImg = wallpaperData.absolutePath() + "/" const auto previewImg = wallpaperData.absolutePath() + "/"
+ wallpaperData.previewImage(); + wallpaperData.previewImage();
m_monitorListModel->setData(modelIndex, wallpaper->appID(), (int)MonitorListModel::MonitorRole::AppID); m_monitorListModel->setData(modelIndex, wallpaper->appID(), (int)MonitorListModel::MonitorRole::AppID);
m_monitorListModel->setData(modelIndex, (int)wallpaper->state(), (int)MonitorListModel::MonitorRole::AppState); m_monitorListModel->setData(modelIndex, (int)wallpaper->state(), (int)MonitorListModel::MonitorRole::AppState);
m_monitorListModel->setData(modelIndex, previewImg, (int)MonitorListModel::MonitorRole::PreviewImage); m_monitorListModel->setData(modelIndex, previewImg, (int)MonitorListModel::MonitorRole::PreviewImage);
m_monitorListModel->setData(modelIndex, m_monitorListModel->setData(modelIndex,
(int) wallpaperData.type(), (int)wallpaperData.type(),
(int) MonitorListModel::MonitorRole::InstalledType); (int)MonitorListModel::MonitorRole::InstalledType);
return true; return true;
} }
} }
@ -328,15 +328,15 @@ void ScreenPlayTimelineManager::updateMonitorListModelData(const int selectedTim
for (const auto& wallpaperData : timeline->wallpaperDataList) { for (const auto& wallpaperData : timeline->wallpaperDataList) {
if (wallpaperData.monitors().contains(monitorIndex)) { if (wallpaperData.monitors().contains(monitorIndex)) {
const auto previewImg = wallpaperData.absolutePath() + "/" const auto previewImg = wallpaperData.absolutePath() + "/"
+ wallpaperData.previewImage(); + wallpaperData.previewImage();
m_monitorListModel->setData(modelIndex, m_monitorListModel->setData(modelIndex,
wallpaperData.file(), wallpaperData.file(),
(int) MonitorListModel::MonitorRole::AppID); (int)MonitorListModel::MonitorRole::AppID);
m_monitorListModel->setData(modelIndex, (int)timeline->state, (int)MonitorListModel::MonitorRole::AppState); m_monitorListModel->setData(modelIndex, (int)timeline->state, (int)MonitorListModel::MonitorRole::AppState);
m_monitorListModel->setData(modelIndex, previewImg, (int)MonitorListModel::MonitorRole::PreviewImage); m_monitorListModel->setData(modelIndex, previewImg, (int)MonitorListModel::MonitorRole::PreviewImage);
m_monitorListModel->setData(modelIndex, m_monitorListModel->setData(modelIndex,
(int) wallpaperData.type(), (int)wallpaperData.type(),
(int) MonitorListModel::MonitorRole::InstalledType); (int)MonitorListModel::MonitorRole::InstalledType);
return true; return true;
} }
} }
@ -667,11 +667,11 @@ QCoro::Task<bool> ScreenPlayTimelineManager::setValueAtMonitorTimelineIndex(
const int monitorIndex, const int monitorIndex,
const int timelineIndex, const int timelineIndex,
const QString sectionIdentifier, const QString sectionIdentifier,
const QString &key, const QString& key,
const QString &value) const QString& value)
{ {
auto wallpaperSectionOpt = wallpaperSection(timelineIndex, sectionIdentifier); auto wallpaperSectionOpt = wallpaperSection(timelineIndex, sectionIdentifier);
if(!wallpaperSectionOpt.has_value()) if (!wallpaperSectionOpt.has_value())
co_return false; co_return false;
auto wallpaperSection = wallpaperSectionOpt.value(); auto wallpaperSection = wallpaperSectionOpt.value();
@ -693,15 +693,15 @@ QCoro::Task<bool> ScreenPlayTimelineManager::setValueAtMonitorTimelineIndex(
} }
// Skip when the values was changed on an not running wallpaper // Skip when the values was changed on an not running wallpaper
if(!found){ if (!found) {
co_return true; co_return true;
} }
// Now set the value in the ScreenPlayWallpaper class so it does // Now set the value in the ScreenPlayWallpaper class so it does
// get propagated to the running wallpaper. // get propagated to the running wallpaper.
for (auto &activeWallpaper : wallpaperSection->activeWallpaperList) { for (auto& activeWallpaper : wallpaperSection->activeWallpaperList) {
if(activeWallpaper->monitors().contains(monitorIndex)){ if (activeWallpaper->monitors().contains(monitorIndex)) {
activeWallpaper->setWallpaperValue(key,value); activeWallpaper->setWallpaperValue(key, value);
} }
} }
@ -722,15 +722,15 @@ QCoro::Task<bool> ScreenPlayTimelineManager::setWallpaperAtTimelineIndex(
// Check if we already have a wallpaper at the same position or on one or more of the specified monitors // Check if we already have a wallpaper at the same position or on one or more of the specified monitors
auto it = std::find_if(timelineSection->wallpaperDataList.begin(), auto it = std::find_if(timelineSection->wallpaperDataList.begin(),
timelineSection->wallpaperDataList.end(), timelineSection->wallpaperDataList.end(),
[&wallpaperData](const WallpaperData &existingWallpaper) { [&wallpaperData](const WallpaperData& existingWallpaper) {
return std::any_of(wallpaperData.monitors().begin(), return std::any_of(wallpaperData.monitors().begin(),
wallpaperData.monitors().end(), wallpaperData.monitors().end(),
[&existingWallpaper](int monitor) { [&existingWallpaper](int monitor) {
return existingWallpaper.monitors() return existingWallpaper.monitors()
.contains(monitor); .contains(monitor);
}); });
}); });
if (it != timelineSection->wallpaperDataList.end()) { if (it != timelineSection->wallpaperDataList.end()) {
// TODO // TODO

View File

@ -33,7 +33,7 @@ ScreenPlayWallpaper::ScreenPlayWallpaper(
{ {
Util util; Util util;
std::optional<QJsonObject> projectOpt = util.openJsonFileToObject(m_wallpaperData.absolutePath() std::optional<QJsonObject> projectOpt = util.openJsonFileToObject(m_wallpaperData.absolutePath()
+ "/project.json"); + "/project.json");
if (projectOpt.has_value()) { if (projectOpt.has_value()) {
m_projectJson = projectOpt.value(); m_projectJson = projectOpt.value();
} }
@ -44,7 +44,7 @@ ScreenPlayWallpaper::ScreenPlayWallpaper(
} else { } else {
if (m_wallpaperData.properties().isEmpty()) { if (m_wallpaperData.properties().isEmpty()) {
if (auto obj = util.openJsonFileToObject(m_wallpaperData.absolutePath() if (auto obj = util.openJsonFileToObject(m_wallpaperData.absolutePath()
+ "/project.json")) { + "/project.json")) {
if (obj->contains("properties")) if (obj->contains("properties"))
projectSettingsListModelProperties = obj->value("properties").toObject(); projectSettingsListModelProperties = obj->value("properties").toObject();
} }
@ -75,22 +75,22 @@ ScreenPlayWallpaper::ScreenPlayWallpaper(
const QString screens = "{" + tmpScreenNumber + "}"; const QString screens = "{" + tmpScreenNumber + "}";
m_appArgumentsList = QStringList{"--screens", m_appArgumentsList = QStringList { "--screens",
screens, screens,
"--projectpath", "--projectpath",
m_wallpaperData.absolutePath(), m_wallpaperData.absolutePath(),
"--appID", "--appID",
m_appID, m_appID,
"--volume", "--volume",
QString::number(static_cast<double>(m_wallpaperData.volume())), QString::number(static_cast<double>(m_wallpaperData.volume())),
"--fillmode", "--fillmode",
QVariant::fromValue(m_wallpaperData.fillMode()).toString(), QVariant::fromValue(m_wallpaperData.fillMode()).toString(),
"--type", "--type",
QVariant::fromValue(m_wallpaperData.type()).toString(), QVariant::fromValue(m_wallpaperData.type()).toString(),
"--check", "--check",
QString::number(m_settings->checkWallpaperVisible()), QString::number(m_settings->checkWallpaperVisible()),
"--mainapppid", "--mainapppid",
QString::number(m_processManager.getCurrentPID())}; QString::number(m_processManager.getCurrentPID()) };
// Fixes issue 84 media key overlay in Qt apps // Fixes issue 84 media key overlay in Qt apps
if (m_wallpaperData.type() != ContentTypes::InstalledType::GodotWallpaper) { if (m_wallpaperData.type() != ContentTypes::InstalledType::GodotWallpaper) {

View File

@ -133,7 +133,7 @@ std::optional<ScreenPlay::WallpaperData> ScreenPlay::WallpaperData::loadTimeline
wallpaperData.setType( wallpaperData.setType(
QStringToEnum<ContentTypes::InstalledType>(typeString, QStringToEnum<ContentTypes::InstalledType>(typeString,
ContentTypes::InstalledType::VideoWallpaper)); ContentTypes::InstalledType::VideoWallpaper));
wallpaperData.setFillMode( wallpaperData.setFillMode(
QStringToEnum<Video::FillMode>(fillModeString, Video::FillMode::Cover)); QStringToEnum<Video::FillMode>(fillModeString, Video::FillMode::Cover));

View File

@ -158,9 +158,9 @@ QCoro::Task<bool> WallpaperTimelineSection::removeWallpaper(const int monitorInd
{ {
// Remove WallpaperData first // Remove WallpaperData first
size_t removedCount = std::erase_if(wallpaperDataList, size_t removedCount = std::erase_if(wallpaperDataList,
[monitorIndex](const auto &wallpaperData) { [monitorIndex](const auto& wallpaperData) {
return wallpaperData.monitors().contains(monitorIndex); return wallpaperData.monitors().contains(monitorIndex);
}); });
if (removedCount == 0) { if (removedCount == 0) {
qCritical() << "No wallpaper data found for monitor index:" << monitorIndex; qCritical() << "No wallpaper data found for monitor index:" << monitorIndex;
co_return false; co_return false;