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

Merge branch 'master' into 107-refactor-create-screen

# Conflicts:
#	ScreenPlay/qml/Create/Create.qml
#	ScreenPlay/qml/Create/ImportContent.qml
This commit is contained in:
Elias Steurer 2020-09-27 21:07:03 +02:00
commit bd7e95fd02
42 changed files with 709 additions and 650 deletions

1
.gitignore vendored
View File

@ -88,3 +88,4 @@ compile_commands.json
CTestTestfile.cmake
_deps
.cmake/**
/Common/ffmpeg/*

View File

@ -26,7 +26,25 @@ build:windows:
paths:
- Common\vcpkg\
script:
- .\install_dependencies_windows.bat
- git submodule update --init
- git submodule update --recursive
- cd Common
- if (!(Test-Path "vcpkg")){git clone https://github.com/microsoft/vcpkg.git}
- cd vcpkg
- git remote set-url origin https://github.com/microsoft/vcpkg.git
- git pull origin master
- git checkout 18ab4b72a26284f0df28295ce7bf9b21c96f20f4
- cmd /c bootstrap-vcpkg.bat
- ls
- cmd /c vcpkg.exe install openssl --triplet x64-windows --recurse
- cd ..
- cd ..
- curl.exe -L https://www.gyan.dev/ffmpeg/builds/packages/ffmpeg-4.3.1-2020-09-16-full_build.zip --output ffmpeg.zip
- tar -xvf ffmpeg.zip --strip-components 2 ffmpeg-4.3.1-full_build/bin
- if (!(Test-Path "Common/ffmpeg")){ mkdir Common/ffmpeg }
- cmd /c DEL ffplay.exe
- cmd /c move /Y ffmpeg.exe Common/ffmpeg
- cmd /c move /Y ffprobe.exe Common/ffmpeg
- mkdir BUILD_WINDOWS
- cd BUILD_WINDOWS
- cmake.exe ../ -DCMAKE_PREFIX_PATH=c:/Qt/5.15.1/msvc2019 -DCMAKE_IGNORE_PATH=C:/Strawberry/c/bin -DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_TOOLCHAIN_FILE="$(Get-Location)/../Common/vcpkg/scripts/buildsystems/vcpkg.cmake" -DVCPKG_TARGET_TRIPLET=x64-windows "-GCodeBlocks - Ninja" -B.

3
.gitmodules vendored
View File

@ -1,6 +1,3 @@
[submodule "Common/qt-google-analytics"]
path = Common/qt-google-analytics
url = https://github.com/HSAnet/qt-google-analytics.git
[submodule "Common/qt-breakpad"]
path = Common/qt-breakpad
url = https://github.com/kelteseth/qt-breakpad

View File

@ -16,8 +16,8 @@ elseif(APPLE)
endif()
set(VCPKG_INCLUDE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/Common/vcpkg/installed/${VCPKG_ARCH}/include/)
set(VCPKG_TOOLS_PATH ${CMAKE_CURRENT_SOURCE_DIR}/Common/vcpkg/installed/${VCPKG_ARCH}/tools/)
set(QT_TELEMTRY_INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/Common/qt-google-analytics/)
set(QT_BREAKPAD_INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/Common/qt-breakpad/)
find_package(Git REQUIRED)
@ -51,10 +51,7 @@ project(ScreenPlay)
add_subdirectory(ScreenPlay)
add_subdirectory(ScreenPlaySDK)
add_subdirectory(ScreenPlayShader)
add_subdirectory(ScreenPlayWallpaper)
add_subdirectory(ScreenPlayWidget)
add_subdirectory(ScreenPlaySysInfo)
add_subdirectory(Common/qt-breakpad)

@ -1 +0,0 @@
Subproject commit f5bf92fc2b349ca1c3c76a18a58fadfab5bb9f33

View File

@ -4,7 +4,7 @@
``` bash
git clone --recursive https://gitlab.com/kelteseth/ScreenPlay.git
```
3. Download the latest [__Qt 5.14__](https://www.qt.io/download-qt-installer). Earlier versions are not supported!
3. Download the latest [__Qt 5.15__](https://www.qt.io/download-qt-installer). Earlier versions are not supported!
4. Start install-dependencies.bat to download dependencies into the Common/ folder
``` bash
//Windows
@ -16,15 +16,11 @@ chmod +x install-dependencies.sh
.\install-dependencies.sh
```
* This will install these dependencies via __vcpkg__
* libzippp
* nlohmann-json
* openSSL 1.1.1d
* zlib& libzip
* breakpad
* sentry-native
* Download these dependencies via __git submodules__
* stomt-qt-sdk
* qt-google-analytics
* qt-breakpad
* Download ffmpeg binaries
5. **Follow the steps below for your OS**.
6. Open the CMakeLists.txt via QtCreator. **This can take some time until QtCreator parses all files!**
@ -52,7 +48,7 @@ chmod +x install-dependencies.sh
2. [Download and install Qt 5 binary installer from qt.io](https://www.qt.io/download-qt-installer)
- Install the Maintaince tool
- Select the following features to install:
- Qt 5.14.2
- Qt 5.15.2
- MSVC 2017 64-bit
- Qt WebEngine
- Developer and Designer Tools
@ -75,14 +71,14 @@ sudo zypper install -t pattern devel_basis
2. [Download and install Qt 5 binary installer from qt.io](https://www.qt.io/download-qt-installer)
- Install the Maintaince tool
- Select the following features to install:
- Qt 5.14.2
- Qt 5.15.2
- GCC
- Qt WebEngine
### OSX
1. [Download and install Qt 5 binary installer from qt.io](https://www.qt.io/download-qt-installer)
- Install the Maintaince tool
- Select the following features to install:
- Qt 5.14.2
- Qt 5.15.2
- Qt WebEngine
- Developer and Designer Tools
- OpenSSL 1.1.1.c Toolkit

View File

@ -18,10 +18,8 @@ find_package(
LinguistTools
REQUIRED)
find_package(ZLIB REQUIRED)
find_package(OpenSSL REQUIRED)
find_package(libzippp CONFIG REQUIRED)
find_package(sentry CONFIG REQUIRED)
set(src main.cpp
app.cpp
@ -85,12 +83,13 @@ add_executable(${PROJECT_NAME} ${src} ${headers} ${resources} ${qml})
if(WIN32)
# Icon
target_sources(${PROJECT_NAME} PRIVATE ScreenPlay.rc)
# Disable console window on Windows
# https://stackoverflow.com/questions/8249028/how-do-i-keep-my-qt-c-program-from-opening-a-console-in-windows
set_property(TARGET ${PROJECT_NAME} PROPERTY WIN32_EXECUTABLE true)
endif()
# Disable console window on Windows
# https://stackoverflow.com/questions/8249028/how-do-i-keep-my-qt-c-program-from-opening-a-console-in-windows
set_property(TARGET ${PROJECT_NAME} PROPERTY WIN32_EXECUTABLE true)
target_compile_definitions(${PROJECT_NAME} PRIVATE "GIT_VERSION=${GIT_VERSION}")
@ -101,14 +100,23 @@ target_link_libraries(${PROJECT_NAME}
Qt5::Widgets
Qt5::Core
Qt5::WebEngine
libzippp::libzippp
sentry::sentry
ScreenPlaySDK
QTBreakpadplugin)
)
target_include_directories(${PROJECT_NAME}
PRIVATE
${QT_TELEMTRY_INCLUDE}
${QT_BREAKPAD_INCLUDE})
${QT_TELEMTRY_INCLUDE})
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/bin/assets/fonts)
configure_file(assets/fonts/NotoSansCJKkr-Regular.otf ${CMAKE_BINARY_DIR}/bin/assets/fonts COPYONLY)
# Copy ffmpeg. If the ffmpeg files are missing, start the
# install_dependencies_XXX for your system!
if(WIN32)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../Common/ffmpeg/ffmpeg.exe ${CMAKE_BINARY_DIR}/bin/ COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../Common/ffmpeg/ffprobe.exe ${CMAKE_BINARY_DIR}/bin/ COPYONLY)
else()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../Common/ffmpeg/ffmpeg ${CMAKE_BINARY_DIR}/bin/ COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../Common/ffmpeg/ffprobe ${CMAKE_BINARY_DIR}/bin/ COPYONLY)
endif()

View File

@ -47,13 +47,9 @@ App::App()
QGuiApplication::setOrganizationName("ScreenPlay");
QGuiApplication::setOrganizationDomain("screen-play.app");
QGuiApplication::setApplicationName("ScreenPlay");
QGuiApplication::setApplicationVersion("0.12.0");
QGuiApplication::setApplicationVersion("0.12.1");
QGuiApplication::setQuitOnLastWindowClosed(false);
#ifdef Q_OS_WINDOWS
QtBreakpad::init(QDir::current().absolutePath());
#endif
QFontDatabase::addApplicationFont(":/assets/fonts/LibreBaskerville-Italic.ttf");
QFontDatabase::addApplicationFont(":/assets/fonts/Roboto-Light.ttf");
@ -137,9 +133,8 @@ void App::init()
using std::make_shared, std::make_unique;
// Util should be created as first so we redirect qDebugs etc. into the log
m_util = std::make_unique<Util>(&m_networkAccessManager);
m_globalVariables = make_shared<GlobalVariables>();
auto* nam = new QNetworkAccessManager(this);
m_util = make_unique<Util>(nam);
m_installedListModel = make_shared<InstalledListModel>(m_globalVariables);
m_installedListFilter = make_shared<InstalledListFilter>(m_installedListModel);
m_monitorListModel = make_shared<MonitorListModel>();
@ -151,10 +146,25 @@ void App::init()
// Only create tracker if user did not disallow!
if (m_settings->anonymousTelemetry()) {
m_telemetry = make_shared<GAnalytics>("UA-152830367-3");
m_telemetry->setNetworkAccessManager(nam);
m_telemetry->setNetworkAccessManager(&m_networkAccessManager);
m_telemetry->setSendInterval(1000);
m_telemetry->startSession();
m_telemetry->sendEvent("version", QApplication::applicationVersion());
sentry_options_t* options = sentry_options_new();
sentry_options_set_dsn(options, "https://425ea0b77def4f91a5a9decc01b36ff4@o428218.ingest.sentry.io/5373419");
QString executableSuffix;
#ifdef Q_OS_WIN
executableSuffix = ".exe";
#endif
const QString appPath = QGuiApplication::applicationDirPath();
sentry_options_set_handler_path(options, QString(appPath + "/crashpad_handler" + executableSuffix).toStdString().c_str());
sentry_options_set_database_path(options, appPath.toStdString().c_str());
const int sentryInitStatus = sentry_init(options);
if (sentryInitStatus != 0) {
qWarning() << "Unable to inti sentry crashhandler with statuscode: " << sentryInitStatus;
}
}
m_create = make_unique<Create>(m_globalVariables);
@ -180,6 +190,7 @@ void App::init()
qmlRegisterSingletonInstance("ScreenPlay", 1, 0, "ScreenPlay", this);
loadSteamPlugin();
m_mainWindowEngine->load(QUrl(QStringLiteral("qrc:/main.qml")));
}

View File

@ -49,10 +49,6 @@
#include <memory>
#include "ganalytics.h"
#ifdef Q_OS_WINDOWS
#include "qt_breakpad.h"
#endif
#include "src/create.h"
#include "src/globalvariables.h"
#include "src/installedlistfilter.h"
@ -63,6 +59,9 @@
#include "src/settings.h"
#include "src/util.h"
#include "ganalytics.h"
#include <sentry.h>
class ScreenPlayWorkshopPlugin;
namespace ScreenPlay {
@ -253,6 +252,7 @@ private:
private:
QPluginLoader m_workshopPlugin;
QNetworkAccessManager m_networkAccessManager;
std::unique_ptr<QQmlApplicationEngine> m_mainWindowEngine;
std::unique_ptr<Create> m_create;

View File

@ -32,19 +32,21 @@
**
****************************************************************************/
#include <QApplication>
#include "app.h"
#include <QApplication>
#include <QDebug>
#include <sentry.h>
int main(int argc, char* argv[])
{
// Buggy with every Qt version except 5.14.0!
// Displays wrong DPI scaled monitor resolution
// 4k with 150% scaling to FULL HD on Windows
// https://bugreports.qt.io/browse/QTBUG-81694
#if defined(Q_OS_LINUX) || defined(Q_OS_OSX)
// Buggy with every Qt version except 5.14.0!
// Displays wrong DPI scaled monitor resolution
// 4k with 150% scaling to FULL HD on Windows
// https://bugreports.qt.io/browse/QTBUG-81694
#if defined(Q_OS_LINUX) || defined(Q_OS_OSX)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif
#endif
QApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
QApplication qtGuiApp(argc, argv);
@ -54,7 +56,10 @@ int main(int argc, char* argv[])
if (app.m_isAnotherScreenPlayInstanceRunning) {
return 0;
} else {
app.init();
return qtGuiApp.exec();
const int status = qtGuiApp.exec();
sentry_shutdown();
return status;
}
}

