1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-11-07 03:22:33 +01:00
This commit is contained in:
kelteseth 2018-04-18 18:39:25 +02:00
parent bca82eeda7
commit 43f43d73f9
26 changed files with 406 additions and 358 deletions

View File

@ -18,26 +18,26 @@
#include <QUrl>
#include <QVariant>
#include <QWindow>
#include <QtGlobal>
#include <QtQuick/QQuickItem>
#include <QtGlobal>
#ifdef Q_OS_WIN
#include <qt_windows.h>
#include <qt_windows.h>
#endif
#include "qmlutilities.h"
#include "create.h"
#include "installedlistfilter.h"
#include "installedlistmodel.h"
#include "monitorlistmodel.h"
#include "profilelistmodel.h"
#include "qmlutilities.h"
#include "screenplay.h"
#include "sdkconnector.h"
#include "settings.h"
#include "startuperror.h"
#include "steam/steam_api.h"
#include "steamworkshop.h"
#include "steamworkshoplistmodel.h"
#include "screenplay.h"
#include "create.h"
int main(int argc, char* argv[])
{
@ -77,12 +77,11 @@ int main(int argc, char* argv[])
InstalledListFilter installedListFilter(&installedListModel);
// Create settings in the end because for now it depends on
// such things as the profile list model to complete
// It will also set the m_absoluteStoragePath in profileListModel and installedListModel
Settings settings(&profileListModel, &monitorListModel, &installedListModel, &sdkConnector, steamID, &app);
ScreenPlay screenPlay(&installedListModel,&settings,&monitorListModel,&app, &sdkConnector);
ScreenPlay screenPlay(&installedListModel, &settings, &monitorListModel, &app, &sdkConnector);
QDir SPWorkingDir(QDir::currentPath());
QDir SPBaseDir(QDir::currentPath());
@ -126,7 +125,7 @@ int main(int argc, char* argv[])
#endif
SteamWorkshop steamWorkshop(steamID, &steamWorkshopListModel, &settings);
Create create(&settings,&qmlUtil);
Create create(&settings, &qmlUtil);
// All the list need the default path from the settings
// to know where to look for the files

View File

@ -37,7 +37,7 @@ Rectangle {
}
Connections {
target: steamWorkshop
target: screenPlayCreate
onLocalWorkshopCreationStatusChanged: {
if (status === LocalWorkshopCreationStatus.Started) {
loader.setSource("CreateImportStatus.qml")

View File

@ -54,7 +54,7 @@ Item {
color: "black"
anchors {
top: parent.top
topMargin: 80
topMargin: 180
horizontalCenter: parent.horizontalCenter
}
@ -66,6 +66,23 @@ Item {
opengl: true
fillMode: VideoOutput.Stretch
Slider {
id: sliVideoPosition
height: 30
width: parent.width * .8
from: 0
to: 1
anchors {
horizontalCenter: parent.horizontalCenter
bottom: parent.bottom
bottomMargin: 20
}
onValueChanged: {
print(player.position)
player.seek(sliVideoPosition.value * player.duration)
}
}
Image {
id: imgPreview
anchors.fill: parent
@ -78,6 +95,20 @@ Item {
anchors.verticalCenter: parent.verticalCenter
visible: false
}
Text {
id: txtDescriptionThumbnail
text: qsTr("Select preview image")
font.family: "Roboto"
opacity: .5
renderType: Text.NativeRendering
font.pixelSize: 14
color: "white"
anchors {
horizontalCenter: parent.horizontalCenter
bottom: parent.bottom
bottomMargin: 10
}
}
}
}
@ -90,6 +121,7 @@ Item {
onSeekFinished: {
busyIndicator.visible = false
pause()
print(player.metaData.videoFrameRate)
}
}
@ -116,19 +148,53 @@ Item {
Rectangle {
id: contentWrapper
width: 800
height: 350
height: 300
z: 10
radius: 4
anchors {
top: parent.top
topMargin: 250
topMargin: 300
horizontalCenter: parent.horizontalCenter
}
Item {
id: chooseImageWrapper
height: 60
anchors {
top: parent.top
topMargin: 50
right: parent.right
left: parent.left
}
FileDialog {
id: fileDialogOpenPreview
nameFilters: ["Image files (*.jpg *.png)"]
onAccepted: {
imgPreview.source = currentFile
imgPreview.opacity = 1
//currentFile
}
}
Button {
id: btnChooseImage
text: qsTr("Select Image Manually")
Material.background: Material.Orange
Material.foreground: "white"
icon.source: "qrc:/assets/icons/icon_folder_open.svg"
icon.color: "white"
icon.width: 16
icon.height: 16
anchors.centerIn: parent
onClicked: fileDialogOpenPreview.open()
}
}
Column {
spacing: 20
anchors {
top: parent.top
top: chooseImageWrapper.top
topMargin: 50
right: parent.right
rightMargin: 78
@ -137,75 +203,7 @@ Item {
left: parent.left
leftMargin: 78
}
Item {
height: 60
width: parent.width
Slider {
id: sliVideoPosition
height: parent.height
width: parent.width * .4
from: 0
to: 1
anchors {
left: parent.left
verticalCenter: parent.verticalCenter
}
onValueChanged: {
player.seek(sliVideoPosition.value * player.duration)
}
}
FileDialog {
id: fileDialogOpenPreview
nameFilters: ["Image files (*.jpg *.png)"]
onAccepted: {
imgPreview.source = currentFile
//currentFile
}
}
Switch {
id: switcherImage
anchors.centerIn: parent
height: parent.height
onPositionChanged: {
if (position === 1) {
btnChooseImage.enabled = true
sliVideoPosition.enabled = false
player.pause()
isVideoPlaying = false
imgPreview.opacity = 1
} else {
btnChooseImage.enabled = false
sliVideoPosition.enabled = true
isVideoPlaying = true
imgPreview.opacity = 0
}
}
}
Item {
height: parent.height
width: parent.width * .4
anchors {
right: parent.right
verticalCenter: parent.verticalCenter
}
Button {
id: btnChooseImage
enabled: false
text: qsTr("Select Image Manually")
Material.background: Material.Orange
Material.foreground: "white"
icon.source: "qrc:/assets/icons/icon_folder_open.svg"
icon.color:"white"
icon.width: 16
icon.height: 16
anchors {
right: parent.right
verticalCenter: parent.verticalCenter
}
onClicked: fileDialogOpenPreview.open()
}
}
}
TextField {
id: txtTitle
height: 60
@ -214,46 +212,6 @@ Item {
text: qsTr("")
placeholderText: "Title"
}
Item {
height: 60
width: parent.width
Text {
id: txtUseSteamWorkshop
text: screenPlaySettings.localStoragePath
color: "#626262"
anchors {
left: parent.left
verticalCenter: parent.verticalCenter
}
verticalAlignment: Text.AlignVCenter
font.pointSize: 12
renderType: Text.NativeRendering
font.family: "Roboto"
}
Button {
text: qsTr("Choose Folder")
Material.background: Material.Orange
Material.foreground: "white"
icon.source: "qrc:/assets/icons/icon_folder_open.svg"
icon.color:"white"
icon.width: 16
icon.height: 16
anchors {
right: parent.right
verticalCenter: parent.verticalCenter
}
onClicked: {
fileDialogSetPath.open()
}
}
FolderDialog {
id: fileDialogSetPath
onAccepted: {
//currentFile
}
}
}
}
Button {
@ -261,7 +219,7 @@ Item {
Material.background: Material.Orange
Material.foreground: "white"
icon.source: "qrc:/assets/icons/icon_upload.svg"
icon.color:"white"
icon.color: "white"
icon.width: 16
icon.height: 16
anchors {
@ -285,12 +243,20 @@ Item {
return
}
if (switcherImage.position === 1) {
steamWorkshop.createLocalWorkshopItem(
if (fileDialogOpenPreview.currentFile != "") {
screenPlayCreate.importVideo(
txtTitle.text.replace(/\s/g, ''), file,
fileDialogOpenPreview.currentFile)
createImport.state = "out"
fileDialogOpenPreview.currentFile,
player.duration)
} else {
screenPlayCreate.importVideo(
txtTitle.text.replace(/\s/g, ''), file,
player.position,
player.duration,
player.metaData.videoFrameRate)
}
player.stop()
createImport.state = "out"
}
}
}
@ -337,13 +303,13 @@ Item {
PropertyChanges {
target: contentWrapper
opacity: 1
anchors.topMargin: 250
anchors.topMargin: 300
}
PropertyChanges {
target: videoOutWrapper
z: 12
opacity: 1
anchors.topMargin: 20
anchors.topMargin: 70
}
}
]

View File

@ -24,7 +24,7 @@ Item {
}
Connections {
target: steamWorkshop
target: screenPlayCreate
onLocalWorkshopCreationStatusChanged: {
switch (status) {
case LocalWorkshopCreationStatus.Started:

View File

@ -180,7 +180,10 @@ Item {
width: 32
height: width
cursorShape: Qt.PointingHandCursor
onClicked: createNew.state = "out"
onClicked: {
createNew.state = "out"
timerBack.start()
}
Image {
id: imgClose
@ -196,6 +199,11 @@ Item {
source: imgClose
color: "gray"
}
Timer {
id:timerBack
interval: 800
onTriggered: utility.setNavigation("Create")
}
}
}

View File

@ -12,6 +12,7 @@ Item {
signal setSidebarActive(var active)
property bool refresh: false
property bool enabled: true
Component.onCompleted: {
installedListFilter.sortByRoleType("All")
@ -50,10 +51,6 @@ Item {
active: false
z: 99
anchors.fill: parent
onStatusChanged: {
print(status)
}
source: "qrc:/qml/Installed/InstalledUserHelper.qml"
}
@ -66,6 +63,7 @@ Item {
cellWidth: 340
cacheBuffer: 10000
cellHeight: 200
interactive: pageInstalled.enabled
anchors {
topMargin: 0
rightMargin: 0
@ -76,7 +74,7 @@ Item {
width: parent.width
property bool isVisible: false
onIsVisibleChanged: {
if(isVisible){
if (isVisible) {
txtHeader.color = "orange"
txtHeader.text = qsTr("Refreshing!")
} else {
@ -92,7 +90,6 @@ Item {
color: "gray"
font.pixelSize: 18
}
}
footer: Item {
property bool isVisible: true
@ -122,10 +119,8 @@ Item {
installedListModel.reset()
installedListModel.loadScreens()
}
}
model: installedListFilter
delegate: ScreenPlayItem {
@ -159,7 +154,7 @@ Item {
navWallpaper.state = "inactive"
navWidgets.state = "inactive"
navScenes.state = "inactive"
} else if (name === "Wallpaper") {
} else if (name === "Videos") {
installedListFilter.sortByRoleType("Wallpaper")
navAll.state = "inactive"
navWallpaper.state = "active"
@ -171,7 +166,7 @@ Item {
navWallpaper.state = "inactive"
navWidgets.state = "active"
navScenes.state = "inactive"
}else if (name === "Scenes") {
} else if (name === "Scenes") {
installedListFilter.sortByRoleType("Scenes")
navAll.state = "inactive"
navWallpaper.state = "inactive"
@ -238,7 +233,7 @@ Item {
InstalledNavigation {
id: navWallpaper
state: "inactive"
name: qsTr("Wallpaper")
name: qsTr("Videos")
iconSource: "qrc:/assets/icons/icon_movie.svg"
onPageClicked: {
onPageChanged(name)
@ -283,7 +278,6 @@ Item {
right: parent.right
rightMargin: 30
bottom: parent.bottom
}
onTextChanged: {
if (txtSearch.text.length === 0) {
@ -295,8 +289,10 @@ Item {
selectByMouse: true
text: qsTr("")
placeholderText: "Search for Wallpaper & Widgets"
placeholderText: qsTr("Search for Wallpaper & Widgets")
}
}
}
}

View File

@ -1,7 +1,7 @@
import QtQuick 2.9
import QtGraphicalEffects 1.0
import QtQuick.Controls 2.3
import QtQuick.Controls.Styles 1.4
Item {
id: screenPlayItem
width: 320
@ -233,6 +233,7 @@ Item {
id: miWorkshop
text: qsTr("Open workshop Page")
enabled: false
onClicked: {
Qt.openUrlExternally(
"steam://url/CommunityFilePage/" + workshopID)

View File

@ -14,7 +14,7 @@ Item {
onStateChanged: {
bgMouseArea.focus = monitors.state == "active" ? true : false
if(monitors.state === "active"){
screenPlay.requestProjectSettingsListModelAt(at)
screenPlay.requestProjectSettingsListModelAt(0)
}
}

View File

@ -101,7 +101,7 @@ Item {
}
Item {
id: screenPlayItemWrapper
id: screenPlay
anchors.centerIn: parent
height: 180
width: 320
@ -109,8 +109,8 @@ Item {
Image {
id: mask
source: "qrc:/assets/images/Window.svg"
sourceSize: Qt.size(screenPlayItemWrapper.width,
screenPlayItemWrapper.height)
sourceSize: Qt.size(screenPlay.width,
screenPlay.height)
visible: false
smooth: true
asynchronous: true
@ -226,12 +226,30 @@ Item {
workshopItem.state = "downloading"
steamWorkshop.subscribeItem(workshopItem.steamID)
}
Connections {
target: steamWorkshop
onWorkshopItemInstalled:{
print(appID)
if(appID === steamWorkshop.appID){
workshopItem.state = "installed"
print("match!")
}
print(workshopItem.steamID, publishedFile)
if(workshopItem.steamID == publishedFile){
}
}
}
}
}
FastBlur {
id: effBlur
anchors.fill: itemWrapper
source: itemWrapper
source:itemWrapper
radius: 0
}
@ -328,6 +346,40 @@ Item {
opacity: 1
anchors.topMargin: 0
}
},
State {
name: "installed"
PropertyChanges {
target: button
opacity: 0
}
PropertyChanges {
target: txtTitle
opacity: 0
}
PropertyChanges {
target: shadow
opacity: 0
}
PropertyChanges {
target: effBlur
radius: 64
}
PropertyChanges {
target: itmDownloading
opacity: 1
anchors.topMargin: 0
}
PropertyChanges {
target: txtDownloading
text: qsTr("Download complete!")
}
}
]
transitions: [
@ -375,7 +427,7 @@ Item {
SequentialAnimation {
PropertyAnimation {
target: effBlur
duration: 200
duration: 500
properties: "radius"
}
PropertyAnimation {

View File

@ -124,6 +124,11 @@ int MonitorListModel::size()
return m_monitorList.size();
}
void MonitorListModel::wallpaperRemoved()
{
}
bool MonitorListModel::getMonitorListItemAt(int position, Monitor* monitor)
{
//TODO Reimplement wallpaper replacement

View File

@ -59,6 +59,7 @@ public slots:
QRect getAbsoluteDesktopSize();
void reloadMonitors();
int size();
void wallpaperRemoved();
private:
QVector<Monitor> m_monitorList;

View File

@ -54,6 +54,7 @@ QHash<int, QByteArray> ProjectSettingsListModel::roleNames() const
void ProjectSettingsListModel::init(QString file)
{
qDebug() << file;
QFile configTmp;
configTmp.setFileName(file);
QJsonDocument configJsonDocument;
@ -75,6 +76,7 @@ void ProjectSettingsListModel::init(QString file)
if (obj.contains("properties")) {
tmpParent = obj.value("properties").toObject();
} else {
qWarning("Could not find settings");
return;
}

View File

@ -8,6 +8,7 @@ ScreenPlay::ScreenPlay(InstalledListModel* ilm, Settings* set, MonitorListModel*
m_mlm = mlm;
m_qGuiApplication = qGuiApplication;
m_sdkc = sdkc;
}
void ScreenPlay::createWallpaper(int monitorIndex, QUrl absoluteStoragePath, QString previewImage, float volume, QString fillMode)
@ -19,11 +20,7 @@ void ScreenPlay::createWallpaper(int monitorIndex, QUrl absoluteStoragePath, QSt
}
// Remove previous wallpaper
// for (int i = 0; i < m_screenPlayWallpaperList.length(); ++i) {
// if(m_screenPlayWallpaperList.at(i).data()->screenNumber().at(0) == monitorIndex){
// m_sdkc->closeWallpapersAt(i);
// }
// }
removeWallpaperAt(monitorIndex);
m_settings->increaseActiveWallpaperCounter();
QVector<int> tmpMonitorIndex;
@ -40,12 +37,6 @@ void ScreenPlay::createWidget(QUrl absoluteStoragePath, QString previewImage)
return;
}
if (project.m_file.toString().endsWith(".exe")) {
} else if (project.m_file.toString().endsWith(".qml")) {
}
qDebug() << absoluteStoragePath << previewImage;
QString fullPath = absoluteStoragePath.toString() + "/" + project.m_file.toString();
m_screenPlayWidgetList.append(QSharedPointer<ScreenPlayWidget>(new ScreenPlayWidget(absoluteStoragePath.toString(), previewImage, fullPath, this)));
@ -81,14 +72,14 @@ QString ScreenPlay::generateID()
QChar nextChar = possibleCharacters.at(index);
randomString.append(nextChar);
}
return "appID="+randomString;
return randomString;
}
void ScreenPlay::setWallpaperValue(int at, QString key, QString value)
{
for (int i = 0; i < m_screenPlayWallpaperList.count(); ++i) {
if(m_screenPlayWallpaperList.at(i).data()->screenNumber().at(0) == at){
if (m_screenPlayWallpaperList.at(i).data()->screenNumber().at(0) == at) {
m_sdkc->setWallpaperValue(m_screenPlayWallpaperList.at(i).data()->appID(), key, value);
return;
@ -96,6 +87,27 @@ void ScreenPlay::setWallpaperValue(int at, QString key, QString value)
}
}
void ScreenPlay::removeWallpaperAt(int at)
{
for (int i = 0; i < m_screenPlayWallpaperList.length(); ++i) {
if (m_screenPlayWallpaperList.at(i).data()->screenNumber().at(0) == at) {
qDebug() << i << m_screenPlayWallpaperList.at(i).data()->screenNumber().at(0);
m_sdkc->closeWallpapersAt(at);
//m_screenPlayWallpaperList.removeAt(i);
}
}
}
QVector<int> ScreenPlay::getMonitorByAppID(QString appID)
{
for (int i = 0; i < m_screenPlayWallpaperList.length(); ++i) {
if(m_screenPlayWallpaperList.at(i).data()->appID() == appID){
return m_screenPlayWallpaperList.at(i).data()->screenNumber();
}
}
}
Settings* ScreenPlay::settings() const
{
return m_settings;

View File

@ -47,8 +47,10 @@ public slots:
void createWidget(QUrl absoluteStoragePath, QString previewImage);
void removeAllWallpaper();
void requestProjectSettingsListModelAt(int index);
QString generateID();
void setWallpaperValue(int at, QString key, QString value);
void removeWallpaperAt(int at);
QVector<int> getMonitorByAppID(QString appID);
QString generateID();
private:
QVector<QSharedPointer<ScreenPlayWallpaper>> m_screenPlayWallpaperList;
@ -86,7 +88,7 @@ public:
proArgs.append(QString::number(m_screenNumber.at(0)));
proArgs.append(m_projectPath);
m_appID = parent->generateID();
proArgs.append(m_appID);
proArgs.append("appID="+m_appID);
proArgs.append(parent->m_settings->decoder());
proArgs.append(QString::number(volume));
proArgs.append(fillMode);

View File

@ -6,6 +6,7 @@
SDKConnector::SDKConnector(QObject* parent)
: QObject(parent)
{
m_server = QSharedPointer<QLocalServer>(new QLocalServer(this));
connect(m_server.data(), &QLocalServer::newConnection, this, &SDKConnector::newConnection);
@ -28,6 +29,22 @@ void SDKConnector::closeAllWallpapers()
}
}
void SDKConnector::closeWallpapersAt(int at)
{
for (int i = 0; i < m_clients.size(); ++i) {
qDebug() << i << m_clients.length();
if(m_clients.at(i).data()->monitor().size() > 0){
if(m_clients.at(i).data()->monitor().at(0) == at){
qDebug() << "SDKC" << i ;
m_clients.at(i).data()->close();
}
} else {
qDebug() << "no wp window";
}
}
}
void SDKConnector::setWallpaperValue(QString appID, QString key, QString value)
{
@ -44,6 +61,22 @@ void SDKConnector::setWallpaperValue(QString appID, QString key, QString value)
}
}
void SDKConnector::setSceneValue(QString appID, QString key, QString value)
{
for (int i = 0; i < m_clients.count(); ++i) {
if (m_clients.at(i).data()->appID() == appID) {
QJsonObject obj;
obj.insert("type",QJsonValue("qmlScene"));
obj.insert(key, QJsonValue(value));
QByteArray send = QJsonDocument(obj).toJson();
m_clients.at(i).data()->socket()->write(send);
m_clients.at(i).data()->socket()->waitForBytesWritten();
}
}
}
void SDKConnection::setSocket(QLocalSocket* socket)
{
m_socket = socket;

View File

@ -1,13 +1,15 @@
#pragma once
#include <QJsonValue>
#include <QLocalServer>
#include <QLocalSocket>
#include <QObject>
#include <QSharedPointer>
#include <QTimer>
#include <QJsonValue>
#include <QVector>
/*!
\class SDKConnector
\brief Used for every Wallpaper, Scene or Widget communication via Windows pipes/QLocalSocket
@ -20,30 +22,38 @@ class SDKConnector : public QObject {
public:
explicit SDKConnector(QObject* parent = nullptr);
signals:
public slots:
void newConnection();
void closeAllWallpapers();
void closeWallpapersAt(int at);
void setWallpaperValue(QString appID, QString key, QString value);
void setSceneValue(QString appID, QString key, QString value);
private:
QSharedPointer<QLocalServer> m_server;
QVector<QSharedPointer<SDKConnection>> m_clients;
};
class SDKConnection : public QObject {
Q_OBJECT
Q_PROPERTY(QString appID READ appID WRITE setAppID NOTIFY appIDChanged)
Q_PROPERTY(QVector<int> monitor READ monitor WRITE setMonitor NOTIFY monitorChanged)
public:
explicit SDKConnection(QLocalSocket* socket, QObject* parent = nullptr)
{
m_socket = socket;
connect(m_socket, &QLocalSocket::readyRead, this, &SDKConnection::readyRead);
connect(m_socket, &QLocalSocket::disconnected, this, &SDKConnection::disconnected);
}
~SDKConnection()
{
qDebug() << "destroying SDKConnection Object";
}
void setSocket(QLocalSocket* socket);
@ -53,23 +63,36 @@ public:
return m_appID;
}
QLocalSocket *socket() const;
QLocalSocket* socket() const;
QVector<int> monitor() const
{
return m_monitor;
}
signals:
void requestCloseAt(int at);
void appIDChanged(QString appID);
void monitorChanged(QVector<int> monitor);
public slots:
void readyRead()
{
QString msg = QString(m_socket->readAll());
msg.contains("appID=");
m_appID = msg;
qDebug() << msg;
if (msg.contains("appID=")) {
m_appID = msg.remove("appID=");
//m_monitor.append(m_sp->getMonitorByAppID(m_appID).at(0));
qDebug() << m_appID << m_monitor;
}
}
void disconnected(){
void disconnected()
{
close();
}
void close()
{
m_socket->close();
@ -84,7 +107,18 @@ public slots:
emit appIDChanged(m_appID);
}
void setMonitor(QVector<int> monitor)
{
if (m_monitor == monitor)
return;
m_monitor = monitor;
emit monitorChanged(m_monitor);
}
private:
QLocalSocket* m_socket;
QString m_appID;
QVector<int> m_monitor;
};

View File

@ -30,7 +30,7 @@ Settings::Settings(ProfileListModel* plm, MonitorListModel* mlm, InstalledListMo
}
QJsonDocument configJsonDocument;
QJsonParseError parseError;
QJsonParseError parseError{};
QJsonObject configObj;
configTmp.open(QIODevice::ReadOnly | QIODevice::Text);
@ -51,7 +51,7 @@ Settings::Settings(ProfileListModel* plm, MonitorListModel* mlm, InstalledListMo
//Checks if the settings file has the same version as ScreeenPlay
if (!(major == m_version.major && minor == m_version.minor && patch == m_version.patch)) {
//TODO Display error message
// TODO(Kelteseth): Display error message
qWarning("Version missmatch");
return;
}
@ -150,7 +150,7 @@ void Settings::writeSingleSettingConfig(QString name, QVariant value)
{
QJsonDocument configJsonDocument;
QJsonParseError parseError;
QJsonParseError parseError{};
QJsonObject configObj;
QFile configTmp;

View File

@ -3,13 +3,11 @@
SteamWorkshop::SteamWorkshop(QObject* parent)
: QObject(parent)
{
initSteam();
}
void SteamWorkshop::initSteam()
{
if(m_settings->offlineMode()){
if (m_settings->offlineMode()) {
if (SteamAPI_RestartAppIfNecessary(m_appID)) {
qWarning() << "SteamAPI_RestartAppIfNecessary";
@ -21,8 +19,7 @@ void SteamWorkshop::initSteam()
m_steamErrorAPIInit = true;
}
if(!(m_steamErrorAPIInit || m_steamErrorRestart)){
if (!(m_steamErrorAPIInit || m_steamErrorRestart)) {
m_settings->setOfflineMode(false);
m_pollTimer = new QTimer(this);
QObject::connect(m_pollTimer, &QTimer::timeout, [&]() { SteamAPI_RunCallbacks(); });
@ -34,15 +31,17 @@ void SteamWorkshop::initSteam()
SteamWorkshop::SteamWorkshop(AppId_t nConsumerAppId, SteamWorkshopListModel* wlm, Settings* s)
{
m_appID = nConsumerAppId;
m_workshopListModel = wlm;
m_settings = s;
// Register namespace seperated enums because qml has no enum scope WTF
qRegisterMetaType<LocalWorkshopCreationStatus::Value>();
qRegisterMetaType<RemoteWorkshopCreationStatus::Value>();
qmlRegisterUncreatableMetaObject(LocalWorkshopCreationStatus::staticMetaObject, "LocalWorkshopCreationStatus", 1, 0, "LocalWorkshopCreationStatus", "Error: only enums");
qmlRegisterUncreatableMetaObject(RemoteWorkshopCreationStatus::staticMetaObject, "RemoteWorkshopCreationStatus", 1, 0, "RemoteWorkshopCreationStatus", "Error: only enums");
initSteam();
}
void SteamWorkshop::createWorkshopItem()
@ -112,14 +111,12 @@ void SteamWorkshop::submitWorkshopItem(QString title, QString description, QStri
SteamUGC()->SetItemPreview(m_UGCUpdateHandle, QByteArray(preview.toLatin1()).data());
auto tagList = new QScopedPointer<SteamParamStringArray_t>(new SteamParamStringArray_t);
//const char** cchKey[5][2000];
//tagList->data()->m_ppStrings = cchKey;
//tagList->data()->m_nNumStrings = 1;
//tagList->data()->m_ppStrings[1][0] = QByteArray("asas").data();
SteamUGC()->SetItemTags(m_UGCUpdateHandle,tagList->data());
SteamUGC()->SetItemTags(m_UGCUpdateHandle, tagList->data());
auto visibility = static_cast<ERemoteStoragePublishedFileVisibility>(remoteStoragePublishedFileVisibility);
SteamUGC()->SetItemVisibility(m_UGCUpdateHandle, visibility);
@ -155,72 +152,6 @@ bool SteamWorkshop::contentFolderExist(QString folder)
}
}
void SteamWorkshop::createLocalWorkshopItem(QString title, QUrl videoPath, QUrl previewPath)
{
QtConcurrent::run([=]() {
emit localWorkshopCreationStatusChanged(LocalWorkshopCreationStatus::Value::Started);
QString fromVideoPath = QString(videoPath.toString()).replace("file:///", "");
QString fromImagePath = QString(previewPath.toString()).replace("file:///", "");
QString toPath = m_settings->localStoragePath().toString() + "/" + title;
QString toPathWithVideoFile = toPath + "/" + videoPath.fileName();
QString toPathWithImageFile = toPath + "/" + previewPath.fileName();
if (QDir(toPath).exists()) {
if (!QDir(toPath).isEmpty()) {
emit localWorkshopCreationStatusChanged(LocalWorkshopCreationStatus::Value::ErrorFolder);
return;
} else {
//if(!QDir(toPath + ))
}
} else {
//TODO: Display Error
if (!QDir().mkdir(toPath)) {
emit localWorkshopCreationStatusChanged(LocalWorkshopCreationStatus::Value::ErrorFolderCreation);
return;
}
}
//Copy Video File
if (QFile::copy(fromVideoPath, toPathWithVideoFile)) {
emit localWorkshopCreationStatusChanged(LocalWorkshopCreationStatus::Value::CopyVideoFinished);
} else {
emit localWorkshopCreationStatusChanged(LocalWorkshopCreationStatus::Value::ErrorCopyVideo);
}
//Copy Image File
if (QFile::copy(fromImagePath, toPathWithImageFile)) {
emit localWorkshopCreationStatusChanged(LocalWorkshopCreationStatus::Value::CopyImageFinished);
} else {
emit localWorkshopCreationStatusChanged(LocalWorkshopCreationStatus::Value::ErrorCopyImage);
}
//Copy Project File
QFile configFile(toPath + "/" + "project.json");
if (!configFile.open(QIODevice::ReadWrite | QIODevice::Text)) {
emit localWorkshopCreationStatusChanged(LocalWorkshopCreationStatus::Value::ErrorCopyConfig);
return;
}
QTextStream out(&configFile);
QJsonObject configObj;
configObj.insert("file", videoPath.fileName());
configObj.insert("preview", previewPath.fileName());
//TODO
configObj.insert("description", "");
configObj.insert("title", title);
QJsonDocument configJsonDocument(configObj);
out << configJsonDocument.toJson();
configFile.close();
emit localWorkshopCreationStatusChanged(LocalWorkshopCreationStatus::Value::Finished);
});
}
void SteamWorkshop::subscribeItem(unsigned int id)
{
@ -278,12 +209,12 @@ void SteamWorkshop::onWorkshopSearched(SteamUGCQueryCompleted_t* pCallback, bool
} else {
emit workshopSearchResult(details.m_nPublishedFileId, QString(details.m_rgchTitle), QUrl(urlData), 0);
}
// keyValueTags = SteamUGC()->GetQueryUGCNumKeyValueTags(pCallback->m_handle, i);
// if (keyValueTags >= 0) {
// if (SteamUGC()->GetQueryUGCKeyValueTag(pCallback->m_handle, i, 0, cchKey, cchKeySize, cchValueSize, pchValue)) {
// qDebug() << QByteArray(pchKey) << QByteArray(pchValue);
// }
// }
// keyValueTags = SteamUGC()->GetQueryUGCNumKeyValueTags(pCallback->m_handle, i);
// if (keyValueTags >= 0) {
// if (SteamUGC()->GetQueryUGCKeyValueTag(pCallback->m_handle, i, 0, cchKey, cchKeySize, cchValueSize, pchValue)) {
// qDebug() << QByteArray(pchKey) << QByteArray(pchValue);
// }
// }
// if(SteamUGC()->GetQueryUGCStatistic(pCallback->m_handle,i,EItemStatistic::k_EItemStatistic_NumSubscriptions,&subscriber)){
// }
@ -293,7 +224,6 @@ void SteamWorkshop::onWorkshopSearched(SteamUGCQueryCompleted_t* pCallback, bool
}
}
SteamUGC()->ReleaseQueryUGCRequest(pCallback->m_handle);
}
void SteamWorkshop::onWorkshopItemInstalled(ItemInstalled_t* itemInstalled)

View File

@ -3,9 +3,7 @@
#include "settings.h"
#include "steam/steam_api.h"
#include "steamworkshoplistmodel.h"
#include <QScopedPointer>
#include <QByteArray>
#include <QQmlEngine>
#include <QDateTime>
#include <QDebug>
#include <QDir>
@ -14,8 +12,10 @@
#include <QFuture>
#include <QFutureWatcher>
#include <QObject>
#include <QUrl>
#include <QQmlEngine>
#include <QScopedPointer>
#include <QTimer>
#include <QUrl>
/*!
\class Steam Workshop
@ -24,26 +24,6 @@
\todo Workaround because QML enums are like c++98 with a global namespace. https://www.kdab.com/new-qt-5-8-meta-object-support-namespaces/
*/
namespace LocalWorkshopCreationStatus {
Q_NAMESPACE
enum Value {
Idle,
Started,
CopyVideoFinished,
CopyImageFinished,
CopyConfigFinished,
Finished,
ErrorFolder,
ErrorFolderCreation,
ErrorDiskSpace,
ErrorCopyVideo,
ErrorCopyImage,
ErrorCopyConfig,
ErrorUnknown,
};
Q_ENUM_NS(Value)
}
namespace RemoteWorkshopCreationStatus {
Q_NAMESPACE
enum Value {
@ -86,7 +66,6 @@ public slots:
void createWorkshopItem();
void submitWorkshopItem(QString title, QString description, QString language, int remoteStoragePublishedFileVisibility, const QUrl projectFile, const QUrl videoFile, int publishedFileId);
void getAPICallInfo();
void createLocalWorkshopItem(QString title, QUrl videoPath, QUrl previewPath);
void subscribeItem(unsigned int id);
// Properties
@ -120,10 +99,9 @@ public slots:
signals:
void workshopItemCreated(bool userNeedsToAcceptWorkshopLegalAgreement, int eResult, int publishedFileId);
void workshopSearched();
void localWorkshopCreationStatusChanged(LocalWorkshopCreationStatus::Value status);
void remoteWorkshopCreationStatusChanged(RemoteWorkshopCreationStatus::Value status);
void workshopSearchResult(unsigned int id, QString title, QUrl imgUrl,int subscriber);
void workshopItemInstalled(int appID,int publishedFile);
void workshopSearchResult(unsigned int id, QString title, QUrl imgUrl, int subscriber);
void workshopItemInstalled(int appID, int publishedFile);
// Properties
void itemProcessedChanged(unsigned int itemProcessed);
@ -132,15 +110,13 @@ signals:
void appIDChanged(unsigned int appID);
private:
void workshopItemCreated(CreateItemResult_t* pCallback, bool bIOFailure);
CCallResult<SteamWorkshop, CreateItemResult_t> m_createWorkshopItemCallResult;
void onWorkshopSearched(SteamUGCQueryCompleted_t* pCallback, bool bIOFailure);
CCallResult<SteamWorkshop, SteamUGCQueryCompleted_t> m_steamUGCQueryResult;
STEAM_CALLBACK( SteamWorkshop, onWorkshopItemInstalled, ItemInstalled_t );
STEAM_CALLBACK(SteamWorkshop, onWorkshopItemInstalled, ItemInstalled_t);
UGCUpdateHandle_t m_UGCUpdateHandle = 0;
UGCQueryHandle_t m_UGCSearchHandle = 0;

View File

@ -67,7 +67,7 @@ void SteamWorkshopListModel::append(unsigned int id, QString title, QUrl imgUrl,
{
int row = 0;
beginInsertRows(QModelIndex(), row, row);
m_workshopItemList.append(QSharedPointer<WorkshopItem>(new WorkshopItem(id, title, imgUrl, numSubscriptions)));
m_workshopItemList.append(QSharedPointer<WorkshopItem>(new WorkshopItem(id, title, imgUrl , "", numSubscriptions)));
endInsertRows();
}

View File

@ -3,12 +3,13 @@
WorkshopItem::WorkshopItem(){
}
WorkshopItem::WorkshopItem(unsigned int id, QString title, QUrl previewImageUrl, int numSubscriptions)
WorkshopItem::WorkshopItem(unsigned int id, QString title, QUrl previewImageUrl, QString type, int numSubscriptions)
{
m_id = id;
m_title = title;
m_previewImageUrl = previewImageUrl;
m_numSubscriptions = numSubscriptions;
m_type = type;
}
WorkshopItem::~WorkshopItem()

View File

@ -14,10 +14,11 @@
class WorkshopItem {
public:
WorkshopItem();
WorkshopItem(unsigned int id, QString title, QUrl previewImageUrl, int numSubscriptions);
WorkshopItem(unsigned int id, QString title, QUrl previewImageUrl, QString type, int numSubscriptions);
~WorkshopItem();
QUrl m_previewImageUrl;
QString m_title;
QString m_type;
int m_numSubscriptions;
unsigned int m_id;
};

View File

@ -1,24 +1,23 @@
#pragma once
#include <QQuickItem>
#include <QObject>
#include <QLocalSocket>
#include <QLocalServer>
#include <QSharedPointer>
#include <QSharedDataPointer>
#include <QJsonDocument>
#include <QJsonParseError>
#include <QByteArray>
#include <QTimer>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonParseError>
#include <QLocalServer>
#include <QLocalSocket>
#include <QObject>
#include <QQuickItem>
#include <QSharedDataPointer>
#include <QSharedPointer>
#include <QTimer>
class ScreenPlaySDK : public QQuickItem
{
class ScreenPlaySDK : public QQuickItem {
Q_OBJECT
Q_DISABLE_COPY(ScreenPlaySDK)
public:
ScreenPlaySDK(QQuickItem *parent = nullptr);
ScreenPlaySDK(QQuickItem* parent = nullptr);
~ScreenPlaySDK();
Q_PROPERTY(QString contentType READ contentType WRITE setContentType NOTIFY contentTypeChanged)
@ -35,7 +34,6 @@ public:
return m_isConnected;
}
QString appID() const
{
return m_appID;
@ -55,7 +53,7 @@ public slots:
m_contentType = contentType;
if(isConnected()){
if (isConnected()) {
m_socket.data()->write(QByteArray(m_contentType.toLatin1()));
m_socket.data()->flush();
m_socket.data()->waitForBytesWritten();
@ -79,6 +77,7 @@ public slots:
m_appID = appID;
emit appIDChanged(m_appID);
m_socket.data()->write(QByteArray(appID.toUtf8()));
m_socket.data()->waitForBytesWritten();
}
@ -87,7 +86,6 @@ signals:
void incommingMessage(QString key, QString value);
void incommingMessageError(QString msg);
void sdkConnected();
void sdkDisconnected();
void sdkSocketError(QString type);
@ -105,4 +103,3 @@ private:
QString m_appID;
};

View File

@ -19,6 +19,10 @@ SOURCES += \
RESOURCES += \
SPWidgetResources.qrc
# Additional import path used to resolve QML modules just for Qt Quick Designer
# QML_DESIGNER_IMPORT_PATH =
QT_QUICK_CONTROLS_STYLE = "Material"
# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH =

View File

@ -1,6 +1,7 @@
import QtQuick 2.9
import net.aimber.screenplaysdk 1.0
import QtQuick.Window 2.3
import QtQuick.Controls 2.3
Window {
id: mainWindow
@ -52,9 +53,21 @@ Window {
}
}
}
Connections{
target: loader.item
ignoreUnknownSignals: true
onSizeChanged:{
print(size)
mainWindow.width = size.width
mainWindow.height = size.height
}
}
MouseArea {
property point clickPos: "1,1"
anchors.fill: parent
acceptedButtons: Qt.LeftButton | Qt.RightButton
z:99
onPressed: {
@ -68,5 +81,20 @@ Window {
mainWindow.x = new_x
mainWindow.y = new_y
}
onClicked: {
if (mouse.button === Qt.RightButton) {
contextMenu.popup()
}
}
}
Menu {
id: contextMenu
MenuItem {
text: qsTr("Close")
onClicked: {
Qt.quit();
}
}
}
}

View File

@ -7,7 +7,7 @@ SourcePath=$PWD
SteamSDK='ScreenPlay/ThirdParty/steam/redistributable_bin/win64/'
skip="$1"
array=(librhash.dll libopenblas.dll liblz4.dll libjsoncpp.dll libidn2-0.dll libgcrypt-20.dll libicudt58.dll libicuuc58.dll libpcre2-16-0.dll libicuin58.dll QtAVWidgets1.dll QtAV1.dll zlib1.dll libbz2-1.dll libfreetype-6.dll libgcc_s_seh-1.dll libglib-2.0-0.dll libgraphite2.dll libharfbuzz-0.dll libiconv-2.dll libintl-8.dll libpcre-1.dll libpcre16-0.dll libpng16-16.dll libpng16-config libpng-config libstdc++-6.dll libvorbisenc-2.dll libvorbisfile-3.dll libvorbis-0.dll xvidcore.dll libschroedinger-1.0-0.dll libtheora-0.dll libtheoradec-1.dll libtheoraenc-1.dll libmodplug-1.dll libcaca++-0.dll libcaca-0.dll libmp3lame-0.dll libspeexdsp-1.dll libcelt0-2.dll libogg-0.dll libgmodule-2.0-0.dll libgobject-2.0-0.dll libgthread-2.0-0.dll libgio-2.0-0.dll libglib-2.0-0.dll swresample-2.dll swscale-4.dll postproc-54.dll avutil-55.dll avformat-57.dll avresample-3.dll avcodec-57.dll avdevice-57.dll avfilter-6.dll libssp-0.dll libstdc++-6.dll libgomp-1.dll libquadmath-0.dll libatomic-1.dll libgcc_s_seh-1.dll libfreetype-6.dll libwinpthread-1.dll libopencore-amrwb-0.dll libopencore-amrnb-0.dll libopus-0.dll libwavpack-1.dll libbluray-2.dll libvpx-1.dll libx265.dll libx265_main10.dll libtiffxx-5.dll libtiff-5.dll libopenmj2-7.dll libopenjpip-7.dll libopenjpwl-7.dll libopenjp2-7.dll libopenjp3d-7.dll libpng16-16.dll libwebpdecoder-3.dll libwebpdemux-2.dll libwebpmux-3.dll libwebp-7.dll edit.dll libharfbuzz-icu-0.dll libharfbuzz-0.dll libharfbuzz-gobject-0.dll libp11-kit-0.dll libgnutlsxx-28.dll libgnutls-30.dll libcharset-1.dll libiconv-2.dll liblzo2-2.dll libsystre-0.dll libtre-5.dll librtmp-1.dll libintl-8.dll libgettextpo-0.dll libgettextsrc-0-19-8-1.dll libasprintf-0.dll libgettextlib-0-19-8-1.dll libcppunit-1-13-0.dll libpcre32-0.dll libpcrecpp-0.dll libpcreposix-0.dll libpcre-1.dll libpcre16-0.dll zlib1.dll libminizip-1.dll libbz2-1.dll libass-9.dll libspeex-1.dll libcairo-script-interpreter-2.dll libcairo-2.dll libcairo-gobject-2.dll libunistring-2.dll liblzma-5.dll libgmp-10.dll libgmpxx-4.dll libexpat-1.dll libfontconfig-1.dll libxml2-2.dll libgraphite2.dll SDL2.dll libnettle-6.dll libhogweed-4.dll libturbojpeg-0.dll libjpeg-8.dll libx265.dll libx265_main10.dll libx264-155.dll liblsmash.dll liblsmash-2.dll liblcms2-2.dll libpixman-1-0.dll liborc-0.4-0.dll liborc-test-0.4-0.dll libtasn1-6.dll libidn-11.dll libffi-6.dll libgsm.dll libgif-7.dll libopenal-1.dll libfribidi-0.dll libquazip5.dll)
array=(ffmpeg.exe librhash.dll libopenblas.dll liblz4.dll libjsoncpp.dll libidn2-0.dll libgcrypt-20.dll libicudt58.dll libicuuc58.dll libpcre2-16-0.dll libicuin58.dll QtAVWidgets1.dll QtAV1.dll zlib1.dll libbz2-1.dll libfreetype-6.dll libgcc_s_seh-1.dll libglib-2.0-0.dll libgraphite2.dll libharfbuzz-0.dll libiconv-2.dll libintl-8.dll libpcre-1.dll libpcre16-0.dll libpng16-16.dll libpng16-config libpng-config libstdc++-6.dll libvorbisenc-2.dll libvorbisfile-3.dll libvorbis-0.dll xvidcore.dll libschroedinger-1.0-0.dll libtheora-0.dll libtheoradec-1.dll libtheoraenc-1.dll libmodplug-1.dll libcaca++-0.dll libcaca-0.dll libmp3lame-0.dll libspeexdsp-1.dll libcelt0-2.dll libogg-0.dll libgmodule-2.0-0.dll libgobject-2.0-0.dll libgthread-2.0-0.dll libgio-2.0-0.dll libglib-2.0-0.dll swresample-2.dll swscale-4.dll postproc-54.dll avutil-55.dll avformat-57.dll avresample-3.dll avcodec-57.dll avdevice-57.dll avfilter-6.dll libssp-0.dll libstdc++-6.dll libgomp-1.dll libquadmath-0.dll libatomic-1.dll libgcc_s_seh-1.dll libfreetype-6.dll libwinpthread-1.dll libopencore-amrwb-0.dll libopencore-amrnb-0.dll libopus-0.dll libwavpack-1.dll libbluray-2.dll libvpx-1.dll libx265.dll libx265_main10.dll libtiffxx-5.dll libtiff-5.dll libopenmj2-7.dll libopenjpip-7.dll libopenjpwl-7.dll libopenjp2-7.dll libopenjp3d-7.dll libpng16-16.dll libwebpdecoder-3.dll libwebpdemux-2.dll libwebpmux-3.dll libwebp-7.dll edit.dll libharfbuzz-icu-0.dll libharfbuzz-0.dll libharfbuzz-gobject-0.dll libp11-kit-0.dll libgnutlsxx-28.dll libgnutls-30.dll libcharset-1.dll libiconv-2.dll liblzo2-2.dll libsystre-0.dll libtre-5.dll librtmp-1.dll libintl-8.dll libgettextpo-0.dll libgettextsrc-0-19-8-1.dll libasprintf-0.dll libgettextlib-0-19-8-1.dll libcppunit-1-13-0.dll libpcre32-0.dll libpcrecpp-0.dll libpcreposix-0.dll libpcre-1.dll libpcre16-0.dll zlib1.dll libminizip-1.dll libbz2-1.dll libass-9.dll libspeex-1.dll libcairo-script-interpreter-2.dll libcairo-2.dll libcairo-gobject-2.dll libunistring-2.dll liblzma-5.dll libgmp-10.dll libgmpxx-4.dll libexpat-1.dll libfontconfig-1.dll libxml2-2.dll libgraphite2.dll SDL2.dll libnettle-6.dll libhogweed-4.dll libturbojpeg-0.dll libjpeg-8.dll libx265.dll libx265_main10.dll libx264-155.dll liblsmash.dll liblsmash-2.dll liblcms2-2.dll libpixman-1-0.dll liborc-0.4-0.dll liborc-test-0.4-0.dll libtasn1-6.dll libidn-11.dll libffi-6.dll libgsm.dll libgif-7.dll libopenal-1.dll libfribidi-0.dll libquazip5.dll)
echo 'This is script will now copy'
echo 'all depenecies into the release folder'