1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-10-06 09:17:07 +02:00

Multiple refactoring....

Bump Qt to 6.3 to fix video loop
Remove no longer working shader and add new
WIP: Shader compilation path is wrong for some reason
Add Steamless version content path
Remove cmake-format: sortable from CMakeLists.txt
Add Widnow scale indocator icon to the bottom right
Remove unused doctest and benchmark
Fix tests and installer cmake logic
This commit is contained in:
Elias Steurer 2022-04-04 18:06:43 +02:00
parent 42bdd7682c
commit 77a81451ca
47 changed files with 338 additions and 317 deletions

1
.gitignore vendored
View File

@ -250,3 +250,4 @@ cython_debug/
# option (not recommended) you can uncomment the following to ignore the entire idea folder. # option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/ #.idea/
/aqtinstall.log /aqtinstall.log
/ThirdParty/**

View File

@ -1,7 +1,7 @@
project(CMake) project(CMake)
set(FILES set(FILES
# cmake-format: sortable
CopyRecursive.cmake CopyRecursive.cmake
CreateIFWInstaller.cmake CreateIFWInstaller.cmake
FetchContentThirdParty.cmake FetchContentThirdParty.cmake

View File

@ -7,6 +7,8 @@ project(
HOMEPAGE_URL "https://screen-play.app/" HOMEPAGE_URL "https://screen-play.app/"
LANGUAGES CXX) LANGUAGES CXX)
# This sets cmake to compile all dlls into the main directory # This sets cmake to compile all dlls into the main directory
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
@ -14,8 +16,8 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(SCREENPLAY_IFW_ROOT "") set(SCREENPLAY_IFW_ROOT "")
option(SCREENPLAY_STEAM "For FOSS distribution so we do not bundle proprietary code." ON) option(SCREENPLAY_STEAM "For FOSS distribution so we do not bundle proprietary code." ON)
option(SCREENPLAY_TESTS "Enables UI tests." OFF) option(SCREENPLAY_TESTS "Enables UI tests." ON)
option(SCREENPLAY_CREATE_INSTALLER "Indicates whether an installer via the Qt Installer Framework is created." OFF) option(SCREENPLAY_INSTALLER "Indicates whether an installer via the Qt Installer Framework is created." OFF)
# Gitlab CI has many ENV variables. We use this one to check if the current build happens inside the CI # Gitlab CI has many ENV variables. We use this one to check if the current build happens inside the CI
if(DEFINED ENV{CI_COMMIT_MESSAGE}) if(DEFINED ENV{CI_COMMIT_MESSAGE})
@ -87,13 +89,13 @@ add_subdirectory(ScreenPlayUtil)
add_subdirectory(ScreenPlayWeather) add_subdirectory(ScreenPlayWeather)
add_subdirectory(CMake) add_subdirectory(CMake)
add_subdirectory(Tools) add_subdirectory(Tools)
include(${CMAKE_CURRENT_SOURCE_DIR}/CMake/FetchContentThirdParty.cmake) include(${CMAKE_CURRENT_SOURCE_DIR}/CMake/FetchContentThirdParty.cmake)
# Only add target SteamSDKQtEnums
add_subdirectory(ScreenPlayWorkshop/SteamSDK)
if(${SCREENPLAY_STEAM}) if(${SCREENPLAY_STEAM})
add_subdirectory(ScreenPlayWorkshop) add_subdirectory(ScreenPlayWorkshop)
else()
# Only add target SteamSDKQtEnums
add_subdirectory(ScreenPlayWorkshop/SteamSDK)
endif() endif()
if(WIN32) if(WIN32)
@ -104,7 +106,7 @@ message(STATUS "[DEFINE] SOURCE_DIR = ${CMAKE_CURRENT_SOURCE_DI
message(STATUS "[DEFINE] BUILD_DATE = ${BUILD_DATE}") message(STATUS "[DEFINE] BUILD_DATE = ${BUILD_DATE}")
message(STATUS "[DEFINE] BUILD_TYPE = ${CMAKE_BUILD_TYPE}") message(STATUS "[DEFINE] BUILD_TYPE = ${CMAKE_BUILD_TYPE}")
message(STATUS "[DEFINE] GIT_COMMIT_HASH = ${GIT_COMMIT_HASH}") message(STATUS "[DEFINE] GIT_COMMIT_HASH = ${GIT_COMMIT_HASH}")
message(STATUS "[OPTION] SCREENPLAY_CREATE_INSTALLER = ${SCREENPLAY_CREATE_INSTALLER}") message(STATUS "[OPTION] SCREENPLAY_INSTALLER = ${SCREENPLAY_INSTALLER}")
message(STATUS "[OPTION] SCREENPLAY_STEAM = ${SCREENPLAY_STEAM}") message(STATUS "[OPTION] SCREENPLAY_STEAM = ${SCREENPLAY_STEAM}")
message(STATUS "[OPTION] SCREENPLAY_TESTS = ${SCREENPLAY_TESTS}") message(STATUS "[OPTION] SCREENPLAY_TESTS = ${SCREENPLAY_TESTS}")
message(STATUS "[PROJECT] CMAKE_TOOLCHAIN_FILE = ${CMAKE_TOOLCHAIN_FILE}") message(STATUS "[PROJECT] CMAKE_TOOLCHAIN_FILE = ${CMAKE_TOOLCHAIN_FILE}")

View File

@ -5,7 +5,6 @@ set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOMOC ON)
set(SOURCES set(SOURCES
# cmake-format: sortable
app.cpp app.cpp
src/create.cpp src/create.cpp
src/createimportvideo.cpp src/createimportvideo.cpp
@ -24,7 +23,6 @@ set(SOURCES
src/wizards.cpp) src/wizards.cpp)
set(HEADER set(HEADER
# cmake-format: sortable
app.h app.h
src/create.h src/create.h
src/createimportstates.h src/createimportstates.h
@ -45,7 +43,6 @@ set(HEADER
src/wizards.h) src/wizards.h)
set(QML set(QML
# cmake-format: sortable
main.qml main.qml
qml/Common/CloseIcon.qml qml/Common/CloseIcon.qml
qml/Common/ColorPicker.qml qml/Common/ColorPicker.qml
@ -142,7 +139,6 @@ set(QML
qml/Workshop/WorkshopItem.qml) qml/Workshop/WorkshopItem.qml)
set(TS_FILES set(TS_FILES
# cmake-format: sortable
translations/ScreenPlay_.ts translations/ScreenPlay_.ts
translations/ScreenPlay_de_DE.ts translations/ScreenPlay_de_DE.ts
translations/ScreenPlay_es_ES.ts translations/ScreenPlay_es_ES.ts
@ -160,7 +156,6 @@ set(TS_FILES
# Needed on macos # Needed on macos
find_package(Threads REQUIRED) find_package(Threads REQUIRED)
find_package(OpenSSL REQUIRED) find_package(OpenSSL REQUIRED)
find_package(doctest CONFIG REQUIRED)
# CURL must be included before sentry because sentry needs the module and does not include it itself on macos... # CURL must be included before sentry because sentry needs the module and does not include it itself on macos...
find_package(CURL CONFIG REQUIRED) find_package(CURL CONFIG REQUIRED)
@ -191,7 +186,6 @@ target_link_libraries(
ScreenPlayLib ScreenPlayLib
PUBLIC ScreenPlaySDK PUBLIC ScreenPlaySDK
ScreenPlayUtil ScreenPlayUtil
doctest::doctest
sentry::sentry sentry::sentry
Threads::Threads Threads::Threads
Qt6::Quick Qt6::Quick

View File

@ -130,5 +130,6 @@
<file>qml/Create/WizardsFiles/QMLWidgetMain.qml</file> <file>qml/Create/WizardsFiles/QMLWidgetMain.qml</file>
<file>assets/icons/font-awsome/patreon-brands.svg</file> <file>assets/icons/font-awsome/patreon-brands.svg</file>
<file>assets/images/steam_offline.png</file> <file>assets/images/steam_offline.png</file>
<file>assets/images/scale_window_indicator.png</file>
</qresource> </qresource>
</RCC> </RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -39,9 +39,6 @@
Q_IMPORT_QML_PLUGIN(ScreenPlayQmlPlugin) Q_IMPORT_QML_PLUGIN(ScreenPlayQmlPlugin)
#include <sentry.h> #include <sentry.h>
#define DOCTEST_CONFIG_IMPLEMENT
#define DOCTEST_CONFIG_SUPER_FAST_ASSERTS
#include <doctest/doctest.h>
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
@ -49,17 +46,6 @@ int main(int argc, char* argv[])
QApplication qtGuiApp(argc, argv); QApplication qtGuiApp(argc, argv);
// Unit tests
doctest::Context context;
context.setOption("abort-after", 5); // stop test execution after 5 failed assertions
context.setOption("order-by", "name"); // sort the test cases by their name
context.setOption("no-breaks", true); // don't break in the debugger when assertions fail
context.setOption("no-run", true); // No tests are executed by default
context.applyCommandLine(argc, argv); // Every setOption call after applyCommandLine overrides the command line arguments
const int testResult = context.run();
if (context.shouldExit())
return testResult;
ScreenPlay::App app; ScreenPlay::App app;
if (app.m_isAnotherScreenPlayInstanceRunning) { if (app.m_isAnotherScreenPlayInstanceRunning) {

View File

@ -38,14 +38,16 @@ ApplicationWindow {
} }
if (name === "Installed") { if (name === "Installed") {
stackView.replace("qrc:/ScreenPlayQml/qml/Installed/Installed.qml", { stackView.replace("qrc:/ScreenPlayQml/qml/Installed/Installed.qml",
{
"sidebar": sidebar "sidebar": sidebar
}) })
return return
} }
stackView.replace("qrc:/ScreenPlayQml/qml/" + name + "/" + name + ".qml", { stackView.replace(
"modalSource": content "qrc:/ScreenPlayQml/qml/" + name + "/" + name + ".qml", {
}) "modalSource": content
})
sidebar.state = "inactive" sidebar.state = "inactive"
} }
@ -55,10 +57,11 @@ ApplicationWindow {
visible: false visible: false
width: 1400 width: 1400
height: 788 height: 788
title: "ScreenPlay Alpha - " + ScreenPlay.version() title: "ScreenPlay Alpha - V" + ScreenPlay.version()
minimumHeight: 450 minimumHeight: 450
minimumWidth: 1050 minimumWidth: 1050
property bool enableCustomWindowNavigation: Qt.platform.os === "windows" || Qt.platform.os === "osx" property bool enableCustomWindowNavigation: Qt.platform.os === "windows"
|| Qt.platform.os === "osx"
// Partial workaround for // Partial workaround for
// https://bugreports.qt.io/browse/QTBUG-86047 // https://bugreports.qt.io/browse/QTBUG-86047
@ -74,7 +77,7 @@ ApplicationWindow {
} }
} }
Component.onCompleted: { Component.onCompleted: {
if(root.enableCustomWindowNavigation){ if (root.enableCustomWindowNavigation) {
root.flags = Qt.FramelessWindowHint | Qt.Window root.flags = Qt.FramelessWindowHint | Qt.Window
} }
setTheme(ScreenPlay.settings.theme) setTheme(ScreenPlay.settings.theme)
@ -82,7 +85,7 @@ ApplicationWindow {
"sidebar": sidebar "sidebar": sidebar
}) })
if (!ScreenPlay.settings.silentStart) if (!ScreenPlay.settings.silentStart)
root.show() root.showNormal()
} }
Item { Item {
@ -117,7 +120,7 @@ ApplicationWindow {
id: windowNav id: windowNav
enabled: root.enableCustomWindowNavigation enabled: root.enableCustomWindowNavigation
visible: enabled visible: enabled
z:5 z: 5
modalSource: content modalSource: content
width: parent.width width: parent.width
window: root window: root
@ -126,13 +129,12 @@ ApplicationWindow {
Item { Item {
id: content id: content
anchors { anchors {
top: root.enableCustomWindowNavigation ? windowNav.bottom : parent.top top: root.enableCustomWindowNavigation ? windowNav.bottom : parent.top
right: parent.right right: parent.right
bottom: parent.bottom bottom: parent.bottom
left: parent.left left: parent.left
} }
Connections { Connections {
function onThemeChanged(theme) { function onThemeChanged(theme) {
setTheme(theme) setTheme(theme)
@ -287,15 +289,17 @@ ApplicationWindow {
} }
} }
Rectangle { Item {
width: 15 width: 15
height: width height: width
color: "#555"
anchors { anchors {
right: parent.right right: parent.right
bottom: parent.bottom bottom: parent.bottom
margins: 1 margins: 1
} }
Image {
source: "qrc:/assets/images/scale_window_indicator.png"
}
MouseArea { MouseArea {
id: maResize id: maResize
anchors.fill: parent anchors.fill: parent

View File

@ -6,7 +6,7 @@ import ScreenPlay 1.0
SystemTrayIcon { SystemTrayIcon {
id: root id: root
property var window property Window window
visible: true visible: true
icon.source: "qrc:/assets/icons/app.ico" icon.source: "qrc:/assets/icons/app.ico"
tooltip: qsTr("ScreenPlay - Double click to change you settings.") tooltip: qsTr("ScreenPlay - Double click to change you settings.")

View File

@ -75,7 +75,7 @@ Item {
id: txtHeadline id: txtHeadline
y: 80 y: 80
text: qsTr("Get free Widgets and Wallpaper via the Steam Workshop") text: ScreenPlay.settings.steamVersion ? qsTr("Get free Widgets and Wallpaper via the Steam Workshop") : qsTr("Get content via our forum")
font.family: ScreenPlay.settings.font font.family: ScreenPlay.settings.font
font.capitalization: Font.Capitalize font.capitalization: Font.Capitalize
wrapMode: Text.WordWrap wrapMode: Text.WordWrap

View File

@ -383,7 +383,8 @@ Item {
volume = Math.round(sliderVolume.slider.value * 100) / 100; volume = Math.round(sliderVolume.slider.value * 100) / 100;
const screenFile = ScreenPlay.installedListModel.get(root.contentFolderName).m_file; const screenFile = ScreenPlay.installedListModel.get(root.contentFolderName).m_file;
ScreenPlay.screenPlayManager.createWallpaper(root.type, cbVideoFillMode.currentValue, absoluteStoragePath, previewImage, screenFile, activeMonitors, volume, 1, {}, true); let success =ScreenPlay.screenPlayManager.createWallpaper(root.type, cbVideoFillMode.currentValue, absoluteStoragePath, previewImage, screenFile, activeMonitors, volume, 1, {}, true);
print(success)
} }
if (JSUtil.isWidget(root.type)) if (JSUtil.isWidget(root.type))
ScreenPlay.screenPlayManager.createWidget(type, Qt.point(0, 0), absoluteStoragePath, previewImage, {}, true); ScreenPlay.screenPlayManager.createWidget(type, Qt.point(0, 0), absoluteStoragePath, previewImage, {}, true);

View File

@ -19,7 +19,7 @@ Rectangle {
Text { Text {
id: title id: title
text: qsTr("ScreenPlay Alpha %1 - Open Source Wallpaper And Widgets").arg( text: qsTr("ScreenPlay Alpha V%1 - Open Source Wallpaper And Widgets").arg(
ScreenPlay.version()) ScreenPlay.version())
color: Material.primaryTextColor color: Material.primaryTextColor
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter

View File

@ -1,6 +1,5 @@
#include "screenplaymanager.h" #include "screenplaymanager.h"
#include <QScopeGuard> #include <QScopeGuard>
#include <doctest/doctest.h>
namespace ScreenPlay { namespace ScreenPlay {
@ -171,7 +170,7 @@ bool ScreenPlayManager::createWallpaper(
for (auto& wallpaper : m_screenPlayWallpapers) { for (auto& wallpaper : m_screenPlayWallpapers) {
if (wallpaper->screenNumber().length() == 1) { if (wallpaper->screenNumber().length() == 1) {
if (monitors.at(0) == wallpaper->screenNumber().at(0)) { if (monitors.at(0) == wallpaper->screenNumber().at(0)) {
wallpaper->replace( return wallpaper->replace(
path, path,
previewImage, previewImage,
file, file,
@ -180,8 +179,6 @@ bool ScreenPlayManager::createWallpaper(
type, type,
m_settings->checkWallpaperVisible()); m_settings->checkWallpaperVisible());
m_monitorListModel->setWallpaperMonitor(wallpaper, monitorIndex); m_monitorListModel->setWallpaperMonitor(wallpaper, monitorIndex);
return true;
} }
} }
i++; i++;
@ -721,9 +718,4 @@ bool ScreenPlayManager::loadProfiles()
return true; return true;
} }
TEST_CASE("Loads profiles.json")
{
GlobalVariables globalVariables;
ScreenPlayManager manager;
}
} }

View File

@ -239,7 +239,7 @@ void ScreenPlayWallpaper::setSDKConnection(std::unique_ptr<SDKConnection> connec
/*! /*!
\brief Replaces the current wallpaper with the given one. \brief Replaces the current wallpaper with the given one.
*/ */
void ScreenPlayWallpaper::replace( bool ScreenPlayWallpaper::replace(
const QString& absolutePath, const QString& absolutePath,
const QString& previewImage, const QString& previewImage,
const QString& file, const QString& file,
@ -250,11 +250,11 @@ void ScreenPlayWallpaper::replace(
{ {
if (m_isExiting) if (m_isExiting)
return; return false;
if (!m_connection) { if (!m_connection) {
qWarning() << "Cannot replace for unconnected wallpaper!"; qWarning() << "Cannot replace for unconnected wallpaper!";
return; return false;
} }
m_previewImage = previewImage; m_previewImage = previewImage;
@ -272,8 +272,9 @@ void ScreenPlayWallpaper::replace(
obj.insert("file", file); obj.insert("file", file);
obj.insert("checkWallpaperVisible", checkWallpaperVisible); obj.insert("checkWallpaperVisible", checkWallpaperVisible);
m_connection->sendMessage(QJsonDocument(obj).toJson(QJsonDocument::Compact)); const bool success = m_connection->sendMessage(QJsonDocument(obj).toJson(QJsonDocument::Compact));
emit requestSave(); emit requestSave();
return success;
} }
} }

View File

@ -89,7 +89,7 @@ public:
bool start(); bool start();
void replace( bool replace(
const QString& absolutePath, const QString& absolutePath,
const QString& previewImage, const QString& previewImage,
const QString& file, const QString& file,

View File

@ -40,6 +40,10 @@ Settings::Settings(const std::shared_ptr<GlobalVariables>& globalVariables,
: QObject(parent) : QObject(parent)
, m_globalVariables { globalVariables } , m_globalVariables { globalVariables }
{ {
const QString qtVersion = QString("Qt Version: %1.%2.%3").arg(QT_VERSION_MAJOR).arg(QT_VERSION_MINOR).arg(QT_VERSION_PATCH);
setGitBuildHash(COMPILE_INFO + qtVersion);
setSteamVersion(!(QString(SCREENPLAY_STEAM).compare("OFF", Qt::CaseInsensitive) ? false : true));
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
setDesktopEnvironment(DesktopEnvironment::Windows); setDesktopEnvironment(DesktopEnvironment::Windows);
#endif #endif
@ -99,11 +103,7 @@ Settings::Settings(const std::shared_ptr<GlobalVariables>& globalVariables,
} }
initInstalledPath(); initInstalledPath();
setupWidgetAndWindowPaths(); setupWidgetAndWindowPaths();
const QString qtVersion = QString("Qt Version: %1.%2.%3").arg(QT_VERSION_MAJOR).arg(QT_VERSION_MINOR).arg(QT_VERSION_PATCH);
setGitBuildHash(COMPILE_INFO + qtVersion);
setSteamVersion(!(QString(SCREENPLAY_STEAM).compare("OFF", Qt::CaseInsensitive) ? false : true));
} }
/*! /*!
@ -195,8 +195,19 @@ void Settings::restoreDefault(const QString& appConfigLocation, const QString& s
void Settings::initInstalledPath() void Settings::initInstalledPath()
{ {
// If empty use steam workshop location const QString contentPath = m_qSettings.value("ScreenPlayContentPath").toString();
if (QString(m_qSettings.value("ScreenPlayContentPath").toString()).isEmpty()) {
// Steamless
if (!steamVersion() && contentPath.isEmpty()) {
const QString path = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);
m_qSettings.setValue("ScreenPlayContentPath", QUrl::fromUserInput(path));
m_qSettings.sync();
m_globalVariables->setLocalStoragePath(path);
return;
}
// Steam
if (contentPath.isEmpty()) {
/* /*
* ! We must use this (ugly) method, because to stay FOSS we cannot call the steamAPI here ! * ! We must use this (ugly) method, because to stay FOSS we cannot call the steamAPI here !
@ -233,10 +244,10 @@ void Settings::initInstalledPath()
} else { } else {
qWarning() << "The following path could not be resolved to search for workshop content: " << path; qWarning() << "The following path could not be resolved to search for workshop content: " << path;
} }
return;
} else {
m_globalVariables->setLocalStoragePath(QUrl::fromUserInput(m_qSettings.value("ScreenPlayContentPath").toString()));
} }
m_globalVariables->setLocalStoragePath(QUrl::fromUserInput(contentPath));
} }
/*! /*!

View File

@ -9,10 +9,10 @@ find_package(
COMPONENTS Quick Network Core COMPONENTS Quick Network Core
REQUIRED) REQUIRED)
set(SOURCES # cmake-format: sortable set(SOURCES
src/screenplay-sdk_plugin.cpp src/screenplaysdk.cpp) src/screenplay-sdk_plugin.cpp src/screenplaysdk.cpp)
set(HEADER # cmake-format: sortable set(HEADER
inc/screenplay-sdk_plugin.h inc/screenplaysdk.h) inc/screenplay-sdk_plugin.h inc/screenplaysdk.h)
add_library(${PROJECT_NAME} ${SOURCES} ${HEADER}) add_library(${PROJECT_NAME} ${SOURCES} ${HEADER})

View File

@ -1,3 +1,4 @@
cmake_minimum_required(VERSION 3.16)
project(ScreenPlayShader LANGUAGES CXX) project(ScreenPlayShader LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD 20)
@ -9,60 +10,46 @@ find_package(
COMPONENTS Quick Core ShaderTools COMPONENTS Quick Core ShaderTools
REQUIRED) REQUIRED)
# Because this is a plugin, we need this for testing and development. This can be disabled when using the plugin in your project directly. set(QML
option(tst_ScreenPlayShader "Builds TextProject" ON)
set(QML_RESOURCES
# cmake-format: sortable
shader/lightning.frag
shader/lightning.vert
shader/water.frag
shader/water.vert)
# https://doc.qt.io/qt-6/qtshadertools-build.html
qt6_add_shaders(
${PROJECT_NAME}
"${PROJECT_NAME}Shaders"
PREFIX
"/shader"
FILES
lightning.frag
lightning.vert
water.frag
water.vert)
set(QML # cmake-format: sortable
src/ShadertoyShader.qml src/TestMain.qml) src/ShadertoyShader.qml src/TestMain.qml)
set(QML_PLUGIN_SOURCES # cmake-format: sortable qt_add_library(${PROJECT_NAME} STATIC)
src/shaderlibrary.cpp)
set(QML_PLUGIN_HEADER # cmake-format: sortable
src/shaderlibrary.h)
add_library(${PROJECT_NAME} STATIC)
target_include_directories(${PROJECT_NAME} PUBLIC src/) target_include_directories(${PROJECT_NAME} PUBLIC src/)
qt6_add_shaders(${PROJECT_NAME} "shaders"
BATCHABLE
PRECOMPILE
PREFIX
"/ScreenPlayShader"
FILES
#shader/lightning.frag
#shader/lightning.vert
shaders/wobble.frag
shaders/water.frag
shaders/water.vert)
qt_add_qml_module( # https://doc.qt.io/qt-6/qtshadertools-build.html
${PROJECT_NAME}
URI
${PROJECT_NAME}
OUTPUT_DIRECTORY
${CMAKE_BINARY_DIR}/bin/${PROJECT_NAME}
VERSION
1.0
QML_FILES
${QML}
SOURCES
${QML_PLUGIN_SOURCES}
${QML_PLUGIN_HEADER}
RESOURCES
${QML_RESOURCES})
target_link_libraries(${PROJECT_NAME} PRIVATE Qt6::Core Qt6::Quick Qt6::Gui) target_link_libraries(${PROJECT_NAME} PRIVATE Qt6::Core Qt6::Quick)
if(${tst_ScreenPlayShader}) if(${SCREENPLAY_TESTS})
qt_add_executable(tst_ScreenPlayShader src/TestMain.cpp) qt_add_executable(tst_ScreenPlayShader src/TestMain.cpp)
target_link_libraries(tst_ScreenPlayShader PRIVATE Qt6::Quick ${PROJECT_NAME}plugin)
target_compile_definitions(tst_ScreenPlayShader PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>) qt_add_qml_module(
endif() tst_ScreenPlayShader
URI
ScreenPlayShader
VERSION
1.0
QML_FILES
${QML})
target_link_libraries(tst_ScreenPlayShader PRIVATE
Qt6::Quick
Qt::Core
Qt::Gui
Qt::Qml
Qt::Quick
${PROJECT_NAME})
endif()

View File

@ -1,59 +0,0 @@
#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

@ -1,10 +0,0 @@
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

@ -0,0 +1,12 @@
#version 440
layout(location = 0) in vec2 coord;
layout(location = 0) out vec4 fragColor;
layout(std140, binding = 0) uniform buf {
mat4 qt_Matrix;
float qt_Opacity;
};
layout(binding = 1) uniform sampler2D src;
void main() {
vec4 tex = texture(src, coord);
fragColor = vec4(vec3(dot(tex.rgb, vec3(0.344, 0.5, 0.156))), tex.a) * qt_Opacity;
}

View File

@ -0,0 +1,13 @@
#version 440
layout(location = 0) in vec4 qt_Vertex;
layout(location = 1) in vec2 qt_MultiTexCoord0;
layout(location = 0) out vec2 coord;
layout(std140, binding = 0) uniform buf {
mat4 qt_Matrix;
float qt_Opacity;
};
void main() {
coord = qt_MultiTexCoord0;
gl_Position = qt_Matrix * qt_Vertex;
}

View File

@ -0,0 +1,20 @@
#version 440
layout(location = 0) in vec2 qt_TexCoord0;
layout(location = 0) out vec4 fragColor;
layout(binding = 1) uniform sampler2D source;
layout(std140, binding = 0) uniform buf {
mat4 qt_Matrix;
float qt_Opacity;
float amplitude;
float frequency;
float time;
} ubuf;
void main()
{
vec2 p = sin(ubuf.time + ubuf.frequency * qt_TexCoord0);
fragColor = texture(source, qt_TexCoord0 + ubuf.amplitude * vec2(p.y, -p.x)) * ubuf.qt_Opacity;
}

View File

@ -3,7 +3,6 @@
#include <QVersionNumber> #include <QVersionNumber>
#include <QtQml/qqmlextensionplugin.h> #include <QtQml/qqmlextensionplugin.h>
Q_IMPORT_QML_PLUGIN(ScreenPlayShaderPlugin)
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {

View File

@ -2,7 +2,6 @@ import QtQuick
import QtQuick.Layouts import QtQuick.Layouts
import QtQuick.Controls import QtQuick.Controls
import QtQuick.Controls.Material import QtQuick.Controls.Material
import ScreenPlayShader 1.0
Window { Window {
id: root id: root
@ -11,6 +10,21 @@ Window {
visible: true visible: true
title: qsTr("ScreenPlayShader") title: qsTr("ScreenPlayShader")
Image {
id: img
anchors.centerIn: parent
layer.enabled: true
layer.effect: ShaderEffect {
//property variant source: theSource
property real amplitude: 0.04 * 1
property real frequency: 20
property real time: 0
NumberAnimation on time { loops: Animation.Infinite; from: 0; to: Math.PI * 2; duration: 600 }
fragmentShader: " :/ScreenPlayShader/shaders/wobble.frag.qsb"
}
source: Qt.resolvedUrl(
"file:///C:/Users/Eli/Desktop/jasmin-ne-Z4zOxNBri5I-unsplash.jpg")
}
} }

View File

@ -21,15 +21,15 @@
ShaderLibrary::ShaderLibrary(QQuickItem* parent) ShaderLibrary::ShaderLibrary(QQuickItem* parent)
: QQuickItem(parent) : QQuickItem(parent)
{ {
QFile lightningFragFile("qrc:/ScreenPlaySysInfo/src/lightning.frag"); QFile lightningFragFile(":/shader/lightning.frag");
lightningFragFile.open(QIODevice::ReadOnly); lightningFragFile.open(QIODevice::ReadOnly);
QFile lightningVertFile("qrc:/ScreenPlaySysInfo/src/lightning.vert"); QFile lightningVertFile(":/shader/lightning.vert");
lightningVertFile.open(QIODevice::ReadOnly); lightningVertFile.open(QIODevice::ReadOnly);
m_lightning = std::make_unique<Shader>(lightningVertFile.readAll(), lightningFragFile.readAll()); m_lightning = std::make_unique<Shader>(lightningVertFile.readAll(), lightningFragFile.readAll());
QFile waterFragFile("qrc:/ScreenPlaySysInfo/src/water.frag"); QFile waterFragFile(":/shader/water.frag");
waterFragFile.open(QIODevice::ReadOnly); waterFragFile.open(QIODevice::ReadOnly);
QFile waterVertFile("qrc:/ScreenPlaySysInfo/src/water.vert"); QFile waterVertFile(":/shader/water.vert");
waterVertFile.open(QIODevice::ReadOnly); waterVertFile.open(QIODevice::ReadOnly);
m_water = std::make_unique<Shader>(waterVertFile.readAll(), waterFragFile.readAll()); m_water = std::make_unique<Shader>(waterVertFile.readAll(), waterFragFile.readAll());
} }

View File

@ -14,14 +14,12 @@ find_package(
COMPONENTS Quick Core COMPONENTS Quick Core
REQUIRED) REQUIRED)
# Because this is a plugin, we need this for testing and development. This can be disabled when using the plugin in your project directly.
option(tst_ScreenPlaySysInfo "Builds TextProject" ON)
set(QML # cmake-format: sortable set(QML
src/TestMain.qml) src/TestMain.qml)
set(QML_PLUGIN_SOURCES set(QML_PLUGIN_SOURCES
# cmake-format: sortable
src/cpu.cpp src/cpu.cpp
src/gpu.cpp src/gpu.cpp
src/ipaddress.cpp src/ipaddress.cpp
@ -31,7 +29,7 @@ set(QML_PLUGIN_SOURCES
src/uptime.cpp) src/uptime.cpp)
set(QML_PLUGIN_HEADER set(QML_PLUGIN_HEADER
# cmake-format: sortable
src/cpu.h src/cpu.h
src/gpu.h src/gpu.h
src/ipaddress.h src/ipaddress.h
@ -41,10 +39,13 @@ set(QML_PLUGIN_HEADER
src/sysinfo.h src/sysinfo.h
src/uptime.h) src/uptime.h)
add_library(${PROJECT_NAME} STATIC) qt_add_library(${PROJECT_NAME} STATIC)
target_link_libraries(${PROJECT_NAME} PRIVATE Qt6::Core Qt6::Quick infoware) target_link_libraries(${PROJECT_NAME} PRIVATE Qt6::Core Qt6::Quick infoware)
target_include_directories(${PROJECT_NAME} PUBLIC src/) target_include_directories(${PROJECT_NAME} PUBLIC src/)
if(WIN32)
target_link_libraries(${PROJECT_NAME} PRIVATE ole32.lib winmm.lib)
endif()
qt_add_qml_module( qt_add_qml_module(
${PROJECT_NAME} ${PROJECT_NAME}
@ -60,7 +61,7 @@ qt_add_qml_module(
${QML_PLUGIN_SOURCES} ${QML_PLUGIN_SOURCES}
${QML_PLUGIN_HEADER}) ${QML_PLUGIN_HEADER})
if(${tst_ScreenPlaySysInfo}) if(${SCREENPLAY_TESTS})
qt_add_executable(tst_ScreenPlaySysInfo src/TestMain.cpp) qt_add_executable(tst_ScreenPlaySysInfo src/TestMain.cpp)
target_link_libraries(tst_ScreenPlaySysInfo PRIVATE Qt6::Quick ${PROJECT_NAME}plugin) target_link_libraries(tst_ScreenPlaySysInfo PRIVATE Qt6::Quick ${PROJECT_NAME}plugin)
target_compile_definitions(tst_ScreenPlaySysInfo PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>) target_compile_definitions(tst_ScreenPlaySysInfo PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>)

View File

@ -9,11 +9,11 @@ find_package(
COMPONENTS Core Quick COMPONENTS Core Quick
REQUIRED) REQUIRED)
set(SOURCES # cmake-format: sortable set(SOURCES
inc/public/ScreenPlayUtil/httpfileserver.cpp src/contenttypes.cpp src/util.cpp) inc/public/ScreenPlayUtil/httpfileserver.cpp src/contenttypes.cpp src/util.cpp)
set(HEADER set(HEADER
# cmake-format: sortable
inc/public/ScreenPlayUtil/AutoPropertyHelpers.h inc/public/ScreenPlayUtil/AutoPropertyHelpers.h
inc/public/ScreenPlayUtil/ConstRefPropertyHelpers.h inc/public/ScreenPlayUtil/ConstRefPropertyHelpers.h
inc/public/ScreenPlayUtil/contenttypes.h inc/public/ScreenPlayUtil/contenttypes.h
@ -27,7 +27,7 @@ set(HEADER
inc/public/ScreenPlayUtil/SingletonHelper.h inc/public/ScreenPlayUtil/SingletonHelper.h
inc/public/ScreenPlayUtil/util.h) inc/public/ScreenPlayUtil/util.h)
add_library(${PROJECT_NAME} STATIC ${SOURCES} ${HEADER}) qt_add_library(${PROJECT_NAME} STATIC ${SOURCES} ${HEADER})
find_path(CPP_HTTPLIB_INCLUDE_DIRS "httplib.h") find_path(CPP_HTTPLIB_INCLUDE_DIRS "httplib.h")
target_include_directories(${PROJECT_NAME} PUBLIC ${CPP_HTTPLIB_INCLUDE_DIRS}) target_include_directories(${PROJECT_NAME} PUBLIC ${CPP_HTTPLIB_INCLUDE_DIRS})

View File

@ -19,23 +19,23 @@ find_package(
Positioning) Positioning)
if(WIN32) if(WIN32)
set(SOURCES # cmake-format: sortable set(SOURCES
src/windowsdesktopproperties.cpp src/winwindow.cpp) src/windowsdesktopproperties.cpp src/winwindow.cpp)
set(HEADER # cmake-format: sortable set(HEADER
src/windowsdesktopproperties.h src/winwindow.h) src/windowsdesktopproperties.h src/winwindow.h)
elseif(APPLE) elseif(APPLE)
set(SOURCES # cmake-format: sortable set(SOURCES
src/macintegration.cpp src/macwindow.cpp) src/macintegration.cpp src/macwindow.cpp)
set(HEADER set(HEADER
# cmake-format: sortable
src/macbridge.h src/macbridge.h
src/MacBridge.mm src/MacBridge.mm
src/macintegration.h src/macintegration.h
src/macwindow.h) src/macwindow.h)
elseif(UNIX) elseif(UNIX)
set(SOURCES # cmake-format: sortable set(SOURCES
src/linuxwindow.cpp) src/linuxwindow.cpp)
set(HEADER # cmake-format: sortable set(HEADER
src/linuxwindow.h) src/linuxwindow.h)
endif() endif()
@ -43,7 +43,7 @@ set(SOURCES ${SOURCES} main.cpp src/basewindow.cpp)
set(HEADER ${HEADER} src/basewindow.h) set(HEADER ${HEADER} src/basewindow.h)
set(QML set(QML
# cmake-format: sortable
qml/GifWallpaper.qml qml/GifWallpaper.qml
qml/MultimediaView.qml qml/MultimediaView.qml
qml/MultimediaWebView.qml qml/MultimediaWebView.qml
@ -71,7 +71,6 @@ target_link_libraries(
PRIVATE ScreenPlaySDK PRIVATE ScreenPlaySDK
ScreenPlayUtil ScreenPlayUtil
ScreenPlayWeatherplugin ScreenPlayWeatherplugin
ScreenPlaySysInfoplugin
Qt6::Quick Qt6::Quick
Qt6::Gui Qt6::Gui
Qt6::Widgets Qt6::Widgets
@ -81,6 +80,9 @@ target_link_libraries(
Qt6::Multimedia Qt6::Multimedia
Qt6::WebEngineCore Qt6::WebEngineCore
Qt6::WebEngineQuick) Qt6::WebEngineQuick)
if(WIN32)
target_link_libraries(${PROJECT_NAME} PRIVATE ScreenPlaySysInfoplugin)
endif()
if(UNIX AND NOT APPLE) if(UNIX AND NOT APPLE)
include(CopyRecursive) include(CopyRecursive)

View File

@ -11,11 +11,16 @@ Item {
property bool isWindows: Qt.platform.os === "windows" property bool isWindows: Qt.platform.os === "windows"
signal requestFadeIn signal requestFadeIn
property string source: Wallpaper.projectSourceFileAbsolute
onSourceChanged: {
// Qt 6.3 workaround
mediaPlayer.stop()
mediaPlayer.source = Qt.resolvedUrl(root.source)
mediaPlayer.play()
}
MediaPlayer { MediaPlayer {
id: mediaPlayer id: mediaPlayer
source: Wallpaper.projectSourceFileAbsolute
Component.onCompleted: { Component.onCompleted: {
mediaPlayer.play() mediaPlayer.play()
root.requestFadeIn() root.requestFadeIn()

View File

@ -32,7 +32,6 @@ Rectangle {
loader.source = "qrc:/ScreenPlayWallpaper/qml/MultimediaView.qml" loader.source = "qrc:/ScreenPlayWallpaper/qml/MultimediaView.qml"
} }
print(loader.source)
fadeIn() fadeIn()
break break
case InstalledType.HTMLWallpaper: case InstalledType.HTMLWallpaper:
@ -197,7 +196,9 @@ Rectangle {
anchors { anchors {
top: parent.top top: parent.top
topMargin: -3 // To fix the offset from setupWallpaperForOneScreen // To fix the offset from setupWallpaperForOneScreen
// but I'm not sure when it happens
//topMargin: -3
left: parent.left left: parent.left
right: parent.right right: parent.right
} }

View File

@ -205,7 +205,7 @@ void BaseWindow::replaceWallpaper(
if (type.contains("websiteWallpaper", Qt::CaseInsensitive)) { if (type.contains("websiteWallpaper", Qt::CaseInsensitive)) {
setProjectSourceFileAbsolute(file); setProjectSourceFileAbsolute(file);
} else { } else {
setProjectSourceFileAbsolute(QUrl::fromLocalFile(absolutePath + "/" + file)); setProjectSourceFileAbsolute(QUrl::fromUserInput(absolutePath + "/" + file));
} }
if (m_type == ScreenPlay::InstalledType::InstalledType::QMLWallpaper || m_type == ScreenPlay::InstalledType::InstalledType::HTMLWallpaper) if (m_type == ScreenPlay::InstalledType::InstalledType::QMLWallpaper || m_type == ScreenPlay::InstalledType::InstalledType::HTMLWallpaper)

View File

@ -3,25 +3,22 @@ project(
VERSION 0.1 VERSION 0.1
LANGUAGES CXX) LANGUAGES CXX)
set(CMAKE_AUTOMOC ON)
set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_AUTOMOC ON)
find_package( find_package(
Qt6 6.2 Qt6
COMPONENTS Core Quick COMPONENTS Core Quick
REQUIRED) REQUIRED)
# Because this is a plugin, we need this for testing and development. This can be disabled when using the plugin in your project directly. set(QML
option(tst_ScreenPlayWeather "Builds TextProject" ON)
set(QML # cmake-format: sortable
src/TestMain.qml) src/TestMain.qml)
set(QML_PLUGIN_SOURCES # cmake-format: sortable set(QML_PLUGIN_SOURCES
src/screenplayweather.cpp) src/screenplayweather.cpp)
set(QML_PLUGIN_HEADER # cmake-format: sortable set(QML_PLUGIN_HEADER
src/day.h src/screenplayweather.h) src/day.h src/screenplayweather.h)
qt_add_library(${PROJECT_NAME} STATIC) qt_add_library(${PROJECT_NAME} STATIC)
@ -42,7 +39,7 @@ qt_add_qml_module(
${QML_PLUGIN_SOURCES} ${QML_PLUGIN_SOURCES}
${QML_PLUGIN_HEADER}) ${QML_PLUGIN_HEADER})
if(${tst_ScreenPlayWeather}) if(${SCREENPLAY_TESTS})
qt_add_executable(tst_ScreenPlayWeather src/TestMain.cpp) qt_add_executable(tst_ScreenPlayWeather src/TestMain.cpp)
target_link_libraries(tst_ScreenPlayWeather PRIVATE Qt6::Quick ${PROJECT_NAME}plugin) target_link_libraries(tst_ScreenPlayWeather PRIVATE Qt6::Quick ${PROJECT_NAME}plugin)
target_compile_definitions(tst_ScreenPlayWeather PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>) target_compile_definitions(tst_ScreenPlayWeather PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>)

View File

@ -1,6 +1,5 @@
#include <QGuiApplication> #include <QGuiApplication>
#include <QQmlApplicationEngine> #include <QQmlApplicationEngine>
#include <QVersionNumber>
#include <QtQml/qqmlextensionplugin.h> #include <QtQml/qqmlextensionplugin.h>
Q_IMPORT_QML_PLUGIN(ScreenPlayWeatherPlugin) Q_IMPORT_QML_PLUGIN(ScreenPlayWeatherPlugin)

View File

@ -4,13 +4,13 @@ set(CMAKE_CXX_STANDARD 20)
set(CMAKE_AUTORCC ON) set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOMOC ON)
set(SOURCES # cmake-format: sortable set(SOURCES
main.cpp src/widgetwindow.cpp) main.cpp src/widgetwindow.cpp)
set(HEADER # cmake-format: sortable set(HEADER
src/widgetwindow.h) src/widgetwindow.h)
set(QML # cmake-format: sortable set(QML
qml/Test.qml qml/Widget.qml) qml/Test.qml qml/Widget.qml)
find_package( find_package(
@ -49,6 +49,10 @@ target_link_libraries(
Qt6::WebEngineCore Qt6::WebEngineCore
Qt6::WebEngineQuick) Qt6::WebEngineQuick)
if(WIN32)
target_link_libraries(${PROJECT_NAME} PRIVATE ScreenPlaySysInfoplugin)
endif()
qt_add_qml_module( qt_add_qml_module(
${PROJECT_NAME} ${PROJECT_NAME}
URI URI

View File

@ -1,17 +1,23 @@
project(ScreenPlayWorkshop LANGUAGES CXX) project(ScreenPlayWorkshop
VERSION 0.1
LANGUAGES CXX)
add_subdirectory(SteamSDK)
set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOMOC ON)
set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package( find_package(
Qt6 Qt6
COMPONENTS Quick Widgets Gui COMPONENTS Quick Widgets Gui
REQUIRED) REQUIRED)
set(QML
src/TestMain.qml)
set(SOURCES set(SOURCES
# cmake-format: sortable
src/installedlistmodel.cpp src/installedlistmodel.cpp
src/steamaccount.cpp src/steamaccount.cpp
src/steamapiwrapper.cpp src/steamapiwrapper.cpp
@ -22,7 +28,7 @@ set(SOURCES
src/workshop.cpp) src/workshop.cpp)
set(HEADER set(HEADER
# cmake-format: sortable
src/installedlistmodel.h src/installedlistmodel.h
src/steamaccount.h src/steamaccount.h
src/steamapiwrapper.h src/steamapiwrapper.h
@ -51,26 +57,32 @@ elseif(UNIX)
set(STEAM_BIN ${STEAM_LIB}) set(STEAM_BIN ${STEAM_LIB})
endif() endif()
add_library(${PROJECT_NAME} SHARED ${SOURCES} ${HEADER}) qt_add_library(${PROJECT_NAME} STATIC)
# Needed by the automatic generated target missing includes
# https://github.com/qt/qtdeclarative/blob/7a7064e14f094e843e1ee832cc927e86f887621a/src/qml/Qt6QmlMacros.cmake#L2042
target_include_directories(${PROJECT_NAME} PUBLIC src/)
target_link_libraries( target_link_libraries(
${PROJECT_NAME} ${PROJECT_NAME}
PRIVATE Qt6::Core PUBLIC Qt6::Core
Qt6::Quick Qt6::Quick
${STEAM_LIB} ${STEAM_LIB}
ScreenPlayUtil ScreenPlayUtil
SteamSDK) SteamSDK
SteamSDKQtEnums)
qt_add_qml_module( qt_add_qml_module(
${PROJECT_NAME} ${PROJECT_NAME}
OUTPUT_DIRECTORY
${WORKSHOP_PLUGIN_DIR}
URI URI
"Workshop" "Workshop"
OUTPUT_DIRECTORY
${WORKSHOP_PLUGIN_DIR}
VERSION
1.0
QML_FILES
${QML}
SOURCES SOURCES
${SOURCES} ${SOURCES}
${HEADER} ${HEADER})
VERSION
1.0)
if(${SCREENPLAY_STEAM}) if(${SCREENPLAY_STEAM})
if(APPLE) if(APPLE)
@ -88,21 +100,8 @@ if(${SCREENPLAY_STEAM})
endif() endif()
endif() endif()
# Needed by the automatic generated target missing includes #if(${SCREENPLAY_TESTS})
# https://github.com/qt/qtdeclarative/blob/7a7064e14f094e843e1ee832cc927e86f887621a/src/qml/Qt6QmlMacros.cmake#L2042 # qt_add_executable(tst_ScreenPlayWorkshop src/TestMain.cpp)
target_include_directories(${PROJECT_NAME} PUBLIC src/) # target_link_libraries(tst_ScreenPlayWorkshop PRIVATE Qt6::Quick ${PROJECT_NAME}plugin)
# target_compile_definitions(tst_ScreenPlayWorkshop PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>)
target_link_libraries( #endif()
${PROJECT_NAME}
PRIVATE Qt6::Core
Qt6::Quick
${STEAM_LIB}
ScreenPlayUtil
SteamSDK
SteamSDKQtEnums)
if(${tst_ScreenPlayWorkshop})
qt_add_executable(tst_ScreenPlayWorkshop src/TestMain.cpp)
target_link_libraries(tst_ScreenPlayWorkshop PRIVATE Qt6::Quick ${PROJECT_NAME}plugin)
target_compile_definitions(tst_ScreenPlayWorkshop PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>)
endif()

View File

@ -52,13 +52,13 @@ set(HEADER
public/steam/steamuniverse.h) public/steam/steamuniverse.h)
if(${SCREENPLAY_STEAM}) if(${SCREENPLAY_STEAM})
add_library(${PROJECT_NAME} STATIC ${HEADER}) qt_add_library(${PROJECT_NAME} STATIC ${HEADER})
target_include_directories(${PROJECT_NAME} PUBLIC public/) target_include_directories(${PROJECT_NAME} PUBLIC public/)
target_link_libraries(${PROJECT_NAME}) target_link_libraries(${PROJECT_NAME})
endif() endif()
# We allaways need the generated enums as a workaround to register these enums in app.cpp. Registering in the ScreenPlayWorkshop plugin does # We allaways need the generated enums as a workaround to register these enums in app.cpp. Registering in the ScreenPlayWorkshop plugin does
# not work for some reason. # not work for some reason.
add_library(SteamSDKQtEnums STATIC public/steam/steam_qt_enums_generated.h) qt_add_library(SteamSDKQtEnums STATIC public/steam/steam_qt_enums_generated.h)
target_include_directories(SteamSDKQtEnums PUBLIC public/) target_include_directories(SteamSDKQtEnums PUBLIC public/)
target_link_libraries(SteamSDKQtEnums PRIVATE Qt6::Core) target_link_libraries(SteamSDKQtEnums PRIVATE Qt6::Core)

View File

@ -0,0 +1,25 @@
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QtQml/qqmlextensionplugin.h>
Q_IMPORT_QML_PLUGIN(ScreenPlayWorkshopPlugin)
int main(int argc, char* argv[])
{
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
// The first subfolder is the libraryName followed by the regular
// folder strucutre: LibararyName/Subfolder
const QUrl url(u"qrc:/ScreenPlayWorkshop/src/TestMain.qml"_qs);
QObject::connect(
&engine, &QQmlApplicationEngine::objectCreated,
&app, [url](QObject* obj, const QUrl& objUrl) {
if (!obj && url == objUrl)
QCoreApplication::exit(-1);
},
Qt::QueuedConnection);
engine.load(url);
return app.exec();
}

View File

@ -0,0 +1,14 @@
import QtQuick
import QtQuick.Layouts
import QtQuick.Controls
import QtQuick.Controls.Material
import Workshop 1.0
Window {
id: root
width: 1366
height: 768
visible: true
title: qsTr("ScreenPlayWorkshop")
}

View File

@ -34,7 +34,7 @@ namespace ScreenPlayWorkshop {
class InstalledListModel : public QAbstractListModel { class InstalledListModel : public QAbstractListModel {
Q_OBJECT Q_OBJECT
QML_NAMED_ELEMENT(InstalledListModel) QML_ELEMENT
Q_PROPERTY(QUrl absoluteStoragePath READ absoluteStoragePath WRITE setabsoluteStoragePath NOTIFY absoluteStoragePathChanged) Q_PROPERTY(QUrl absoluteStoragePath READ absoluteStoragePath WRITE setabsoluteStoragePath NOTIFY absoluteStoragePathChanged)
public: public:

View File

@ -16,7 +16,8 @@ namespace ScreenPlayWorkshop {
class SteamAccount : public QObject { class SteamAccount : public QObject {
Q_OBJECT Q_OBJECT
QML_NAMED_ELEMENT(SteamAccount) QML_ELEMENT
Q_PROPERTY(QString username READ username WRITE setUsername NOTIFY usernameChanged) Q_PROPERTY(QString username READ username WRITE setUsername NOTIFY usernameChanged)
Q_PROPERTY(quint32 accountID READ accountID WRITE setAccountID NOTIFY accountIDChanged) Q_PROPERTY(quint32 accountID READ accountID WRITE setAccountID NOTIFY accountIDChanged)
Q_PROPERTY(QImage avatar READ avatar WRITE setAvatar NOTIFY avatarChanged) Q_PROPERTY(QImage avatar READ avatar WRITE setAvatar NOTIFY avatarChanged)

View File

@ -40,8 +40,8 @@ struct SteamItemUpdate {
class SteamWorkshop : public QObject { class SteamWorkshop : public QObject {
Q_OBJECT Q_OBJECT
QML_ELEMENT
QML_NAMED_ELEMENT(SteamWorkshop)
Q_PROPERTY(bool online READ online WRITE setOnline NOTIFY onlineChanged) Q_PROPERTY(bool online READ online WRITE setOnline NOTIFY onlineChanged)
Q_PROPERTY(unsigned long long itemProcessed READ itemProcessed WRITE setItemProcessed NOTIFY itemProcessedChanged) Q_PROPERTY(unsigned long long itemProcessed READ itemProcessed WRITE setItemProcessed NOTIFY itemProcessedChanged)
Q_PROPERTY(unsigned long long bytesTotal READ bytesTotal WRITE setBytesTotal NOTIFY bytesTotalChanged) Q_PROPERTY(unsigned long long bytesTotal READ bytesTotal WRITE setBytesTotal NOTIFY bytesTotalChanged)

View File

@ -2,7 +2,7 @@ project(Tools LANGUAGES CXX)
file(GLOB PYTHON *.py) file(GLOB PYTHON *.py)
set(FILES # cmake-format: sortable set(FILES
Installer/installscript.qs Installer/package.xml) Installer/installscript.qs Installer/package.xml)
add_custom_target( add_custom_target(

View File

@ -8,39 +8,25 @@ import time
from pathlib import Path from pathlib import Path
from concurrent.futures import ThreadPoolExecutor from concurrent.futures import ThreadPoolExecutor
qt_version = "6.2.3"
steam_build = "OFF"
build_tests = "OFF"
create_installer = "OFF"
qt_path = ""
cmake_target_triplet = ""
cmake_build_type = ""
executable_file_ending = ""
deploy_command = ""
aqt_path = ""
cmake_bin_path = ""
file_endings = [".ninja_deps", ".ninja", ".ninja_log", ".lib", ".a", ".dylib", ".exp",
".manifest", ".cmake", ".cbp", "CMakeCache.txt"]
vcvars = "" # We support 2019 or 2022
# Based on https://gist.github.com/l2m2/0d3146c53c767841c6ba8c4edbeb4c2c # Based on https://gist.github.com/l2m2/0d3146c53c767841c6ba8c4edbeb4c2c
def get_vs_env_dict(): def get_vs_env_dict():
vcvars = "" # We support 2019 or 2022
# Hardcoded VS path # Hardcoded VS path
# check if vcvars64.bat is available # check if vcvars64.bat is available.
msvc_2019_path = "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Auxiliary\\Build\\vcvars64.bat" msvc_2019_path = "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Auxiliary\\Build\\vcvars64.bat"
msvc_2022_path = "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Auxiliary\\Build\\vcvars64.bat" msvc_2022_path = "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Auxiliary\\Build\\vcvars64.bat"
if Path(msvc_2019_path).exists(): if Path(msvc_2019_path).exists():
vcvars = msvc_2019_path vcvars = msvc_2019_path
elif Path(msvc_2022_path).exists(): # Prefer newer MSVC and override if exists
if Path(msvc_2022_path).exists():
vcvars = msvc_2022_path vcvars = msvc_2022_path
else: else:
raise RuntimeError("No Visual Studio installation found, only 2019 and 2022 are supported.") raise RuntimeError("No Visual Studio installation found, only 2019 and 2022 are supported.")
print("Loading MSVC env variables via {vcvars}".format(vcvars=vcvars)) print(f"\n\nLoading MSVC env variables via {vcvars}\n\n")
cmd = [vcvars, '&&', 'set'] cmd = [vcvars, '&&', 'set']
popen = subprocess.Popen( popen = subprocess.Popen(
@ -79,11 +65,11 @@ if __name__ == "__main__":
help="Absolute qt path. If not set the default path is used\Windows: C:\Qt\nLinux & macOS:~/Qt/.") help="Absolute qt path. If not set the default path is used\Windows: C:\Qt\nLinux & macOS:~/Qt/.")
parser.add_argument('-sign', action="store_true", dest="sign_build", parser.add_argument('-sign', action="store_true", dest="sign_build",
help="Enable if you want to sign the apps. This is macOS only for now.") help="Enable if you want to sign the apps. This is macOS only for now.")
parser.add_argument('-steam', action="store_true", dest="steam_build", parser.add_argument('-steam', action="store_true", dest="build_steam",
help="Enable if you want to build the Steam workshop plugin.") help="Enable if you want to build the Steam workshop plugin.")
parser.add_argument('-tests', action="store_true", dest="build_tests", parser.add_argument('-tests', action="store_true", dest="build_tests",
help="Build tests.") help="Build tests.")
parser.add_argument('-installer', action="store_true", dest="create_installer", parser.add_argument('-installer', action="store_true", dest="build_installer",
help="Create a installer.") help="Create a installer.")
args = parser.parse_args() args = parser.parse_args()
@ -92,12 +78,38 @@ if __name__ == "__main__":
exit(1) exit(1)
root_path = Path.cwd() root_path = Path.cwd()
qt_version = "6.3.0"
qt_path = ""
build_steam = "OFF"
build_tests = "OFF"
build_installer = "OFF"
cmake_target_triplet = ""
cmake_build_type = ""
executable_file_ending = ""
deploy_command = ""
aqt_path = ""
cmake_bin_path = ""
remove_files_from_build_folder = [
".ninja_deps",
".ninja",
".ninja_log",
".lib",
".a",
".dylib",
".exp",
".manifest",
".cmake",
".cbp",
"CMakeCache.txt",
"steam_appid.txt" # This file is only needed for testing. It must not be in a release version!
]
if root_path.name == "Tools": if root_path.name == "Tools":
root_path = root_path.parent root_path = root_path.parent
if args.use_aqt: if args.use_aqt:
aqt_path = Path(("{root_path}/../aqt/").format(root_path=root_path)).resolve() aqt_path = Path(f"{root_path}/../aqt/").resolve()
if not Path(aqt_path).exists(): if not Path(aqt_path).exists():
print("aqt path does not exist at %s. Please make sure you have installed aqt." % aqt_path) print("aqt path does not exist at %s. Please make sure you have installed aqt." % aqt_path)
@ -127,40 +139,34 @@ if __name__ == "__main__":
raise NotImplementedError("Unsupported platform, ScreenPlay only supports Windows, macOS and Linux.") raise NotImplementedError("Unsupported platform, ScreenPlay only supports Windows, macOS and Linux.")
# Prepare # Prepare
cmake_toolchain_file = ("'{root_path}/../ScreenPlay-vcpkg/scripts/buildsystems/vcpkg.cmake'").format(root_path=root_path) cmake_toolchain_file = f"'{root_path}/../ScreenPlay-vcpkg/scripts/buildsystems/vcpkg.cmake'"
print("cmake_toolchain_file: %s " % cmake_toolchain_file) print("cmake_toolchain_file: %s " % cmake_toolchain_file)
print("Starting build with type %s. Qt Version: %s. Root path: %s" % (args.build_type, qt_version, root_path)) print("Starting build with type %s. Qt Version: %s. Root path: %s" % (args.build_type, qt_version, root_path))
if args.steam_build: if args.build_steam:
steam_build = "ON" build_steam = "OFF"
if args.build_tests: if args.build_tests:
build_tests = "ON" build_tests = "OFF"
if args.create_installer: if args.build_installer:
create_installer = "ON" build_installer = "OFF"
cmake_configure_command = 'cmake ../ \ cmake_configure_command = f'cmake ../ \
-DCMAKE_PREFIX_PATH={prefix_path} \ -DCMAKE_PREFIX_PATH={qt_path} \
-DCMAKE_BUILD_TYPE={type} \ -DCMAKE_BUILD_TYPE={args.build_type} \
-DVCPKG_TARGET_TRIPLET={triplet} \ -DVCPKG_TARGET_TRIPLET={cmake_target_triplet} \
-DCMAKE_TOOLCHAIN_FILE={toolchain} \ -DCMAKE_TOOLCHAIN_FILE={cmake_toolchain_file} \
-DSCREENPLAY_STEAM={steam} \ -DSCREENPLAY_STEAM={build_steam} \
-DSCREENPLAY_TESTS={tests} \ -DSCREENPLAY_TESTS={build_tests} \
-DSCREENPLAY_CREATE_INSTALLER={installer} \ -DSCREENPLAY_INSTALLER={build_installer} \
-G "CodeBlocks - Ninja" \ -G "CodeBlocks - Ninja" \
-B.'.format( -B.'
prefix_path=qt_path,
type=args.build_type,
triplet=cmake_target_triplet,
toolchain=cmake_toolchain_file,
steam=steam_build,
tests = build_tests,
installer= create_installer)
build_folder = root_path.joinpath(f"build-{cmake_target_triplet}-{args.build_type}") build_folder = root_path.joinpath(f"build-{cmake_target_triplet}-{args.build_type}")
clean_build_dir(build_folder) clean_build_dir(build_folder)
# Build # Build
start_time = time.time() start_time = time.time()
print(cmake_configure_command)
run(cmake_configure_command, cwd=build_folder) run(cmake_configure_command, cwd=build_folder)
run("cmake --build . --target all", cwd=build_folder) run("cmake --build . --target all", cwd=build_folder)
@ -251,20 +257,20 @@ if __name__ == "__main__":
# Some dlls like openssl do no longer get copied automatically. # Some dlls like openssl do no longer get copied automatically.
# Lets just copy all of them into bin. # Lets just copy all of them into bin.
if platform.system() == "Windows": if platform.system() == "Windows":
vcpkg_bin_path = Path(("{root_path}/../ScreenPlay-vcpkg/installed/x64-windows/bin").format(root_path=root_path)).resolve() vcpkg_bin_path = Path(f"{root_path}/../ScreenPlay-vcpkg/installed/x64-windows/bin").resolve()
print(vcpkg_bin_path) print(vcpkg_bin_path)
for file in vcpkg_bin_path.iterdir(): for file in vcpkg_bin_path.iterdir():
if file.suffix == ".dll" and file.is_file(): if file.suffix == ".dll" and file.is_file():
print(file, bin_dir) print(file, bin_dir)
shutil.copy2(file, bin_dir) shutil.copy2(file, bin_dir)
for file_ending in file_endings: for file_ending in remove_files_from_build_folder:
for file in bin_dir.rglob("*" + file_ending): for file in bin_dir.rglob("*" + file_ending):
if file.is_file(): if file.is_file():
print("Remove: %s" % file.resolve()) print("Remove: %s" % file.resolve())
file.unlink() file.unlink()
if args.create_installer: if args.build_installer:
os.chdir(build_folder) os.chdir(build_folder)
print("Running cpack at: ", os.getcwd()) print("Running cpack at: ", os.getcwd())
run("cpack", cwd=build_folder) run("cpack", cwd=build_folder)

View File

@ -13,8 +13,6 @@ vcpkg_packages_list = [
"openssl", "openssl",
"curl", "curl",
"sentry-native", "sentry-native",
"doctest",
"benchmark",
"cpp-httplib" "cpp-httplib"
] ]