mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-09-18 16:32:33 +02:00
Videos working again!
This commit is contained in:
parent
831030cf89
commit
2ead9670ff
@ -12,7 +12,8 @@ SOURCES += main.cpp \
|
||||
src/packagefilehandler.cpp \
|
||||
src/wallpaper.cpp \
|
||||
src/profilelistmodel.cpp \
|
||||
src/profile.cpp
|
||||
src/profile.cpp \
|
||||
src/projectfile.cpp
|
||||
|
||||
RESOURCES += qml.qrc
|
||||
|
||||
@ -25,7 +26,8 @@ HEADERS += \
|
||||
src/packagefilehandler.h \
|
||||
src/wallpaper.h \
|
||||
src/profilelistmodel.h \
|
||||
src/profile.h
|
||||
src/profile.h \
|
||||
src/projectfile.h
|
||||
|
||||
INCLUDEPATH += \
|
||||
$$PWD/ThirdParty/ \
|
||||
|
@ -1,26 +1,29 @@
|
||||
import QtQuick 2.0
|
||||
//import QtAV 1.07
|
||||
import QtQuick 2.7
|
||||
import QtAV 1.07
|
||||
|
||||
|
||||
Rectangle {
|
||||
color: "orange"
|
||||
color: "gray"
|
||||
visible: true
|
||||
|
||||
|
||||
// height: parent.height
|
||||
// width: parent.width
|
||||
|
||||
|
||||
// Connections {
|
||||
// target: installedListModel
|
||||
// onSetScreenToVideo:{
|
||||
// installedListModel.setScreenVisibleFromQml(true)
|
||||
// video.stop()
|
||||
// video.source = absolutePath;
|
||||
// video.play();
|
||||
// }
|
||||
// }
|
||||
// Video {
|
||||
// id: video
|
||||
// anchors.fill: parent
|
||||
// }
|
||||
Video {
|
||||
id: video
|
||||
anchors.fill: parent
|
||||
videoCodecPriority: ["CUDA", "D3D11", "DXVA", "VAAPI", "FFmpeg"]
|
||||
onPlaybackStateChanged: {
|
||||
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
|
||||
video.source = Qt.resolvedUrl("file:///" + wallpaper.absoluteFilePath.toString())
|
||||
video.play()
|
||||
}
|
||||
onStopped: {
|
||||
video.play()
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -18,13 +18,13 @@ QVariant InstalledListModel::data(const QModelIndex& index, int role) const
|
||||
if (index.row() < rowCount())
|
||||
switch (role) {
|
||||
case TitleRole:
|
||||
return m_screenPlayFiles.at(index.row())._title;
|
||||
return m_screenPlayFiles.at(index.row()).m_title;
|
||||
case PreviewRole:
|
||||
return m_screenPlayFiles.at(index.row())._preview;
|
||||
return m_screenPlayFiles.at(index.row()).m_preview;
|
||||
case FolderIdRole:
|
||||
return m_screenPlayFiles.at(index.row())._folderId;
|
||||
return m_screenPlayFiles.at(index.row()).m_folderId;
|
||||
case FileIdRole:
|
||||
return m_screenPlayFiles.at(index.row())._file;
|
||||
return m_screenPlayFiles.at(index.row()).m_file;
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
@ -42,13 +42,24 @@ QHash<int, QByteArray> InstalledListModel::roleNames() const
|
||||
return roles;
|
||||
}
|
||||
|
||||
bool InstalledListModel::getProjectByName(QString profileName, ProjectFile *spf)
|
||||
{
|
||||
for (int i = 0; i < m_screenPlayFiles.size(); i++) {
|
||||
if (m_screenPlayFiles.at(i).m_folderId == profileName) {
|
||||
*spf = m_screenPlayFiles.at(i);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void InstalledListModel::append(const QJsonObject obj, const QString folderName)
|
||||
{
|
||||
int row = 0;
|
||||
|
||||
beginInsertRows(QModelIndex(), row, row);
|
||||
|
||||
ScreenPlayFile tmpFile(obj, folderName);
|
||||
ProjectFile tmpFile(obj, folderName);
|
||||
m_screenPlayFiles.append(tmpFile);
|
||||
|
||||
endInsertRows();
|
||||
@ -89,39 +100,14 @@ QVariantMap InstalledListModel::get(QString folderId)
|
||||
|
||||
for (int i = 0; i < m_screenPlayFiles.count(); i++) {
|
||||
|
||||
if (m_screenPlayFiles[i]._folderId == folderId) {
|
||||
map.insert("screenTitle", m_screenPlayFiles[i]._title);
|
||||
map.insert("screenPreview", m_screenPlayFiles[i]._preview);
|
||||
map.insert("screenFile", m_screenPlayFiles[i]._file);
|
||||
if (m_screenPlayFiles[i].m_folderId == folderId) {
|
||||
map.insert("screenTitle", m_screenPlayFiles[i].m_title);
|
||||
map.insert("screenPreview", m_screenPlayFiles[i].m_preview);
|
||||
map.insert("screenFile", m_screenPlayFiles[i].m_file);
|
||||
}
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
void InstalledListModel::setScreenVisibleFromQml(bool visible)
|
||||
{
|
||||
emit setScreenVisible(visible);
|
||||
}
|
||||
|
||||
void InstalledListModel::setScreenToVideoFromQml(QString absolutePath)
|
||||
{
|
||||
emit setScreenToVideo(absolutePath);
|
||||
}
|
||||
|
||||
ScreenPlayFile::ScreenPlayFile(QJsonObject obj, QString folderName)
|
||||
{
|
||||
if (obj.contains("description"))
|
||||
_description = obj.value("description");
|
||||
|
||||
if (obj.contains("file"))
|
||||
_file = obj.value("file");
|
||||
|
||||
if (obj.contains("preview"))
|
||||
_preview = obj.value("preview");
|
||||
|
||||
if (obj.contains("title"))
|
||||
_title = obj.value("title");
|
||||
|
||||
_folderId = folderName;
|
||||
}
|
||||
|
@ -15,8 +15,10 @@
|
||||
#include <QString>
|
||||
#include <QUrl>
|
||||
#include <QtConcurrent/QtConcurrent>
|
||||
#include "profilelistmodel.h"
|
||||
#include "projectfile.h"
|
||||
|
||||
|
||||
class ScreenPlayFile;
|
||||
|
||||
class InstalledListModel : public QAbstractListModel {
|
||||
Q_OBJECT
|
||||
@ -29,12 +31,13 @@ public:
|
||||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
|
||||
void append(const QJsonObject, const QString);
|
||||
QHash<int, QByteArray> roleNames() const override;
|
||||
bool getProjectByName(QString profileName, ProjectFile* spf);
|
||||
|
||||
Q_INVOKABLE void loadScreens();
|
||||
Q_INVOKABLE QVariantMap get(QString folderId);
|
||||
Q_INVOKABLE void setScreenVisibleFromQml(bool visible);
|
||||
Q_INVOKABLE void setScreenToVideoFromQml(QString absolutePath);
|
||||
Q_PROPERTY(QUrl absoluteStoragePath READ absoluteStoragePath WRITE setabsoluteStoragePath NOTIFY absoluteStoragePathChanged)
|
||||
|
||||
|
||||
enum InstalledRole {
|
||||
TitleRole,
|
||||
PreviewRole,
|
||||
@ -66,24 +69,8 @@ signals:
|
||||
void absoluteStoragePathChanged(QUrl absoluteStoragePath);
|
||||
|
||||
private:
|
||||
QList<ScreenPlayFile> m_screenPlayFiles;
|
||||
QList<ProjectFile> m_screenPlayFiles;
|
||||
QUrl m_absoluteStoragePath;
|
||||
};
|
||||
|
||||
class ScreenPlayFile {
|
||||
|
||||
public:
|
||||
ScreenPlayFile();
|
||||
ScreenPlayFile(QJsonObject obj, QString folderName);
|
||||
|
||||
QVariant _description;
|
||||
QVariant _file;
|
||||
QVariant _preview;
|
||||
QVariant _title;
|
||||
QString _folderId;
|
||||
QUrl _absolutePath;
|
||||
|
||||
QVariantList _tags; //TODO: Implement me!
|
||||
};
|
||||
|
||||
#endif // INSTALLEDLISTMODEL_H
|
||||
|
@ -6,6 +6,7 @@ MonitorListModel::MonitorListModel(QObject *parent)
|
||||
loadMonitors();
|
||||
}
|
||||
|
||||
|
||||
QHash<int, QByteArray> MonitorListModel::roleNames() const
|
||||
{
|
||||
static const QHash<int, QByteArray> roles{
|
||||
|
@ -94,6 +94,8 @@ void ProfileListModel::loadProfiles()
|
||||
if (profileObj.contains("isLooping"))
|
||||
tmpProfile.m_isLooping = profileObj.value("isLooping").toBool();
|
||||
|
||||
tmpProfile.m_absolutePath = m_absoluteStoragePath;
|
||||
|
||||
m_profileList.append(tmpProfile);
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@ public:
|
||||
NumberRole = Qt::UserRole + 2
|
||||
};
|
||||
|
||||
|
||||
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
|
||||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
|
||||
virtual QHash<int, QByteArray> roleNames() const override;
|
||||
|
22
src/projectfile.cpp
Normal file
22
src/projectfile.cpp
Normal file
@ -0,0 +1,22 @@
|
||||
#include "projectfile.h"
|
||||
|
||||
ProjectFile::ProjectFile()
|
||||
{
|
||||
|
||||
}
|
||||
ProjectFile::ProjectFile(QJsonObject obj, QString folderName)
|
||||
{
|
||||
if (obj.contains("description"))
|
||||
m_description = obj.value("description");
|
||||
|
||||
if (obj.contains("file"))
|
||||
m_file = obj.value("file");
|
||||
|
||||
if (obj.contains("preview"))
|
||||
m_preview = obj.value("preview");
|
||||
|
||||
if (obj.contains("title"))
|
||||
m_title = obj.value("title");
|
||||
|
||||
m_folderId = folderName;
|
||||
}
|
25
src/projectfile.h
Normal file
25
src/projectfile.h
Normal file
@ -0,0 +1,25 @@
|
||||
#ifndef PROJECTFILE_H
|
||||
#define PROJECTFILE_H
|
||||
|
||||
#include <QJsonObject>
|
||||
#include <QUrl>
|
||||
#include <QVariant>
|
||||
#include <QVariantList>
|
||||
|
||||
class ProjectFile
|
||||
{
|
||||
public:
|
||||
ProjectFile();
|
||||
ProjectFile(QJsonObject obj, QString folderName);
|
||||
|
||||
QVariant m_description;
|
||||
QVariant m_file;
|
||||
QVariant m_preview;
|
||||
QVariant m_title;
|
||||
QString m_folderId;
|
||||
QUrl m_absolutePath;
|
||||
|
||||
QVariantList m_tags; //TODO: Implement me!
|
||||
};
|
||||
|
||||
#endif // PROJECTFILE_H
|
@ -8,7 +8,6 @@ Settings::Settings(ProfileListModel* plm, MonitorListModel* mlm, InstalledListMo
|
||||
m_mlm = mlm;
|
||||
m_ilm = ilm;
|
||||
|
||||
|
||||
QFile configTmp;
|
||||
QString appConfigLocation = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation);
|
||||
|
||||
@ -27,7 +26,6 @@ Settings::Settings(ProfileListModel* plm, MonitorListModel* mlm, InstalledListMo
|
||||
createDefaultConfig();
|
||||
}
|
||||
|
||||
|
||||
QJsonDocument configJsonDocument;
|
||||
QJsonParseError parseError;
|
||||
QJsonObject configObj;
|
||||
@ -55,7 +53,6 @@ Settings::Settings(ProfileListModel* plm, MonitorListModel* mlm, InstalledListMo
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (QString(configObj.value("absoluteStoragePath").toString()).isEmpty()) {
|
||||
m_absoluteStoragePath = appConfigLocation;
|
||||
} else {
|
||||
@ -65,7 +62,6 @@ Settings::Settings(ProfileListModel* plm, MonitorListModel* mlm, InstalledListMo
|
||||
m_ilm->setabsoluteStoragePath(m_absoluteStoragePath);
|
||||
m_plm->m_absoluteStoragePath = m_absoluteStoragePath;
|
||||
|
||||
|
||||
//Create default folders
|
||||
if (!QDir(m_absoluteStoragePath.toString() + "/ProfilePackages").exists()) {
|
||||
if (!QDir().mkdir(appConfigLocation + "/ProfilePackages")) {
|
||||
@ -96,16 +92,19 @@ Settings::Settings(ProfileListModel* plm, MonitorListModel* mlm, InstalledListMo
|
||||
m_highPriorityStart = configObj.value("highPriorityStart").toBool();
|
||||
m_sendStatistics = configObj.value("sendStatistics").toBool();
|
||||
m_renderer = static_cast<Renderer>(configObj.value("renderer-value").toInt());
|
||||
}
|
||||
|
||||
Settings::~Settings()
|
||||
{
|
||||
}
|
||||
|
||||
void Settings::createNewProfile(int screenNumber)
|
||||
{
|
||||
}
|
||||
|
||||
void Settings::constructWallpaper(Profile profile, QString monitorID)
|
||||
void Settings::constructWallpaper(Profile profile, QString monitorID, ProjectFile pf)
|
||||
{
|
||||
m_wallpapers.append(QSharedPointer<Wallpaper>(new Wallpaper(profile)));
|
||||
m_wallpapers.append(QSharedPointer<Wallpaper>(new Wallpaper(profile,pf)));
|
||||
}
|
||||
|
||||
void Settings::loadActiveProfiles()
|
||||
@ -129,15 +128,27 @@ void Settings::loadActiveProfiles()
|
||||
QString profileName = activeProfilesTmp.at(i).toObject().value("profile").toString();
|
||||
QString monitorID = activeProfilesTmp.at(i).toObject().value("monitorID").toString();
|
||||
Profile profile;
|
||||
ProjectFile spf;
|
||||
|
||||
if (!m_plm->getProfileByName(profileName, &profile))
|
||||
continue;
|
||||
if (!m_ilm->getProjectByName(profile.m_wallpaperId, &spf))
|
||||
continue;
|
||||
|
||||
constructWallpaper(profile, monitorID);
|
||||
|
||||
|
||||
|
||||
constructWallpaper(profile, monitorID, spf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Settings::removeAll()
|
||||
{
|
||||
qDebug() << "destruct settings";
|
||||
m_wallpapers.clear();
|
||||
}
|
||||
|
||||
void Settings::createDefaultConfig()
|
||||
{
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QObject>
|
||||
#include <QThread>
|
||||
#include <QPair>
|
||||
#include <QQmlPropertyMap>
|
||||
#include <QStandardPaths>
|
||||
@ -18,6 +19,7 @@
|
||||
#include <QVector>
|
||||
#include <QSharedPointer>
|
||||
|
||||
|
||||
#include "monitorlistmodel.h"
|
||||
#include "installedlistmodel.h"
|
||||
#include "profilelistmodel.h"
|
||||
@ -30,7 +32,7 @@ class Settings : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit Settings(ProfileListModel* plm, MonitorListModel* mlm, InstalledListModel* ilm, QObject* parent = nullptr);
|
||||
|
||||
~Settings();
|
||||
Q_PROPERTY(bool autostart READ autostart WRITE setAutostart NOTIFY autostartChanged)
|
||||
Q_PROPERTY(bool highPriorityStart READ highPriorityStart WRITE setHighPriorityStart NOTIFY highPriorityStartChanged)
|
||||
Q_PROPERTY(Renderer renderer READ renderer WRITE setRenderer NOTIFY rendererChanged)
|
||||
@ -38,8 +40,9 @@ public:
|
||||
Q_PROPERTY(Version version READ version)
|
||||
|
||||
Q_INVOKABLE void createNewProfile(int screenNumber);
|
||||
Q_INVOKABLE void constructWallpaper(Profile profile, QString monitorID);
|
||||
Q_INVOKABLE void constructWallpaper(Profile profile, QString monitorID, ProjectFile spf);
|
||||
void loadActiveProfiles();
|
||||
void removeAll();
|
||||
|
||||
|
||||
enum Renderer {
|
||||
@ -151,6 +154,7 @@ private:
|
||||
ProfileListModel* m_plm;
|
||||
InstalledListModel* m_ilm;
|
||||
MonitorListModel* m_mlm;
|
||||
QThread m_thread;
|
||||
|
||||
QVector<QSharedPointer<Wallpaper>> m_wallpapers;
|
||||
QVector<QSharedPointer<ActiveProfiles>> m_activeProfiles;
|
||||
|
@ -18,17 +18,21 @@ Wallpaper::Wallpaper(QWindow* parent)
|
||||
{
|
||||
}
|
||||
|
||||
Wallpaper::Wallpaper(Profile profile)
|
||||
Wallpaper::Wallpaper(Profile profile, ProjectFile projf)
|
||||
{
|
||||
|
||||
m_profile = profile;
|
||||
m_project = projf;
|
||||
QString tmp = profile.m_absolutePath.toString() + "/Wallpaper/" + profile.m_wallpaperId + "/" + projf.m_file.toString();
|
||||
tmp.replace("/","\\\\");
|
||||
setAbsoluteFilePath(tmp);
|
||||
|
||||
this->setX(m_profile.m_rect.x());
|
||||
this->setY(m_profile.m_rect.y());
|
||||
this->setWidth(m_profile.m_rect.width());
|
||||
this->setHeight(m_profile.m_rect.height());
|
||||
this->m_hwnd = (HWND)this->winId();
|
||||
|
||||
|
||||
HWND progman_hwnd = FindWindowW(L"Progman", L"Program Manager");
|
||||
|
||||
// Spawn new worker window below desktop (using some undocumented Win32 magic)
|
||||
@ -55,9 +59,9 @@ Wallpaper::Wallpaper(Profile profile)
|
||||
m_quickRenderer = new QQuickView(this);
|
||||
m_quickRenderer->setWidth(this->width());
|
||||
m_quickRenderer->setHeight(this->height());
|
||||
m_context = m_quickRenderer->rootContext();
|
||||
m_context->setContextProperty("wallpaper", this);
|
||||
m_quickRenderer->setResizeMode(QQuickView::ResizeMode::SizeRootObjectToView);
|
||||
m_quickRenderer->setSource(QUrl("qrc:/qml/Components/Screens/ScreenVideo.qml"));
|
||||
m_context = m_quickRenderer->rootContext();
|
||||
m_quickRenderer->show();
|
||||
}
|
||||
}
|
||||
|
@ -8,25 +8,48 @@
|
||||
#include <QWindow>
|
||||
#include <qt_windows.h>
|
||||
#include <QUrl>
|
||||
#include <QDir>
|
||||
|
||||
#include "profile.h"
|
||||
#include "projectfile.h"
|
||||
|
||||
class Wallpaper : public QWindow {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit Wallpaper(QWindow* parent = 0);
|
||||
Wallpaper(Profile profile);
|
||||
~Wallpaper();
|
||||
QQmlContext* context() const;
|
||||
Wallpaper(Profile profile, ProjectFile projf);
|
||||
Q_PROPERTY(QString absoluteFilePath READ absoluteFilePath WRITE setAbsoluteFilePath NOTIFY absoluteFilePathChanged)
|
||||
|
||||
|
||||
|
||||
|
||||
QString absoluteFilePath() const
|
||||
{
|
||||
return m_absoluteFilePath;
|
||||
}
|
||||
|
||||
public slots:
|
||||
void setAbsoluteFilePath(QString absoluteFilePath)
|
||||
{
|
||||
if (m_absoluteFilePath == absoluteFilePath)
|
||||
return;
|
||||
|
||||
m_absoluteFilePath = absoluteFilePath;
|
||||
emit absoluteFilePathChanged(m_absoluteFilePath);
|
||||
}
|
||||
|
||||
signals:
|
||||
void absoluteFilePathChanged(QString absoluteFilePath);
|
||||
|
||||
private:
|
||||
HWND m_hwnd = nullptr;
|
||||
HWND m_worker_hwnd = nullptr;
|
||||
HWND m_hwnd;
|
||||
HWND m_worker_hwnd;
|
||||
QQuickView* m_quickRenderer = nullptr;
|
||||
QQmlContext* m_context = nullptr;
|
||||
|
||||
Profile m_profile;
|
||||
ProjectFile m_project;
|
||||
QString m_absoluteFilePath;
|
||||
};
|
||||
|
||||
#endif // WALLPAPER_H
|
||||
|
Loading…
Reference in New Issue
Block a user