mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-11-22 10:42:29 +01:00
Fix godot export by using qcoro
This commit is contained in:
parent
340562d3ca
commit
b92f2298f3
@ -9,6 +9,7 @@ set(CMAKE_AUTOMOC ON)
|
|||||||
include(GenerateCMakeVariableHeader)
|
include(GenerateCMakeVariableHeader)
|
||||||
|
|
||||||
set(SOURCES
|
set(SOURCES
|
||||||
|
|
||||||
# cmake-format: sort
|
# cmake-format: sort
|
||||||
src/app.cpp
|
src/app.cpp
|
||||||
src/create.cpp
|
src/create.cpp
|
||||||
@ -27,6 +28,7 @@ set(SOURCES
|
|||||||
src/wizards.cpp)
|
src/wizards.cpp)
|
||||||
|
|
||||||
set(HEADER
|
set(HEADER
|
||||||
|
|
||||||
# cmake-format: sort
|
# cmake-format: sort
|
||||||
inc/public/ScreenPlay/app.h
|
inc/public/ScreenPlay/app.h
|
||||||
inc/public/ScreenPlay/create.h
|
inc/public/ScreenPlay/create.h
|
||||||
@ -47,6 +49,7 @@ set(HEADER
|
|||||||
inc/public/ScreenPlay/wizards.h)
|
inc/public/ScreenPlay/wizards.h)
|
||||||
|
|
||||||
set(QML
|
set(QML
|
||||||
|
|
||||||
# cmake-format: sort
|
# cmake-format: sort
|
||||||
main.qml
|
main.qml
|
||||||
qml/Community/CommunityNavItem.qml
|
qml/Community/CommunityNavItem.qml
|
||||||
@ -101,6 +104,7 @@ set(QML
|
|||||||
qml/Workshop/WorkshopView.qml)
|
qml/Workshop/WorkshopView.qml)
|
||||||
|
|
||||||
set(TS_FILES
|
set(TS_FILES
|
||||||
|
|
||||||
# cmake-format: sort
|
# cmake-format: sort
|
||||||
translations/ScreenPlay_.ts
|
translations/ScreenPlay_.ts
|
||||||
translations/ScreenPlay_de_DE.ts
|
translations/ScreenPlay_de_DE.ts
|
||||||
@ -117,6 +121,7 @@ set(TS_FILES
|
|||||||
translations/ScreenPlay_zh_CN.ts)
|
translations/ScreenPlay_zh_CN.ts)
|
||||||
|
|
||||||
set(RESOURCES
|
set(RESOURCES
|
||||||
|
|
||||||
# cmake-format: sort
|
# cmake-format: sort
|
||||||
"legal/Font Awesome Free License.txt"
|
"legal/Font Awesome Free License.txt"
|
||||||
"legal/Qt LGPLv3.txt"
|
"legal/Qt LGPLv3.txt"
|
||||||
@ -263,15 +268,15 @@ endif()
|
|||||||
find_package(
|
find_package(
|
||||||
Qt6
|
Qt6
|
||||||
COMPONENTS Core
|
COMPONENTS Core
|
||||||
Quick
|
Quick
|
||||||
QuickControls2
|
QuickControls2
|
||||||
Gui
|
Gui
|
||||||
Widgets
|
Widgets
|
||||||
WebSockets
|
WebSockets
|
||||||
Svg
|
Svg
|
||||||
Xml
|
Xml
|
||||||
LinguistTools
|
LinguistTools
|
||||||
Test)
|
Test)
|
||||||
|
|
||||||
add_library(ScreenPlayApp STATIC)
|
add_library(ScreenPlayApp STATIC)
|
||||||
|
|
||||||
@ -306,32 +311,34 @@ qt_add_qml_module(
|
|||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
ScreenPlayApp
|
ScreenPlayApp
|
||||||
PUBLIC ScreenPlaySDK
|
PUBLIC ScreenPlaySDK
|
||||||
LibArchive::LibArchive
|
LibArchive::LibArchive
|
||||||
ScreenPlayUtil
|
ScreenPlayUtil
|
||||||
ScreenPlayUtilplugin
|
ScreenPlayUtilplugin
|
||||||
QArchive
|
QArchive
|
||||||
Plausibleplugin
|
Plausibleplugin
|
||||||
Threads::Threads
|
Threads::Threads
|
||||||
Qt6::Quick
|
QCoro6::Qml
|
||||||
Qt6::Gui
|
Qt6::Quick
|
||||||
Qt6::Widgets
|
Qt6::Gui
|
||||||
Qt6::Core
|
Qt6::Widgets
|
||||||
Qt6::WebSockets
|
Qt6::Core
|
||||||
Qt6::Svg
|
Qt6::WebSockets
|
||||||
Qt6::QuickControls2
|
Qt6::Svg
|
||||||
Qt6::Xml)
|
Qt6::QuickControls2
|
||||||
|
Qt6::Xml)
|
||||||
|
|
||||||
if(${SCREENPLAY_STEAM})
|
if(${SCREENPLAY_STEAM})
|
||||||
target_link_libraries(ScreenPlayApp PUBLIC ScreenPlayWorkshopplugin ScreenPlayWorkshop)
|
target_link_libraries(ScreenPlayApp PUBLIC ScreenPlayWorkshopplugin ScreenPlayWorkshop)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
qt_add_executable(${PROJECT_NAME} main.cpp)
|
qt_add_executable(${PROJECT_NAME} main.cpp)
|
||||||
target_link_libraries(${PROJECT_NAME} PRIVATE ScreenPlayApp ScreenPlayAppplugin)
|
target_link_libraries(${PROJECT_NAME} PRIVATE ScreenPlayApp ScreenPlayAppplugin QCoro6::Qml)
|
||||||
|
|
||||||
if(${SCREENPLAY_TESTS})
|
if(${SCREENPLAY_TESTS})
|
||||||
add_executable(tst_ScreenPlay tests/tst_main.cpp)
|
add_executable(tst_ScreenPlay tests/tst_main.cpp)
|
||||||
target_link_libraries(tst_ScreenPlay PRIVATE ScreenPlayApp ScreenPlayAppplugin Qt6::Test)
|
target_link_libraries(tst_ScreenPlay PRIVATE ScreenPlayApp ScreenPlayAppplugin Qt6::Test)
|
||||||
generate_cmake_variable_header(tst_ScreenPlay)
|
generate_cmake_variable_header(tst_ScreenPlay)
|
||||||
|
|
||||||
if(${SCREENPLAY_STEAM})
|
if(${SCREENPLAY_STEAM})
|
||||||
target_link_libraries(tst_ScreenPlay PUBLIC ScreenPlayWorkshopplugin ScreenPlayWorkshop)
|
target_link_libraries(tst_ScreenPlay PUBLIC ScreenPlayWorkshopplugin ScreenPlayWorkshop)
|
||||||
endif()
|
endif()
|
||||||
@ -342,8 +349,8 @@ if(${SCREENPLAY_TESTS})
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(WIN32
|
if(WIN32
|
||||||
OR UNIX
|
OR UNIX
|
||||||
AND NOT APPLE)
|
AND NOT APPLE)
|
||||||
include(CopyRecursive)
|
include(CopyRecursive)
|
||||||
set(FONTS_OUT_DIR ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/assets/fonts)
|
set(FONTS_OUT_DIR ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/assets/fonts)
|
||||||
file(MAKE_DIRECTORY ${FONTS_OUT_DIR})
|
file(MAKE_DIRECTORY ${FONTS_OUT_DIR})
|
||||||
@ -366,6 +373,7 @@ if(WIN32)
|
|||||||
|
|
||||||
# Copy ffmpeg. If the ffmpeg files are missing, start the install_dependencies_XXX for your system!
|
# Copy ffmpeg. If the ffmpeg files are missing, start the install_dependencies_XXX for your system!
|
||||||
file(GLOB files "${CMAKE_CURRENT_SOURCE_DIR}/../ThirdParty/ffmpeg/*")
|
file(GLOB files "${CMAKE_CURRENT_SOURCE_DIR}/../ThirdParty/ffmpeg/*")
|
||||||
|
|
||||||
foreach(filename ${files})
|
foreach(filename ${files})
|
||||||
configure_file(${filename} ${CMAKE_BINARY_DIR}/bin/ COPYONLY)
|
configure_file(${filename} ${CMAKE_BINARY_DIR}/bin/ COPYONLY)
|
||||||
endforeach()
|
endforeach()
|
||||||
@ -375,11 +383,9 @@ if(WIN32)
|
|||||||
|
|
||||||
configure_file(${VCPKG_BIN_PATH}/libssl-3-x64.dll ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ COPYONLY)
|
configure_file(${VCPKG_BIN_PATH}/libssl-3-x64.dll ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ COPYONLY)
|
||||||
configure_file(${VCPKG_BIN_PATH}/libcrypto-3-x64.dll ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ COPYONLY)
|
configure_file(${VCPKG_BIN_PATH}/libcrypto-3-x64.dll ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ COPYONLY)
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
|
|
||||||
# Set the path to the icon file
|
# Set the path to the icon file
|
||||||
set(APP_ICON_MACOSX ${CMAKE_CURRENT_SOURCE_DIR}/assets/icons/ScreenPlay.icns)
|
set(APP_ICON_MACOSX ${CMAKE_CURRENT_SOURCE_DIR}/assets/icons/ScreenPlay.icns)
|
||||||
|
|
||||||
@ -391,6 +397,7 @@ if(APPLE)
|
|||||||
|
|
||||||
# Specify the name of the icon file for the bundle
|
# Specify the name of the icon file for the bundle
|
||||||
set(MACOSX_BUNDLE_ICON_FILE ScreenPlay.icns) # Only the file name
|
set(MACOSX_BUNDLE_ICON_FILE ScreenPlay.icns) # Only the file name
|
||||||
|
|
||||||
# Fore some reason this only works with maually copy
|
# Fore some reason this only works with maually copy
|
||||||
configure_file(${APP_ICON_MACOSX} "${RESOURCES_DIR}/ScreenPlay.icns" COPYONLY)
|
configure_file(${APP_ICON_MACOSX} "${RESOURCES_DIR}/ScreenPlay.icns" COPYONLY)
|
||||||
|
|
||||||
@ -398,26 +405,26 @@ if(APPLE)
|
|||||||
set_target_properties(
|
set_target_properties(
|
||||||
${PROJECT_NAME}
|
${PROJECT_NAME}
|
||||||
PROPERTIES OUTPUT_NAME ${PROJECT_NAME}
|
PROPERTIES OUTPUT_NAME ${PROJECT_NAME}
|
||||||
MACOSX_BUNDLE TRUE
|
MACOSX_BUNDLE TRUE
|
||||||
MACOSX_RPATH TRUE
|
MACOSX_RPATH TRUE
|
||||||
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist
|
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist
|
||||||
MACOSX_FRAMEWORK_IDENTIFIER app.screenplay
|
MACOSX_FRAMEWORK_IDENTIFIER app.screenplay
|
||||||
XCODE_ATTRIBUTE_LD_RUNPATH_SEARCH_PATHS "@loader_path/Libraries"
|
XCODE_ATTRIBUTE_LD_RUNPATH_SEARCH_PATHS "@loader_path/Libraries"
|
||||||
RESOURCE "${RESOURCE_FILES};${APP_ICON_MACOSX}" # Include the icon in the resources
|
RESOURCE "${RESOURCE_FILES};${APP_ICON_MACOSX}" # Include the icon in the resources
|
||||||
XCODE_ATTRIBUTE_ENABLE_HARDENED_RUNTIME TRUE
|
XCODE_ATTRIBUTE_ENABLE_HARDENED_RUNTIME TRUE
|
||||||
XCODE_ATTRIBUTE_EXECUTABLE_NAME ${PROJECT_NAME})
|
XCODE_ATTRIBUTE_EXECUTABLE_NAME ${PROJECT_NAME})
|
||||||
|
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
TARGET ${PROJECT_NAME}
|
TARGET ${PROJECT_NAME}
|
||||||
POST_BUILD
|
POST_BUILD
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/../ThirdParty/ffmpeg/ffmpeg
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/../ThirdParty/ffmpeg/ffmpeg
|
||||||
${CMAKE_BINARY_DIR}/bin/ScreenPlay.app/Contents/MacOS/)
|
${CMAKE_BINARY_DIR}/bin/ScreenPlay.app/Contents/MacOS/)
|
||||||
|
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
TARGET ${PROJECT_NAME}
|
TARGET ${PROJECT_NAME}
|
||||||
POST_BUILD
|
POST_BUILD
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/../ThirdParty/ffmpeg/ffprobe
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/../ThirdParty/ffmpeg/ffprobe
|
||||||
${CMAKE_BINARY_DIR}/bin/ScreenPlay.app/Contents/MacOS/)
|
${CMAKE_BINARY_DIR}/bin/ScreenPlay.app/Contents/MacOS/)
|
||||||
|
|
||||||
# fonts
|
# fonts
|
||||||
include(CopyRecursive)
|
include(CopyRecursive)
|
||||||
@ -430,7 +437,6 @@ if(APPLE)
|
|||||||
set(QM_OUT_DIR "${RESOURCES_DIR}/translations")
|
set(QM_OUT_DIR "${RESOURCES_DIR}/translations")
|
||||||
file(MAKE_DIRECTORY ${QM_OUT_DIR})
|
file(MAKE_DIRECTORY ${QM_OUT_DIR})
|
||||||
set_source_files_properties(${TS_FILES} PROPERTIES OUTPUT_LOCATION ${QM_OUT_DIR})
|
set_source_files_properties(${TS_FILES} PROPERTIES OUTPUT_LOCATION ${QM_OUT_DIR})
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Must be called here, because we need to change the OUTPUT_LOCATION for macos
|
# Must be called here, because we need to change the OUTPUT_LOCATION for macos
|
||||||
|
@ -58,7 +58,7 @@ public:
|
|||||||
QString ffmpegOutput() const { return m_ffmpegOutput; }
|
QString ffmpegOutput() const { return m_ffmpegOutput; }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void createWallpaperStateChanged(Import::State state);
|
void createWallpaperStateChanged(ScreenPlay::Import::State state);
|
||||||
void progressChanged(float progress);
|
void progressChanged(float progress);
|
||||||
void abortCreateWallpaper();
|
void abortCreateWallpaper();
|
||||||
void workingDirChanged(QString workingDir);
|
void workingDirChanged(QString workingDir);
|
||||||
|
@ -11,9 +11,7 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
|
|
||||||
#include "ScreenPlay/projectsettingslistmodel.h"
|
|
||||||
#include "ScreenPlay/screenplaywallpaper.h"
|
#include "ScreenPlay/screenplaywallpaper.h"
|
||||||
#include "ScreenPlay/screenplaywidget.h"
|
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
#include <qt_windows.h>
|
#include <qt_windows.h>
|
||||||
|
@ -3,11 +3,13 @@
|
|||||||
#include "ScreenPlay/CMakeVariables.h"
|
#include "ScreenPlay/CMakeVariables.h"
|
||||||
#include "ScreenPlay/app.h"
|
#include "ScreenPlay/app.h"
|
||||||
#include "ScreenPlayUtil/logginghandler.h"
|
#include "ScreenPlayUtil/logginghandler.h"
|
||||||
|
#include "qcorotask.h"
|
||||||
|
#include "qml/qcoroqml.h"
|
||||||
|
#include "qml/qcoroqmltask.h"
|
||||||
#include <QCommandLineParser>
|
#include <QCommandLineParser>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QGuiApplication>
|
#include <QGuiApplication>
|
||||||
#include <QStyleFactory>
|
#include <QStyleFactory>
|
||||||
|
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
#include <sentry.h>
|
#include <sentry.h>
|
||||||
#endif
|
#endif
|
||||||
@ -22,7 +24,7 @@ Q_IMPORT_QML_PLUGIN(PlausiblePlugin)
|
|||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
|
QCoro::Qml::registerTypes();
|
||||||
#if !defined(Q_OS_LINUX)
|
#if !defined(Q_OS_LINUX)
|
||||||
qputenv("QT_MEDIA_BACKEND", "ffmpeg");
|
qputenv("QT_MEDIA_BACKEND", "ffmpeg");
|
||||||
#endif
|
#endif
|
||||||
|
@ -2,6 +2,7 @@ import QtQuick
|
|||||||
import Qt5Compat.GraphicalEffects
|
import Qt5Compat.GraphicalEffects
|
||||||
import QtQuick.Controls
|
import QtQuick.Controls
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
|
import QtQuick.Dialogs
|
||||||
import QtQuick.Controls.Material
|
import QtQuick.Controls.Material
|
||||||
import QtQuick.Controls.Material.impl
|
import QtQuick.Controls.Material.impl
|
||||||
import ScreenPlayApp
|
import ScreenPlayApp
|
||||||
@ -18,71 +19,74 @@ Item {
|
|||||||
|
|
||||||
function indexOfValue(model, value) {
|
function indexOfValue(model, value) {
|
||||||
for (var i = 0; i < model.length; i++) {
|
for (var i = 0; i < model.length; i++) {
|
||||||
let ourValue = model[i].value;
|
let ourValue = model[i].value
|
||||||
if (value === ourValue)
|
if (value === ourValue)
|
||||||
return i;
|
return i
|
||||||
}
|
}
|
||||||
return -1;
|
return -1
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is used for removing wallpaper. We need to clear
|
// This is used for removing wallpaper. We need to clear
|
||||||
// the preview image/gif so we can release the file for deletion.
|
// the preview image/gif so we can release the file for deletion.
|
||||||
function clear() {
|
function clear() {
|
||||||
imagePreview.source = "";
|
imagePreview.source = ""
|
||||||
animatedImagePreview.source = "";
|
animatedImagePreview.source = ""
|
||||||
txtHeadline.text = "";
|
txtHeadline.text = ""
|
||||||
root.state = "inactive";
|
root.state = "inactive"
|
||||||
}
|
}
|
||||||
|
|
||||||
width: 400
|
width: 400
|
||||||
state: "inactive"
|
state: "inactive"
|
||||||
property bool hasPreviewGif: false
|
property bool hasPreviewGif: false
|
||||||
onContentFolderNameChanged: {
|
onContentFolderNameChanged: {
|
||||||
const item = App.installedListModel.get(root.contentFolderName);
|
const item = App.installedListModel.get(root.contentFolderName)
|
||||||
txtHeadline.text = item.m_title;
|
txtHeadline.text = item.m_title
|
||||||
const previewGiFilePath = Qt.resolvedUrl(item.m_absoluteStoragePath + "/" + item.m_previewGIF);
|
const previewGiFilePath = Qt.resolvedUrl(
|
||||||
const previewImageFilePath = Qt.resolvedUrl(item.m_absoluteStoragePath + "/" + item.m_preview);
|
item.m_absoluteStoragePath + "/" + item.m_previewGIF)
|
||||||
root.hasPreviewGif = App.util.fileExists(previewGiFilePath);
|
const previewImageFilePath = Qt.resolvedUrl(
|
||||||
|
item.m_absoluteStoragePath + "/" + item.m_preview)
|
||||||
|
root.hasPreviewGif = App.util.fileExists(previewGiFilePath)
|
||||||
if (hasPreviewGif) {
|
if (hasPreviewGif) {
|
||||||
animatedImagePreview.source = previewGiFilePath;
|
animatedImagePreview.source = previewGiFilePath
|
||||||
animatedImagePreview.playing = true;
|
animatedImagePreview.playing = true
|
||||||
} else {
|
} else {
|
||||||
imagePreview.source = previewImageFilePath;
|
imagePreview.source = previewImageFilePath
|
||||||
}
|
}
|
||||||
if (App.util.isWidget(root.type) || (monitorSelection.activeMonitors.length > 0)) {
|
if (App.util.isWidget(root.type)
|
||||||
btnLaunchContent.enabled = true;
|
|| (monitorSelection.activeMonitors.length > 0)) {
|
||||||
return;
|
btnLaunchContent.enabled = true
|
||||||
|
return
|
||||||
}
|
}
|
||||||
btnLaunchContent.enabled = false;
|
btnLaunchContent.enabled = false
|
||||||
}
|
}
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
function onSetSidebarItem(folderName, type) {
|
function onSetSidebarItem(folderName, type) {
|
||||||
|
|
||||||
// Toggle sidebar if clicked on the same content twice
|
// Toggle sidebar if clicked on the same content twice
|
||||||
if (root.contentFolderName === folderName && root.state !== "inactive") {
|
if (root.contentFolderName === folderName
|
||||||
root.state = "inactive";
|
&& root.state !== "inactive") {
|
||||||
return;
|
root.state = "inactive"
|
||||||
|
return
|
||||||
}
|
}
|
||||||
root.contentFolderName = folderName;
|
root.contentFolderName = folderName
|
||||||
root.type = type;
|
root.type = type
|
||||||
if (App.util.isWallpaper(root.type)) {
|
if (App.util.isWallpaper(root.type)) {
|
||||||
if (type === ContentTypes.InstalledType.VideoWallpaper)
|
if (type === ContentTypes.InstalledType.VideoWallpaper)
|
||||||
root.state = "activeWallpaper";
|
root.state = "activeWallpaper"
|
||||||
else
|
else
|
||||||
root.state = "activeScene";
|
root.state = "activeScene"
|
||||||
btnLaunchContent.text = qsTr("Set Wallpaper");
|
btnLaunchContent.text = qsTr("Set Wallpaper")
|
||||||
} else {
|
} else {
|
||||||
root.state = "activeWidget";
|
root.state = "activeWidget"
|
||||||
btnLaunchContent.text = qsTr("Set Widget");
|
btnLaunchContent.text = qsTr("Set Widget")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
target: App.util
|
target: App.util
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseHoverBlocker {
|
MouseHoverBlocker {}
|
||||||
}
|
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
@ -329,42 +333,80 @@ Item {
|
|||||||
"text": qsTr("Scale-Down")
|
"text": qsTr("Scale-Down")
|
||||||
}]
|
}]
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
cbVideoFillMode.currentIndex = root.indexOfValue(cbVideoFillMode.model, App.settings.videoFillMode);
|
cbVideoFillMode.currentIndex = root.indexOfValue(
|
||||||
|
cbVideoFillMode.model,
|
||||||
|
App.settings.videoFillMode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
MessageDialog {
|
||||||
|
id: errorDialog
|
||||||
|
buttons: MessageDialog.Ok
|
||||||
|
}
|
||||||
|
|
||||||
Button {
|
Button {
|
||||||
id: btnLaunchContent
|
id: btnLaunchContent
|
||||||
objectName: "btnLaunchContent"
|
objectName: "btnLaunchContent"
|
||||||
enabled: App.util.isWidget(root.type) ? true : monitorSelection.isSelected
|
enabled: App.util.isWidget(
|
||||||
Material.background: Material.accent
|
root.type) ? true : monitorSelection.isSelected
|
||||||
Material.foreground: "white"
|
|
||||||
icon.source: "qrc:/qml/ScreenPlayApp/assets/icons/icon_plus.svg"
|
icon.source: "qrc:/qml/ScreenPlayApp/assets/icons/icon_plus.svg"
|
||||||
icon.color: "white"
|
icon.color: "white"
|
||||||
font.pointSize: 12
|
font.pointSize: 12
|
||||||
onClicked: {
|
onClicked: {
|
||||||
const item = App.installedListModel.get(root.contentFolderName);
|
const item = App.installedListModel.get(
|
||||||
const absoluteStoragePath = item.m_absoluteStoragePath;
|
root.contentFolderName)
|
||||||
const previewImage = item.m_preview;
|
const absoluteStoragePath = item.m_absoluteStoragePath
|
||||||
|
const previewImage = item.m_preview
|
||||||
if (App.util.isWallpaper(root.type)) {
|
if (App.util.isWallpaper(root.type)) {
|
||||||
let activeMonitors = monitorSelection.getActiveMonitors();
|
let activeMonitors = monitorSelection.getActiveMonitors(
|
||||||
|
)
|
||||||
// TODO Alert user to choose a monitor
|
// TODO Alert user to choose a monitor
|
||||||
if (activeMonitors.length === 0)
|
if (activeMonitors.length === 0)
|
||||||
return;
|
return
|
||||||
|
|
||||||
// We only have sliderVolume if it is a VideoWallpaper
|
// We only have sliderVolume if it is a VideoWallpaper
|
||||||
let volume = 0;
|
let volume = 0
|
||||||
if (type === ContentTypes.InstalledType.VideoWallpaper)
|
if (type === ContentTypes.InstalledType.VideoWallpaper)
|
||||||
volume = Math.round(sliderVolume.slider.value * 100) / 100;
|
volume = Math.round(
|
||||||
const screenFile = item.m_file;
|
sliderVolume.slider.value * 100) / 100
|
||||||
let success = App.screenPlayManager.createWallpaper(root.type, cbVideoFillMode.currentValue, absoluteStoragePath, previewImage, screenFile, activeMonitors, volume, 1, {}, true);
|
if (type === ContentTypes.InstalledType.GodotWallpaper) {
|
||||||
|
App.util.exportGodotProject(
|
||||||
|
absoluteStoragePath,
|
||||||
|
App.globalVariables.godotEditorExecutablePath).then(
|
||||||
|
result => {
|
||||||
|
if(!result.success){
|
||||||
|
errorDialog.text = ("Error exporting Godot")
|
||||||
|
errorDialog.informativeText = result.messag
|
||||||
|
errorDialog.open()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const screenFile = item.m_file
|
||||||
|
let success = App.screenPlayManager.createWallpaper(
|
||||||
|
root.type,
|
||||||
|
cbVideoFillMode.currentValue,
|
||||||
|
absoluteStoragePath,
|
||||||
|
previewImage, screenFile,
|
||||||
|
activeMonitors, volume,
|
||||||
|
1, {}, true)
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const screenFile = item.m_file
|
||||||
|
let success = App.screenPlayManager.createWallpaper(
|
||||||
|
root.type, cbVideoFillMode.currentValue,
|
||||||
|
absoluteStoragePath, previewImage, screenFile,
|
||||||
|
activeMonitors, volume, 1, {}, true)
|
||||||
}
|
}
|
||||||
if (App.util.isWidget(root.type))
|
if (App.util.isWidget(root.type))
|
||||||
App.screenPlayManager.createWidget(type, Qt.point(0, 0), absoluteStoragePath, previewImage, {}, true);
|
App.screenPlayManager.createWidget(type,
|
||||||
root.state = "inactive";
|
Qt.point(0, 0),
|
||||||
monitorSelection.reset();
|
absoluteStoragePath,
|
||||||
|
previewImage, {},
|
||||||
|
true)
|
||||||
|
root.state = "inactive"
|
||||||
|
monitorSelection.reset()
|
||||||
}
|
}
|
||||||
|
|
||||||
anchors {
|
anchors {
|
||||||
|
@ -6,6 +6,7 @@ set(CMAKE_AUTORCC ON)
|
|||||||
set(CMAKE_AUTOMOC ON)
|
set(CMAKE_AUTOMOC ON)
|
||||||
|
|
||||||
find_package(fmt CONFIG REQUIRED)
|
find_package(fmt CONFIG REQUIRED)
|
||||||
|
|
||||||
# Needed on macos
|
# Needed on macos
|
||||||
find_package(Threads REQUIRED)
|
find_package(Threads REQUIRED)
|
||||||
find_package(LibArchive REQUIRED)
|
find_package(LibArchive REQUIRED)
|
||||||
@ -15,6 +16,7 @@ find_package(
|
|||||||
REQUIRED)
|
REQUIRED)
|
||||||
|
|
||||||
set(QML
|
set(QML
|
||||||
|
|
||||||
# cmake-format: sort
|
# cmake-format: sort
|
||||||
qml/CloseIcon.qml
|
qml/CloseIcon.qml
|
||||||
qml/ColorImage.qml
|
qml/ColorImage.qml
|
||||||
@ -41,6 +43,7 @@ set(QML
|
|||||||
qml/TextField.qml)
|
qml/TextField.qml)
|
||||||
|
|
||||||
set(SOURCES
|
set(SOURCES
|
||||||
|
|
||||||
# cmake-format: sort
|
# cmake-format: sort
|
||||||
src/archive.cpp
|
src/archive.cpp
|
||||||
src/contenttypes.cpp
|
src/contenttypes.cpp
|
||||||
@ -52,6 +55,7 @@ set(SOURCES
|
|||||||
src/util.cpp)
|
src/util.cpp)
|
||||||
|
|
||||||
set(HEADER
|
set(HEADER
|
||||||
|
|
||||||
# cmake-format: sort
|
# cmake-format: sort
|
||||||
inc/public/ScreenPlayUtil/archive.h
|
inc/public/ScreenPlayUtil/archive.h
|
||||||
inc/public/ScreenPlayUtil/contenttypes.h
|
inc/public/ScreenPlayUtil/contenttypes.h
|
||||||
@ -71,7 +75,7 @@ if(APPLE)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(RESOURCES # cmake-format: sort
|
set(RESOURCES # cmake-format: sort
|
||||||
assets/icons/attach_file.svg assets/icons/description.svg assets/icons/folder.svg)
|
assets/icons/attach_file.svg assets/icons/description.svg assets/icons/folder.svg)
|
||||||
|
|
||||||
qt_add_library(
|
qt_add_library(
|
||||||
${PROJECT_NAME}
|
${PROJECT_NAME}
|
||||||
@ -108,12 +112,15 @@ target_include_directories(${PROJECT_NAME}plugin PUBLIC inc/public/ScreenPlayUti
|
|||||||
|
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
${PROJECT_NAME}
|
${PROJECT_NAME}
|
||||||
PUBLIC Qt6::Core
|
PUBLIC
|
||||||
Qt6::Quick
|
Qt6::Core
|
||||||
Qt6::Gui
|
Qt6::Quick
|
||||||
fmt::fmt-header-only
|
Qt6::Gui
|
||||||
LibArchive::LibArchive
|
QCoro6::Core
|
||||||
QArchive)
|
QCoro6::Qml
|
||||||
|
fmt::fmt-header-only
|
||||||
|
LibArchive::LibArchive
|
||||||
|
QArchive)
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
# Used for query windows monitor data
|
# Used for query windows monitor data
|
||||||
|
@ -26,6 +26,9 @@
|
|||||||
#include <optional>
|
#include <optional>
|
||||||
|
|
||||||
#include "ScreenPlayUtil/contenttypes.h"
|
#include "ScreenPlayUtil/contenttypes.h"
|
||||||
|
#include "qcorotask.h"
|
||||||
|
#include "qml/qcoroqml.h"
|
||||||
|
#include "qml/qcoroqmltask.h"
|
||||||
|
|
||||||
namespace ScreenPlay {
|
namespace ScreenPlay {
|
||||||
|
|
||||||
@ -46,6 +49,46 @@ T QStringToEnum(const QString& key, const T defaultValue)
|
|||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class GodotExport : public QObject {
|
||||||
|
Q_OBJECT
|
||||||
|
QML_ELEMENT
|
||||||
|
QML_UNCREATABLE("")
|
||||||
|
Q_CLASSINFO("RegisterEnumClassesUnscoped", "false")
|
||||||
|
public:
|
||||||
|
enum class Result {
|
||||||
|
Failed,
|
||||||
|
Ok,
|
||||||
|
};
|
||||||
|
Q_ENUM(Result)
|
||||||
|
};
|
||||||
|
|
||||||
|
class Result {
|
||||||
|
Q_GADGET
|
||||||
|
Q_PROPERTY(bool success READ success WRITE setSuccess)
|
||||||
|
Q_PROPERTY(QVariant status READ status WRITE setStatus)
|
||||||
|
Q_PROPERTY(QString messag READ messag WRITE setMessag)
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit Result() { }
|
||||||
|
explicit Result(bool success, const QVariant& status = {}, const QString& messag = "")
|
||||||
|
{
|
||||||
|
m_success = success;
|
||||||
|
m_status = status;
|
||||||
|
m_messag = messag;
|
||||||
|
}
|
||||||
|
bool success() const { return m_success; }
|
||||||
|
void setSuccess(bool success) { m_success = success; }
|
||||||
|
QString messag() const { return m_messag; }
|
||||||
|
void setMessag(const QString& messag) { m_messag = messag; }
|
||||||
|
QVariant status() const { return m_status; }
|
||||||
|
void setStatus(const QVariant& status) { m_status = status; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool m_success;
|
||||||
|
QString m_messag;
|
||||||
|
QVariant m_status;
|
||||||
|
};
|
||||||
|
|
||||||
class Util : public QObject {
|
class Util : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
QML_ELEMENT
|
QML_ELEMENT
|
||||||
@ -78,6 +121,7 @@ public:
|
|||||||
QStringList getAvailableFillModes() const;
|
QStringList getAvailableFillModes() const;
|
||||||
// QML callable functions
|
// QML callable functions
|
||||||
Q_INVOKABLE QString toLocal(const QString& url) const;
|
Q_INVOKABLE QString toLocal(const QString& url) const;
|
||||||
|
Q_INVOKABLE QCoro::QmlTask exportGodotProject(const QString& absolutePath, const QString& godotEditorExecutablePath);
|
||||||
|
|
||||||
Q_INVOKABLE bool isWallpaper(const ScreenPlay::ContentTypes::InstalledType type) const;
|
Q_INVOKABLE bool isWallpaper(const ScreenPlay::ContentTypes::InstalledType type) const;
|
||||||
Q_INVOKABLE bool isWidget(const ScreenPlay::ContentTypes::InstalledType type) const;
|
Q_INVOKABLE bool isWidget(const ScreenPlay::ContentTypes::InstalledType type) const;
|
||||||
|
@ -622,4 +622,80 @@ bool Util::copyPreviewThumbnail(QJsonObject& obj, const QString& previewThumbnai
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QCoro::QmlTask Util::exportGodotProject(const QString& absolutePath, const QString& godotEditorExecutablePath)
|
||||||
|
{
|
||||||
|
return QCoro::QmlTask([this, absolutePath, godotEditorExecutablePath]() -> QCoro::Task<Result> {
|
||||||
|
QString projectPath = toLocal(absolutePath);
|
||||||
|
std::optional<QJsonObject> projectOpt = openJsonFileToObject(projectPath + "/project.json");
|
||||||
|
QJsonObject projectJson;
|
||||||
|
if (!projectOpt.has_value()) {
|
||||||
|
co_return Result { false };
|
||||||
|
}
|
||||||
|
projectJson = projectOpt.value();
|
||||||
|
if (!projectJson.contains("version"))
|
||||||
|
co_return Result { false };
|
||||||
|
|
||||||
|
const quint64 version = projectJson.value("version").toInt();
|
||||||
|
const QString packageFileName = QString("project-v%1.zip").arg(version);
|
||||||
|
QFileInfo godotPackageFile(projectPath + "/" + packageFileName);
|
||||||
|
// Skip reexport
|
||||||
|
if (godotPackageFile.exists())
|
||||||
|
co_return Result { true };
|
||||||
|
|
||||||
|
qInfo() << "No suitable version found for Godot package" << packageFileName << " at" << godotPackageFile.absoluteFilePath() << " exporting a new pck as zip.";
|
||||||
|
|
||||||
|
// Prepare the Godot export command
|
||||||
|
const QList<QString>
|
||||||
|
godotCmd
|
||||||
|
= { "--export-pack", "--headless", "Windows Desktop", packageFileName };
|
||||||
|
|
||||||
|
QProcess process;
|
||||||
|
process.setWorkingDirectory(projectPath);
|
||||||
|
process.setProgram(godotEditorExecutablePath);
|
||||||
|
process.setArguments(godotCmd);
|
||||||
|
using namespace QCoro;
|
||||||
|
auto coro_process = qCoro(process);
|
||||||
|
qInfo() << "Start" << process.program() << " " << process.arguments() << process.workingDirectory();
|
||||||
|
co_await coro_process.start();
|
||||||
|
co_await coro_process.waitForFinished();
|
||||||
|
|
||||||
|
// Capture the standard output and error
|
||||||
|
QString stdoutString = process.readAllStandardOutput();
|
||||||
|
QString stderrString = process.readAllStandardError();
|
||||||
|
|
||||||
|
// If you want to print the output to the console:
|
||||||
|
if (!stdoutString.isEmpty())
|
||||||
|
qDebug() << "Output:" << stdoutString;
|
||||||
|
if (!stderrString.isEmpty())
|
||||||
|
qDebug() << "Error:" << stderrString;
|
||||||
|
|
||||||
|
// Check for errors
|
||||||
|
if (process.exitStatus() != QProcess::NormalExit || process.exitCode() != 0) {
|
||||||
|
QString errorMessage = tr("Failed to export Godot project. Error: %1").arg(process.errorString());
|
||||||
|
qCritical() << errorMessage;
|
||||||
|
co_return Result { false, {}, errorMessage };
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if the project.zip file was created
|
||||||
|
QString zipPath = QDir(projectPath).filePath(packageFileName);
|
||||||
|
if (!QFile::exists(zipPath)) {
|
||||||
|
qCritical() << "Expected export file (" << packageFileName << ") was not created.";
|
||||||
|
co_return Result { false };
|
||||||
|
}
|
||||||
|
|
||||||
|
// Optional: Verify if the .zip file is valid
|
||||||
|
// (A complete verification would involve extracting the file and checking its contents,
|
||||||
|
// but for simplicity, we're just checking its size here)
|
||||||
|
QFileInfo zipInfo(zipPath);
|
||||||
|
if (zipInfo.size() <= 0) {
|
||||||
|
qCritical() << "The exported " << packageFileName << " file seems to be invalid.";
|
||||||
|
co_return Result { false };
|
||||||
|
}
|
||||||
|
qInfo() << "exportGodotProject END";
|
||||||
|
co_return Result { true };
|
||||||
|
}());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "moc_util.cpp"
|
||||||
|
16
ThirdParty/CMakeLists.txt
vendored
16
ThirdParty/CMakeLists.txt
vendored
@ -4,6 +4,7 @@ FetchContent_Populate(
|
|||||||
QArchive
|
QArchive
|
||||||
GIT_REPOSITORY https://github.com/antony-jr/QArchive.git
|
GIT_REPOSITORY https://github.com/antony-jr/QArchive.git
|
||||||
GIT_TAG e587f30507c0e6d92f79a2dc1a6aa7ebb1f8e679
|
GIT_TAG e587f30507c0e6d92f79a2dc1a6aa7ebb1f8e679
|
||||||
|
|
||||||
# Workaround because: 1. QtCreator cannot handle QML_ELEMENT stuff when it is in bin folder
|
# Workaround because: 1. QtCreator cannot handle QML_ELEMENT stuff when it is in bin folder
|
||||||
# https://bugreports.qt.io/browse/QTCREATORBUG-27083
|
# https://bugreports.qt.io/browse/QTCREATORBUG-27083
|
||||||
SOURCE_DIR ${THIRD_PARTY_PATH}/QArchive)
|
SOURCE_DIR ${THIRD_PARTY_PATH}/QArchive)
|
||||||
@ -12,21 +13,34 @@ FetchContent_Populate(
|
|||||||
qml-plausible
|
qml-plausible
|
||||||
GIT_REPOSITORY https://gitlab.com/kelteseth/qml-plausible.git
|
GIT_REPOSITORY https://gitlab.com/kelteseth/qml-plausible.git
|
||||||
GIT_TAG 322d8e17cab77b496f0d7fafb19f6dcda4193ed7
|
GIT_TAG 322d8e17cab77b496f0d7fafb19f6dcda4193ed7
|
||||||
|
|
||||||
# Workaround because: 1. QtCreator cannot handle QML_ELEMENT stuff when it is in bin folder
|
# Workaround because: 1. QtCreator cannot handle QML_ELEMENT stuff when it is in bin folder
|
||||||
# https://bugreports.qt.io/browse/QTCREATORBUG-27083
|
# https://bugreports.qt.io/browse/QTCREATORBUG-27083
|
||||||
SOURCE_DIR ${THIRD_PARTY_PATH}/qml-plausible)
|
SOURCE_DIR ${THIRD_PARTY_PATH}/qml-plausible)
|
||||||
|
|
||||||
|
FetchContent_Populate(
|
||||||
|
qcoro
|
||||||
|
GIT_REPOSITORY https://github.com/danvratil/qcoro.git
|
||||||
|
GIT_TAG 12c052e
|
||||||
|
|
||||||
|
# Workaround because: 1. QtCreator cannot handle QML_ELEMENT stuff when it is in bin folder
|
||||||
|
# https://bugreports.qt.io/browse/QTCREATORBUG-27083
|
||||||
|
SOURCE_DIR ${THIRD_PARTY_PATH}/qqcoro)
|
||||||
|
|
||||||
add_subdirectory(qml-plausible)
|
add_subdirectory(qml-plausible)
|
||||||
add_subdirectory(QArchive)
|
add_subdirectory(QArchive)
|
||||||
|
add_subdirectory(qqcoro)
|
||||||
|
|
||||||
|
qcoro_enable_coroutines()
|
||||||
|
|
||||||
if(UNIX AND NOT APPLE)
|
if(UNIX AND NOT APPLE)
|
||||||
FetchContent_Populate(
|
FetchContent_Populate(
|
||||||
qt-layer-shell
|
qt-layer-shell
|
||||||
GIT_REPOSITORY https://github.com/KDE/layer-shell-qt.git
|
GIT_REPOSITORY https://github.com/KDE/layer-shell-qt.git
|
||||||
GIT_TAG 721c0ae334554eb2396a2d4d3358f896b8c77412
|
GIT_TAG 721c0ae334554eb2396a2d4d3358f896b8c77412
|
||||||
|
|
||||||
# Workaround because: 1. QtCreator cannot handle QML_ELEMENT stuff when it is in bin folder
|
# Workaround because: 1. QtCreator cannot handle QML_ELEMENT stuff when it is in bin folder
|
||||||
# https://bugreports.qt.io/browse/QTCREATORBUG-27083
|
# https://bugreports.qt.io/browse/QTCREATORBUG-27083
|
||||||
SOURCE_DIR ${THIRD_PARTY_PATH}/qt-layer-shell)
|
SOURCE_DIR ${THIRD_PARTY_PATH}/qt-layer-shell)
|
||||||
add_subdirectory(qt-layer-shell)
|
add_subdirectory(qt-layer-shell)
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
Loading…
Reference in New Issue
Block a user