View File

@ -9,6 +9,9 @@ import Qt.labs.platform 1.0
import ScreenPlay 1.0
import Settings 1.0
import ScreenPlay.Shader 1.0
import "ShaderWrapper" as ShaderWrapper
import "qml/"
import "qml/Monitors" as Monitors
import "qml/Common" as Common
@ -25,7 +28,7 @@ ApplicationWindow {
visible: false
width: 1400
height: 788
title: "ScreenPlay Alpha - V0.12.0"
title: "ScreenPlay Alpha - V0.12.1"
minimumHeight: 450
minimumWidth: 1050
onVisibilityChanged: {
@ -34,6 +37,8 @@ ApplicationWindow {
}
}
// Partial workaround for
// https://bugreports.qt.io/browse/QTBUG-86047
Material.accent: Material.color(Material.Orange)
@ -91,7 +96,6 @@ ApplicationWindow {
pageLoaderCreate.visible = true
pageLoaderWorkshop.visible = false
pageLoaderCreate.setSource("qrc:/qml/Create/Create.qml")
pageLoaderCreate.item.checkFFMPEG()
} else if (name === "Workshop") {
if (ScreenPlay.settings.steamVersion) {

View File

@ -4,7 +4,6 @@
<file>qml/Create/Create.qml</file>
<file>qml/Create/Wizards/CreateWallpaper/CreateWallpaperVideoImportConvert.qml</file>
<file>qml/Create/Wizards/CreateWallpaper/CreateWallpaperResult.qml</file>
<file>qml/Create/FFMPEGPopup.qml</file>
<file>qml/Create/Wizard.qml</file>
<file>qml/Create/Wizards/CreateEmptyWidget/CreateEmptyWidget.qml</file>
<file>qml/Create/Footer.qml</file>

View File

@ -57,7 +57,6 @@ Item {
icon.source: "qrc:/assets/icons/icon_supervisor_account.svg"
}
CommunityNavItem {
enabled: false
text: qsTr("Steam Workshop")
openLink: "steam://url/GameHub/672870"
icon.source: "qrc:/assets/icons/icon_steam.svg"

View File

@ -1,389 +0,0 @@
import QtQuick 2.12
import QtQuick.Layouts 1.12
import QtQuick.Controls 2.12
import QtQuick.Controls.Material 2.12
import QtQuick.Particles 2.0
import QtGraphicalEffects 1.0
import ScreenPlay 1.0
import ScreenPlay.Create 1.0
import ScreenPlay.QMLUtilities 1.0
import "Wizards/CreateWallpaper"
Popup {
id: ffmpegPopup
height: 600
padding: 30
width: 900
background: Rectangle {
anchors.fill: parent
color: Material.theme === Material.Light ? "white" : Material.background
}
Connections {
target: ScreenPlay.util
function onAquireFFMPEGStatusChanged(aquireFFMPEGStatus) {
switch (aquireFFMPEGStatus) {
case QMLUtilities.Init:
break
case QMLUtilities.Download:
btnNotNow.enabled = false
btnDownload.enabled = false
busyIndicator.running = true
txtStatus.text = qsTr("Begin downloading FFMPEG")
break
case QMLUtilities.DownloadFailed:
btnNotNow.enabled = true
txtStatus.text = qsTr("FFMPEG download failed")
busyIndicator.running = false
break
case QMLUtilities.DownloadSuccessful:
txtStatus.text = qsTr("FFMPEG download successful")
break
case QMLUtilities.Extracting:
txtStatus.text = qsTr("Extracting FFMPEG")
break
case QMLUtilities.ExtractingFailedReadFromBuffer:
btnNotNow.enabled = true
txtStatus.text = qsTr("ERROR extracting ffmpeg from RAM")
busyIndicator.running = false
break
case QMLUtilities.ExtractingFailedFFMPEG:
btnNotNow.enabled = true
txtStatus.text = qsTr("ERROR extracing ffmpeg")
busyIndicator.running = false
break
case QMLUtilities.ExtractingFailedFFMPEGSave:
btnNotNow.enabled = true
txtStatus.text = qsTr("ERROR saving FFMPEG to disk")
busyIndicator.running = false
break
case QMLUtilities.ExtractingFailedFFPROBE:
btnNotNow.enabled = true
txtStatus.text = qsTr("ERROR extracing FFPROBE")
busyIndicator.running = false
break
case QMLUtilities.ExtractingFailedFFPROBESave:
btnNotNow.enabled = true
txtStatus.text = qsTr("ERROR saving FFPROBE to disk")
busyIndicator.running = false
break
case QMLUtilities.ExtractingSuccessful:
txtStatus.text = qsTr("Extraction successful")
break
case QMLUtilities.FinishedSuccessful:
txtStatus.text = qsTr("All done and ready to go!")
busyIndicator.running = false
column.state = "finishedSuccessful"
ScreenPlay.util.setFfmpegAvailable(true)
break
}
}
}
Popup {
id: closeDialog
width: 400
height: 250
background: Rectangle {
anchors.fill: parent
color: Material.theme === Material.Light ? "white" : Material.background
}
Text {
text: qsTr("You cannot create Wallaper without FFMPEG installed!")
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
font.pointSize: 16
height: 50
font.family: ScreenPlay.settings.font
anchors.fill: parent
anchors.margins: 50
wrapMode: Text.WordWrap
color: Material.color(Material.Orange)
}
RowLayout {
height: 30
anchors {
right: parent.right
bottom: parent.bottom
left: parent.left
margins: 20
}
Button {
text: qsTr("Abort")
onClicked: {
ffmpegPopup.close()
closeDialog.close()
ScreenPlay.util.setNavigation("Installed")
}
Layout.alignment: Qt.AlignRight
}
Button {
text: qsTr("Download FFMPEG")
highlighted: true
onClicked: closeDialog.close()
Layout.alignment: Qt.AlignRight
}
}
anchors.centerIn: Overlay.overlay
closePolicy: Popup.NoAutoClose
focus: true
modal: true
}
ColumnLayout {
id: column
anchors.fill: parent
Text {
id: txtDownloadFFMPEG
text: qsTr("Before we can start creating content you need to download FFMPEG")
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
font.pointSize: 16
Layout.fillWidth: true
Layout.preferredHeight: 60
color: Material.foreground
font.family: ScreenPlay.settings.font
}
Item {
Layout.fillHeight: true
Layout.fillWidth: true
Item {
width: parent.width * .33
anchors {
top: parent.top
bottom: parent.bottom
left: parent.left
}
Image {
id: imgFFMPEGLogo
source: "qrc:/assets/images/FFmpeg_Logo_new.svg"
width: sourceSize.width
height: sourceSize.height
anchors {
horizontalCenter: parent.horizontalCenter
margins: 20
top: parent.top
}
}
BusyIndicator {
id: busyIndicator
anchors.centerIn: parent
running: false
}
Text {
id: txtStatus
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
font.pointSize: 14
height: 50
Layout.fillWidth: true
color: Material.color(Material.Orange)
font.family: ScreenPlay.settings.font
wrapMode: Text.WordWrap
anchors {
top: busyIndicator.bottom
topMargin: 20
right: parent.right
left: parent.left
}
}
}
Page {
width: parent.width * .66
background: Rectangle {
anchors.fill: parent
color: Material.theme === Material.Light ? Material.background : Qt.darker(
Material.background)
radius: 3
}
padding: 10
anchors {
top: parent.top
bottom: parent.bottom
right: parent.right
}
Flickable {
anchors.fill: parent
clip: true
contentHeight: txtExpander.paintedHeight + 100
contentWidth: parent.width
ScrollBar.vertical: ScrollBar {
snapMode: ScrollBar.SnapOnRelease
policy: ScrollBar.AlwaysOn
}
MouseArea {
anchors.fill: parent
id: maHoverEffect
}
Text {
id: txtExpander
anchors {
fill: parent
margins: 30
leftMargin: 0
}
color: Material.foreground
height: txtExpander.paintedHeight
wrapMode: Text.WordWrap
font.pointSize: 12
font.family: ScreenPlay.settings.font
onLinkHovered: maHoverEffect.cursorShape = Qt.PointingHandCursor
onLinkActivated: Qt.openUrlExternally(link)
linkColor: Material.color(Material.LightBlue)
text: qsTr("<b>Why do we bother you with this?</b>
<br><br> Well its because of <b>copyright</b> and many many <b>patents</b>.
" + "Files like .mp4 or .webm are containers for video and audio. Every audio
" + "and video file is encoded with a certain codec. These can be open source
" + "and free to use like <a href='https://wikipedia.org/wiki/VP8'>VP8</a> and the newer <a href='https://wikipedia.org/wiki/VP9'>VP9</a> (the one YouTube uses for their webms)
" + "but there are also some proprietary ones like <a href='https://wikipedia.org/wiki/H.264/MPEG-4_AVC'>h264</a> and the successor <a href='https://wikipedia.org/wiki/High_Efficiency_Video_Coding'>h265</a>." + "
<br>
<br>
" + "\n\n We as software developer now need to deal with stuff like this in a field we
" + "do not have any expertise in. The desicion to enable only free codecs for content was
" + "an easy one but we still need to provide a way for our user to import wallpaper
" + "without a hassle. We do not provide <a href='https://ffmpeg.org/'>FFMPEG</a> for
" + "converting video and audio with ScreenPlay because we are not allowed to. We let the user download <a href='https://ffmpeg.org/'>FFMPEG</a> which
" + "is perfectly fine!
<br>
Sorry for this little inconvenience :)" + "
<br>
<br>
<center>
<b>
IF YOU DO NOT HAVE AN INTERNET CONNECT YOU CAN SIMPLY PUT FFMPEG AND FFPROBE
IN THE SAME FOLDER AS YOUR SCREENPLAY EXECUTABLE!
</b>
<br>
<br>
This is usually:
<br> C:\\Program Files (x86)\\Steam\\steamapps\\common\\ScreenPlay
<br>
if you installed ScreenPlay via Steam!
</center>
<br>
<br>
" + "<b>~ Kelteseth | Elias Steurer</b>")
}
}
}
}
RowLayout {
spacing: 20
Layout.fillWidth: true
Layout.alignment: Qt.AlignBottom
Button {
id: btnDownload
text: qsTr("Download FFMPEG")
onClicked: ScreenPlay.util.downloadFFMPEG()
highlighted: true
Layout.fillWidth: true
}
Button {
id: btnNotNow
text: qsTr("Not now!")
onClicked: closeDialog.open()
Layout.fillWidth: true
}
}
states: [
State {
name: "finishedSuccessful"
PropertyChanges {
target: column
opacity: 0
enabled: false
}
PropertyChanges {
target: successWrapper
opacity: 1
enabled: true
}
}
]
transitions: [
Transition {
from: "*"
to: "finishedSuccessful"
PropertyAnimation {
target: successWrapper
property: "opacity"
duration: 250
}
}
]
}
Item {
id: successWrapper
anchors.fill: parent
anchors.margins: 30
opacity: 0
enabled: false
Text {
id: txtDownloadFFMPEGComplete
text: qsTr("You can now start creating content!")
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
font.pointSize: 16
height: 50
Layout.fillWidth: true
color: Material.foreground
font.family: ScreenPlay.settings.font
anchors {
horizontalCenter: parent.horizontalCenter
top: parent.top
topMargin: 30
}
}
Image {
id: imgOk
fillMode: Image.PreserveAspectFit
source: "qrc:/assets/icons/icon_done.svg"
width: 180
height: width
sourceSize: Qt.size(width, width)
anchors.centerIn: parent
smooth: true
}
ColorOverlay {
anchors.fill: imgOk
source: imgOk
color: Material.color(Material.LightGreen)
}
Button {
text: qsTr("Start!")
highlighted: true
onClicked: ffmpegPopup.close()
anchors {
horizontalCenter: parent.horizontalCenter
top: imgOk.bottom
margins: 30
}
}
}
}

View File

@ -82,6 +82,7 @@ Item {
cellHeight: 200
cacheBuffer: 160
interactive: pageInstalled.enabled
snapMode: GridView.SnapToRow
anchors {
topMargin: 0
rightMargin: 0
@ -209,7 +210,8 @@ Item {
text: qsTr("Open containing folder")
icon.source: "qrc:/assets/icons/icon_folder_open.svg"
onClicked: {
ScreenPlay.util.openFolderInExplorer(contextMenu.absoluteStoragePath)
ScreenPlay.util.openFolderInExplorer(
contextMenu.absoluteStoragePath)
}
}
MenuItem {

View File

@ -82,7 +82,7 @@ Item {
Button {
id: btnWorkshop
text: qsTr("Browse the Steam Workshop")
Material.background: Material.Blue
Material.background: Material.color(Material.Green)
Material.foreground: "white"
smooth: true
font.pointSize: 18

View File

@ -8,17 +8,6 @@ ScreenPlay::SDKConnection::SDKConnection(QLocalSocket* socket, QObject* parent)
connect(m_socket, &QLocalSocket::readyRead, this, &SDKConnection::readyRead);
}
ScreenPlay::SDKConnection::~SDKConnection()
{
// We need to call this manually because
// sometimes it wont close the connection in
// the descructor
m_socket->disconnect();
m_socket->disconnectFromServer();
m_socket->close();
}
void ScreenPlay::SDKConnection::readyRead()
{

View File

@ -69,7 +69,6 @@ public:
SDKConnection.
*/
explicit SDKConnection(QLocalSocket* socket, QObject* parent = nullptr);
~SDKConnection();
QString appID() const
{

View File

@ -16,7 +16,9 @@ Util::Util(QNetworkAccessManager* networkAccessManager, QObject* parent)
, m_networkAccessManager { networkAccessManager }
{
utilPointer = this;
qRegisterMetaType<Util::AquireFFMPEGStatus>();
// Fix log access vilation on quit
QObject::connect(QGuiApplication::instance(), &QGuiApplication::aboutToQuit, this, []() { utilPointer = nullptr; });
qmlRegisterUncreatableType<Util>("ScreenPlay.QMLUtilities", 1, 0, "QMLUtilities", "Error only for enums");
// In release mode redirect messages to logging otherwhise we break the nice clickable output :(
@ -27,21 +29,6 @@ Util::Util(QNetworkAccessManager* networkAccessManager, QObject* parent)
// This gives us nice clickable output in QtCreator
qSetMessagePattern("%{if-category}%{category}: %{endif}%{message}\n Loc: [%{file}:%{line}]");
QString path = QApplication::instance()->applicationDirPath() + "/";
QFile fileFFMPEG;
QFile fileFFPROBE;
#ifdef Q_OS_WIN
fileFFMPEG.setFileName(path + "ffmpeg.exe");
fileFFPROBE.setFileName(path + "ffprobe.exe");
#else
fileFFMPEG.setFileName(path + "ffmpeg");
fileFFPROBE.setFileName(path + "ffprobe");
#endif
if (fileFFMPEG.exists() && fileFFPROBE.exists())
setFfmpegAvailable(true);
}
/*!
@ -289,94 +276,6 @@ void Util::Util::requestDataProtection()
});
}
/*!
\brief Downloads and extracts ffmpeg static version from https://ffmpeg.zeranoe.com
The progress is tracked via setAquireFFMPEGStatus(AquireFFMPEGStatus);
*/
void Util::downloadFFMPEG()
{
QNetworkRequest req;
QString ffmpegVersion { "ffmpeg-4.3.1" };
#ifdef Q_OS_WIN
req.setUrl(QUrl("https://ffmpeg.zeranoe.com/builds/win64/static/" + ffmpegVersion + "-win64-static.zip"));
#elif defined(Q_OS_OSX)
req.setUrl(QUrl("https://ffmpeg.zeranoe.com/builds/macos64/static/" + ffmpegVersion + "-macos64-static.zip"));
#endif
setAquireFFMPEGStatus(AquireFFMPEGStatus::Download);
QNetworkReply* reply = m_networkAccessManager->get(req);
QObject::connect(reply, &QNetworkReply::finished, this, [this, reply, ffmpegVersion]() {
using namespace libzippp;
using namespace std;
setAquireFFMPEGStatus(AquireFFMPEGStatus::DownloadSuccessful);
QByteArray download = reply->readAll();
auto* archive = ZipArchive::fromBuffer(download.data(), download.size(), ZipArchive::OpenMode::READ_ONLY, true);
if (archive == nullptr) {
setAquireFFMPEGStatus(AquireFFMPEGStatus::ExtractingFailedReadFromBuffer);
return;
}
string path = QApplication::instance()->applicationDirPath().toStdString() + "/";
ZipEntry entryFFMPEG;
std::string entryFFMPEGPath;
#ifdef Q_OS_WIN
entryFFMPEG = archive->getEntry(ffmpegVersion.toStdString() + "-win64-static/bin/ffmpeg.exe");
entryFFMPEGPath = path + "ffmpeg.exe";
#elif defined(Q_OS_OSX)
entryFFMPEG = archive->getEntry(ffmpegVersion.toStdString() +"-macos64-static/bin/ffmpeg");
entryFFMPEGPath = path + "ffmpeg";
#endif
if (entryFFMPEG.isNull()) {
qDebug() << "entryFFMPEG is null. No more entry is available.";
qDebug() << "Download size was: " << download.size() << "bytes";
setAquireFFMPEGStatus(AquireFFMPEGStatus::ExtractingFailedFFMPEG);
return;
}
if (!saveExtractedByteArray(entryFFMPEG, entryFFMPEGPath)) {
qDebug() << "could not save ffmpeg";
setAquireFFMPEGStatus(AquireFFMPEGStatus::ExtractingFailedFFMPEGSave);
return;
}
ZipEntry entryFFPROBE;
std::string entryFFPROBEPath;
#ifdef Q_OS_WIN
entryFFPROBE = archive->getEntry(ffmpegVersion.toStdString() + "-win64-static/bin/ffprobe.exe");
entryFFPROBEPath = path + "ffprobe.exe";
#elif defined(Q_OS_OSX)
entryFFPROBE = archive->getEntry(ffmpegVersion.toStdString() +"-macos64-static/bin/ffprobe");
entryFFPROBEPath = path + "ffprobe";
#endif
if (entryFFPROBE.isNull()) {
qDebug() << "null";
setAquireFFMPEGStatus(AquireFFMPEGStatus::ExtractingFailedFFPROBE);
return;
}
if (!saveExtractedByteArray(entryFFPROBE, entryFFPROBEPath)) {
qDebug() << "could not save ffprobe";
setAquireFFMPEGStatus(AquireFFMPEGStatus::ExtractingFailedFFPROBESave);
return;
}
setAquireFFMPEGStatus(AquireFFMPEGStatus::FinishedSuccessful);
});
QObject::connect(reply, QOverload<QNetworkReply::NetworkError>::of(&QNetworkReply::error),
[this](QNetworkReply::NetworkError code) {
this->setAquireFFMPEGStatus(AquireFFMPEGStatus::DownloadFailed);
});
}
SearchType::SearchType Util::getSearchTypeFromInstalledType(const InstalledType::InstalledType type)
{
using InstalledType::InstalledType;
@ -464,26 +363,4 @@ void Util::logToGui(QtMsgType type, const QMessageLogContext& context, const QSt
utilPointer->appendDebugMessages(log);
}
/*!
\brief Convenient function for the ffmpeg download extraction via libzippp. Extracts a given bytearray
to a given absolute file path and file name. Returns false if extraction or saving wasn't successful.
*/
bool Util::saveExtractedByteArray(libzippp::ZipEntry& entry, std::string& absolutePathAndName)
{
std::ofstream ofUnzippedFile(absolutePathAndName, std::ofstream::binary);
if (ofUnzippedFile) {
if (entry.readContent(ofUnzippedFile) != 0) {
qDebug() << "Error cannot read ffmpeg zip content";
return false;
}
} else {
qDebug() << "Coud not open ofstream" << QString::fromStdString(absolutePathAndName);
return false;
}
ofUnzippedFile.close();
return true;
}
}

View File

@ -58,7 +58,7 @@
#include <optional>
#include "globalvariables.h"
#include "libzippp.h"
namespace ScreenPlay {
@ -80,39 +80,11 @@ T QStringToEnum(const QString& key, const T defaultValue)
class Util : public QObject {
Q_OBJECT
Q_PROPERTY(bool ffmpegAvailable READ ffmpegAvailable NOTIFY ffmpegAvailableChanged)
Q_PROPERTY(AquireFFMPEGStatus aquireFFMPEGStatus READ aquireFFMPEGStatus NOTIFY aquireFFMPEGStatusChanged)
Q_PROPERTY(QString debugMessages READ debugMessages NOTIFY debugMessagesChanged)
public:
explicit Util(QNetworkAccessManager* networkAccessManager, QObject* parent = nullptr);
enum class AquireFFMPEGStatus {
Init,
Download,
DownloadFailed,
DownloadSuccessful,
Extracting,
ExtractingFailedReadFromBuffer,
ExtractingFailedFFMPEG,
ExtractingFailedFFMPEGSave,
ExtractingFailedFFPROBE,
ExtractingFailedFFPROBESave,
ExtractingSuccessful,
FinishedSuccessful,
};
Q_ENUM(AquireFFMPEGStatus)
bool ffmpegAvailable() const
{
return m_ffmpegAvailable;
}
AquireFFMPEGStatus aquireFFMPEGStatus() const
{
return m_aquireFFMPEGStatus;
}
QString debugMessages() const
{
return m_debugMessages;
@ -125,8 +97,6 @@ signals:
void setSidebarItem(QString folderName, ScreenPlay::InstalledType::InstalledType type);
void allLicenseLoaded(QString licensesText);
void allDataProtectionLoaded(QString dataProtectionText);
void ffmpegAvailableChanged(bool ffmpegAvailable);
void aquireFFMPEGStatusChanged(ScreenPlay::Util::AquireFFMPEGStatus aquireFFMPEGStatus);
void debugMessagesChanged(QString debugMessages);
public slots:
@ -136,8 +106,6 @@ public slots:
void requestAllLicenses();
void requestDataProtection();
void downloadFFMPEG();
static SearchType::SearchType getSearchTypeFromInstalledType(const InstalledType::InstalledType type);
static std::optional<InstalledType::InstalledType> getInstalledTypeFromString(const QString& type);
static std::optional<QJsonObject> parseQByteArrayToQJsonObject(const QByteArray& byteArray);
@ -166,24 +134,6 @@ public slots:
emit requestToggleWallpaperConfiguration();
}
void setFfmpegAvailable(bool ffmpegAvailable)
{
if (m_ffmpegAvailable == ffmpegAvailable)
return;
m_ffmpegAvailable = ffmpegAvailable;
emit ffmpegAvailableChanged(m_ffmpegAvailable);
}
void setAquireFFMPEGStatus(ScreenPlay::Util::AquireFFMPEGStatus aquireFFMPEGStatus)
{
if (m_aquireFFMPEGStatus == aquireFFMPEGStatus)
return;
m_aquireFFMPEGStatus = aquireFFMPEGStatus;
emit aquireFFMPEGStatusChanged(m_aquireFFMPEGStatus);
}
void appendDebugMessages(QString debugMessages)
{
if (m_debugMessages.size() > 10000) {
@ -194,14 +144,10 @@ public slots:
emit debugMessagesChanged(m_debugMessages);
}
private:
bool saveExtractedByteArray(libzippp::ZipEntry& entry, std::string& absolutePathAndName);
private:
QNetworkAccessManager* m_networkAccessManager { nullptr };
bool m_ffmpegAvailable { false };
AquireFFMPEGStatus m_aquireFFMPEGStatus { AquireFFMPEGStatus::Init };
QString m_debugMessages {};
};

View File

@ -19,7 +19,7 @@ set(headers
inc/screenplay-sdk_plugin.h
inc/screenplaysdk.h)
add_library(${PROJECT_NAME} ${src} ${headers})
add_library(${PROJECT_NAME} ${src} ${headers})
target_link_libraries(${PROJECT_NAME}
PRIVATE

View File

@ -0,0 +1,66 @@
cmake_minimum_required(VERSION 3.17 )
project(ScreenPlayShader LANGUAGES CXX)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOMOC ON)
find_package(
Qt5
COMPONENTS Quick
Core
REQUIRED)
set(src
screenplayshader_plugin.cpp
shaderlibrary.cpp
)
set(headers
screenplayshader_plugin.h
shaderlibrary.h
)
set(shader shader.qrc)
add_library(${PROJECT_NAME} SHARED ${src} ${headers} ${shader})
target_link_libraries(${PROJECT_NAME}
PRIVATE
Qt5::Core
Qt5::Quick
Qt5::Gui)
target_include_directories(
${PROJECT_NAME}
PUBLIC inc
)
# QML module deployment
set(URI "ScreenPlay/Shader")
string(REPLACE "." "/" TARGETPATH ${URI})
if (NOT DEFINED QT_QMAKE_EXECUTABLE)
get_target_property (QT_QMAKE_EXECUTABLE Qt5::qmake IMPORTED_LOCATION)
if (NOT QT_QMAKE_EXECUTABLE)
message(FATAL_ERROR "Cannot find qmake")
endif()
endif()
execute_process(COMMAND ${QT_QMAKE_EXECUTABLE} -query QT_INSTALL_QML OUTPUT_VARIABLE QT_INSTALL_QML_RAW)
string(STRIP ${QT_INSTALL_QML_RAW} QT_INSTALL_QML)
set(DESTDIR "${QT_INSTALL_QML}/${TARGETPATH}")
message("DESTDIR ${DESTDIR}")
file(MAKE_DIRECTORY ${DESTDIR})
configure_file(qmldir ${DESTDIR} COPYONLY)
# Copies ScreenPlayShader.* into qt qml plugins folder
add_custom_command(
TARGET ${PROJECT_NAME}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:ScreenPlayShader>
${DESTDIR}/$<TARGET_FILE_NAME:ScreenPlayShader>)

View File

@ -0,0 +1,164 @@
import QtQuick 2.12
import QtQuick.Controls 2.12
ShaderEffect {
id: root
// based on shadertoy default variables
readonly property vector3d iResolution: defaultResolution
readonly property vector3d defaultResolution: Qt.vector3d(
root.width, root.height,
root.width / root.height)
property real iTime: 0
property real iTimeDelta: 100
property int iFrame: 10
property real iFrameRate
property vector4d iMouse
//only Image or ShaderEffectSource
property var iChannel0: ich0
property var iChannel1: ich1
property var iChannel2: ich2
property var iChannel3: ich3
property var iChannelTime: [0, 1, 2, 3]
property var iChannelResolution: [calcResolution(iChannel0), calcResolution(
iChannel1), calcResolution(iChannel2), calcResolution(iChannel3)]
property vector4d iDate
property real iSampleRate: 44100
property bool hoverEnabled: false
property bool running: true
function restart() {
root.iTime = 0
running = true
timer1.restart()
}
function calcResolution(channel) {
if (channel) {
return Qt.vector3d(channel.width, channel.height,
channel.width / channel.height)
} else {
return defaultResolution
}
}
Image {
id: ich0
visible: false
}
Image {
id: ich1
visible: false
}
Image {
id: ich2
visible: false
}
Image {
id: ich3
visible: false
}
Timer {
id: timer1
running: root.running
triggeredOnStart: true
interval: 16
repeat: true
onTriggered: {
root.iTime += 0.016
}
}
Timer {
running: root.running
interval: 1000
property date currentDate: new Date()
onTriggered: {
currentDate = new Date()
root.iDate.x = currentDate.getFullYear()
root.iDate.y = currentDate.getMonth()
root.iDate.z = currentDate.getDay()
root.iDate.w = currentDate.getSeconds()
}
}
readonly property string gles2Ver: "
#define texture texture2D
precision mediump float;"
readonly property string gles3Ver: "#version 300 es
#define varying in
#define gl_FragColor fragColor
precision mediump float;
out vec4 fragColor;"
readonly property string gl3Ver: "
#version 150
#define varying in
#define gl_FragColor fragColor
#define lowp
#define mediump
#define highp
out vec4 fragColor;"
readonly property string gl3Ver_igpu: "
#version 130
#define varying in
#define gl_FragColor fragColor
#define lowp
#define mediump
#define highp
out vec4 fragColor;"
readonly property string gl2Ver: "
#version 110
#define texture texture2D"
property string versionString: (GraphicsInfo.majorVersion === 3
|| GraphicsInfo.majorVersion === 4) ? gl3Ver : gl2Ver
vertexShader: "
uniform mat4 qt_Matrix;
attribute vec4 qt_Vertex;
attribute vec2 qt_MultiTexCoord0;
varying vec2 qt_TexCoord0;
varying vec4 vertex;
void main() {
vertex = qt_Vertex;
gl_Position = qt_Matrix * vertex;
qt_TexCoord0 = qt_MultiTexCoord0;
}"
readonly property string forwardString: versionString + "
varying vec2 qt_TexCoord0;
varying vec4 vertex;
uniform lowp float qt_Opacity;
uniform vec3 iResolution;
uniform float iTime;
uniform float iTimeDelta;
uniform int iFrame;
uniform float iFrameRate;
uniform float iChannelTime[4];
uniform vec3 iChannelResolution[4];
uniform vec4 iMouse;
uniform vec4 iDate;
uniform float iSampleRate;
uniform sampler2D iChannel0;
uniform sampler2D iChannel1;
uniform sampler2D iChannel2;
uniform sampler2D iChannel3;"
readonly property string startCode: "
void main(void)
{
mainImage(gl_FragColor, vec2(vertex.x, iResolution.y - vertex.y));
}"
property bool runShader: true
property string pixelShader
onPixelShaderChanged: root.fragmentShader = forwardString + pixelShader + startCode
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 761 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -0,0 +1,84 @@
#ifdef GL_ES
precision mediump float;
#endif
uniform float time;
uniform vec2 resolution;
float hash( float n ) { return fract(sin(n)*753.5453123); }
// Slight modification of iq's noise function.
float noise( in vec2 x )
{
vec2 p = floor(x);
vec2 f = fract(x);
f = f*f*(3.0-2.0*f);
float n = p.x + p.y*157.0;
return mix(
mix( hash(n+ 0.0), hash(n+ 1.0),f.x),
mix( hash(n+157.0), hash(n+158.0),f.x),
f.y);
}
float fbm(vec2 p, vec3 a)
{
float v = 0.0;
v += noise(p*a.x)*1.20;
v += noise(p*a.y)*1.20;
v += noise(p*a.z)*.125;
return v;
}
vec3 drawLines( vec2 uv, vec3 fbmOffset, vec3 color1, vec3 color2 )
{
float timeVal = time * 0.1;
vec3 finalColor = vec3( 0.0 );
for( int i=0; i < 3; ++i )
{
float indexAsFloat = float(i);
float amp = 40.0 + (indexAsFloat*10.0);
float period = 2.0 + (indexAsFloat+2.0);
float thickness = mix( 0.9, 1.0, noise(uv*10.0) );
float t = abs( 0.9 / (sin(uv.x + fbm( uv + timeVal * period, fbmOffset )) * amp) * thickness );
finalColor += t * color1;
}
for( int i=0; i < 0; ++i )
{
float indexAsFloat = float(i);
float amp = 40.0 + (indexAsFloat*7.0);
float period = 2.0 + (indexAsFloat+8.0);
float thickness = mix( 0.7, 1.0, noise(uv*10.0) );
float t = abs( 0.8 / (sin(uv.x + fbm( uv + timeVal * period, fbmOffset )) * amp) * thickness );
finalColor += t * color2 * 0.6;
}
return finalColor;
}
void main( void )
{
vec2 uv = ( gl_FragCoord.xy / resolution.xy ) * 1.0 - 1.8;
uv.x *= resolution.x/resolution.y;
uv.xy = uv.yx;
vec3 lineColor1 = vec3( 2.3, 0.5, .5 );
vec3 lineColor2 = vec3( 0.3, 0.5, 2.5 );
vec3 finalColor = vec3(0.0);
float t = sin( time ) * 0.5 + 0.5;
float pulse = mix( 0.10, 0.20, t);
finalColor += drawLines( uv, vec3( 1.0, 1.0, 8.0), lineColor2, lineColor2 );
gl_FragColor = vec4( finalColor, 1.0 );
}

View File

@ -0,0 +1,9 @@
uniform highp mat4 qt_Matrix;
attribute highp vec4 qt_Vertex;
attribute highp vec2 qt_MultiTexCoord0;
varying highp vec2 coord;
void main() {
coord = qt_MultiTexCoord0;
gl_Position = qt_Matrix * qt_Vertex;
}

2
ScreenPlayShader/qmldir Normal file
View File

@ -0,0 +1,2 @@
module ScreenPlay.Shader
plugin ScreenPlayShader

View File

@ -0,0 +1,18 @@
#include "screenplayshader_plugin.h"
#include <QQmlEngine>
#include <QUrl>
#include <qqml.h>
QObject* ScreenPlayShaderLibrarySingleton(QQmlEngine* engine, QJSEngine* scriptEngine)
{
Q_UNUSED(scriptEngine)
return new ShaderLibrary();
}
void ScreenPlayShaderPlugin::registerTypes(const char* uri)
{
qmlRegisterType(QUrl("qrc:/ShaderWrapper/ShadertoyShader.qml"), "ScreenPlay.ShadertoyShader", 1,0, "ShadertoyShader");
qmlRegisterSingletonType<ShaderLibrary>(uri, 1, 0, "ShaderLibrary", ScreenPlayShaderLibrarySingleton);
}

View File

@ -0,0 +1,15 @@
#pragma once
#include <QQmlExtensionPlugin>
#include "shaderlibrary.h"
class ScreenPlayShaderPlugin : public QQmlExtensionPlugin {
Q_OBJECT
Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)
public:
void registerTypes(const char* uri) override;
private:
ShaderLibrary m_shaderLibrary;
};

View File

@ -0,0 +1,14 @@
<RCC>
<qresource prefix="/">
<file>lightning.frag</file>
<file>lightning.vert</file>
<file>water.frag</file>
<file>water.vert</file>
<file>assets/Shadertoy_Bayer.png</file>
<file>assets/Shadertoy_Gray_Noise_Medium.png</file>
<file>assets/Shadertoy_Lichen.jpg</file>
</qresource>
<qresource prefix="/ShaderWrapper">
<file>ShadertoyShader.qml</file>
</qresource>
</RCC>

View File

@ -0,0 +1,22 @@
#include "shaderlibrary.h"
ShaderLibrary::ShaderLibrary(QQuickItem* parent)
: QQuickItem(parent)
{
QFile lightningFragFile(":/lightning.frag");
lightningFragFile.open(QIODevice::ReadOnly);
QFile lightningVertFile(":/lightning.vert");
lightningVertFile.open(QIODevice::ReadOnly);
m_lightning = std::make_unique<Shader>(lightningVertFile.readAll(), lightningFragFile.readAll());
QFile waterFragFile(":/water.frag");
waterFragFile.open(QIODevice::ReadOnly);
QFile waterVertFile(":/water.vert");
waterVertFile.open(QIODevice::ReadOnly);
m_water = std::make_unique<Shader>(waterVertFile.readAll(), waterFragFile.readAll());
}
ShaderLibrary::~ShaderLibrary()
{
}

View File

@ -0,0 +1,108 @@
#pragma once
#include <QObject>
#include <QQuickItem>
#include <QString>
#include <memory>
class Shader : public QObject {
Q_OBJECT
Q_PROPERTY(QString vertex READ vertex WRITE setVertex NOTIFY vertexChanged)
Q_PROPERTY(QString fragment READ fragment WRITE setFragment NOTIFY fragmentChanged)
public:
Shader() { }
Shader(const QString& vertex, const QString& fragment)
{
m_vertex = vertex;
m_fragment = fragment;
}
QString vertex() const
{
return m_vertex;
}
QString fragment() const
{
return m_fragment;
}
public slots:
void setVertex(QString vertex)
{
if (m_vertex == vertex)
return;
m_vertex = vertex;
emit vertexChanged(m_vertex);
}
void setFragment(QString fragment)
{
if (m_fragment == fragment)
return;
m_fragment = fragment;
emit fragmentChanged(m_fragment);
}
signals:
void vertexChanged(QString vertex);
void fragmentChanged(QString fragment);
private:
QString m_vertex;
QString m_fragment;
};
class ShaderLibrary : public QQuickItem {
Q_OBJECT
Q_DISABLE_COPY(ShaderLibrary)
Q_PROPERTY(Shader* lightning READ lightning WRITE setLightning NOTIFY lightningChanged)
Q_PROPERTY(Shader* water READ water WRITE setWater NOTIFY waterChanged)
public:
explicit ShaderLibrary(QQuickItem* parent = nullptr);
~ShaderLibrary() override;
Shader* lightning() const
{
return m_lightning.get();
}
Shader* water() const
{
return m_water.get();
}
public slots:
void setLightning(Shader* lightning)
{
if (m_lightning.get() == lightning)
return;
m_lightning.reset(lightning);
emit lightningChanged(m_lightning.get());
}
void setWater(Shader* water)
{
if (m_water.get() == water)
return;
m_water.reset(water);
emit waterChanged(m_water.get());
}
signals:
void lightningChanged(Shader* lightning);
void waterChanged(Shader* water);
private:
std::unique_ptr<Shader> m_lightning;
std::unique_ptr<Shader> m_water;
};

View File

@ -0,0 +1,59 @@
#ifdef GL_ES
precision mediump float;
#endif
uniform sampler2D qt_Texture0;
varying vec4 qt_TexCoord0;
//uniform float reflectionOffset; // allows player to control reflection position
//uniform float reflectionBlur ; // works only if projec's driver is set to GLES3, more information here https://docs.godotengine.org/ru/stable/tutorials/shading/screen-reading_shaders.html
//uniform float calculatedOffset ; // this is controlled by script, it takes into account camera position and water object position, that way reflection stays in the same place when camera is moving
//uniform float calculatedAspect ; // is controlled by script, ensures that noise is not affected by object scale
//uniform sampler2D noiseTexture;
//uniform float offsetStrength;
//uniform float maxOffset;
//uniform vec2 distortionScale;
//uniform vec2 distortionSpeed;
//uniform float waveSmoothing;
//uniform float mainWaveSpeed ;
//uniform float mainWaveFrequency ;
//uniform float mainWaveAmplitude;
//uniform float secondWaveSpeed ;
//uniform float secondWaveFrequency ;
//uniform float secondWaveAmplitude ;
//uniform float thirdWaveSpeed ;
//uniform float thirdWaveFrequency ;
//uniform float thirdWaveAmplitude ;
//uniform float squashing ;
//uniform vec4 shorelineColor; //: hint_color = vec4(1.);
//uniform float shorelineSize; //: hint_range(0., 0.1) = 0.0025;
//uniform float shorelineFoamSize ; // : hint_range(0., 0.1)
//uniform float foamSpeed;
//uniform vec2 foamScale;
uniform float time;
void main(void)
{
vec2 uv = fragCoord.xy / iResolution.xy;
vec4 texture_color = vec4(0.192156862745098, 0.6627450980392157, 0.9333333333333333, 1.0);
vec4 k = vec4(time)*0.8;
k.xy = uv * 7.0;
float val1 = length(0.5-fract(k.xyw*=mat3(vec3(-2.0,-1.0,0.0), vec3(3.0,-1.0,1.0), vec3(1.0,-1.0,-1.0))*0.5));
float val2 = length(0.5-fract(k.xyw*=mat3(vec3(-2.0,-1.0,0.0), vec3(3.0,-1.0,1.0), vec3(1.0,-1.0,-1.0))*0.2));
float val3 = length(0.5-fract(k.xyw*=mat3(vec3(-2.0,-1.0,0.0), vec3(3.0,-1.0,1.0), vec3(1.0,-1.0,-1.0))*0.5));
vec4 color = vec4 ( pow(min(min(val1,val2),val3), 7.0) * 3.0)+texture_color;
gl_FragColor = color;
//gl_FragColor = texture2D(qt_Texture0, qt_TexCoord0.st);
}

View File

@ -0,0 +1,10 @@
attribute vec4 qt_Vertex;
attribute vec4 qt_MultiTexCoord0;
uniform mat4 qt_ModelViewProjectionMatrix;
varying vec4 qt_TexCoord0;
void main(void)
{
gl_Position = qt_ModelViewProjectionMatrix * qt_Vertex;
qt_TexCoord0 = qt_MultiTexCoord0;
}

View File

@ -24,7 +24,7 @@ set(headers screenplaysysinfo_plugin.h
mathhelper.h
storage.h)
add_library(${PROJECT_NAME} ${src} ${headers})
add_library(${PROJECT_NAME} SHARED ${src} ${headers})
target_link_libraries(${PROJECT_NAME}
PRIVATE

View File

@ -1,6 +1,9 @@
import QtQuick 2.14
import QtQml 2.14
import ScreenPlayWallpaper 1.0
import ScreenPlay.Shader 1.0
import "ShaderWrapper" as ShaderWrapper
Rectangle {
id: root
@ -218,4 +221,5 @@ Rectangle {
}
}
}
}

View File

@ -6,7 +6,6 @@
#include <QtWebEngine>
#if defined(Q_OS_WIN)
#include "src/winwindow.h"
#endif

View File

@ -28,8 +28,7 @@ BaseWindow::BaseWindow(QString projectFilePath, const QVector<int> activeScreens
QJsonDocument configJsonDocument;
QJsonParseError parseError;
if (projectFilePath.contains("file:\\\\\\"))
projectFilePath = projectFilePath.remove("file:\\\\\\");
projectFile.setFileName(projectFilePath + "/project.json");
projectFile.open(QIODevice::ReadOnly | QIODevice::Text);
@ -64,7 +63,7 @@ BaseWindow::BaseWindow(QString projectFilePath, const QVector<int> activeScreens
qFatal("No type was specified inside the json object!");
}
setBasePath(projectFilePath);
setBasePath(QUrl::fromUserInput(projectFilePath).toLocalFile());
setFullContentPath("file:///" + projectFilePath + "/" + projectObject.value("file").toString());
auto reloadQMLLambda = [this]() { emit reloadQML(type()); };
@ -166,9 +165,11 @@ QString BaseWindow::loadFromFile(const QString& filename)
{
QFile file;
file.setFileName(basePath() + "/" + filename);
qWarning() << " loadFromFile: " << file.fileName() << file.readAll();
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
return file.readAll();
}
qWarning() << "Could not loadFromFile: " << file.fileName();
return "";
}

View File

@ -4,13 +4,14 @@ cd Common
git clone https://github.com/microsoft/vcpkg.git
cd vcpkg
git pull
git checkout 2bc6cd714
# master 10.09.2020 - 18ab4b72a26284f0df28295ce7bf9b21c96f20f4
git checkout 18ab4b72a26284f0df28295ce7bf9b21c96f20f4
chmod +x bootstrap-vcpkg.sh
./bootstrap-vcpkg.sh
chmod +x vcpkg
if [[ "$OSTYPE" == "darwin"* ]]; then
./vcpkg install zlib libzip libzippp openssl-unix libzip breakpad --triplet x64-osx --recurse
./vcpkg install openssl-unix sentry-native --triplet x64-osx --recurse
else
./vcpkg install zlib libzip libzippp openssl-unix libzip breakpad --triplet x64-linux --recurse
./vcpkg install openssl-unix sentry-native --triplet x64-linux --recurse
fi

View File

@ -4,6 +4,31 @@ cd Common
git clone https://github.com/microsoft/vcpkg.git
cd vcpkg
git pull
git checkout 2bc6cd714
rem master 10.09.2020 - 18ab4b72a26284f0df28295ce7bf9b21c96f20f4
git checkout 18ab4b72a26284f0df28295ce7bf9b21c96f20f4
call bootstrap-vcpkg.bat
vcpkg.exe install zlib libzip libzippp openssl breakpad --triplet x64-windows --recurse
rem Install vcpkg dependencies
vcpkg.exe install openssl sentry-native --triplet x64-windows --recurse
cd ..
cd ..
rem Donwload ffmpeg
curl.exe -L https://www.gyan.dev/ffmpeg/builds/packages/ffmpeg-4.3.1-2020-09-16-full_build.zip --output ffmpeg.zip
rem Extract ffmpeg. Needs Windows 10 build 17063 or higher!
rem We only need the content of the bin folder
rem --strip-components 2 removes folder
tar -xvf ffmpeg.zip --strip-components 2 ffmpeg-4.3.1-full_build/bin
rem Remove not used ffplay
DEL ffplay.exe
rem Move ffmpeg into folder
move /Y ffmpeg.exe Common/ffmpeg
move /Y ffprobe.exe Common/ffmpeg
DEL ffmpeg.zip
pause