mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-11-25 04:02:50 +01:00
WIP: Move timeline and wallpaper data into dedicated files
Change initial stop position to sections this provides more informations
This commit is contained in:
parent
a71b3ea53e
commit
7831290365
@ -10,6 +10,9 @@ include(GenerateCMakeVariableHeader)
|
||||
|
||||
set(SOURCES
|
||||
# cmake-format: sort
|
||||
src/wallpaperdata.cpp
|
||||
src/wallpapertimelinesection.cpp
|
||||
src/screenplaytimeline.cpp
|
||||
src/app.cpp
|
||||
src/applicationengine.cpp
|
||||
src/create.cpp
|
||||
@ -29,6 +32,9 @@ set(SOURCES
|
||||
|
||||
set(HEADER
|
||||
# cmake-format: sort
|
||||
inc/public/ScreenPlay/wallpaperdata.h
|
||||
inc/public/ScreenPlay/wallpapertimelinesection.h
|
||||
inc/public/ScreenPlay/screenplaytimeline.h
|
||||
inc/public/ScreenPlay/app.h
|
||||
inc/public/ScreenPlay/applicationengine.h
|
||||
inc/public/ScreenPlay/create.h
|
||||
@ -56,7 +62,6 @@ set(QML
|
||||
qml/Components/LineHandle.qml
|
||||
qml/Components/LineIndicator.qml
|
||||
qml/Components/ScreenPlayProPopup.qml
|
||||
qml/Components/Section.qml
|
||||
qml/Components/Timeline.qml
|
||||
qml/Community/CommunityNavItem.qml
|
||||
qml/Community/CommunityView.qml
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include <QVector>
|
||||
|
||||
#include "ScreenPlay/screenplaywallpaper.h"
|
||||
#include "ScreenPlay/wallpapertimelinesection.h"
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
#include <qt_windows.h>
|
||||
@ -33,7 +34,6 @@ struct Monitor {
|
||||
|
||||
int m_index { 0 };
|
||||
QRect m_geometry;
|
||||
std::shared_ptr<ScreenPlayWallpaper> m_activeWallpaper { nullptr };
|
||||
};
|
||||
|
||||
class MonitorListModel : public QAbstractListModel {
|
||||
@ -56,24 +56,21 @@ public:
|
||||
|
||||
QHash<int, QByteArray> roleNames() const override;
|
||||
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
|
||||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
|
||||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
|
||||
|
||||
void setWallpaperMonitor(
|
||||
const std::shared_ptr<ScreenPlayWallpaper>& wallpaper,
|
||||
void setWallpaperMonitor(const std::shared_ptr<WallpaperTimelineSection>& timelineSection,
|
||||
const QVector<int> monitors);
|
||||
|
||||
std::optional<QString> getAppIDByMonitorIndex(const int index) const;
|
||||
Q_INVOKABLE void reset();
|
||||
Q_INVOKABLE QRect absoluteDesktopSize() const;
|
||||
|
||||
signals:
|
||||
void monitorReloadCompleted();
|
||||
void setNewActiveMonitor(int index, QString path);
|
||||
void monitorConfigurationChanged();
|
||||
|
||||
public slots:
|
||||
void reset();
|
||||
void clearActiveWallpaper();
|
||||
void closeWallpaper(const QString& appID);
|
||||
QRect absoluteDesktopSize() const;
|
||||
private slots:
|
||||
|
||||
void screenAdded(QScreen* screen)
|
||||
{
|
||||
@ -91,6 +88,7 @@ private:
|
||||
|
||||
private:
|
||||
QVector<Monitor> m_monitorList;
|
||||
std::shared_ptr<WallpaperTimelineSection> m_activeTimelineSection;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -7,22 +7,20 @@
|
||||
#include <QProcess>
|
||||
#include <QVariantMap>
|
||||
|
||||
#include "ScreenPlayUtil/projectfile.h"
|
||||
#include "ScreenPlay/screenplaytimeline.h"
|
||||
#include "ScreenPlayUtil/util.h"
|
||||
#include "globalvariables.h"
|
||||
#include "installedlistmodel.h"
|
||||
#include "monitorlistmodel.h"
|
||||
#include "profilelistmodel.h"
|
||||
#include "projectsettingslistmodel.h"
|
||||
#include "screenplaywallpaper.h"
|
||||
#include "screenplaywidget.h"
|
||||
#include "settings.h"
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
|
||||
namespace ScreenPlay {
|
||||
|
||||
|
||||
|
||||
class ScreenPlayManager : public QObject {
|
||||
Q_OBJECT
|
||||
QML_ELEMENT
|
||||
@ -66,7 +64,7 @@ public:
|
||||
QString identifier);
|
||||
Q_INVOKABLE void removeAllTimlineSections();
|
||||
Q_INVOKABLE bool removeTimelineAt(const int index);
|
||||
Q_INVOKABLE QVariantMap initialStopPositions();
|
||||
Q_INVOKABLE QJsonArray initialSectionsList();
|
||||
Q_INVOKABLE bool setWallpaperAtTimelineIndex(
|
||||
const ScreenPlay::ContentTypes::InstalledType type,
|
||||
const QString& absolutePath,
|
||||
@ -91,9 +89,7 @@ public:
|
||||
Q_INVOKABLE bool setWallpaperFillModeAtMonitorIndex(const int index, const int fillmode);
|
||||
Q_INVOKABLE bool setAllWallpaperValue(const QString& key, const QString& value);
|
||||
Q_INVOKABLE bool setWallpaperValue(const QString& appID, const QString& key, const QString& value);
|
||||
|
||||
|
||||
signals:
|
||||
signals:
|
||||
void activeWallpaperCounterChanged(int activeWallpaperCounter);
|
||||
void activeWidgetsCounterChanged(int activeWidgetsCounter);
|
||||
void monitorConfigurationChanged();
|
||||
@ -112,31 +108,25 @@ private slots:
|
||||
void setActiveWallpaperCounter(int activeWallpaperCounter);
|
||||
void setActiveWidgetsCounter(int activeWidgetsCounter);
|
||||
|
||||
|
||||
private:
|
||||
void printTimelines();
|
||||
bool loadProfiles();
|
||||
void updateQmlTimelines();
|
||||
|
||||
void updateIndices();
|
||||
bool loadWidgetConfig(const QJsonObject& widget);
|
||||
std::optional<WallpaperData> loadWallpaperConfig(const QJsonObject& wallpaper);
|
||||
bool checkIsAnotherScreenPlayInstanceRunning();
|
||||
bool removeWallpaper(const QString& appID);
|
||||
bool removeWidget(const QString& appID);
|
||||
std::optional<std::shared_ptr<WallpaperTimelineSection>> loadTimelineWallpaperConfig(const QJsonObject& timelineObj);
|
||||
std::shared_ptr<WallpaperTimelineSection> findActiveWallpaperTimelineSection();
|
||||
std::shared_ptr<WallpaperTimelineSection> getCurrentTimeline();
|
||||
void activateNewTimeline();
|
||||
|
||||
private:
|
||||
bool loadWidgetConfig(const QJsonObject& widget);
|
||||
std::shared_ptr<GlobalVariables> m_globalVariables;
|
||||
std::shared_ptr<MonitorListModel> m_monitorListModel;
|
||||
std::shared_ptr<Settings> m_settings;
|
||||
std::unique_ptr<QLocalServer> m_server;
|
||||
|
||||
QVector<std::shared_ptr<WallpaperTimelineSection>> m_wallpaperTimelineSectionsList;
|
||||
QVector<std::shared_ptr<ScreenPlayWidget>> m_screenPlayWidgets;
|
||||
std::vector<std::unique_ptr<SDKConnection>> m_unconnectedClients;
|
||||
ScreenPlayTimeline m_screenPlayTimeline;
|
||||
|
||||
int m_activeWallpaperCounter { 0 };
|
||||
int m_activeWidgetsCounter { 0 };
|
||||
@ -146,8 +136,7 @@ private:
|
||||
|
||||
Util m_util;
|
||||
|
||||
// We use a 24 hour system
|
||||
const QString m_timelineTimeFormat = "hh:mm:ss";
|
||||
const quint16 m_webSocketPort = 16395;
|
||||
};
|
||||
|
||||
}
|
||||
|
37
ScreenPlay/inc/public/ScreenPlay/screenplaytimeline.h
Normal file
37
ScreenPlay/inc/public/ScreenPlay/screenplaytimeline.h
Normal file
@ -0,0 +1,37 @@
|
||||
// SPDX-License-Identifier: LicenseRef-EliasSteurerTachiom OR AGPL-3.0-only
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QFileInfoList>
|
||||
#include <QJsonObject>
|
||||
#include <QObject>
|
||||
#include <QProcess>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <memory>
|
||||
|
||||
#include "ScreenPlay/wallpapertimelinesection.h"
|
||||
|
||||
namespace ScreenPlay {
|
||||
|
||||
|
||||
struct ScreenPlayTimeline{
|
||||
|
||||
|
||||
float calculateRelativePosition(const QTime& endTime);
|
||||
|
||||
std::optional<std::shared_ptr<WallpaperTimelineSection>> loadTimelineWallpaperConfig(const QJsonObject& timelineObj);
|
||||
std::shared_ptr<WallpaperTimelineSection> findActiveWallpaperTimelineSection();
|
||||
std::optional<std::shared_ptr<WallpaperTimelineSection>> activeWallpaperSectionByAppID(const QString& appID);
|
||||
std::shared_ptr<WallpaperTimelineSection> getCurrentTimeline();
|
||||
|
||||
|
||||
QVector<std::shared_ptr<WallpaperTimelineSection>> m_wallpaperTimelineSectionsList;
|
||||
|
||||
// We use a24 hour system
|
||||
const QString m_timelineTimeFormat = "hh:mm:ss";
|
||||
};
|
||||
|
||||
}
|
@ -17,77 +17,12 @@
|
||||
#include "ScreenPlay/sdkconnection.h"
|
||||
#include "ScreenPlay/settings.h"
|
||||
#include "ScreenPlayUtil/processmanager.h"
|
||||
#include "ScreenPlay/wallpaperdata.h"
|
||||
#include "ScreenPlay/wallpapertimelinesection.h"
|
||||
|
||||
|
||||
namespace ScreenPlay {
|
||||
|
||||
struct WallpaperData {
|
||||
bool isLooping = false;
|
||||
QString absolutePath;
|
||||
QString previewImage;
|
||||
float playbackRate = {};
|
||||
float volume = {};
|
||||
QString file;
|
||||
QJsonObject properties;
|
||||
ContentTypes::InstalledType type = ContentTypes::InstalledType::Unknown;
|
||||
Video::FillMode fillMode = Video::FillMode::Fill;
|
||||
QVector<int> monitors;
|
||||
QJsonObject serialize() const
|
||||
{
|
||||
QJsonObject data;
|
||||
data.insert("isLooping", isLooping);
|
||||
data.insert("absolutePath", absolutePath);
|
||||
data.insert("previewImage", previewImage);
|
||||
data.insert("playbackRate", playbackRate);
|
||||
data.insert("volume", volume);
|
||||
data.insert("file", file);
|
||||
data.insert("properties", properties);
|
||||
data.insert("type", QVariant::fromValue(type).toString());
|
||||
data.insert("fillMode", QVariant::fromValue(fillMode).toString());
|
||||
|
||||
// Serialize QVector<int> monitors
|
||||
QJsonArray monitorArray;
|
||||
for (int monitor : monitors) {
|
||||
monitorArray.append(monitor);
|
||||
}
|
||||
data.insert("monitors", monitorArray);
|
||||
|
||||
return data;
|
||||
}
|
||||
};
|
||||
|
||||
class ScreenPlayWallpaper;
|
||||
// Represents one line in the UI. ScreenPlayManager has a list of
|
||||
// WallpaperTimeline. Only the active timeline section has
|
||||
// a filled vector of ScreenPlayWallpaper
|
||||
struct WallpaperTimelineSection {
|
||||
// Is active is needed as an additional flag during switching.
|
||||
// When timeline A is no longer in the time range, then we can
|
||||
// use this flag to know that it was the last active timeline and
|
||||
// remove all active wallpaper.
|
||||
bool isActive = false;
|
||||
|
||||
QString identifier;
|
||||
int index = 0; // Needed to check
|
||||
float relativePosition = 0.0f;
|
||||
QTime startTime;
|
||||
QTime endTime;
|
||||
// Data from the profiles.json that we need when we
|
||||
// enable this section of the pipeline. We keep a copy
|
||||
// here when this timeline needs to become active
|
||||
std::vector<WallpaperData> wallpaperData;
|
||||
// All active wallpaper.
|
||||
std::vector<std::shared_ptr<ScreenPlayWallpaper>> activeWallpaperList;
|
||||
|
||||
// Check if currentTime falls within the timeline section
|
||||
bool containsTime(const QTime& time) const
|
||||
{
|
||||
if (endTime < startTime) { // Timeline spans midnight
|
||||
return (time >= startTime || time < endTime);
|
||||
} else {
|
||||
return (time >= startTime && time < endTime);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class ScreenPlayWallpaper : public QObject {
|
||||
Q_OBJECT
|
||||
@ -295,5 +230,8 @@ private:
|
||||
// while exiting. This flag is to ignore all setWallpaperValue calls
|
||||
bool m_isExiting { false };
|
||||
qint64 m_processID { 0 };
|
||||
qint64 m_pingAliveTimerMissedPings = 0;
|
||||
const qint64 m_pingAliveTimerMaxAllowedMissedPings = 3;
|
||||
};
|
||||
|
||||
}
|
||||
|
35
ScreenPlay/inc/public/ScreenPlay/wallpaperdata.h
Normal file
35
ScreenPlay/inc/public/ScreenPlay/wallpaperdata.h
Normal file
@ -0,0 +1,35 @@
|
||||
// SPDX-License-Identifier: LicenseRef-EliasSteurerTachiom OR AGPL-3.0-only
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QFileInfoList>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
#include <QObject>
|
||||
#include <QProcess>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
#include "ScreenPlayUtil/contenttypes.h"
|
||||
|
||||
namespace ScreenPlay {
|
||||
|
||||
struct WallpaperData {
|
||||
bool isLooping = false;
|
||||
QString absolutePath;
|
||||
QString previewImage;
|
||||
float playbackRate = {};
|
||||
float volume = {};
|
||||
QString file;
|
||||
QJsonObject properties;
|
||||
ContentTypes::InstalledType type = ContentTypes::InstalledType::Unknown;
|
||||
Video::FillMode fillMode = Video::FillMode::Fill;
|
||||
QVector<int> monitors;
|
||||
QJsonObject serialize() const;
|
||||
|
||||
static std::optional<WallpaperData> loadWallpaperConfig(const QJsonObject& wallpaperObj);
|
||||
|
||||
};
|
||||
}
|
81
ScreenPlay/inc/public/ScreenPlay/wallpapertimelinesection.h
Normal file
81
ScreenPlay/inc/public/ScreenPlay/wallpapertimelinesection.h
Normal file
@ -0,0 +1,81 @@
|
||||
// SPDX-License-Identifier: LicenseRef-EliasSteurerTachiom OR AGPL-3.0-only
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QFileInfoList>
|
||||
#include <QJsonObject>
|
||||
#include <QObject>
|
||||
#include <QProcess>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
#include "ScreenPlay/wallpaperdata.h"
|
||||
|
||||
namespace ScreenPlay {
|
||||
class ScreenPlayWallpaper;
|
||||
// Represents one line in the UI. ScreenPlayManager has a list of
|
||||
// WallpaperTimeline. Only the active timeline section has
|
||||
// a filled vector of ScreenPlayWallpaper
|
||||
struct WallpaperTimelineSection {
|
||||
// Is active is needed as an additional flag during switching.
|
||||
// When timeline A is no longer in the time range, then we can
|
||||
// use this flag to know that it was the last active timeline and
|
||||
// remove all active wallpaper.
|
||||
bool isActive = false;
|
||||
|
||||
QString identifier;
|
||||
int index = 0; // Needed to check
|
||||
float relativePosition = 0.0f;
|
||||
QTime startTime;
|
||||
QTime endTime;
|
||||
// Data from the profiles.json that we need when we
|
||||
// enable this section of the pipeline. We keep a copy
|
||||
// here when this timeline needs to become active
|
||||
std::vector<WallpaperData> wallpaperData;
|
||||
// All active wallpaper.
|
||||
std::vector<std::shared_ptr<ScreenPlayWallpaper>> activeWallpaperList;
|
||||
|
||||
bool close();
|
||||
|
||||
// Check if currentTime falls within the timeline section
|
||||
bool containsTime(const QTime& time) const
|
||||
{
|
||||
if (endTime < startTime) { // Timeline spans midnight
|
||||
return (time >= startTime || time < endTime);
|
||||
} else {
|
||||
return (time >= startTime && time < endTime);
|
||||
}
|
||||
}
|
||||
|
||||
QJsonObject serialize() const
|
||||
{
|
||||
QJsonObject data;
|
||||
data.insert("isActive", isActive);
|
||||
data.insert("identifier", identifier);
|
||||
data.insert("index", index);
|
||||
data.insert("relativePosition", relativePosition);
|
||||
data.insert("startTime", startTime.toString());
|
||||
data.insert("endTime", endTime.toString());
|
||||
|
||||
// Serialize vector<WallpaperData>
|
||||
QJsonArray wallpaperDataArray;
|
||||
for (const auto& wallpaper : wallpaperData) {
|
||||
QJsonObject wallpaperObject = wallpaper.serialize(); // Assuming WallpaperData has a serialize method
|
||||
wallpaperDataArray.append(wallpaperObject);
|
||||
}
|
||||
data.insert("wallpaperData", wallpaperDataArray);
|
||||
|
||||
// Serialize vector<std::shared_ptr<ScreenPlayWallpaper>>
|
||||
// QJsonArray activeWallpaperArray;
|
||||
// for (const auto& wallpaper : activeWallpaperList) {
|
||||
// QJsonObject wallpaperObject = wallpaper->serialize(); // Assuming ScreenPlayWallpaper has a serialize method
|
||||
// activeWallpaperArray.append(wallpaperObject);
|
||||
// }
|
||||
// data.insert("activeWallpaperList", activeWallpaperArray);
|
||||
|
||||
return data;
|
||||
}
|
||||
};
|
||||
}
|
@ -3,6 +3,7 @@ import QtQuick.Controls
|
||||
|
||||
Rectangle {
|
||||
id: root
|
||||
z: selected ? 99 : 0
|
||||
property int index: 0
|
||||
property string identifier
|
||||
property bool selected: false
|
||||
@ -24,9 +25,14 @@ Rectangle {
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
color: "gold"
|
||||
anchors.fill: parent
|
||||
visible: root.selected
|
||||
color: "gold"
|
||||
height: 3
|
||||
anchors {
|
||||
right: parent.right
|
||||
left: parent.left
|
||||
top: parent.bottom
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
|
@ -1,8 +0,0 @@
|
||||
import QtQuick
|
||||
|
||||
Item {
|
||||
property int index: 0
|
||||
property real relativeLinePosition: 0
|
||||
property LineHandle lineHandle
|
||||
property LineIndicator lineIndicator
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
pragma ValueTypeBehavior: Addressable
|
||||
pragma ValueTypeBehavior
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
@ -8,7 +9,7 @@ import ScreenPlayUtil
|
||||
Control {
|
||||
id: root
|
||||
height: 160
|
||||
implicitWidth: 800
|
||||
implicitWidth: 600
|
||||
topPadding: 20
|
||||
leftPadding: 20
|
||||
rightPadding: 20
|
||||
@ -26,7 +27,7 @@ Control {
|
||||
|
||||
function printTimelines() {
|
||||
print("################# qml:");
|
||||
for (let i = 0; i < timeLine.sectionsList.length; i++) {
|
||||
for (var i = 0; i < timeLine.sectionsList.length; i++) {
|
||||
print(timeLine.sectionsList[i].index, timeLine.sectionsList[i].identifier, timeLine.sectionsList[i].relativeLinePosition);
|
||||
}
|
||||
}
|
||||
@ -37,7 +38,7 @@ Control {
|
||||
property string identifier
|
||||
property int index: 0
|
||||
property real relativeLinePosition: lineHandle.linePosition
|
||||
//onRelativeLinePositionChanged: print("relativelinepos: ", relativeLinePosition)
|
||||
onRelativeLinePositionChanged: print("relativelinepos: ", relativeLinePosition)
|
||||
property LineHandle lineHandle
|
||||
property LineIndicator lineIndicator
|
||||
}
|
||||
@ -47,24 +48,26 @@ Control {
|
||||
id: timeLine
|
||||
|
||||
property var sectionsList: []
|
||||
property var lineColors: ["#FFB300", "#FB8C00", "#F4511E", "#E53935", "#D81B60", "#8E24AA", "#5E35B1", "#3949AB", "#1E88E5", "#00897B", "#43A047", "#C0CA33"]
|
||||
property var lineColors: ["#1E88E5", "#00897B", "#43A047", "#C0CA33", "#FFB300", "#FB8C00", "#F4511E", "#E53935", "#D81B60", "#8E24AA", "#5E35B1", "#3949AB"]
|
||||
onWidthChanged: timeLine.updatePositions()
|
||||
|
||||
property var initialSectionsList: []
|
||||
Component.onCompleted: {
|
||||
const initialStopPositions = App.screenPlayManager.initialStopPositions();
|
||||
createAllSections(initialStopPositions);
|
||||
}
|
||||
|
||||
function createAllSections(initialStopPositions) {
|
||||
for (let identifier in initialStopPositions) {
|
||||
let stopPosition = initialStopPositions[identifier];
|
||||
addSection(identifier, stopPosition);
|
||||
let sectionObects = App.screenPlayManager.initialSectionsList();
|
||||
for (let sectionObject in sectionObects) {
|
||||
initialSectionsList.push(sectionObects[sectionObject]);
|
||||
}
|
||||
initialSectionsList.sort(function (a, b) {
|
||||
return b.index - a.index;
|
||||
});
|
||||
for (let index in initialSectionsList) {
|
||||
let section = initialSectionsList[index];
|
||||
addSection(section.identifier, section.relativePosition);
|
||||
}
|
||||
}
|
||||
|
||||
function removeAll() {
|
||||
print("removeAll", timeLine.sectionsList.length);
|
||||
for (let i = 0; i < timeLine.sectionsList.length; i++) {
|
||||
for (var i = 0; i < timeLine.sectionsList.length; i++) {
|
||||
// ORDER is important here! Destory the children first
|
||||
print("remove index ", i);
|
||||
let section = timeLine.sectionsList[i];
|
||||
@ -83,7 +86,7 @@ Control {
|
||||
// IMPORTANT: The new element is always on the left. The first
|
||||
// handle always persists because the
|
||||
// user can never delete it. It only gets "pushed" further
|
||||
// to the right, by increasing the size.
|
||||
// to the right, by decreasing its size.
|
||||
function addSection(identifier, stopPosition) {
|
||||
print("stopPosition", stopPosition);
|
||||
|
||||
@ -146,7 +149,7 @@ Control {
|
||||
}
|
||||
|
||||
function sectionFromHandle(lineHandle) {
|
||||
for (let i = 0; i < timeLine.sectionsList.length; i++) {
|
||||
for (var i = 0; i < timeLine.sectionsList.length; i++) {
|
||||
if (timeLine.sectionsList[i].lineHandle === lineHandle)
|
||||
return timeLine.sectionsList[i];
|
||||
}
|
||||
@ -165,7 +168,7 @@ Control {
|
||||
}
|
||||
|
||||
function lineIndicatorSelected(activeTimelineIndex) {
|
||||
for (let i = 0; i < timeLine.sectionsList.length; i++) {
|
||||
for (var i = 0; i < timeLine.sectionsList.length; i++) {
|
||||
if (i === activeTimelineIndex) {
|
||||
timeLine.sectionsList[i].lineIndicator.selected = true;
|
||||
continue;
|
||||
@ -182,7 +185,7 @@ Control {
|
||||
timeLine.sectionsList.sort(function (a, b) {
|
||||
return a.relativeLinePosition - b.relativeLinePosition;
|
||||
});
|
||||
for (let i = 0; i < timeLine.sectionsList.length; i++) {
|
||||
for (var i = 0; i < timeLine.sectionsList.length; i++) {
|
||||
timeLine.sectionsList[i].index = i;
|
||||
timeLine.sectionsList[i].lineIndicator.index = i;
|
||||
//print("updateIndicatorIndexes:", timeLine.sectionsList[i].index, timeLine.sectionsList[i].relativeLinePosition)
|
||||
@ -208,7 +211,7 @@ Control {
|
||||
|
||||
function updatePositions() {
|
||||
// Iterate through each handle in the 'sectionList' array
|
||||
for (let i = 0; i < timeLine.sectionsList.length; i++) {
|
||||
for (var i = 0; i < timeLine.sectionsList.length; i++) {
|
||||
let handle = timeLine.sectionsList[i].lineHandle;
|
||||
|
||||
// Determine the minimum position for the current handle
|
||||
@ -238,7 +241,7 @@ Control {
|
||||
//timeLine.sectionsList[i].relativeLinePosition =prevPos / timeLine.width
|
||||
// print("sections: ", i, "prev minimum ",prevPos,"next maximum", nextPos, timeLine.sectionsList[i].relativeLinePosition)
|
||||
}
|
||||
for (let i = 0; i < timeLine.sectionsList.length; i++) {
|
||||
for (var i = 0; i < timeLine.sectionsList.length; i++) {
|
||||
let section = timeLine.sectionsList[i];
|
||||
section.relativeLinePosition = section.lineHandle.linePosition;
|
||||
// print(section.relativeLinePosition, section.lineHandle.lineMinimum, section.lineHandle.lineMaximum)
|
||||
@ -259,21 +262,21 @@ Control {
|
||||
}
|
||||
|
||||
function updateIndicatorColor() {
|
||||
for (let i = 0; i < timeLine.sectionsList.length; i++) {
|
||||
for (var i = 0; i < timeLine.sectionsList.length; i++) {
|
||||
let lineIndicator = timeLine.sectionsList[i].lineIndicator;
|
||||
lineIndicator.color = getColorAtIndex(i);
|
||||
}
|
||||
}
|
||||
|
||||
function updateLastHandle() {
|
||||
for (let i = 0; i < timeLine.sectionsList.length; i++) {
|
||||
for (var i = 0; i < timeLine.sectionsList.length; i++) {
|
||||
timeLine.sectionsList[i].lineHandle.isLast = i === timeLine.sectionsList.length - 1;
|
||||
timeLine.sectionsList[i].lineIndicator.isLast = i === timeLine.sectionsList.length - 1;
|
||||
}
|
||||
}
|
||||
|
||||
function updateIndicatorPositions() {
|
||||
for (let i = 0; i < timeLine.sectionsList.length; i++) {
|
||||
for (var i = 0; i < timeLine.sectionsList.length; i++) {
|
||||
const lineIndicator = timeLine.sectionsList[i].lineIndicator;
|
||||
//print(i, lineIndicator.x, lineIndicator.width, timeLine.sectionsList[i].relativeLinePosition)
|
||||
const handle = timeLine.sectionsList[i].lineHandle;
|
||||
|
@ -12,7 +12,7 @@ import "../Components"
|
||||
|
||||
Drawer {
|
||||
id: root
|
||||
height: 250
|
||||
height: 300
|
||||
modal: false
|
||||
edge: Qt.BottomEdge
|
||||
background: Rectangle {
|
||||
@ -22,70 +22,57 @@ Drawer {
|
||||
property bool hasPreviewGif: false
|
||||
property var type: ContentTypes.InstalledType.QMLWallpaper
|
||||
property string contentFolderName
|
||||
onClosed: {
|
||||
root.contentFolderName = ""
|
||||
root.type = ContentTypes.InstalledType.Unknown
|
||||
}
|
||||
|
||||
function setInstalledDrawerItem(folderName, type) {
|
||||
|
||||
// Toggle sidebar if clicked on the same content twice
|
||||
if (root.contentFolderName === folderName)
|
||||
return
|
||||
|
||||
if (!App.util.isWallpaper(root.type)){
|
||||
return
|
||||
return;
|
||||
if (!App.util.isWallpaper(type)) {
|
||||
return;
|
||||
}
|
||||
|
||||
root.contentFolderName = folderName
|
||||
root.type = type
|
||||
root.contentFolderName = folderName;
|
||||
root.type = type;
|
||||
print("setInstalledDrawerItem", folderName,typeof(folderName), type);
|
||||
if (type === ContentTypes.InstalledType.VideoWallpaper)
|
||||
installedDrawerWrapper.state = "wallpaper"
|
||||
installedDrawerWrapper.state = "wallpaper";
|
||||
else
|
||||
installedDrawerWrapper.state = "scene"
|
||||
btnLaunchContent.text = qsTr("Set Wallpaper")
|
||||
root.open()
|
||||
}
|
||||
installedDrawerWrapper.state = "scene";
|
||||
|
||||
function indexOfValue(model, value) {
|
||||
for (var i = 0; i < model.length; i++) {
|
||||
let ourValue = model[i].value
|
||||
if (value === ourValue)
|
||||
return i
|
||||
}
|
||||
return -1
|
||||
root.open();
|
||||
}
|
||||
|
||||
// This is used for removing wallpaper. We need to clear
|
||||
// the preview image/gif so we can release the file for deletion.
|
||||
function clear() {
|
||||
root.close()
|
||||
imagePreview.source = ""
|
||||
animatedImagePreview.source = ""
|
||||
txtHeadline.text = ""
|
||||
installedDrawerWrapper.state = "inactive"
|
||||
|
||||
root.close();
|
||||
root.contentFolderName = "";
|
||||
root.type = ContentTypes.InstalledType.Unknown;
|
||||
imagePreview.source = "";
|
||||
animatedImagePreview.source = "";
|
||||
txtHeadline.text = "";
|
||||
installedDrawerWrapper.state = "inactive";
|
||||
}
|
||||
|
||||
onContentFolderNameChanged: {
|
||||
const item = App.installedListModel.get(root.contentFolderName)
|
||||
//txtHeadline.text = item.m_title
|
||||
const previewGiFilePath = Qt.resolvedUrl(
|
||||
item.m_absoluteStoragePath + "/" + item.m_previewGIF)
|
||||
const previewImageFilePath = Qt.resolvedUrl(
|
||||
item.m_absoluteStoragePath + "/" + item.m_preview)
|
||||
root.hasPreviewGif = App.util.fileExists(previewGiFilePath)
|
||||
if (hasPreviewGif) {
|
||||
animatedImagePreview.source = previewGiFilePath
|
||||
animatedImagePreview.playing = true
|
||||
} else {
|
||||
imagePreview.source = previewImageFilePath
|
||||
}
|
||||
if (App.util.isWidget(root.type)
|
||||
|| (monitorSelection.activeMonitors.length > 0)) {
|
||||
btnLaunchContent.enabled = true
|
||||
if (root.contentFolderName === ""){
|
||||
console.error("empty folder name")
|
||||
return
|
||||
}
|
||||
btnLaunchContent.enabled = false
|
||||
|
||||
const item = App.installedListModel.get(root.contentFolderName);
|
||||
print(root.contentFolderName);
|
||||
txtHeadline.text = item.m_title;
|
||||
const previewGiFilePath = Qt.resolvedUrl(item.m_absoluteStoragePath + "/" + item.m_previewGIF);
|
||||
const previewImageFilePath = Qt.resolvedUrl(item.m_absoluteStoragePath + "/" + item.m_preview);
|
||||
root.hasPreviewGif = App.util.fileExists(previewGiFilePath);
|
||||
if (hasPreviewGif) {
|
||||
animatedImagePreview.source = previewGiFilePath;
|
||||
animatedImagePreview.playing = true;
|
||||
} else {
|
||||
imagePreview.source = previewImageFilePath;
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
@ -94,7 +81,7 @@ Drawer {
|
||||
RowLayout {
|
||||
id: installedDrawerWrapper
|
||||
state: "inactive"
|
||||
spacing: 30
|
||||
spacing: 20
|
||||
|
||||
anchors {
|
||||
margins: 10
|
||||
@ -105,7 +92,7 @@ Drawer {
|
||||
spacing: 5
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
Layout.horizontalStretchFactor: 3
|
||||
Layout.horizontalStretchFactor: 4
|
||||
|
||||
Text {
|
||||
Layout.leftMargin: 20
|
||||
@ -118,18 +105,19 @@ Drawer {
|
||||
|
||||
Timeline {
|
||||
id: timeline
|
||||
Layout.topMargin: 50
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
Connections {
|
||||
target: App.screenPlayManager
|
||||
function onPrintQmlTimeline() {
|
||||
timeline.printTimelines()
|
||||
timeline.printTimelines();
|
||||
}
|
||||
}
|
||||
|
||||
ToolButton {
|
||||
text: "❌" //qsTr("Remove all timeline ranges")
|
||||
enabled: timeline.length > 1
|
||||
// enabled: timeline.length > 1
|
||||
onClicked: timeline.removeAll()
|
||||
anchors {
|
||||
right: parent.right
|
||||
@ -140,7 +128,7 @@ Drawer {
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
Layout.horizontalStretchFactor: 2
|
||||
Layout.horizontalStretchFactor: 4
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
spacing: 10
|
||||
@ -166,7 +154,7 @@ Drawer {
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
Layout.horizontalStretchFactor: 1
|
||||
Layout.horizontalStretchFactor: 3
|
||||
Layout.fillHeight: true
|
||||
Layout.fillWidth: true
|
||||
spacing: 10
|
||||
@ -175,7 +163,7 @@ Drawer {
|
||||
id: imageWrapper
|
||||
color: "#2b2b2b"
|
||||
|
||||
Layout.preferredHeight: 100
|
||||
Layout.preferredHeight: 160
|
||||
Layout.fillWidth: true
|
||||
Layout.alignment: Qt.AlignTop
|
||||
Layout.topMargin: 20
|
||||
@ -261,62 +249,44 @@ Drawer {
|
||||
Layout.fillWidth: true
|
||||
Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom
|
||||
objectName: "btnLaunchContent"
|
||||
enabled: App.util.isWidget(root.type) && activeMonitors.length > 0 ? true : monitorSelection.isSelected
|
||||
text: qsTr("Set Wallpaper");
|
||||
// enabled: App.util.isWidget(root.type) && activeMonitors.length > 0 ? true : monitorSelection.isSelected
|
||||
icon.source: "qrc:/qml/ScreenPlayApp/assets/icons/icon_plus.svg"
|
||||
icon.color: "white"
|
||||
font.pointSize: 12
|
||||
onClicked: {
|
||||
const item = App.installedListModel.get(
|
||||
root.contentFolderName)
|
||||
const absoluteStoragePath = item.m_absoluteStoragePath
|
||||
const previewImage = item.m_preview
|
||||
const item = App.installedListModel.get(root.contentFolderName);
|
||||
const absoluteStoragePath = item.m_absoluteStoragePath;
|
||||
const previewImage = item.m_preview;
|
||||
if (App.util.isWallpaper(root.type)) {
|
||||
if (type === ContentTypes.InstalledType.GodotWallpaper) {
|
||||
if (App.globalVariables.isBasicVersion()) {
|
||||
installedDrawerWrapper.state = "inactive"
|
||||
return
|
||||
installedDrawerWrapper.state = "inactive";
|
||||
return;
|
||||
}
|
||||
}
|
||||
let activeMonitors = monitorSelection.getActiveMonitors()
|
||||
let activeMonitors = monitorSelection.getActiveMonitors();
|
||||
if (type === ContentTypes.InstalledType.GodotWallpaper) {
|
||||
App.util.exportGodotProject(
|
||||
absoluteStoragePath,
|
||||
App.globalVariables.godotEditorExecutablePath).then(
|
||||
result => {
|
||||
if (!result.success) {
|
||||
dialog.title = ("Error exporting Godot")
|
||||
dialog.message = result.message
|
||||
dialog.open()
|
||||
} else {
|
||||
const screenFile = item.m_file
|
||||
let volume = 1
|
||||
let success = App.screenPlayManager.createWallpaper(
|
||||
root.type,
|
||||
cbVideoFillMode.currentValue,
|
||||
absoluteStoragePath,
|
||||
previewImage,
|
||||
screenFile,
|
||||
activeMonitors,
|
||||
volume,
|
||||
1, {}, true)
|
||||
}
|
||||
})
|
||||
root.close()
|
||||
return
|
||||
App.util.exportGodotProject(absoluteStoragePath, App.globalVariables.godotEditorExecutablePath).then(result => {
|
||||
if (!result.success) {
|
||||
dialog.title = ("Error exporting Godot");
|
||||
dialog.message = result.message;
|
||||
dialog.open();
|
||||
} else {
|
||||
const screenFile = item.m_file;
|
||||
let volume = 1;
|
||||
let success = App.screenPlayManager.createWallpaper(root.type, cbVideoFillMode.currentValue, absoluteStoragePath, previewImage, screenFile, activeMonitors, volume, 1, {}, true);
|
||||
}
|
||||
});
|
||||
root.close();
|
||||
return;
|
||||
}
|
||||
const activeTimeline = timeline.getActiveTimeline()
|
||||
const file = item.m_file
|
||||
let success = App.screenPlayManager.setWallpaperAtTimelineIndex(
|
||||
root.type,
|
||||
absoluteStoragePath,
|
||||
previewImage,
|
||||
file,
|
||||
activeMonitors,
|
||||
timeline.activeTimelineIndex,
|
||||
activeTimeline.identifier, true)
|
||||
const activeTimeline = timeline.getActiveTimeline();
|
||||
const file = item.m_file;
|
||||
let success = App.screenPlayManager.setWallpaperAtTimelineIndex(root.type, absoluteStoragePath, previewImage, file, activeMonitors, timeline.activeTimelineIndex, activeTimeline.identifier, true);
|
||||
}
|
||||
root.close()
|
||||
monitorSelection.reset()
|
||||
root.close();
|
||||
monitorSelection.reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -383,7 +353,6 @@ Drawer {
|
||||
opacity: 1
|
||||
anchors.topMargin: 0
|
||||
}
|
||||
|
||||
}
|
||||
]
|
||||
transitions: [
|
||||
@ -478,8 +447,8 @@ Drawer {
|
||||
icon.width: 15
|
||||
icon.height: 15
|
||||
onClicked: {
|
||||
root.close()
|
||||
installedDrawerWrapper.state = "inactive"
|
||||
root.close();
|
||||
installedDrawerWrapper.state = "inactive";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ Item {
|
||||
|
||||
InstalledDrawer {
|
||||
id: installedDrawer
|
||||
objectName: "installedSidebar"
|
||||
objectName: "installedDrawer"
|
||||
width: root.width
|
||||
}
|
||||
|
||||
|
@ -21,12 +21,10 @@ Item {
|
||||
property bool containsAudio: false
|
||||
property int version: App.globalVariables.version
|
||||
property bool hasLicense: {
|
||||
if ((root.version === GlobalVariables.OpenSourceStandalone
|
||||
|| root.version === GlobalVariables.OpenSourceSteam)
|
||||
&& root.type === Util.ContentTypes.InstalledType.GodotWallpaper) {
|
||||
return false
|
||||
if ((root.version === GlobalVariables.OpenSourceStandalone || root.version === GlobalVariables.OpenSourceSteam) && root.type === Util.ContentTypes.InstalledType.GodotWallpaper) {
|
||||
return false;
|
||||
}
|
||||
return true
|
||||
return true;
|
||||
}
|
||||
|
||||
signal clicked(var folderName, var type)
|
||||
@ -37,16 +35,16 @@ Item {
|
||||
height: 180
|
||||
onTypeChanged: {
|
||||
if (App.util.isWidget(type)) {
|
||||
icnType.source = "qrc:/qml/ScreenPlayApp/assets/icons/icon_widgets.svg"
|
||||
return
|
||||
icnType.source = "qrc:/qml/ScreenPlayApp/assets/icons/icon_widgets.svg";
|
||||
return;
|
||||
}
|
||||
if (App.util.isScene(type)) {
|
||||
icnType.source = "qrc:/qml/ScreenPlayApp/assets/icons/icon_code.svg"
|
||||
return
|
||||
icnType.source = "qrc:/qml/ScreenPlayApp/assets/icons/icon_code.svg";
|
||||
return;
|
||||
}
|
||||
if (App.util.isVideo(type)) {
|
||||
icnType.source = "qrc:/qml/ScreenPlayApp/assets/icons/icon_movie.svg"
|
||||
return
|
||||
icnType.source = "qrc:/qml/ScreenPlayApp/assets/icons/icon_movie.svg";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -54,10 +52,10 @@ Item {
|
||||
running: true
|
||||
onTriggered: showAnim.start()
|
||||
interval: {
|
||||
var itemIndexMax = itemIndex
|
||||
var itemIndexMax = itemIndex;
|
||||
if (itemIndex > 30)
|
||||
itemIndexMax = 3
|
||||
5 * itemIndexMax * Math.random()
|
||||
itemIndexMax = 3;
|
||||
5 * itemIndexMax * Math.random();
|
||||
}
|
||||
}
|
||||
|
||||
@ -261,31 +259,29 @@ Item {
|
||||
onExited: handleMouseExit()
|
||||
onClicked: function (mouse) {
|
||||
if (!root.hasLicense) {
|
||||
root.openOpenLicensePopup()
|
||||
return
|
||||
root.openOpenLicensePopup();
|
||||
return;
|
||||
}
|
||||
if (App.util.isWidget(root.type))
|
||||
return
|
||||
return;
|
||||
if (mouse.button === Qt.LeftButton)
|
||||
root.clicked(root.folderName, root.type)
|
||||
root.clicked(root.folderName, root.type);
|
||||
else if (mouse.button === Qt.RightButton)
|
||||
root.openContextMenu(Qt.point(mouseX, mouseY))
|
||||
root.openContextMenu(Qt.point(mouseX, mouseY));
|
||||
}
|
||||
function handleMouseEnter(){
|
||||
|
||||
function handleMouseEnter() {
|
||||
if (!root.hasLicense)
|
||||
return
|
||||
root.state = "hover"
|
||||
screenPlayItemImage.state = "hover"
|
||||
screenPlayItemImage.enter()
|
||||
return;
|
||||
root.state = "hover";
|
||||
screenPlayItemImage.state = "hover";
|
||||
screenPlayItemImage.enter();
|
||||
}
|
||||
function handleMouseExit(){
|
||||
if(widgetStartButton.enabled && widgetStartButton.hovered)
|
||||
return
|
||||
root.state = ""
|
||||
screenPlayItemImage.state = "loaded"
|
||||
screenPlayItemImage.exit()
|
||||
|
||||
function handleMouseExit() {
|
||||
if (widgetStartButton.enabled && widgetStartButton.hovered)
|
||||
return;
|
||||
root.state = "";
|
||||
screenPlayItemImage.state = "loaded";
|
||||
screenPlayItemImage.exit();
|
||||
}
|
||||
}
|
||||
|
||||
@ -296,18 +292,13 @@ Item {
|
||||
text: qsTr("Start")
|
||||
opacity: enabled && (widgetStartButton.hovered || hoverArea.containsMouse) ? 1 : 0
|
||||
onClicked: {
|
||||
App.screenPlayManager.startWidget(
|
||||
root.type, Qt.point(0, 0),
|
||||
root.absoluteStoragePath,
|
||||
m_preview, {}, true)
|
||||
App.screenPlayManager.startWidget(root.type, Qt.point(0, 0), root.absoluteStoragePath, m_preview, {}, true);
|
||||
}
|
||||
onHoveredChanged: {
|
||||
print(hovered)
|
||||
if(hovered)
|
||||
hoverArea.handleMouseEnter()
|
||||
if (hovered)
|
||||
hoverArea.handleMouseEnter();
|
||||
else
|
||||
hoverArea.handleMouseExit()
|
||||
|
||||
hoverArea.handleMouseExit();
|
||||
}
|
||||
|
||||
anchors {
|
||||
@ -368,7 +359,6 @@ Item {
|
||||
to: 1
|
||||
easing.type: Easing.OutQuart
|
||||
}
|
||||
|
||||
},
|
||||
Transition {
|
||||
from: "hover"
|
||||
|
@ -217,7 +217,7 @@ Rectangle {
|
||||
id: quickActionRow
|
||||
anchors {
|
||||
top: parent.top
|
||||
right: parent.right
|
||||
right: miConfig.left
|
||||
rightMargin: 10
|
||||
bottom: parent.bottom
|
||||
}
|
||||
@ -313,19 +313,17 @@ Rectangle {
|
||||
rightMargin: 10
|
||||
bottom: parent.bottom
|
||||
}
|
||||
Material.accent: contentActive ? "gold" : Material.secondaryTextColor
|
||||
property bool contentActive: App.screenPlayManager.activeWallpaperCounter > 0
|
||||
Material.accent: contentActive ? "gold" : Material.secondaryTextColor
|
||||
property bool contentActive: App.screenPlayManager.activeWallpaperCounter > 0
|
||||
|
||||
background: Rectangle {
|
||||
color: Material.theme === Material.Light ? Material.background : "#242424"
|
||||
border.color: {
|
||||
if(contentActive){
|
||||
return "gold"
|
||||
if (miConfig.contentActive) {
|
||||
return "gold";
|
||||
} else {
|
||||
Material.theme === Material.Light ? Material.iconDisabledColor : Qt.darker(
|
||||
Material.background)
|
||||
Material.theme === Material.Light ? Material.iconDisabledColor : Qt.darker(Material.background);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
border.width: 1
|
||||
|
@ -264,6 +264,10 @@ void InstalledListModel::loadInstalledContent()
|
||||
*/
|
||||
QVariantMap InstalledListModel::get(const QString& folderName) const
|
||||
{
|
||||
if (folderName.isEmpty()) {
|
||||
qCritical() << "Invalid (empty) folder name";
|
||||
return {};
|
||||
}
|
||||
|
||||
if (m_screenPlayFiles.count() == 0)
|
||||
return {};
|
||||
@ -285,6 +289,8 @@ QVariantMap InstalledListModel::get(const QString& folderName) const
|
||||
}
|
||||
}
|
||||
|
||||
qWarning() << "Installed item not found for: " << folderName;
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -74,34 +74,39 @@ QVariant MonitorListModel::data(const QModelIndex& index, int role) const
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
|
||||
|
||||
auto roleEnum = static_cast<MonitorRole>(role);
|
||||
|
||||
if (row < rowCount())
|
||||
switch (roleEnum) {
|
||||
case MonitorRole::AppID:
|
||||
if (m_monitorList.at(row).m_activeWallpaper) {
|
||||
return m_monitorList.at(row).m_activeWallpaper->appID();
|
||||
} else {
|
||||
return QVariant("");
|
||||
}
|
||||
case MonitorRole::Index:
|
||||
return m_monitorList.at(row).m_index;
|
||||
case MonitorRole::Geometry:
|
||||
return m_monitorList.at(row).m_geometry;
|
||||
case MonitorRole::InstalledType:
|
||||
if (m_monitorList.at(row).m_activeWallpaper) {
|
||||
return static_cast<int>(m_monitorList.at(row).m_activeWallpaper->type());
|
||||
} else {
|
||||
return { "" };
|
||||
}
|
||||
case MonitorRole::PreviewImage:
|
||||
if (m_monitorList.at(row).m_activeWallpaper) {
|
||||
QString absolutePath = m_monitorList.at(row).m_activeWallpaper->absolutePath();
|
||||
return absolutePath + "/" + m_monitorList.at(row).m_activeWallpaper->previewImage();
|
||||
} else {
|
||||
return QVariant("");
|
||||
}
|
||||
}
|
||||
if (row > rowCount())
|
||||
return {};
|
||||
|
||||
switch (roleEnum) {
|
||||
case MonitorRole::AppID:
|
||||
return 1;
|
||||
// if (m_monitorList.at(row).m_activeWallpaper) {
|
||||
// return m_monitorList.at(row).m_activeWallpaper->appID();
|
||||
// } else {
|
||||
// return QVariant("");
|
||||
// }
|
||||
case MonitorRole::Index:
|
||||
return m_monitorList.at(row).m_index;
|
||||
case MonitorRole::Geometry:
|
||||
return m_monitorList.at(row).m_geometry;
|
||||
case MonitorRole::InstalledType:
|
||||
// if (m_monitorList.at(row).m_activeWallpaper) {
|
||||
// return static_cast<int>(m_monitorList.at(row).m_activeWallpaper->type());
|
||||
// } else {
|
||||
return { "" };
|
||||
// }
|
||||
case MonitorRole::PreviewImage:
|
||||
// if (m_monitorList.at(row).m_activeWallpaper) {
|
||||
// QString absolutePath = m_monitorList.at(row).m_activeWallpaper->absolutePath();
|
||||
// return absolutePath + "/" + m_monitorList.at(row).m_activeWallpaper->previewImage();
|
||||
// } else {
|
||||
return QVariant("");
|
||||
}
|
||||
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
@ -177,48 +182,6 @@ void MonitorListModel::loadMonitors()
|
||||
emit monitorReloadCompleted();
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Clears the listmodel.
|
||||
*/
|
||||
void MonitorListModel::clearActiveWallpaper()
|
||||
{
|
||||
int i { 0 };
|
||||
for (Monitor& monitor : m_monitorList) {
|
||||
monitor.m_activeWallpaper = nullptr;
|
||||
emit dataChanged(
|
||||
index(i, 0),
|
||||
index(i, 0),
|
||||
QVector<int> {
|
||||
static_cast<int>(MonitorRole::PreviewImage),
|
||||
static_cast<int>(MonitorRole::InstalledType),
|
||||
static_cast<int>(MonitorRole::AppID) });
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Removes the preview image and appID inside an monitor item.
|
||||
*/
|
||||
void MonitorListModel::closeWallpaper(const QString& appID)
|
||||
{
|
||||
int i {};
|
||||
for (auto& item : m_monitorList) {
|
||||
if (item.m_activeWallpaper) {
|
||||
if (item.m_activeWallpaper->appID() == appID) {
|
||||
item.m_activeWallpaper = nullptr;
|
||||
emit dataChanged(
|
||||
index(i, 0),
|
||||
index(i, 0),
|
||||
QVector<int> {
|
||||
static_cast<int>(MonitorRole::PreviewImage),
|
||||
static_cast<int>(MonitorRole::InstalledType),
|
||||
static_cast<int>(MonitorRole::AppID) });
|
||||
}
|
||||
}
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief MonitorListModel::getAbsoluteDesktopSize
|
||||
* \return
|
||||
@ -233,11 +196,12 @@ QRect MonitorListModel::absoluteDesktopSize() const
|
||||
\brief Sets a shared_ptr to the monitor list. This should be used to set and
|
||||
remove the shared_ptr.
|
||||
*/
|
||||
void MonitorListModel::setWallpaperMonitor(const std::shared_ptr<ScreenPlayWallpaper>& wallpaper, const QVector<int> monitors)
|
||||
void MonitorListModel::setWallpaperMonitor(
|
||||
const std::shared_ptr<WallpaperTimelineSection>& timelineSection, const QVector<int> monitors)
|
||||
{
|
||||
|
||||
m_activeTimelineSection = timelineSection;
|
||||
for (const int monitor : monitors) {
|
||||
m_monitorList[monitor].m_activeWallpaper = wallpaper;
|
||||
// m_monitorList[monitor].m_activeWallpaper = wallpaper;
|
||||
|
||||
emit dataChanged(
|
||||
index(monitor, 0),
|
||||
@ -254,11 +218,11 @@ void MonitorListModel::setWallpaperMonitor(const std::shared_ptr<ScreenPlayWallp
|
||||
*/
|
||||
std::optional<QString> MonitorListModel::getAppIDByMonitorIndex(const int index) const
|
||||
{
|
||||
for (auto& monitor : m_monitorList) {
|
||||
if (monitor.m_index == index && monitor.m_activeWallpaper) {
|
||||
return { monitor.m_activeWallpaper->appID() };
|
||||
}
|
||||
}
|
||||
// for (auto& monitor : m_monitorList) {
|
||||
// if (monitor.m_index == index && monitor.m_activeWallpaper) {
|
||||
// return { monitor.m_activeWallpaper->appID() };
|
||||
// }
|
||||
// }
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,8 @@
|
||||
#include "ScreenPlay/screenplaymanager.h"
|
||||
#include "ScreenPlayUtil/util.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <QScopeGuard>
|
||||
namespace ScreenPlay {
|
||||
|
||||
@ -46,35 +48,7 @@ ScreenPlayManager::ScreenPlayManager(
|
||||
QObject::connect(&m_contentTimer, &QTimer::timeout, this, &ScreenPlayManager::checkActiveWallpaperTimeline);
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Returns the wallpaper timeline that has the isActive
|
||||
flag enabled.
|
||||
*/
|
||||
std::shared_ptr<WallpaperTimelineSection> ScreenPlayManager::findActiveWallpaperTimelineSection()
|
||||
{
|
||||
const QTime currentTime = QTime::currentTime();
|
||||
for (const auto& section : m_wallpaperTimelineSectionsList) {
|
||||
if (section->isActive) {
|
||||
return section;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Returns the current active timline. There must always be an active timeline!
|
||||
*/
|
||||
std::shared_ptr<WallpaperTimelineSection> ScreenPlayManager::getCurrentTimeline()
|
||||
{
|
||||
const QTime currentTime = QTime::currentTime();
|
||||
for (const auto& section : m_wallpaperTimelineSectionsList) {
|
||||
if (section->containsTime(currentTime)) {
|
||||
return section;
|
||||
}
|
||||
}
|
||||
qCritical() << "No active timeline";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Checks if we need to display a different wallpaper at the current time.
|
||||
@ -84,7 +58,7 @@ std::shared_ptr<WallpaperTimelineSection> ScreenPlayManager::getCurrentTimeline(
|
||||
*/
|
||||
void ScreenPlayManager::checkActiveWallpaperTimeline()
|
||||
{
|
||||
std::shared_ptr<WallpaperTimelineSection> currentTimeline = getCurrentTimeline();
|
||||
std::shared_ptr<WallpaperTimelineSection> currentTimeline = m_screenPlayTimeline.getCurrentTimeline();
|
||||
if (!currentTimeline) {
|
||||
qCritical() << "No active timeline found. There must always be an active timeline.";
|
||||
return;
|
||||
@ -92,7 +66,7 @@ void ScreenPlayManager::checkActiveWallpaperTimeline()
|
||||
|
||||
// Check for currently active timeline.
|
||||
std::shared_ptr<WallpaperTimelineSection> activeTimelineSection = nullptr;
|
||||
for (const auto& section : m_wallpaperTimelineSectionsList) {
|
||||
for (const auto& section : m_screenPlayTimeline.m_wallpaperTimelineSectionsList) {
|
||||
if (section->isActive) {
|
||||
activeTimelineSection = section;
|
||||
break;
|
||||
@ -120,7 +94,7 @@ void ScreenPlayManager::checkActiveWallpaperTimeline()
|
||||
void ScreenPlayManager::activateNewTimeline()
|
||||
{
|
||||
// Remove old timeline content
|
||||
auto oldTimeline = findActiveWallpaperTimelineSection();
|
||||
auto oldTimeline = m_screenPlayTimeline.findActiveWallpaperTimelineSection();
|
||||
// Will be null on startup, where there is no old timeline
|
||||
if (oldTimeline) {
|
||||
|
||||
@ -134,7 +108,7 @@ void ScreenPlayManager::activateNewTimeline()
|
||||
}
|
||||
|
||||
// Activate new timeline content
|
||||
std::shared_ptr<WallpaperTimelineSection> newTimelineSection = getCurrentTimeline();
|
||||
std::shared_ptr<WallpaperTimelineSection> newTimelineSection = m_screenPlayTimeline.getCurrentTimeline();
|
||||
if (!newTimelineSection) {
|
||||
qCritical() << "No active timeline found. There must always be an active timeline.";
|
||||
return;
|
||||
@ -173,12 +147,13 @@ bool ScreenPlayManager::setWallpaperAtTimelineIndex(
|
||||
wallpaperData.previewImage = previewImage;
|
||||
wallpaperData.file = file;
|
||||
wallpaperData.monitors = monitorIndex;
|
||||
wallpaperData.fillMode = m_settings->videoFillMode();
|
||||
bool ok = false;
|
||||
for (auto& timelineSection : m_wallpaperTimelineSectionsList) {
|
||||
for (auto& timelineSection : m_screenPlayTimeline.m_wallpaperTimelineSectionsList) {
|
||||
const bool sameIndex = timelineSection->index == timelineIndex;
|
||||
const bool sameIdentifier = timelineSection->identifier == identifier;
|
||||
if (sameIndex && sameIdentifier) {
|
||||
// TODO vec
|
||||
// TODO support more than one wallpaper per timeline
|
||||
timelineSection->wallpaperData = { wallpaperData };
|
||||
ok = true;
|
||||
break;
|
||||
@ -251,7 +226,7 @@ std::shared_ptr<ScreenPlayWallpaper> ScreenPlayManager::startWallpaper(
|
||||
// Remove file:///
|
||||
wallpaperData.absolutePath = QUrl::fromUserInput(wallpaperData.absolutePath).toLocalFile();
|
||||
const QString appID = Util().generateRandomString();
|
||||
qInfo() << "Start wallpaper" << wallpaperData.absolutePath << appID;
|
||||
qInfo() << "Start wallpaper" << wallpaperData.absolutePath << appID;
|
||||
|
||||
// Only support remove wallpaper that spans over 1 monitor
|
||||
// if (wallpaperData.monitors.length() == 1) {
|
||||
@ -281,7 +256,7 @@ std::shared_ptr<ScreenPlayWallpaper> ScreenPlayManager::startWallpaper(
|
||||
if (!wallpaper->start()) {
|
||||
return nullptr;
|
||||
}
|
||||
m_monitorListModel->setWallpaperMonitor(wallpaper, wallpaperData.monitors);
|
||||
// m_monitorListModel->setWallpaperMonitor(wallpaper, wallpaperData.monitors);
|
||||
return wallpaper;
|
||||
}
|
||||
|
||||
@ -337,12 +312,12 @@ bool ScreenPlayManager::startWidget(
|
||||
bool ScreenPlayManager::removeAllWallpapers(bool saveToProfile)
|
||||
{
|
||||
|
||||
if (m_wallpaperTimelineSectionsList.empty()) {
|
||||
if (m_screenPlayTimeline.m_wallpaperTimelineSectionsList.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
QStringList appIDs;
|
||||
auto activeTimelineSection = findActiveWallpaperTimelineSection();
|
||||
auto activeTimelineSection = m_screenPlayTimeline.findActiveWallpaperTimelineSection();
|
||||
if (!activeTimelineSection) {
|
||||
qWarning() << "Trying to remove all Wallpapers while findActiveSection is empty.";
|
||||
return false;
|
||||
@ -415,7 +390,7 @@ bool ScreenPlayManager::removeWallpaperAt(int index)
|
||||
*/
|
||||
bool ScreenPlayManager::requestProjectSettingsAtMonitorIndex(const int index)
|
||||
{
|
||||
auto activeTimelineSection = findActiveWallpaperTimelineSection();
|
||||
auto activeTimelineSection = m_screenPlayTimeline.findActiveWallpaperTimelineSection();
|
||||
if (!activeTimelineSection) {
|
||||
return false;
|
||||
}
|
||||
@ -465,7 +440,7 @@ bool ScreenPlayManager::setWallpaperFillModeAtMonitorIndex(const int index, cons
|
||||
*/
|
||||
bool ScreenPlayManager::setAllWallpaperValue(const QString& key, const QString& value)
|
||||
{
|
||||
auto activeTimelineSection = findActiveWallpaperTimelineSection();
|
||||
auto activeTimelineSection = m_screenPlayTimeline.findActiveWallpaperTimelineSection();
|
||||
if (!activeTimelineSection) {
|
||||
return false;
|
||||
}
|
||||
@ -483,7 +458,7 @@ bool ScreenPlayManager::setAllWallpaperValue(const QString& key, const QString&
|
||||
ScreenPlayWallpaper* ScreenPlayManager::getWallpaperByAppID(const QString& appID)
|
||||
{
|
||||
|
||||
auto activeTimelineSection = findActiveWallpaperTimelineSection();
|
||||
auto activeTimelineSection = m_screenPlayTimeline.findActiveWallpaperTimelineSection();
|
||||
if (!activeTimelineSection) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -504,7 +479,7 @@ bool ScreenPlayManager::moveTimelineAt(const int index, const QString identifier
|
||||
m_contentTimer.stop();
|
||||
auto updateTimer = qScopeGuard([this] { m_contentTimer.start(); });
|
||||
|
||||
auto& wallpapterTimelineSection = m_wallpaperTimelineSectionsList.at(index);
|
||||
auto& wallpapterTimelineSection = m_screenPlayTimeline.m_wallpaperTimelineSectionsList.at(index);
|
||||
QTime newPositionTime = QTime::fromString(positionTimeString, "hh:mm");
|
||||
if (!newPositionTime.isValid()) {
|
||||
qWarning() << "Unable to move with invalid time:" << positionTimeString;
|
||||
@ -516,12 +491,12 @@ bool ScreenPlayManager::moveTimelineAt(const int index, const QString identifier
|
||||
// The identiefier is only used for debugging
|
||||
wallpapterTimelineSection->identifier = identifier;
|
||||
|
||||
const auto timelineCount = m_wallpaperTimelineSectionsList.size();
|
||||
const auto timelineCount = m_screenPlayTimeline.m_wallpaperTimelineSectionsList.size();
|
||||
// Only update the next timeline startTime
|
||||
// if we are not end last wallpaper, that always
|
||||
// must end at 24:00
|
||||
if (index <= timelineCount) {
|
||||
auto& wallpapterTimelineSectionNext = m_wallpaperTimelineSectionsList.at(index + 1);
|
||||
auto& wallpapterTimelineSectionNext = m_screenPlayTimeline.m_wallpaperTimelineSectionsList.at(index + 1);
|
||||
wallpapterTimelineSectionNext->startTime = newPositionTime;
|
||||
}
|
||||
|
||||
@ -568,19 +543,19 @@ QString ScreenPlayManager::getTimeString(double relativeLinePosition)
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Update m_wallpaperTimelineSectionsList index based on the startTime;
|
||||
\brief Update m_screenPlayTimeline.m_wallpaperTimelineSectionsList index based on the startTime;
|
||||
*/
|
||||
void ScreenPlayManager::updateIndices()
|
||||
{
|
||||
// Sort the vector based on startTime
|
||||
std::sort(m_wallpaperTimelineSectionsList.begin(), m_wallpaperTimelineSectionsList.end(),
|
||||
std::sort(m_screenPlayTimeline.m_wallpaperTimelineSectionsList.begin(), m_screenPlayTimeline.m_wallpaperTimelineSectionsList.end(),
|
||||
[](const auto& a, const auto& b) {
|
||||
return a->startTime < b->startTime;
|
||||
});
|
||||
|
||||
// Update the indices based on new order
|
||||
for (int i = 0; i < m_wallpaperTimelineSectionsList.size(); ++i) {
|
||||
m_wallpaperTimelineSectionsList[i]->index = i;
|
||||
for (int i = 0; i < m_screenPlayTimeline.m_wallpaperTimelineSectionsList.size(); ++i) {
|
||||
m_screenPlayTimeline.m_wallpaperTimelineSectionsList[i]->index = i;
|
||||
}
|
||||
}
|
||||
|
||||
@ -598,7 +573,7 @@ bool ScreenPlayManager::addTimelineAt(const int index, const float reltiaveLineP
|
||||
|
||||
// We always get the new endTime
|
||||
const QString newStopPosition = getTimeString(reltiaveLinePosition);
|
||||
QTime newStopPositionTime = QTime::fromString(newStopPosition, m_timelineTimeFormat);
|
||||
QTime newStopPositionTime = QTime::fromString(newStopPosition, m_screenPlayTimeline.m_timelineTimeFormat);
|
||||
if (!newStopPositionTime.isValid()) {
|
||||
return false;
|
||||
}
|
||||
@ -623,22 +598,22 @@ bool ScreenPlayManager::addTimelineAt(const int index, const float reltiaveLineP
|
||||
newTimelineSection->identifier = identifier;
|
||||
newTimelineSection->endTime = newStopPositionTime;
|
||||
// In case we do a full reset, we must set the start time manually
|
||||
if (m_wallpaperTimelineSectionsList.empty()) {
|
||||
newTimelineSection->startTime = QTime::fromString("00:00:00", m_timelineTimeFormat);
|
||||
if (m_screenPlayTimeline.m_wallpaperTimelineSectionsList.empty()) {
|
||||
newTimelineSection->startTime = QTime::fromString("00:00:00", m_screenPlayTimeline.m_timelineTimeFormat);
|
||||
} else {
|
||||
|
||||
// We can use the given index here, because it points
|
||||
// the the current item at that index, and we have not yet
|
||||
// added our new timelineSection to our list.
|
||||
newTimelineSection->startTime = m_wallpaperTimelineSectionsList.at(index)->startTime;
|
||||
newTimelineSection->startTime = m_screenPlayTimeline.m_wallpaperTimelineSectionsList.at(index)->startTime;
|
||||
}
|
||||
|
||||
const bool isLast = (m_wallpaperTimelineSectionsList.length() - 1) == index;
|
||||
const bool isLast = (m_screenPlayTimeline.m_wallpaperTimelineSectionsList.length() - 1) == index;
|
||||
if (isLast) {
|
||||
m_wallpaperTimelineSectionsList.last()->startTime = newTimelineSection->endTime;
|
||||
m_screenPlayTimeline.m_wallpaperTimelineSectionsList.last()->startTime = newTimelineSection->endTime;
|
||||
}
|
||||
|
||||
m_wallpaperTimelineSectionsList.append(newTimelineSection);
|
||||
m_screenPlayTimeline.m_wallpaperTimelineSectionsList.append(newTimelineSection);
|
||||
|
||||
updateIndices();
|
||||
printTimelines();
|
||||
@ -659,7 +634,7 @@ void ScreenPlayManager::removeAllTimlineSections()
|
||||
// this shared ptr. We can have many timlines, but the current timeline
|
||||
// can have no active wallpaper
|
||||
|
||||
auto activeTimelineSection = findActiveWallpaperTimelineSection();
|
||||
auto activeTimelineSection = m_screenPlayTimeline.findActiveWallpaperTimelineSection();
|
||||
if (!activeTimelineSection) {
|
||||
qCritical() << "There must always be (lightning) an active timline";
|
||||
return;
|
||||
@ -667,15 +642,12 @@ void ScreenPlayManager::removeAllTimlineSections()
|
||||
|
||||
if (activeTimelineSection) {
|
||||
// Close the localsocket
|
||||
for (auto& activeWallpaper : activeTimelineSection->activeWallpaperList) {
|
||||
activeWallpaper->close();
|
||||
}
|
||||
activeTimelineSection->close();
|
||||
// Reset all active wallpaper
|
||||
activeTimelineSection->activeWallpaperList.clear();
|
||||
activeTimelineSection.reset();
|
||||
}
|
||||
|
||||
m_wallpaperTimelineSectionsList.clear();
|
||||
m_screenPlayTimeline.m_wallpaperTimelineSectionsList.clear();
|
||||
removeAllWallpapers();
|
||||
removeAllWidgets();
|
||||
// Do not call requestSaveProfiles, because qml will add
|
||||
@ -689,7 +661,7 @@ void ScreenPlayManager::removeAllTimlineSections()
|
||||
bool ScreenPlayManager::removeTimelineAt(const int index)
|
||||
{
|
||||
printTimelines();
|
||||
const auto timelineCount = m_wallpaperTimelineSectionsList.size();
|
||||
const auto timelineCount = m_screenPlayTimeline.m_wallpaperTimelineSectionsList.size();
|
||||
if (timelineCount == 0) {
|
||||
qCritical() << "Timeline empty";
|
||||
return false;
|
||||
@ -701,7 +673,7 @@ bool ScreenPlayManager::removeTimelineAt(const int index)
|
||||
m_contentTimer.stop();
|
||||
auto updateTimer = qScopeGuard([this] { m_contentTimer.start(); });
|
||||
|
||||
auto& wallpapterTimelineSection = m_wallpaperTimelineSectionsList.at(index);
|
||||
auto& wallpapterTimelineSection = m_screenPlayTimeline.m_wallpaperTimelineSectionsList.at(index);
|
||||
|
||||
// When we have two timelines, we know that only the first
|
||||
// timeline can be removed and the second one will then span
|
||||
@ -714,8 +686,8 @@ bool ScreenPlayManager::removeTimelineAt(const int index)
|
||||
qCritical() << "Removing the last timeline is not allowed. This must always span the whole timeline";
|
||||
return false;
|
||||
}
|
||||
m_wallpaperTimelineSectionsList.removeAt(index);
|
||||
m_wallpaperTimelineSectionsList.first()->startTime = QTime::fromString("00:00:00", m_timelineTimeFormat);
|
||||
m_screenPlayTimeline.m_wallpaperTimelineSectionsList.removeAt(index);
|
||||
m_screenPlayTimeline.m_wallpaperTimelineSectionsList.first()->startTime = QTime::fromString("00:00:00", m_screenPlayTimeline.m_timelineTimeFormat);
|
||||
updateIndices();
|
||||
printTimelines();
|
||||
return true;
|
||||
@ -728,18 +700,18 @@ bool ScreenPlayManager::removeTimelineAt(const int index)
|
||||
// cannot be deleted
|
||||
QTime endTime;
|
||||
if (index == 0) {
|
||||
endTime = QTime::fromString("00:00:00", m_timelineTimeFormat);
|
||||
endTime = QTime::fromString("00:00:00", m_screenPlayTimeline.m_timelineTimeFormat);
|
||||
} else {
|
||||
endTime = m_wallpaperTimelineSectionsList.at(index - 1)->endTime;
|
||||
endTime = m_screenPlayTimeline.m_wallpaperTimelineSectionsList.at(index - 1)->endTime;
|
||||
}
|
||||
auto timelineAfter = m_wallpaperTimelineSectionsList.at(index + 1);
|
||||
auto timelineAfter = m_screenPlayTimeline.m_wallpaperTimelineSectionsList.at(index + 1);
|
||||
// before remove <- expand
|
||||
// |-----------|-----------|-----------|
|
||||
// 0 1 2
|
||||
// Now when removing timeline at index 1, the next (after)
|
||||
// wallpaper gets the remaining space
|
||||
timelineAfter->startTime = endTime;
|
||||
m_wallpaperTimelineSectionsList.removeAt(index);
|
||||
m_screenPlayTimeline.m_wallpaperTimelineSectionsList.removeAt(index);
|
||||
updateIndices();
|
||||
printTimelines();
|
||||
|
||||
@ -753,19 +725,22 @@ bool ScreenPlayManager::removeTimelineAt(const int index)
|
||||
void ScreenPlayManager::printTimelines()
|
||||
{
|
||||
std::cout << "#############################\n";
|
||||
for (auto& timeline : m_wallpaperTimelineSectionsList) {
|
||||
std::cout << timeline->index << ": " << timeline->identifier.toStdString() << "\t" << timeline->relativePosition << " start: " << timeline->startTime.toString().toStdString() << " end: " << timeline->endTime.toString().toStdString() << std::endl;
|
||||
for (auto& timeline : m_screenPlayTimeline.m_wallpaperTimelineSectionsList) {
|
||||
std::cout << timeline->index << ": " << timeline->identifier.toStdString() << "\t"
|
||||
<< timeline->relativePosition
|
||||
<< " start: " << timeline->startTime.toString().toStdString()
|
||||
<< " end: " << timeline->endTime.toString().toStdString() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Qml function to build our timeline on creation in qml.
|
||||
*/
|
||||
QVariantMap ScreenPlayManager::initialStopPositions()
|
||||
QJsonArray ScreenPlayManager::initialSectionsList()
|
||||
{
|
||||
QVariantMap sectionPositions;
|
||||
for (const auto& timelineSection : m_wallpaperTimelineSectionsList) {
|
||||
sectionPositions.insert({ timelineSection->identifier }, { timelineSection->relativePosition });
|
||||
QJsonArray sectionPositions;
|
||||
for (const auto& timelineSection : m_screenPlayTimeline.m_wallpaperTimelineSectionsList) {
|
||||
sectionPositions.push_back(timelineSection->serialize());
|
||||
}
|
||||
return sectionPositions;
|
||||
}
|
||||
@ -800,7 +775,7 @@ void ScreenPlayManager::newConnection()
|
||||
return;
|
||||
}
|
||||
|
||||
auto activeTimelineSection = findActiveWallpaperTimelineSection();
|
||||
auto activeTimelineSection = m_screenPlayTimeline.findActiveWallpaperTimelineSection();
|
||||
if (!activeTimelineSection) {
|
||||
return;
|
||||
}
|
||||
@ -854,19 +829,21 @@ void ScreenPlayManager::setActiveWidgetsCounter(int activeWidgetsCounter)
|
||||
bool ScreenPlayManager::removeWallpaper(const QString& appID)
|
||||
{
|
||||
|
||||
auto activeTimelineSection = findActiveWallpaperTimelineSection();
|
||||
if (!activeTimelineSection) {
|
||||
qCritical() << "No timeline found.";
|
||||
auto wallpaperSectionOpt = m_screenPlayTimeline.activeWallpaperSectionByAppID(appID);
|
||||
if (!wallpaperSectionOpt.has_value()) {
|
||||
qCritical() << "No wallpaper found.";
|
||||
return false;
|
||||
}
|
||||
if(!wallpaperSectionOpt.value()) {
|
||||
qCritical() << "No wallpaperSectionOpt invalid.";
|
||||
return false;
|
||||
}
|
||||
auto& wallpaperSection = wallpaperSectionOpt.value();
|
||||
|
||||
if(activeTimelineSection->activeWallpaperList.empty())
|
||||
return true;
|
||||
|
||||
activeTimelineSection->activeWallpaperList.erase(
|
||||
wallpaperSection->activeWallpaperList.erase(
|
||||
std::remove_if(
|
||||
activeTimelineSection->activeWallpaperList.begin(),
|
||||
activeTimelineSection->activeWallpaperList.end(),
|
||||
wallpaperSection->activeWallpaperList.begin(),
|
||||
wallpaperSection->activeWallpaperList.end(),
|
||||
[this, appID](std::shared_ptr<ScreenPlayWallpaper>& wallpaper) {
|
||||
if (wallpaper->appID() != appID) {
|
||||
return false;
|
||||
@ -876,16 +853,16 @@ bool ScreenPlayManager::removeWallpaper(const QString& appID)
|
||||
|
||||
// The MonitorListModel contains a shared_ptr of this object that needs to be removed
|
||||
// for shared_ptr to release the object.
|
||||
m_monitorListModel->setWallpaperMonitor({}, wallpaper->monitors());
|
||||
// m_monitorListModel->setWallpaperMonitor({}, wallpaper->monitors());
|
||||
|
||||
wallpaper->close();
|
||||
|
||||
return true;
|
||||
}));
|
||||
|
||||
if (activeWallpaperCounter() != activeTimelineSection->activeWallpaperList.size()) {
|
||||
if (activeWallpaperCounter() != wallpaperSection->activeWallpaperList.size()) {
|
||||
qWarning() << "activeWallpaperCounter value: " << activeWallpaperCounter()
|
||||
<< "does not match m_screenPlayWallpapers length:" << activeTimelineSection->activeWallpaperList.size();
|
||||
<< "does not match m_screenPlayWallpapers length:" << wallpaperSection->activeWallpaperList.size();
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -913,7 +890,6 @@ bool ScreenPlayManager::removeWidget(const QString& appID)
|
||||
|
||||
setActiveWidgetsCounter(activeWidgetsCounter() - 1);
|
||||
|
||||
|
||||
return true;
|
||||
}),
|
||||
m_screenPlayWidgets.end());
|
||||
@ -932,8 +908,8 @@ bool ScreenPlayManager::removeWidget(const QString& appID)
|
||||
*/
|
||||
bool ScreenPlayManager::setWallpaperValue(const QString& appID, const QString& key, const QString& value)
|
||||
{
|
||||
std::shared_ptr<WallpaperTimelineSection> activeTimelineSection = findActiveWallpaperTimelineSection();
|
||||
if(!activeTimelineSection){
|
||||
std::shared_ptr<WallpaperTimelineSection> activeTimelineSection = m_screenPlayTimeline.findActiveWallpaperTimelineSection();
|
||||
if (!activeTimelineSection) {
|
||||
qCritical() << "setWallpaperValue failed, because no active timeline section was found";
|
||||
return false;
|
||||
}
|
||||
@ -956,7 +932,7 @@ bool ScreenPlayManager::saveProfiles()
|
||||
m_saveLimiter.stop();
|
||||
|
||||
QJsonArray timelineWallpaperList {};
|
||||
for (const auto& activeTimelineWallpaper : std::as_const(m_wallpaperTimelineSectionsList)) {
|
||||
for (const auto& activeTimelineWallpaper : std::as_const(m_screenPlayTimeline.m_wallpaperTimelineSectionsList)) {
|
||||
QJsonObject timelineWallpaper;
|
||||
timelineWallpaper.insert("startTime", activeTimelineWallpaper->startTime.toString());
|
||||
timelineWallpaper.insert("endTime", activeTimelineWallpaper->endTime.toString());
|
||||
@ -987,7 +963,6 @@ bool ScreenPlayManager::saveProfiles()
|
||||
profile.insert("version", m_settings->getProfilesVersion().toString());
|
||||
profile.insert("profiles", activeProfileList);
|
||||
|
||||
|
||||
if (m_util.writeJsonObjectToFile({ m_globalVariables->localSettingsPath().toString() + "/profiles.json" }, profile)) {
|
||||
emit profilesSaved();
|
||||
return true;
|
||||
@ -1032,21 +1007,21 @@ bool ScreenPlayManager::loadProfiles()
|
||||
|
||||
for (QJsonValueRef timelineWallpaper : wallpaper.toObject().value("timelineWallpaper").toArray()) {
|
||||
QJsonObject wallpaperObj = timelineWallpaper.toObject();
|
||||
std::optional<std::shared_ptr<WallpaperTimelineSection>> wallpaperDataOpt = loadTimelineWallpaperConfig(wallpaperObj);
|
||||
std::optional<std::shared_ptr<WallpaperTimelineSection>> wallpaperDataOpt = m_screenPlayTimeline.loadTimelineWallpaperConfig(wallpaperObj);
|
||||
if (!wallpaperDataOpt.has_value()) {
|
||||
containsInvalidData = true;
|
||||
break;
|
||||
}
|
||||
|
||||
std::shared_ptr<WallpaperTimelineSection> wallpaperData = wallpaperDataOpt.value();
|
||||
wallpaperData->index = m_wallpaperTimelineSectionsList.length();
|
||||
wallpaperData->index = m_screenPlayTimeline.m_wallpaperTimelineSectionsList.length();
|
||||
wallpaperData->identifier = m_util.generateRandomString(4);
|
||||
|
||||
qInfo() << wallpaperData->index
|
||||
<< wallpaperData->startTime
|
||||
<< wallpaperData->endTime;
|
||||
|
||||
m_wallpaperTimelineSectionsList.append(wallpaperDataOpt.value());
|
||||
m_screenPlayTimeline.m_wallpaperTimelineSectionsList.append(wallpaperDataOpt.value());
|
||||
}
|
||||
|
||||
for (const QJsonValueRef widget : wallpaper.toObject().value("widgets").toArray()) {
|
||||
@ -1062,144 +1037,29 @@ bool ScreenPlayManager::loadProfiles()
|
||||
if (containsInvalidData)
|
||||
saveProfiles();
|
||||
|
||||
checkActiveWallpaperTimeline();
|
||||
activateNewTimeline();
|
||||
m_contentTimer.start();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Calculates the relative position of a given time within a day.
|
||||
*
|
||||
* This function takes a QTime object representing the end time and calculates its
|
||||
* position relative to a fixed start and end time on the same day. The relative position
|
||||
* is a normalized value between 0 and 1, rounded to four decimal places.
|
||||
*
|
||||
* \param endTime The time for which to calculate the relative position.
|
||||
* \return A float representing the normalized relative position of endTime, rounded to four decimal places.
|
||||
*/
|
||||
float calculateRelativePosition(const QTime& endTime)
|
||||
void ScreenPlayManager::updateQmlTimelines()
|
||||
{
|
||||
QTime startTime(0, 0, 0); // Start of the day
|
||||
QTime maxTime(23, 59, 59); // End of the day range
|
||||
QVariantList data;
|
||||
for (const auto& timelineSection : m_screenPlayTimeline.m_wallpaperTimelineSectionsList) {
|
||||
if (timelineSection->wallpaperData.empty())
|
||||
continue;
|
||||
|
||||
// Total number of seconds from startTime to maxTime
|
||||
int totalSeconds = startTime.secsTo(maxTime);
|
||||
|
||||
// Seconds from startTime to the given endTime
|
||||
int endTimeSeconds = startTime.secsTo(endTime);
|
||||
|
||||
// Calculate the relative position
|
||||
float relativePosition = static_cast<float>(endTimeSeconds) / totalSeconds;
|
||||
|
||||
// Round to four decimal places
|
||||
return qRound(relativePosition * 10000.0) / 10000.0;
|
||||
// We just use the frist one
|
||||
const auto& wp = timelineSection->wallpaperData.front();
|
||||
data.append(QVariant::fromValue(wp.previewImage));
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Parses one timeline wallpaper:
|
||||
|
||||
"timelineWallpaper": [
|
||||
{
|
||||
"endTime": "08:32:00",
|
||||
"startTime": "00:00:00",
|
||||
"wallpaper": [
|
||||
[...]
|
||||
]
|
||||
},
|
||||
*/
|
||||
std::optional<std::shared_ptr<WallpaperTimelineSection>> ScreenPlayManager::loadTimelineWallpaperConfig(const QJsonObject& timelineObj)
|
||||
{
|
||||
const QTime startTime = QTime::fromString(timelineObj.value("startTime").toString(), m_timelineTimeFormat);
|
||||
const QTime endTime = QTime::fromString(timelineObj.value("endTime").toString(), m_timelineTimeFormat);
|
||||
if (startTime > endTime) {
|
||||
qCritical() << "Invalid time, start time is later than end time: " << startTime.toString() << endTime.toString();
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
// TODO check license
|
||||
auto timelineSection = std::make_shared<WallpaperTimelineSection>();
|
||||
timelineSection->startTime = startTime;
|
||||
timelineSection->endTime = endTime;
|
||||
timelineSection->relativePosition = calculateRelativePosition(endTime);
|
||||
const auto wallpaperList = timelineObj.value("wallpaper").toArray();
|
||||
for (auto& wallpaper : wallpaperList) {
|
||||
std::optional<WallpaperData> wallpaperDataOpt = loadWallpaperConfig(wallpaper.toObject());
|
||||
if (!wallpaperDataOpt.has_value())
|
||||
return std::nullopt;
|
||||
timelineSection->wallpaperData.push_back(wallpaperDataOpt.value());
|
||||
}
|
||||
return timelineSection;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Loads the wallpaper object in the wallpaper array:
|
||||
|
||||
"timelineWallpaper": [
|
||||
{
|
||||
"endTime": "08:32:00",
|
||||
"startTime": "00:00:00",
|
||||
"wallpaper": [
|
||||
{
|
||||
"absolutePath": "file:///C:/Code/Cpp/ScreenPlay/672870/1234567",
|
||||
"file": "AAA.webm",
|
||||
"fillMode": "Cover",
|
||||
"isLooping": false,
|
||||
"monitors": [
|
||||
0
|
||||
],
|
||||
"playbackRate": 1,
|
||||
"previewImage": "previewThumbnail.jpg",
|
||||
"properties": {
|
||||
},
|
||||
"type": "VideoWallpaper",
|
||||
"volume": 1
|
||||
}
|
||||
]
|
||||
},
|
||||
*/
|
||||
std::optional<WallpaperData> ScreenPlayManager::loadWallpaperConfig(const QJsonObject& wallpaperObj)
|
||||
{
|
||||
if (wallpaperObj.empty())
|
||||
return std::nullopt;
|
||||
|
||||
QJsonArray monitorsArray = wallpaperObj.value("monitors").toArray();
|
||||
|
||||
QVector<int> monitors;
|
||||
for (const QJsonValueRef monitorNumber : monitorsArray) {
|
||||
int value = monitorNumber.toInt(-1);
|
||||
if (value == -1) {
|
||||
qWarning() << "Could not parse monitor number to display content at";
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
if (monitors.contains(value)) {
|
||||
qWarning() << "The monitor: " << value << " is sharing the config multiple times. ";
|
||||
return std::nullopt;
|
||||
}
|
||||
monitors.append(value);
|
||||
}
|
||||
|
||||
float volume = static_cast<float>(wallpaperObj.value("volume").toDouble(-1.0));
|
||||
|
||||
if (volume == -1.0F)
|
||||
volume = 1.0f;
|
||||
|
||||
WallpaperData wallpaperData;
|
||||
wallpaperData.monitors = monitors;
|
||||
wallpaperData.volume = volume;
|
||||
wallpaperData.absolutePath = wallpaperObj.value("absolutePath").toString();
|
||||
wallpaperData.previewImage = wallpaperObj.value("previewImage").toString();
|
||||
wallpaperData.playbackRate = wallpaperObj.value("playbackRate").toDouble(1.0);
|
||||
wallpaperData.file = wallpaperObj.value("file").toString();
|
||||
wallpaperData.properties = wallpaperObj.value("properties").toObject();
|
||||
|
||||
const QString fillModeString = wallpaperObj.value("fillMode").toString();
|
||||
const QString typeString = wallpaperObj.value("type").toString();
|
||||
wallpaperData.type = QStringToEnum<ContentTypes::InstalledType>(typeString, ContentTypes::InstalledType::VideoWallpaper);
|
||||
wallpaperData.fillMode = QStringToEnum<Video::FillMode>(fillModeString, Video::FillMode::Cover);
|
||||
return wallpaperData;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Loads a widget from C:\Users\XXX\AppData\Local\ScreenPlay\ScreenPlay\profiles.json
|
||||
|
106
ScreenPlay/src/screenplaytimeline.cpp
Normal file
106
ScreenPlay/src/screenplaytimeline.cpp
Normal file
@ -0,0 +1,106 @@
|
||||
#include "screenplaytimeline.h"
|
||||
#include "ScreenPlay/screenplaywallpaper.h"
|
||||
#include "ScreenPlay/wallpaperdata.h"
|
||||
|
||||
namespace ScreenPlay {
|
||||
/*!
|
||||
* \brief Calculates the relative position of a given time within a day.
|
||||
* * This function takes a QTime object representing the end time and calculates its
|
||||
* position relative to a fixed start and end time on the same day. The relative position
|
||||
* is a normalized value between 0 and 1, rounded to four decimal places.
|
||||
* * \param endTime The time for which to calculate the relative position.
|
||||
* \return A float representing the normalized relative position of endTime, rounded to four decimal places.
|
||||
*/
|
||||
float ScreenPlayTimeline::calculateRelativePosition(const QTime &endTime)
|
||||
{
|
||||
QTime startTime(0, 0, 0); // Start of the day
|
||||
QTime maxTime(23, 59, 59); // End of the day range
|
||||
|
||||
// Total number of seconds from startTime to maxTime
|
||||
int totalSeconds = startTime.secsTo(maxTime);
|
||||
|
||||
// Seconds from startTime to the given endTime
|
||||
int endTimeSeconds = startTime.secsTo(endTime);
|
||||
|
||||
// Calculate the relative position
|
||||
float relativePosition = static_cast<float>(endTimeSeconds) / totalSeconds;
|
||||
|
||||
// Round to four decimal places
|
||||
return qRound(relativePosition * 10000.0) / 10000.0;
|
||||
}
|
||||
|
||||
std::optional<std::shared_ptr<ScreenPlay::WallpaperTimelineSection> > ScreenPlay::ScreenPlayTimeline::loadTimelineWallpaperConfig(const QJsonObject &timelineObj)
|
||||
{
|
||||
const QTime startTime = QTime::fromString(timelineObj.value("startTime").toString(), m_timelineTimeFormat);
|
||||
const QTime endTime = QTime::fromString(timelineObj.value("endTime").toString(), m_timelineTimeFormat);
|
||||
if (startTime > endTime) {
|
||||
qCritical() << "Invalid time, start time is later than end time: " << startTime.toString() << endTime.toString();
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
// TODO check license
|
||||
auto timelineSection = std::make_shared<WallpaperTimelineSection>();
|
||||
timelineSection->startTime = startTime;
|
||||
timelineSection->endTime = endTime;
|
||||
timelineSection->relativePosition = calculateRelativePosition(endTime);
|
||||
const auto wallpaperList = timelineObj.value("wallpaper").toArray();
|
||||
for (auto& wallpaper : wallpaperList) {
|
||||
std::optional<WallpaperData> wallpaperDataOpt = WallpaperData::loadWallpaperConfig(wallpaper.toObject());
|
||||
if (!wallpaperDataOpt.has_value())
|
||||
return std::nullopt;
|
||||
timelineSection->wallpaperData.push_back(wallpaperDataOpt.value());
|
||||
}
|
||||
return timelineSection;
|
||||
}
|
||||
/*!
|
||||
\brief Parses one timeline wallpaper:
|
||||
|
||||
"timelineWallpaper": [
|
||||
{
|
||||
"endTime": "08:32:00",
|
||||
"startTime": "00:00:00",
|
||||
"wallpaper": [
|
||||
[...]
|
||||
]
|
||||
},
|
||||
*/
|
||||
std::shared_ptr<WallpaperTimelineSection> ScreenPlayTimeline::findActiveWallpaperTimelineSection()
|
||||
{
|
||||
for (const auto& section : m_wallpaperTimelineSectionsList) {
|
||||
if (section->isActive) {
|
||||
return section;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
/*!
|
||||
\brief Returns the wallpaper timeline that has the isActive
|
||||
flag enabled.
|
||||
*/
|
||||
std::optional<std::shared_ptr<WallpaperTimelineSection> > ScreenPlayTimeline::activeWallpaperSectionByAppID(const QString &appID)
|
||||
{
|
||||
for (const auto& section : m_wallpaperTimelineSectionsList) {
|
||||
for (const auto& wallpaper : section->activeWallpaperList) {
|
||||
if(wallpaper->appID() == appID)
|
||||
return section;
|
||||
}
|
||||
}
|
||||
qCritical() << "No matching appID for:"<< appID;
|
||||
return nullptr;
|
||||
}
|
||||
/*!
|
||||
\brief Returns the current active timline. There must always be an active timeline!
|
||||
*/
|
||||
std::shared_ptr<WallpaperTimelineSection> ScreenPlayTimeline::getCurrentTimeline()
|
||||
{
|
||||
const QTime currentTime = QTime::currentTime();
|
||||
for (const auto& section : m_wallpaperTimelineSectionsList) {
|
||||
if (section->containsTime(currentTime)) {
|
||||
return section;
|
||||
}
|
||||
}
|
||||
qCritical() << "No active timeline";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
}
|
98
ScreenPlay/src/wallpaperdata.cpp
Normal file
98
ScreenPlay/src/wallpaperdata.cpp
Normal file
@ -0,0 +1,98 @@
|
||||
#include "wallpaperdata.h"
|
||||
#include "ScreenPlayUtil/util.h"
|
||||
|
||||
namespace ScreenPlay {
|
||||
|
||||
|
||||
/*!
|
||||
\brief Loads the wallpaper object in the wallpaper array:
|
||||
|
||||
"timelineWallpaper": [
|
||||
{
|
||||
"endTime": "08:32:00",
|
||||
"startTime": "00:00:00",
|
||||
"wallpaper": [
|
||||
{
|
||||
"absolutePath": "file:///C:/Code/Cpp/ScreenPlay/672870/1234567",
|
||||
"file": "AAA.webm",
|
||||
"fillMode": "Cover",
|
||||
"isLooping": false,
|
||||
"monitors": [
|
||||
0
|
||||
],
|
||||
"playbackRate": 1,
|
||||
"previewImage": "previewThumbnail.jpg",
|
||||
"properties": {
|
||||
},
|
||||
"type": "VideoWallpaper",
|
||||
"volume": 1
|
||||
}
|
||||
]
|
||||
},
|
||||
*/
|
||||
QJsonObject WallpaperData::serialize() const
|
||||
{
|
||||
QJsonObject data;
|
||||
data.insert("isLooping", isLooping);
|
||||
data.insert("absolutePath", absolutePath);
|
||||
data.insert("previewImage", previewImage);
|
||||
data.insert("playbackRate", playbackRate);
|
||||
data.insert("volume", volume);
|
||||
data.insert("file", file);
|
||||
data.insert("properties", properties);
|
||||
data.insert("type", QVariant::fromValue(type).toString());
|
||||
data.insert("fillMode", QVariant::fromValue(fillMode).toString());
|
||||
|
||||
// Serialize QVector<int> monitors
|
||||
QJsonArray monitorArray;
|
||||
for (int monitor : monitors) {
|
||||
monitorArray.append(monitor);
|
||||
}
|
||||
data.insert("monitors", monitorArray);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
std::optional<ScreenPlay::WallpaperData> ScreenPlay::WallpaperData::loadWallpaperConfig(const QJsonObject &wallpaperObj)
|
||||
{
|
||||
if (wallpaperObj.empty())
|
||||
return std::nullopt;
|
||||
|
||||
QJsonArray monitorsArray = wallpaperObj.value("monitors").toArray();
|
||||
|
||||
QVector<int> monitors;
|
||||
for (const QJsonValueRef monitorNumber : monitorsArray) {
|
||||
int value = monitorNumber.toInt(-1);
|
||||
if (value == -1) {
|
||||
qWarning() << "Could not parse monitor number to display content at";
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
if (monitors.contains(value)) {
|
||||
qWarning() << "The monitor: " << value << " is sharing the config multiple times. ";
|
||||
return std::nullopt;
|
||||
}
|
||||
monitors.append(value);
|
||||
}
|
||||
|
||||
float volume = static_cast<float>(wallpaperObj.value("volume").toDouble(-1.0));
|
||||
|
||||
if (volume == -1.0F)
|
||||
volume = 1.0f;
|
||||
|
||||
WallpaperData wallpaperData;
|
||||
wallpaperData.monitors = monitors;
|
||||
wallpaperData.volume = volume;
|
||||
wallpaperData.absolutePath = wallpaperObj.value("absolutePath").toString();
|
||||
wallpaperData.previewImage = wallpaperObj.value("previewImage").toString();
|
||||
wallpaperData.playbackRate = wallpaperObj.value("playbackRate").toDouble(1.0);
|
||||
wallpaperData.file = wallpaperObj.value("file").toString();
|
||||
wallpaperData.properties = wallpaperObj.value("properties").toObject();
|
||||
|
||||
const QString fillModeString = wallpaperObj.value("fillMode").toString();
|
||||
const QString typeString = wallpaperObj.value("type").toString();
|
||||
wallpaperData.type = QStringToEnum<ContentTypes::InstalledType>(typeString, ContentTypes::InstalledType::VideoWallpaper);
|
||||
wallpaperData.fillMode = QStringToEnum<Video::FillMode>(fillModeString, Video::FillMode::Cover);
|
||||
return wallpaperData;
|
||||
}
|
||||
}
|
10
ScreenPlay/src/wallpapertimelinesection.cpp
Normal file
10
ScreenPlay/src/wallpapertimelinesection.cpp
Normal file
@ -0,0 +1,10 @@
|
||||
#include "wallpapertimelinesection.h"
|
||||
#include "ScreenPlay/screenplaywallpaper.h"
|
||||
|
||||
bool ScreenPlay::WallpaperTimelineSection::close(){
|
||||
for (auto& wallpaper : activeWallpaperList) {
|
||||
wallpaper->close();
|
||||
}
|
||||
activeWallpaperList.clear();
|
||||
return true;
|
||||
}
|
@ -28,7 +28,6 @@ public:
|
||||
\brief When changing the enum, one also needs to change:
|
||||
GlobalVariables::getAvailableWallpaper
|
||||
GlobalVariables::getAvailableWidgets
|
||||
Common/Util.js isWallpaper() and isWidget()
|
||||
ScreenPlayWallpaper: BaseWindow::parseWallpaperType()
|
||||
*/
|
||||
enum class InstalledType {
|
||||
@ -71,7 +70,6 @@ public:
|
||||
\brief When changing the enum, one also needs to change:
|
||||
GlobalVariables::getAvailableWallpaper
|
||||
GlobalVariables::getAvailableWidgets
|
||||
Common/Util.js isWallpaper() and isWidget()
|
||||
ScreenPlayWallpaper: BaseWindow::parseWallpaperType()
|
||||
*/
|
||||
|
||||
|
@ -408,14 +408,14 @@ QStringList Util::getAvailableTypes() const
|
||||
*/
|
||||
bool Util::isWallpaper(const ScreenPlay::ContentTypes::InstalledType type) const
|
||||
{
|
||||
|
||||
using namespace ScreenPlay;
|
||||
return (type == ContentTypes::InstalledType::VideoWallpaper
|
||||
|| type == ContentTypes::InstalledType::QMLWallpaper
|
||||
|| type == ContentTypes::InstalledType::HTMLWallpaper
|
||||
|| type == ContentTypes::InstalledType::GifWallpaper
|
||||
|| type == ContentTypes::InstalledType::WebsiteWallpaper
|
||||
|| type == ContentTypes::InstalledType::GodotWallpaper);
|
||||
using enum ContentTypes::InstalledType;
|
||||
return (type == VideoWallpaper
|
||||
|| type == QMLWallpaper
|
||||
|| type == HTMLWallpaper
|
||||
|| type == GifWallpaper
|
||||
|| type == WebsiteWallpaper
|
||||
|| type == GodotWallpaper);
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -424,8 +424,8 @@ bool Util::isWallpaper(const ScreenPlay::ContentTypes::InstalledType type) const
|
||||
bool Util::isWidget(const ScreenPlay::ContentTypes::InstalledType type) const
|
||||
{
|
||||
using namespace ScreenPlay;
|
||||
|
||||
return (type == ContentTypes::InstalledType::QMLWidget || type == ContentTypes::InstalledType::HTMLWidget);
|
||||
using enum ContentTypes::InstalledType;
|
||||
return (type == QMLWidget || type == HTMLWidget);
|
||||
}
|
||||
/*!
|
||||
\brief Returns true of the given type is a isScene.
|
||||
@ -433,11 +433,11 @@ bool Util::isWidget(const ScreenPlay::ContentTypes::InstalledType type) const
|
||||
bool Util::isScene(const ScreenPlay::ContentTypes::InstalledType type) const
|
||||
{
|
||||
using namespace ScreenPlay;
|
||||
|
||||
return (type == ContentTypes::InstalledType::HTMLWallpaper
|
||||
|| type == ContentTypes::InstalledType::QMLWallpaper
|
||||
|| type == ContentTypes::InstalledType::WebsiteWallpaper
|
||||
|| type == ContentTypes::InstalledType::GodotWallpaper);
|
||||
using enum ContentTypes::InstalledType;
|
||||
return (type == HTMLWallpaper
|
||||
|| type == QMLWallpaper
|
||||
|| type == WebsiteWallpaper
|
||||
|| type == GodotWallpaper);
|
||||
}
|
||||
/*!
|
||||
\brief Returns true of the given type is a isVideo.
|
||||
@ -445,9 +445,9 @@ bool Util::isScene(const ScreenPlay::ContentTypes::InstalledType type) const
|
||||
bool Util::isVideo(const ScreenPlay::ContentTypes::InstalledType type) const
|
||||
{
|
||||
using namespace ScreenPlay;
|
||||
|
||||
return (type == ContentTypes::InstalledType::VideoWallpaper
|
||||
|| type == ContentTypes::InstalledType::GifWallpaper);
|
||||
using enum ContentTypes::InstalledType;
|
||||
return (type == VideoWallpaper
|
||||
|| type == GifWallpaper);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -57,6 +57,12 @@ Rectangle {
|
||||
root.canFadeByWallpaperFillMode = false;
|
||||
return;
|
||||
}
|
||||
// For example if background is a solid color
|
||||
if(Wallpaper.windowsDesktopProperties.wallpaperPath === ""){
|
||||
root.canFadeByWallpaperFillMode = false;
|
||||
return;
|
||||
}
|
||||
|
||||
imgCover.source = Qt.resolvedUrl("file:///" + Wallpaper.windowsDesktopProperties.wallpaperPath);
|
||||
switch (Wallpaper.windowsDesktopProperties.wallpaperStyle) {
|
||||
case 10:
|
||||
|
Loading…
Reference in New Issue
Block a user