From 2852659e5832c2e6d69ca70d7af5dd2254f3e649 Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Fri, 12 Mar 2021 09:19:19 +0100 Subject: [PATCH 01/21] Add macos fixes --- CMakeLists.txt | 44 +++++++++++++++++++++++++++ ScreenPlay/CMakeLists.txt | 35 +++++++++------------ ScreenPlay/src/settings.cpp | 9 ++++-- ScreenPlayWallpaper/CMakeLists.txt | 6 ++-- ScreenPlayWallpaper/src/macwindow.cpp | 8 ++--- ScreenPlayWidget/CMakeLists.txt | 2 +- 6 files changed, 70 insertions(+), 34 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f4b7b03b..b2d8472a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -79,3 +79,47 @@ add_subdirectory(ScreenPlayUtil) if(WIN32) add_subdirectory(ScreenPlaySysInfo) endif() + + +if(APPLE) + + +# To Create a package, one can run "cpack -G DragNDrop CPackConfig.cmake" on Mac OS X +# ~/Qt/Tools/CMake/CMake.app/Contents/bin/cpack +# where CPackConfig.cmake is created by including CPack +# And then there's ways to customize this as well +set(CPACK_BINARY_DRAGNDROP ON) +set(CPACK_PACKAGE_NAME "ScreenPlay") +set(CPACK_PACKAGE_VENDOR "ScreenPlay") + +set(CPACK_GENERATOR "DragNDrop")#;TGZ;productbuild + +set(CPACK_DMG_FORMAT "UDBZ") +set(CPACK_DMG_VOLUME_NAME "${PROJECT_NAME}") +set(CPACK_SYSTEM_NAME "OSX") + +set(EXECUTABLE "${PROJECT_NAME}.app") + + +install(TARGETS ScreenPlay + RUNTIME + DESTINATION bin + COMPONENT applications) + +install(TARGETS ScreenPlayWallpaper + RUNTIME + DESTINATION bin + COMPONENT applications) + +install(TARGETS ScreenPlayWidget + RUNTIME + DESTINATION bin + COMPONENT applications) + + +# This must always be last! +include(CPack) + + + +endif() diff --git a/ScreenPlay/CMakeLists.txt b/ScreenPlay/CMakeLists.txt index a244c79f..8e02d919 100644 --- a/ScreenPlay/CMakeLists.txt +++ b/ScreenPlay/CMakeLists.txt @@ -85,16 +85,29 @@ endif() add_executable(${PROJECT_NAME} ${src} ${headers} ${resources} ${qml}) if(APPLE) - set_target_properties(${PROJECT_NAME} PROPERTIES MACOSX_BUNDLE true) + #set_target_properties(${PROJECT_NAME} PROPERTIES MACOSX_BUNDLE true) endif() if(WIN32) # Icon target_sources(${PROJECT_NAME} PRIVATE ScreenPlay.rc) + target_link_libraries(${PROJECT_NAME} PRIVATE sentry::sentry) # 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) + + # Copy ffmpeg. If the ffmpeg files are missing, start the install_dependencies_XXX for your system! + file(GLOB files "${CMAKE_CURRENT_SOURCE_DIR}/../Common/ffmpeg/*") + foreach(filename ${files}) + configure_file(${filename} ${CMAKE_BINARY_DIR}/bin/ COPYONLY) + endforeach() + + configure_file(${VCPKG_INSTALLED_PATH}/tools/sentry-native/crashpad_handler.exe ${CMAKE_BINARY_DIR}/bin/ COPYONLY) + + file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/bin/assets/fonts) + configure_file(assets/fonts/NotoSansCJKkr-Regular.otf ${CMAKE_BINARY_DIR}/bin/assets/fonts COPYONLY) + endif() target_compile_definitions(${PROJECT_NAME} PRIVATE "GIT_VERSION=${GIT_VERSION}") @@ -113,28 +126,8 @@ target_link_libraries( benchmark::benchmark_main doctest::doctest) -if(WIN32) - target_link_libraries(${PROJECT_NAME} PRIVATE sentry::sentry) -endif() target_include_directories(${PROJECT_NAME} PRIVATE ${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) - file(GLOB files "${CMAKE_CURRENT_SOURCE_DIR}/../Common/ffmpeg/*") - foreach(filename ${files}) - configure_file(${filename} ${CMAKE_BINARY_DIR}/bin/ COPYONLY) - endforeach() - - configure_file(${VCPKG_INSTALLED_PATH}/tools/sentry-native/crashpad_handler.exe ${CMAKE_BINARY_DIR}/bin/ COPYONLY) -elseif(APPLE) - # cmake-format: off - # Auto ffmpeg download missing for osx - #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) - # cmake-format: on -endif() diff --git a/ScreenPlay/src/settings.cpp b/ScreenPlay/src/settings.cpp index 6bd5facb..eabec94d 100644 --- a/ScreenPlay/src/settings.cpp +++ b/ScreenPlay/src/settings.cpp @@ -175,13 +175,16 @@ void Settings::setupWidgetAndWindowPaths() QDir workingDir(QGuiApplication::applicationDirPath()); #if defined(Q_OS_WIN) || defined(Q_OS_LINUX) +#endif m_globalVariables->setWidgetExecutablePath(QUrl(workingDir.path() + "/ScreenPlayWidget" + ScreenPlayUtil::executableEnding())); m_globalVariables->setWallpaperExecutablePath(QUrl(workingDir.path() + "/ScreenPlayWallpaper" + ScreenPlayUtil::executableEnding())); -#endif + #if defined(Q_OS_OSX) - m_globalVariables->setWidgetExecutablePath(QUrl::fromUserInput(workingDir.path() + "ScreenPlayWidget.app/Contents/MacOS/ScreenPlayWidget").toLocalFile()); - m_globalVariables->setWallpaperExecutablePath(QUrl::fromUserInput(workingDir.path() + "ScreenPlayWallpaper.app/Contents/MacOS/ScreenPlayWallpaper").toLocalFile()); + + // MACOS bundle + //m_globalVariables->setWidgetExecutablePath(QUrl::fromUserInput(workingDir.path() + "ScreenPlayWidget.app/Contents/MacOS/ScreenPlayWidget").toLocalFile()); + //m_globalVariables->setWallpaperExecutablePath(QUrl::fromUserInput(workingDir.path() + "ScreenPlayWallpaper.app/Contents/MacOS/ScreenPlayWallpaper").toLocalFile()); #endif } diff --git a/ScreenPlayWallpaper/CMakeLists.txt b/ScreenPlayWallpaper/CMakeLists.txt index b09d11ac..70ce2490 100644 --- a/ScreenPlayWallpaper/CMakeLists.txt +++ b/ScreenPlayWallpaper/CMakeLists.txt @@ -38,11 +38,9 @@ if(WIN32) endif() if(APPLE) - set_target_properties(${PROJECT_NAME} PROPERTIES MACOSX_BUNDLE true) + #set_target_properties(${PROJECT_NAME} PROPERTIES MACOSX_BUNDLE true) + target_link_libraries(${PROJECT_NAME} PRIVATE "-framework Cocoa") endif() target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::Quick Qt5::Gui Qt5::Widgets Qt5::Core Qt5::WebEngine ScreenPlaySDK ScreenPlayUtil) -if(APPLE) - target_link_libraries(${PROJECT_NAME} PRIVATE "-framework Cocoa") -endif() diff --git a/ScreenPlayWallpaper/src/macwindow.cpp b/ScreenPlayWallpaper/src/macwindow.cpp index 909cc52d..6df388d1 100644 --- a/ScreenPlayWallpaper/src/macwindow.cpp +++ b/ScreenPlayWallpaper/src/macwindow.cpp @@ -15,6 +15,7 @@ MacWindow::MacWindow( qFatal("Could not parse volume"); } setVolume(volumeParsed); + setFillMode(fillmode); // Ether for one Screen or for all if ((QApplication::screens().length() == activeScreensList.length()) && (activeScreensList.length() != 1)) { @@ -28,15 +29,12 @@ MacWindow::MacWindow( //setupWallpaperForMultipleScreens(activeScreensList); } + qmlRegisterSingletonInstance("ScreenPlayWallpaper", 1, 0, "Wallpaper", this); + // WARNING: Setting Window flags must be called *here*! Qt::WindowFlags flags = m_window.flags(); m_window.setFlags(flags | Qt::FramelessWindowHint | Qt::Desktop); - m_window.setResizeMode(QQuickView::ResizeMode::SizeRootObjectToView); - m_window.rootContext()->setContextProperty("window", this); - // Instead of setting "renderType: Text.NativeRendering" every time - - // we can set it here once :) m_window.setTextRenderType(QQuickWindow::TextRenderType::NativeTextRendering); m_window.setSource(QUrl("qrc:/Wallpaper.qml")); diff --git a/ScreenPlayWidget/CMakeLists.txt b/ScreenPlayWidget/CMakeLists.txt index 5a12ccf1..08077ef6 100644 --- a/ScreenPlayWidget/CMakeLists.txt +++ b/ScreenPlayWidget/CMakeLists.txt @@ -28,7 +28,7 @@ if(WIN32) endif() if(APPLE) - set_target_properties(${PROJECT_NAME} PROPERTIES MACOSX_BUNDLE true) + #set_target_properties(${PROJECT_NAME} PROPERTIES MACOSX_BUNDLE true) endif() target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::Quick Qt5::Gui Qt5::Widgets Qt5::Core ScreenPlaySDK) From 5dcf6a83fd0ff2736a23f65866b2aea500ac5816 Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Sat, 13 Mar 2021 16:17:56 +0100 Subject: [PATCH 02/21] Add copy step --- CMakeLists.txt | 50 +++++------------------------- ScreenPlay/CMakeLists.txt | 14 +++++++++ ScreenPlay/src/settings.cpp | 10 ------ ScreenPlayShader/CMakeLists.txt | 20 +++++++++--- ScreenPlayWallpaper/CMakeLists.txt | 8 +++++ ScreenPlayWidget/CMakeLists.txt | 8 +++++ 6 files changed, 53 insertions(+), 57 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4c71eac6..ed5483aa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -81,46 +81,12 @@ if(WIN32) add_subdirectory(ScreenPlaySysInfo) endif() +#if(APPLE) +#add_custom_target(CopyDependencies DEPENDS ScreenPlay) +#add_custom_command(TARGET CopyDependencies POST_BUILD +# COMMAND "ScreenPlayWallpaper" -E copy_directory +# "$" +# "${CMAKE_BINARY_DIR}/bin/ScreenPlay.app/Contents/MacOS/$/" +# COMMENT "Copying into ScreenPlay.app bundle") +#endif() -if(APPLE) - - -# To Create a package, one can run "cpack -G DragNDrop CPackConfig.cmake" on Mac OS X -# ~/Qt/Tools/CMake/CMake.app/Contents/bin/cpack -# where CPackConfig.cmake is created by including CPack -# And then there's ways to customize this as well -set(CPACK_BINARY_DRAGNDROP ON) -set(CPACK_PACKAGE_NAME "ScreenPlay") -set(CPACK_PACKAGE_VENDOR "ScreenPlay") - -set(CPACK_GENERATOR "DragNDrop")#;TGZ;productbuild - -set(CPACK_DMG_FORMAT "UDBZ") -set(CPACK_DMG_VOLUME_NAME "${PROJECT_NAME}") -set(CPACK_SYSTEM_NAME "OSX") - -set(EXECUTABLE "${PROJECT_NAME}.app") - - -install(TARGETS ScreenPlay - RUNTIME - DESTINATION bin - COMPONENT applications) - -install(TARGETS ScreenPlayWallpaper - RUNTIME - DESTINATION bin - COMPONENT applications) - -install(TARGETS ScreenPlayWidget - RUNTIME - DESTINATION bin - COMPONENT applications) - - -# This must always be last! -include(CPack) - - - -endif() diff --git a/ScreenPlay/CMakeLists.txt b/ScreenPlay/CMakeLists.txt index f3e97173..b99753d2 100644 --- a/ScreenPlay/CMakeLists.txt +++ b/ScreenPlay/CMakeLists.txt @@ -131,4 +131,18 @@ target_link_libraries( target_include_directories(${PROJECT_NAME} PRIVATE ${QT_TELEMTRY_INCLUDE}) +if(APPLE) + # Creates a ScreenPlay.app + set_target_properties(${PROJECT_NAME} PROPERTIES + OUTPUT_NAME ${PROJECT_NAME} + MACOSX_BUNDLE TRUE + MACOSX_RPATH TRUE + MACOSX_FRAMEWORK_IDENTIFIER screen-play.app + XCODE_ATTRIBUTE_LD_RUNPATH_SEARCH_PATHS "@loader_path/Libraries" + RESOURCE "${RESOURCE_FILES}" + XCODE_ATTRIBUTE_ENABLE_HARDENED_RUNTIME TRUE + XCODE_ATTRIBUTE_EXECUTABLE_NAME ${PROJECT_NAME} + ) + +endif() diff --git a/ScreenPlay/src/settings.cpp b/ScreenPlay/src/settings.cpp index eabec94d..69bd95cf 100644 --- a/ScreenPlay/src/settings.cpp +++ b/ScreenPlay/src/settings.cpp @@ -174,18 +174,8 @@ void Settings::setupWidgetAndWindowPaths() { QDir workingDir(QGuiApplication::applicationDirPath()); -#if defined(Q_OS_WIN) || defined(Q_OS_LINUX) -#endif m_globalVariables->setWidgetExecutablePath(QUrl(workingDir.path() + "/ScreenPlayWidget" + ScreenPlayUtil::executableEnding())); m_globalVariables->setWallpaperExecutablePath(QUrl(workingDir.path() + "/ScreenPlayWallpaper" + ScreenPlayUtil::executableEnding())); - - -#if defined(Q_OS_OSX) - - // MACOS bundle - //m_globalVariables->setWidgetExecutablePath(QUrl::fromUserInput(workingDir.path() + "ScreenPlayWidget.app/Contents/MacOS/ScreenPlayWidget").toLocalFile()); - //m_globalVariables->setWallpaperExecutablePath(QUrl::fromUserInput(workingDir.path() + "ScreenPlayWallpaper.app/Contents/MacOS/ScreenPlayWallpaper").toLocalFile()); -#endif } /*! diff --git a/ScreenPlayShader/CMakeLists.txt b/ScreenPlayShader/CMakeLists.txt index 158d920b..02571e58 100644 --- a/ScreenPlayShader/CMakeLists.txt +++ b/ScreenPlayShader/CMakeLists.txt @@ -40,8 +40,18 @@ 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 $ ${DESTDIR}/$) +if(APPLE) +add_custom_command(TARGET ${PROJECT_NAME} + POST_BUILD + COMMENT "Copying into ScreenPlay.app bundle" + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/bin/$ + ${CMAKE_BINARY_DIR}/bin/ScreenPlay.app/Contents/MacOS/$) +else() + # Copies ScreenPlayShader.* into qt qml plugins folder + add_custom_command( + TARGET ${PROJECT_NAME} + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy + $ + ${DESTDIR}/$) +endif() diff --git a/ScreenPlayWallpaper/CMakeLists.txt b/ScreenPlayWallpaper/CMakeLists.txt index 70ce2490..ffefca00 100644 --- a/ScreenPlayWallpaper/CMakeLists.txt +++ b/ScreenPlayWallpaper/CMakeLists.txt @@ -44,3 +44,11 @@ endif() target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::Quick Qt5::Gui Qt5::Widgets Qt5::Core Qt5::WebEngine ScreenPlaySDK ScreenPlayUtil) + +if(APPLE) +add_custom_command(TARGET ${PROJECT_NAME} + POST_BUILD + COMMENT "Copying into ScreenPlay.app bundle" + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/bin/${PROJECT_NAME} + ${CMAKE_BINARY_DIR}/bin/ScreenPlay.app/Contents/MacOS/${PROJECT_NAME}) +endif() diff --git a/ScreenPlayWidget/CMakeLists.txt b/ScreenPlayWidget/CMakeLists.txt index 08077ef6..fa3ffdfa 100644 --- a/ScreenPlayWidget/CMakeLists.txt +++ b/ScreenPlayWidget/CMakeLists.txt @@ -32,3 +32,11 @@ if(APPLE) endif() target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::Quick Qt5::Gui Qt5::Widgets Qt5::Core ScreenPlaySDK) + +if(APPLE) +add_custom_command(TARGET ${PROJECT_NAME} + POST_BUILD + COMMENT "Copying into ScreenPlay.app bundle" + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/bin/${PROJECT_NAME} + ${CMAKE_BINARY_DIR}/bin/ScreenPlay.app/Contents/MacOS/${PROJECT_NAME}) +endif() From dd3b94c01aa63af2b706e8a223d7d0d39a318f21 Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Thu, 22 Apr 2021 18:27:26 +0200 Subject: [PATCH 03/21] Add explicit svg dependency to display svg icons Also according to stackoverflow a include is needed for some platforms deployqt --- ScreenPlay/CMakeLists.txt | 2 ++ ScreenPlay/app.h | 1 + 2 files changed, 3 insertions(+) diff --git a/ScreenPlay/CMakeLists.txt b/ScreenPlay/CMakeLists.txt index b99753d2..44039a0a 100644 --- a/ScreenPlay/CMakeLists.txt +++ b/ScreenPlay/CMakeLists.txt @@ -10,6 +10,7 @@ find_package( QuickCompiler Widgets Gui + Svg WebEngine LinguistTools WebSockets @@ -121,6 +122,7 @@ target_link_libraries( Qt5::Core Qt5::WebEngine Qt5::WebSockets + Qt5::Svg ScreenPlaySDK ScreenPlayUtil benchmark::benchmark diff --git a/ScreenPlay/app.h b/ScreenPlay/app.h index 33ce1e40..5d7fc855 100644 --- a/ScreenPlay/app.h +++ b/ScreenPlay/app.h @@ -47,6 +47,7 @@ #include #include #include +#include #include "ganalytics.h" #include "src/create.h" From ba13492c7ef070b976a015a5680c366567fef75b Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Thu, 22 Apr 2021 18:27:55 +0200 Subject: [PATCH 04/21] Fix OSX compilation --- ScreenPlayWallpaper/CMakeLists.txt | 2 +- ScreenPlayWallpaper/Wallpaper.qml | 7 ++---- ScreenPlayWallpaper/main.cpp | 34 +++++++++++++-------------- ScreenPlayWallpaper/src/macwindow.cpp | 23 ++++++++++++------ ScreenPlayWallpaper/src/macwindow.h | 14 ++++++----- 5 files changed, 44 insertions(+), 36 deletions(-) diff --git a/ScreenPlayWallpaper/CMakeLists.txt b/ScreenPlayWallpaper/CMakeLists.txt index 6eedbcfd..87f61364 100644 --- a/ScreenPlayWallpaper/CMakeLists.txt +++ b/ScreenPlayWallpaper/CMakeLists.txt @@ -43,7 +43,7 @@ if(APPLE) target_link_libraries(${PROJECT_NAME} PRIVATE "-framework Cocoa") endif() -target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::Quick Qt5::Gui Qt5::Widgets Qt5::Core Qt5::WebEngine shcore.lib ScreenPlaySDK ScreenPlayUtil) +target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::Quick Qt5::Gui Qt5::Widgets Qt5::Core Qt5::WebEngine ScreenPlaySDK ScreenPlayUtil) diff --git a/ScreenPlayWallpaper/Wallpaper.qml b/ScreenPlayWallpaper/Wallpaper.qml index 864ab7f2..b11aacd2 100644 --- a/ScreenPlayWallpaper/Wallpaper.qml +++ b/ScreenPlayWallpaper/Wallpaper.qml @@ -146,6 +146,8 @@ Rectangle { if (Qt.platform.os === "windows") { return Qt.resolvedUrl( "file:///" + Wallpaper.windowsDesktopProperties.wallpaperPath) + } else { + return "" } } @@ -292,11 +294,6 @@ Rectangle { text: "Wallpaper.canFade " + Wallpaper.canFade font.pointSize: 14 } - Text { - text: "imgCover.source " + Qt.resolvedUrl( - "file:///" + Wallpaper.windowsDesktopProperties.wallpaperPath) - font.pointSize: 14 - } Text { text: "imgCover.status " + imgCover.status font.pointSize: 14 diff --git a/ScreenPlayWallpaper/main.cpp b/ScreenPlayWallpaper/main.cpp index 45690b0c..0f8d81fd 100644 --- a/ScreenPlayWallpaper/main.cpp +++ b/ScreenPlayWallpaper/main.cpp @@ -43,7 +43,7 @@ int main(int argc, char* argv[]) LinuxWindow window({ 0 }, "/home/graphicscore/Desktop/wallpapers/MechaGirl", "appid", "1", "fill", false); #endif #if defined(Q_OS_OSX) - MacWindow window({ 0 }, "test", "appid", "1", "fill"); + MacWindow window({ 0 }, "test", "appID=test", "1", "fill", "videoWallpaper", true, true); #endif return app.exec(); @@ -89,26 +89,26 @@ int main(int argc, char* argv[]) #if defined(Q_OS_LINUX) LinuxWindow window( - activeScreensList.value(), - projectPath, - appID, - fillmode, - volume, - checkWallpaperVisible); - QObject::connect(&sdk, &ScreenPlaySDK::sdkDisconnected, &window, &LinuxWindow::destroyThis); - QObject::connect(&sdk, &ScreenPlaySDK::incommingMessage, &window, &LinuxWindow::messageReceived); + activeScreensList.value(), + projectFilePath, + appID, + volume, + fillmode, + type, + checkWallpaperVisible, + debugMode); #endif #if defined(Q_OS_OSX) MacWindow window( - activeScreensList.value(), - projectPath, - appID, - fillmode, - volume, - checkWallpaperVisible); - QObject::connect(&sdk, &ScreenPlaySDK::sdkDisconnected, &window, &MacWindow::destroyThis); - QObject::connect(&sdk, &ScreenPlaySDK::incommingMessage, &window, &MacWindow::messageReceived); + activeScreensList.value(), + projectFilePath, + appID, + volume, + fillmode, + type, + checkWallpaperVisible, + debugMode); #endif return app.exec(); diff --git a/ScreenPlayWallpaper/src/macwindow.cpp b/ScreenPlayWallpaper/src/macwindow.cpp index 6df388d1..7f98762e 100644 --- a/ScreenPlayWallpaper/src/macwindow.cpp +++ b/ScreenPlayWallpaper/src/macwindow.cpp @@ -1,14 +1,23 @@ #include "macwindow.h" MacWindow::MacWindow( - const QVector& activeScreensList, - const QString& projectPath, - const QString& id, - const QString& volume, - const QString& fillmode) - : BaseWindow(projectPath, activeScreensList, false) + const QVector& activeScreensList, + const QString& projectFilePath, + const QString& appID, + const QString& volume, + const QString& fillmode, + const QString& type, + const bool checkWallpaperVisible, + const bool debugMode) + : BaseWindow( + activeScreensList, + projectFilePath, + type, + checkWallpaperVisible, + appID, + debugMode) { - setAppID(id); + setAppID(appID); bool ok = false; float volumeParsed = volume.toFloat(&ok); if (!ok) { diff --git a/ScreenPlayWallpaper/src/macwindow.h b/ScreenPlayWallpaper/src/macwindow.h index ad4ae00d..50ac64a2 100644 --- a/ScreenPlayWallpaper/src/macwindow.h +++ b/ScreenPlayWallpaper/src/macwindow.h @@ -51,12 +51,14 @@ class MacWindow : public BaseWindow { Q_OBJECT public: - explicit MacWindow( - const QVector& activeScreensList, - const QString& projectPath, - const QString& id, - const QString& volume, - const QString& fillmode); + explicit MacWindow( const QVector& activeScreensList, + const QString& projectFilePath, + const QString& appID, + const QString& volume, + const QString& fillmode, + const QString& type, + const bool checkWallpaperVisible, + const bool debugMode); signals: From 9c7a15ee88fbc56701614e64404cf3af5bf7a269 Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Thu, 22 Apr 2021 18:28:18 +0200 Subject: [PATCH 05/21] Fix crash that only occours with clang --- ScreenPlay/src/screenplaywallpaper.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/ScreenPlay/src/screenplaywallpaper.cpp b/ScreenPlay/src/screenplaywallpaper.cpp index 9f1d17c4..3b0673a4 100644 --- a/ScreenPlay/src/screenplaywallpaper.cpp +++ b/ScreenPlay/src/screenplaywallpaper.cpp @@ -16,7 +16,6 @@ namespace ScreenPlay { ScreenPlayWallpaper::~ScreenPlayWallpaper() { qInfo() << "Remove wallpaper " << m_appID; - m_connection->close(); } /*! From 7a428812cd31279cfdf0232f05e9453cb863f245 Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Sun, 9 May 2021 11:24:33 +0200 Subject: [PATCH 06/21] Fix wallpaper position --- ScreenPlayWallpaper/src/macwindow.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/ScreenPlayWallpaper/src/macwindow.cpp b/ScreenPlayWallpaper/src/macwindow.cpp index 7f98762e..4b0ef33a 100644 --- a/ScreenPlayWallpaper/src/macwindow.cpp +++ b/ScreenPlayWallpaper/src/macwindow.cpp @@ -30,12 +30,9 @@ MacWindow::MacWindow( if ((QApplication::screens().length() == activeScreensList.length()) && (activeScreensList.length() != 1)) { //setupWallpaperForAllScreens(); } else if (activeScreensList.length() == 1) { - //setupWallpaperForOneScreen(activeScreensList.at(0)); - auto* screen = QGuiApplication::screens().at(0); - m_window.setWidth(screen->geometry().width()); - m_window.setHeight(screen->geometry().height()); + auto* screen = QGuiApplication::screens().at(activeScreensList.at(0)); + m_window.setGeometry(screen->geometry()); } else if (activeScreensList.length() > 1) { - //setupWallpaperForMultipleScreens(activeScreensList); } qmlRegisterSingletonInstance("ScreenPlayWallpaper", 1, 0, "Wallpaper", this); From 08f078d5260f37dcbc72a26f0d7397bcf833e485 Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Sun, 9 May 2021 11:25:06 +0200 Subject: [PATCH 07/21] Refactor steam plugin loading --- ScreenPlay/app.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/ScreenPlay/app.cpp b/ScreenPlay/app.cpp index b648c9ea..e9aa9ea8 100644 --- a/ScreenPlay/app.cpp +++ b/ScreenPlay/app.cpp @@ -235,32 +235,32 @@ void App::exit() */ bool App::loadSteamPlugin() { + const bool isDebug = true; + +#ifdef QT_NO_DEBUG + isDebug = false; +#endif + #ifdef Q_OS_MACOS -#ifdef QT_NO_DEBUG - const QString fileSuffix = ".dylib"; -#else - const QString fileSuffix = "d.dylib"; -#endif + const QString fileSuffix = isDebug ? "d.dylib" : ".dylib"; + m_workshopPlugin.setFileName(QApplication::applicationDirPath() + "/libScreenPlayWorkshop" + fileSuffix); #endif #ifdef Q_OS_WIN -#ifdef QT_NO_DEBUG - const QString fileSuffix = ".dll"; -#else - const QString fileSuffix = "d.dll"; -#endif + const QString fileSuffix = isDebug ? "d.dll" : ".dll"; + m_workshopPlugin.setFileName(QApplication::applicationDirPath() + "/ScreenPlayWorkshop" + fileSuffix); #endif #ifdef Q_OS_LINUX const QString fileSuffix = ".so"; #endif - m_workshopPlugin.setFileName(QApplication::applicationDirPath() + "/ScreenPlayWorkshop" + fileSuffix); + if (!m_workshopPlugin.load()) { qWarning() << "Steam plugin not provided!" << QApplication::applicationDirPath() + "/ScreenPlayWorkshop" + fileSuffix; - qWarning() << m_workshopPlugin.fileName() << " - With error: " << m_workshopPlugin.errorString(); + qWarning() << m_workshopPlugin.fileName() << " - With error: " << m_workshopPlugin.errorString() << " debug: " << isDebug; return false; } From fa95faca1aa87015bd1bed831ec6c9e8ef4fc6b0 Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Sun, 9 May 2021 12:00:25 +0200 Subject: [PATCH 08/21] Formatting --- ScreenPlaySDK/src/screenplaysdk.cpp | 1 + ScreenPlayWallpaper/src/basewindow.cpp | 3 ++- ScreenPlayWallpaper/src/macwindow.h | 16 ++++++++-------- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/ScreenPlaySDK/src/screenplaysdk.cpp b/ScreenPlaySDK/src/screenplaysdk.cpp index 04147e7c..bc158017 100644 --- a/ScreenPlaySDK/src/screenplaysdk.cpp +++ b/ScreenPlaySDK/src/screenplaysdk.cpp @@ -140,6 +140,7 @@ void ScreenPlaySDK::readyRead() void ScreenPlaySDK::error(QLocalSocket::LocalSocketError socketError) { + Q_UNUSED(socketError) emit sdkDisconnected(); } diff --git a/ScreenPlayWallpaper/src/basewindow.cpp b/ScreenPlayWallpaper/src/basewindow.cpp index 788bcbfc..dc152e9d 100644 --- a/ScreenPlayWallpaper/src/basewindow.cpp +++ b/ScreenPlayWallpaper/src/basewindow.cpp @@ -18,6 +18,7 @@ BaseWindow::BaseWindow( , m_debugMode(debugMode) , m_sdk(std::make_unique(appID, type)) { + qInfo() << "parent"; QApplication::instance()->installEventFilter(this); qRegisterMetaType(); @@ -30,7 +31,7 @@ BaseWindow::BaseWindow( qmlRegisterType("ScreenPlay.Wallpaper", 1, 0, "Wallpaper"); if (!appID.contains("appID=")) { - qInfo() << "Invalid appID: "<< appID; + qInfo() << "Invalid appID: " << appID; qFatal("AppID does not contain appID="); } diff --git a/ScreenPlayWallpaper/src/macwindow.h b/ScreenPlayWallpaper/src/macwindow.h index 50ac64a2..d47591fe 100644 --- a/ScreenPlayWallpaper/src/macwindow.h +++ b/ScreenPlayWallpaper/src/macwindow.h @@ -51,14 +51,14 @@ class MacWindow : public BaseWindow { Q_OBJECT public: - explicit MacWindow( const QVector& activeScreensList, - const QString& projectFilePath, - const QString& appID, - const QString& volume, - const QString& fillmode, - const QString& type, - const bool checkWallpaperVisible, - const bool debugMode); + explicit MacWindow(const QVector& activeScreensList, + const QString& projectFilePath, + const QString& appID, + const QString& volume, + const QString& fillmode, + const QString& type, + const bool checkWallpaperVisible, + const bool debugMode); signals: From 5445012cb5f93e95eaa1c8cd55acfe5dc92640bc Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Sun, 9 May 2021 12:00:34 +0200 Subject: [PATCH 09/21] Add missing sdk connection --- ScreenPlayWallpaper/src/macwindow.cpp | 36 ++++++++++++++++----------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/ScreenPlayWallpaper/src/macwindow.cpp b/ScreenPlayWallpaper/src/macwindow.cpp index 4b0ef33a..bf983b1a 100644 --- a/ScreenPlayWallpaper/src/macwindow.cpp +++ b/ScreenPlayWallpaper/src/macwindow.cpp @@ -1,23 +1,27 @@ #include "macwindow.h" MacWindow::MacWindow( - const QVector& activeScreensList, - const QString& projectFilePath, - const QString& appID, - const QString& volume, - const QString& fillmode, - const QString& type, - const bool checkWallpaperVisible, - const bool debugMode) + const QVector& activeScreensList, + const QString& projectFilePath, + const QString& appID, + const QString& volume, + const QString& fillmode, + const QString& type, + const bool checkWallpaperVisible, + const bool debugMode) : BaseWindow( - activeScreensList, - projectFilePath, - type, - checkWallpaperVisible, - appID, - debugMode) + activeScreensList, + projectFilePath, + type, + checkWallpaperVisible, + appID, + debugMode) { - setAppID(appID); + + connect(sdk(), &ScreenPlaySDK::sdkDisconnected, this, &MacWindow::destroyThis); + connect(sdk(), &ScreenPlaySDK::incommingMessage, this, &MacWindow::messageReceived); + connect(sdk(), &ScreenPlaySDK::replaceWallpaper, this, &MacWindow::replaceWallpaper); + bool ok = false; float volumeParsed = volume.toFloat(&ok); if (!ok) { @@ -46,6 +50,8 @@ MacWindow::MacWindow( MacIntegration* macIntegration = new MacIntegration(this); macIntegration->SetBackgroundLevel(&m_window); + + sdk()->start(); } void MacWindow::setVisible(bool show) From 2c8a0450bf67e54e8eefc76c40a0a3616e54cf2c Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Sun, 9 May 2021 12:13:36 +0200 Subject: [PATCH 10/21] Fix wallpaper closing --- ScreenPlay/src/screenplaymanager.cpp | 13 ++++++++----- ScreenPlay/src/screenplaywallpaper.cpp | 2 ++ ScreenPlay/src/screenplaywidget.cpp | 7 ++++++- ScreenPlay/src/screenplaywidget.h | 1 + 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/ScreenPlay/src/screenplaymanager.cpp b/ScreenPlay/src/screenplaymanager.cpp index 841b4a44..fa2aa2fd 100644 --- a/ScreenPlay/src/screenplaymanager.cpp +++ b/ScreenPlay/src/screenplaymanager.cpp @@ -362,11 +362,6 @@ void ScreenPlayManager::newConnection() return; } - qWarning() << "There are no wallpaper or widgets that have to SDKConnection " - << "m_screenPlayWallpapers count: " << m_screenPlayWallpapers.size() - << "m_screenPlayWidgets count: " << m_screenPlayWidgets.size() - << "m_unconnectedClients count: " << m_unconnectedClients.size(); - std::unique_ptr matchingConnection; for (int i = 0; i < m_unconnectedClients.size(); ++i) { if (m_unconnectedClients.at(i).get() == connection) { @@ -382,6 +377,7 @@ void ScreenPlayManager::newConnection() for (int i = 0; i < m_screenPlayWallpapers.size(); ++i) { if (m_screenPlayWallpapers.at(i)->appID() == matchingConnection->appID()) { + qInfo() << "Matching Wallpaper found!"; m_screenPlayWallpapers.at(i)->setSDKConnection(std::move(matchingConnection)); return; } @@ -389,12 +385,19 @@ void ScreenPlayManager::newConnection() for (int i = 0; i < m_screenPlayWidgets.size(); ++i) { if (m_screenPlayWidgets.at(i)->appID() == matchingConnection->appID()) { + qInfo() << "Matching Widget found!"; m_screenPlayWidgets.at(i)->setSDKConnection(std::move(matchingConnection)); return; } } qWarning() << "No matching connection found!"; + + qWarning() << "There are no wallpaper or widgets that have to SDKConnection " + << "m_screenPlayWallpapers count: " << m_screenPlayWallpapers.size() + << "m_screenPlayWidgets count: " << m_screenPlayWidgets.size() + << "m_unconnectedClients count: " << m_unconnectedClients.size(); + }); m_unconnectedClients.push_back(std::move(connection)); } diff --git a/ScreenPlay/src/screenplaywallpaper.cpp b/ScreenPlay/src/screenplaywallpaper.cpp index 3b0673a4..f0358ab2 100644 --- a/ScreenPlay/src/screenplaywallpaper.cpp +++ b/ScreenPlay/src/screenplaywallpaper.cpp @@ -15,7 +15,9 @@ namespace ScreenPlay { */ ScreenPlayWallpaper::~ScreenPlayWallpaper() { + m_connection->close(); qInfo() << "Remove wallpaper " << m_appID; + } /*! diff --git a/ScreenPlay/src/screenplaywidget.cpp b/ScreenPlay/src/screenplaywidget.cpp index 15139398..55c9f5bd 100644 --- a/ScreenPlay/src/screenplaywidget.cpp +++ b/ScreenPlay/src/screenplaywidget.cpp @@ -54,7 +54,12 @@ ScreenPlayWidget::ScreenPlayWidget( QVariant::fromValue(m_type).toString(), QString::number(m_position.x()), QString::number(m_position.y()), - }; +}; +} + +ScreenPlayWidget::~ScreenPlayWidget() +{ + m_connection->close(); } bool ScreenPlayWidget::start() diff --git a/ScreenPlay/src/screenplaywidget.h b/ScreenPlay/src/screenplaywidget.h index 9da54a05..4fdfd757 100644 --- a/ScreenPlay/src/screenplaywidget.h +++ b/ScreenPlay/src/screenplaywidget.h @@ -68,6 +68,7 @@ public: const QString& absolutePath, const QString& previewImage, const QJsonObject& properties, const InstalledType::InstalledType type); + ~ScreenPlayWidget(); bool start(); From 103348c1cacedabc2d627f1886209fefd22469d8 Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Sun, 9 May 2021 12:45:14 +0200 Subject: [PATCH 11/21] Move fonts into dedicated big qrc --- ScreenPlay/CMakeLists.txt | 14 +++++++++----- ScreenPlay/app.cpp | 13 ++++--------- ScreenPlay/{Resources.qrc => assets.qrc} | 10 ---------- ScreenPlay/fonts.qrc | 15 +++++++++++++++ 4 files changed, 28 insertions(+), 24 deletions(-) rename ScreenPlay/{Resources.qrc => assets.qrc} (92%) create mode 100644 ScreenPlay/fonts.qrc diff --git a/ScreenPlay/CMakeLists.txt b/ScreenPlay/CMakeLists.txt index f717f648..691c6edb 100644 --- a/ScreenPlay/CMakeLists.txt +++ b/ScreenPlay/CMakeLists.txt @@ -76,13 +76,15 @@ set(l10n set_source_files_properties(${l10n} PROPERTIES OUTPUT_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/translations") qt5_add_translation(qmFiles ${l10n}) +qt5_add_big_resources(fonts fonts.qrc) + if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo") - qt5_add_resources(qml qml.qrc Resources.qrc) + qt5_add_resources(qml qml.qrc assets.qrc) else() - qtquick_compiler_add_resources(qml qml.qrc Resources.qrc) + qtquick_compiler_add_resources(qml qml.qrc assets.qrc) endif() -add_executable(${PROJECT_NAME} ${src} ${headers} ${resources} ${qml}) +add_executable(${PROJECT_NAME} ${src} ${headers} ${resources} ${qml} ${fonts}) if(APPLE) #set_target_properties(${PROJECT_NAME} PROPERTIES MACOSX_BUNDLE true) @@ -105,11 +107,13 @@ if(WIN32) configure_file(${VCPKG_INSTALLED_PATH}/tools/sentry-native/crashpad_handler.exe ${CMAKE_BINARY_DIR}/bin/ COPYONLY) - file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/bin/assets/fonts) - configure_file(assets/fonts/NotoSansCJKkr-Regular.otf ${CMAKE_BINARY_DIR}/bin/assets/fonts COPYONLY) endif() +file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/bin/assets/fonts) +configure_file(assets/fonts/NotoSansCJKkr-Regular.otf ${CMAKE_BINARY_DIR}/bin/assets/fonts COPYONLY) + + target_compile_definitions(${PROJECT_NAME} PRIVATE "GIT_VERSION=${GIT_VERSION}") target_link_libraries( diff --git a/ScreenPlay/app.cpp b/ScreenPlay/app.cpp index 314731c7..01c8de1e 100644 --- a/ScreenPlay/app.cpp +++ b/ScreenPlay/app.cpp @@ -70,9 +70,7 @@ App::App() QFontDatabase::addApplicationFont(":/assets/fonts/NotoSans-Medium.ttf"); QFontDatabase::addApplicationFont(":/assets/fonts/NotoSans-Light.ttf"); - if (-1 == QFontDatabase::addApplicationFont(QGuiApplication::applicationDirPath() + "/assets/fonts/NotoSansCJKkr-Regular.otf")) { - qWarning() << "Could not load korean font from: " << QGuiApplication::applicationDirPath() + "/assets/fonts/NotoSansCJKkr-Regular.otf"; - } + QFontDatabase::addApplicationFont(":/assets/fonts/NotoSansCJKkr-Regular.otf"); QQuickWindow::setTextRenderType(QQuickWindow::TextRenderType::NativeTextRendering); @@ -224,14 +222,13 @@ bool App::loadSteamPlugin() isDebug = false; #endif - #ifdef Q_OS_MACOS - const QString fileSuffix = isDebug ? "d.dylib" : ".dylib"; + const QString fileSuffix = isDebug ? "d.dylib" : ".dylib"; m_workshopPlugin.setFileName(QApplication::applicationDirPath() + "/libScreenPlayWorkshop" + fileSuffix); #endif #ifdef Q_OS_WIN - const QString fileSuffix = isDebug ? "d.dll" : ".dll"; + const QString fileSuffix = isDebug ? "d.dll" : ".dll"; m_workshopPlugin.setFileName(QApplication::applicationDirPath() + "/ScreenPlayWorkshop" + fileSuffix); #endif @@ -239,11 +236,9 @@ bool App::loadSteamPlugin() const QString fileSuffix = ".so"; #endif - - if (!m_workshopPlugin.load()) { qWarning() << "Steam plugin not provided!" << QApplication::applicationDirPath() + "/ScreenPlayWorkshop" + fileSuffix; - qWarning() << m_workshopPlugin.fileName() << " - With error: " << m_workshopPlugin.errorString() << " debug: " << isDebug; + qWarning() << m_workshopPlugin.fileName() << " - With error: " << m_workshopPlugin.errorString() << " debug: " << isDebug; return false; } diff --git a/ScreenPlay/Resources.qrc b/ScreenPlay/assets.qrc similarity index 92% rename from ScreenPlay/Resources.qrc rename to ScreenPlay/assets.qrc index fb87c206..0165efc9 100644 --- a/ScreenPlay/Resources.qrc +++ b/ScreenPlay/assets.qrc @@ -1,16 +1,6 @@ assets/WorkshopPreview.html - assets/fonts/LibreBaskerville-Italic.ttf - assets/fonts/NotoSans-Light.ttf - assets/fonts/NotoSans-Medium.ttf - assets/fonts/NotoSans-Regular.ttf - assets/fonts/NotoSans-Thin.ttf - assets/fonts/Roboto-Light.ttf - assets/fonts/Roboto-Regular.ttf - assets/fonts/Roboto-Thin.ttf - assets/fonts/RobotoMono-Light.ttf - assets/fonts/RobotoMono-Thin.ttf assets/icons/app.ico assets/icons/brand_github.svg assets/icons/brand_gitlab.svg diff --git a/ScreenPlay/fonts.qrc b/ScreenPlay/fonts.qrc new file mode 100644 index 00000000..76558247 --- /dev/null +++ b/ScreenPlay/fonts.qrc @@ -0,0 +1,15 @@ + + + assets/fonts/LibreBaskerville-Italic.ttf + assets/fonts/NotoSans-Light.ttf + assets/fonts/NotoSans-Medium.ttf + assets/fonts/NotoSans-Regular.ttf + assets/fonts/NotoSans-Thin.ttf + assets/fonts/NotoSansCJKkr-Regular.otf + assets/fonts/Roboto-Light.ttf + assets/fonts/Roboto-Regular.ttf + assets/fonts/Roboto-Thin.ttf + assets/fonts/RobotoMono-Light.ttf + assets/fonts/RobotoMono-Thin.ttf + + From d1620f0b19d6f0d3136d81fba2221ad79cff5973 Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Sun, 9 May 2021 12:46:00 +0200 Subject: [PATCH 12/21] Remove no longer needed manual font copy --- ScreenPlay/CMakeLists.txt | 5 ----- 1 file changed, 5 deletions(-) diff --git a/ScreenPlay/CMakeLists.txt b/ScreenPlay/CMakeLists.txt index 691c6edb..d1272853 100644 --- a/ScreenPlay/CMakeLists.txt +++ b/ScreenPlay/CMakeLists.txt @@ -107,13 +107,8 @@ if(WIN32) configure_file(${VCPKG_INSTALLED_PATH}/tools/sentry-native/crashpad_handler.exe ${CMAKE_BINARY_DIR}/bin/ COPYONLY) - endif() -file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/bin/assets/fonts) -configure_file(assets/fonts/NotoSansCJKkr-Regular.otf ${CMAKE_BINARY_DIR}/bin/assets/fonts COPYONLY) - - target_compile_definitions(${PROJECT_NAME} PRIVATE "GIT_VERSION=${GIT_VERSION}") target_link_libraries( From 40100180575cbb09cc3fdee9cc76598c861b1b2b Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Tue, 18 May 2021 16:07:53 +0200 Subject: [PATCH 13/21] Add default Info.plist --- ScreenPlay/CMakeLists.txt | 1 + ScreenPlay/Info.plist | 28 ++++++++++++++++++++++++++++ ScreenPlayWallpaper/CMakeLists.txt | 12 +++++------- ScreenPlayWallpaper/Info.plist | 28 ++++++++++++++++++++++++++++ 4 files changed, 62 insertions(+), 7 deletions(-) create mode 100644 ScreenPlay/Info.plist create mode 100644 ScreenPlayWallpaper/Info.plist diff --git a/ScreenPlay/CMakeLists.txt b/ScreenPlay/CMakeLists.txt index d1272853..19fadd25 100644 --- a/ScreenPlay/CMakeLists.txt +++ b/ScreenPlay/CMakeLists.txt @@ -137,6 +137,7 @@ if(APPLE) OUTPUT_NAME ${PROJECT_NAME} MACOSX_BUNDLE TRUE MACOSX_RPATH TRUE + MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist MACOSX_FRAMEWORK_IDENTIFIER screen-play.app XCODE_ATTRIBUTE_LD_RUNPATH_SEARCH_PATHS "@loader_path/Libraries" RESOURCE "${RESOURCE_FILES}" diff --git a/ScreenPlay/Info.plist b/ScreenPlay/Info.plist new file mode 100644 index 00000000..83d99948 --- /dev/null +++ b/ScreenPlay/Info.plist @@ -0,0 +1,28 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIconFile + + CFBundleIdentifier + app.screen-play + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + APPL + CFBundleVersion + 1.0 + CFBundleDisplayName + ScreenPlayWallpaper + NSUIElement + 1 + LSUIElement + 1 + + diff --git a/ScreenPlayWallpaper/CMakeLists.txt b/ScreenPlayWallpaper/CMakeLists.txt index 87f61364..b0d96698 100644 --- a/ScreenPlayWallpaper/CMakeLists.txt +++ b/ScreenPlayWallpaper/CMakeLists.txt @@ -38,16 +38,14 @@ if(WIN32) target_link_libraries(${PROJECT_NAME} PRIVATE shcore.lib ) endif() -if(APPLE) - #set_target_properties(${PROJECT_NAME} PROPERTIES MACOSX_BUNDLE true) - target_link_libraries(${PROJECT_NAME} PRIVATE "-framework Cocoa") -endif() - target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::Quick Qt5::Gui Qt5::Widgets Qt5::Core Qt5::WebEngine ScreenPlaySDK ScreenPlayUtil) - - if(APPLE) + target_link_libraries(${PROJECT_NAME} PRIVATE "-framework Cocoa") + set_target_properties(${PROJECT_NAME} PROPERTIES + MACOSX_BUNDLE TRUE + MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist + ) add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMENT "Copying into ScreenPlay.app bundle" diff --git a/ScreenPlayWallpaper/Info.plist b/ScreenPlayWallpaper/Info.plist new file mode 100644 index 00000000..83d99948 --- /dev/null +++ b/ScreenPlayWallpaper/Info.plist @@ -0,0 +1,28 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIconFile + + CFBundleIdentifier + app.screen-play + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + APPL + CFBundleVersion + 1.0 + CFBundleDisplayName + ScreenPlayWallpaper + NSUIElement + 1 + LSUIElement + 1 + + From 1e29d44d7d25f3eab703a500451b9bbb1cb3dc5a Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Fri, 21 May 2021 12:02:16 +0200 Subject: [PATCH 14/21] Add ffmpeg and fix video import --- ScreenPlay/CMakeLists.txt | 14 +++++++++++ ScreenPlay/app.cpp | 2 +- ScreenPlay/src/createimportvideo.cpp | 8 +++++-- ScreenPlayWallpaper/Wallpaper.qml | 3 ++- Tools/Readme.md | 15 ++++++++++++ Tools/download_ffmpeg.py | 36 ++++++++++++++++++++++++++++ 6 files changed, 74 insertions(+), 4 deletions(-) create mode 100644 Tools/Readme.md create mode 100644 Tools/download_ffmpeg.py diff --git a/ScreenPlay/CMakeLists.txt b/ScreenPlay/CMakeLists.txt index 19fadd25..c41ff9b5 100644 --- a/ScreenPlay/CMakeLists.txt +++ b/ScreenPlay/CMakeLists.txt @@ -145,4 +145,18 @@ if(APPLE) XCODE_ATTRIBUTE_EXECUTABLE_NAME ${PROJECT_NAME} ) + + add_custom_command( + TARGET ${PROJECT_NAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${CMAKE_CURRENT_SOURCE_DIR}/../Common/ffmpeg/ffmpeg + ${CMAKE_BINARY_DIR}/bin/ScreenPlay.app/Contents/MacOS/ ) + + add_custom_command( + TARGET ${PROJECT_NAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${CMAKE_CURRENT_SOURCE_DIR}/../Common/ffmpeg/ffprobe + ${CMAKE_BINARY_DIR}/bin/ScreenPlay.app/Contents/MacOS/ ) + + endif() diff --git a/ScreenPlay/app.cpp b/ScreenPlay/app.cpp index dc0c4051..e3b12b3d 100644 --- a/ScreenPlay/app.cpp +++ b/ScreenPlay/app.cpp @@ -220,7 +220,7 @@ void App::exit() */ bool App::loadSteamPlugin() { - const bool isDebug = true; + bool isDebug = true; #ifdef QT_NO_DEBUG isDebug = false; diff --git a/ScreenPlay/src/createimportvideo.cpp b/ScreenPlay/src/createimportvideo.cpp index 3db4ad62..0c60835d 100644 --- a/ScreenPlay/src/createimportvideo.cpp +++ b/ScreenPlay/src/createimportvideo.cpp @@ -39,8 +39,12 @@ CreateImportVideo::CreateImportVideo(const QString& videoPath, const QString& ex m_codec = codec; m_process = std::make_unique(this); - m_ffprobeExecutable = QApplication::applicationDirPath() + "/ffprobe" + ScreenPlayUtil::executableEnding(); - m_ffmpegExecutable = QApplication::applicationDirPath() + "/ffmpeg" + ScreenPlayUtil::executableEnding(); + QString fileEnding ; +#ifdef Q_OS_WIN + fileEnding = ScreenPlayUtil::executableEnding(); +#endif + m_ffprobeExecutable = QApplication::applicationDirPath() + "/ffprobe" + fileEnding; + m_ffmpegExecutable = QApplication::applicationDirPath() + "/ffmpeg" + fileEnding ; } /*! diff --git a/ScreenPlayWallpaper/Wallpaper.qml b/ScreenPlayWallpaper/Wallpaper.qml index 0f25062f..7428eb5c 100644 --- a/ScreenPlayWallpaper/Wallpaper.qml +++ b/ScreenPlayWallpaper/Wallpaper.qml @@ -136,7 +136,8 @@ Rectangle { source: { if (Qt.platform.os === "windows") return Qt.resolvedUrl("file:///" + Wallpaper.windowsDesktopProperties.wallpaperPath); - + else + return "" } Component.onCompleted: { diff --git a/Tools/Readme.md b/Tools/Readme.md new file mode 100644 index 00000000..a9afdecd --- /dev/null +++ b/Tools/Readme.md @@ -0,0 +1,15 @@ +## Tools + +This folder contains serveral python tools to help with development: +#### setup.py +- Installs third party dependencies for all platforms +#### build.py +- Build ScreenPlay locally +#### clang_format.py +- Invokers clang-format for all .cpp and .h files +#### qdoc.py +- Builds documentation for all projects into Docs/html +#### download_ffmpeg.py +- Donwload ffmpeg for macos only for now +#### qml_format.py +- Calls qmlformat for all qml files diff --git a/Tools/download_ffmpeg.py b/Tools/download_ffmpeg.py new file mode 100644 index 00000000..29780640 --- /dev/null +++ b/Tools/download_ffmpeg.py @@ -0,0 +1,36 @@ +import zipfile +from urllib.request import urlopen +import os + + +def download_and_extract(file_base_path, name): + print("Download: ", name) + + download_server_base_url = 'https://evermeet.cx/ffmpeg/' + filedata = urlopen(download_server_base_url + name) + datatowrite = filedata.read() + path_and_filename = os.path.join(file_base_path, name) + + print("Save tmp file: ", path_and_filename) + with open(path_and_filename, 'wb') as f: + f.write(datatowrite) + + extraction_path = os.path.join(file_base_path, "../Common/ffmpeg") + + print("Extract to:", extraction_path) + with zipfile.ZipFile(path_and_filename,"r") as zip_ref: + zip_ref.extractall(extraction_path) + + print("Delete tmp file: ", path_and_filename) + os.remove(path_and_filename) + +ffmpeg_7zip_name = 'ffmpeg-4.4.zip' +ffprobe_7zip_name = 'ffprobe-4.4.zip' +current_path = os.path.join(os.path.abspath(os.getcwd()),"") +extraction_path = os.path.abspath(os.path.join(current_path, "../Common/ffmpeg")) + +if not os.path.exists(extraction_path): + os.makedirs(extraction_path) + +download_and_extract(current_path, ffmpeg_7zip_name) +download_and_extract(current_path, ffprobe_7zip_name) From 3cd5d619a7f8b7304f2276a578fc83ed618432fa Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Mon, 24 May 2021 14:27:54 +0200 Subject: [PATCH 15/21] Fix steam plugin missing folder --- ScreenPlay/CMakeLists.txt | 8 ++++---- ScreenPlayWallpaper/CMakeLists.txt | 5 ----- ScreenPlayWidget/CMakeLists.txt | 9 ++++----- ScreenPlayWidget/Info.plist | 28 ++++++++++++++++++++++++++++ 4 files changed, 36 insertions(+), 14 deletions(-) create mode 100644 ScreenPlayWidget/Info.plist diff --git a/ScreenPlay/CMakeLists.txt b/ScreenPlay/CMakeLists.txt index 01c4b82e..c5cd7336 100644 --- a/ScreenPlay/CMakeLists.txt +++ b/ScreenPlay/CMakeLists.txt @@ -86,10 +86,6 @@ endif() add_executable(${PROJECT_NAME} ${src} ${headers} ${resources} ${qml} ${fonts}) -if(APPLE) - #set_target_properties(${PROJECT_NAME} PROPERTIES MACOSX_BUNDLE true) -endif() - if(WIN32) # Icon target_sources(${PROJECT_NAME} PRIVATE ScreenPlay.rc) @@ -132,6 +128,8 @@ endif() if(APPLE) + + # Creates a ScreenPlay.app set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME ${PROJECT_NAME} @@ -145,6 +143,8 @@ if(APPLE) XCODE_ATTRIBUTE_EXECUTABLE_NAME ${PROJECT_NAME} ) + # Needed for the Steam Workshop qml plugin + file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/bin/ScreenPlay.app/Contents/MacOS/Workshop) add_custom_command( TARGET ${PROJECT_NAME} POST_BUILD diff --git a/ScreenPlayWallpaper/CMakeLists.txt b/ScreenPlayWallpaper/CMakeLists.txt index 0b1789cf..791009aa 100644 --- a/ScreenPlayWallpaper/CMakeLists.txt +++ b/ScreenPlayWallpaper/CMakeLists.txt @@ -46,9 +46,4 @@ if(APPLE) MACOSX_BUNDLE TRUE MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist ) -#add_custom_command(TARGET ${PROJECT_NAME} -# POST_BUILD -# COMMENT "Copying into ScreenPlay.app bundle" -# COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/bin/${PROJECT_NAME} -# ${CMAKE_BINARY_DIR}/bin/ScreenPlay.app/Contents/MacOS/${PROJECT_NAME}) endif() diff --git a/ScreenPlayWidget/CMakeLists.txt b/ScreenPlayWidget/CMakeLists.txt index 2aae4c99..a0ee22ee 100644 --- a/ScreenPlayWidget/CMakeLists.txt +++ b/ScreenPlayWidget/CMakeLists.txt @@ -28,11 +28,10 @@ if(WIN32) endif() if(APPLE) -add_custom_command(TARGET ${PROJECT_NAME} - POST_BUILD - COMMENT "Copying into ScreenPlay.app bundle" - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/bin/${PROJECT_NAME} - ${CMAKE_BINARY_DIR}/bin/ScreenPlay.app/Contents/MacOS/${PROJECT_NAME}) + set_target_properties(${PROJECT_NAME} PROPERTIES + MACOSX_BUNDLE TRUE + MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist + ) endif() target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::Quick Qt5::Gui Qt5::Widgets Qt5::Core ScreenPlaySDK ScreenPlayUtil) diff --git a/ScreenPlayWidget/Info.plist b/ScreenPlayWidget/Info.plist new file mode 100644 index 00000000..3efa504f --- /dev/null +++ b/ScreenPlayWidget/Info.plist @@ -0,0 +1,28 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIconFile + + CFBundleIdentifier + app.screen-play.widget + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + APPL + CFBundleVersion + 1.0 + CFBundleDisplayName + ScreenPlayWidget + NSUIElement + 1 + LSUIElement + 1 + + From 2416a7074c6815790ce7f9a14354d637ecd47352 Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Thu, 10 Jun 2021 16:23:39 +0200 Subject: [PATCH 16/21] Fix incorrect setOrganizationDomain --- ScreenPlay/app.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ScreenPlay/app.cpp b/ScreenPlay/app.cpp index 4b486c64..139dd8aa 100644 --- a/ScreenPlay/app.cpp +++ b/ScreenPlay/app.cpp @@ -56,7 +56,7 @@ App::App() QGuiApplication::setWindowIcon(QIcon(":/assets/icons/app.ico")); QGuiApplication::setOrganizationName("ScreenPlay"); - QGuiApplication::setOrganizationDomain("https://screen-play.app"); + QGuiApplication::setOrganizationDomain("screen-play.app"); QGuiApplication::setApplicationName("ScreenPlay"); QGuiApplication::setApplicationVersion("0.13.3"); QGuiApplication::setQuitOnLastWindowClosed(false); From 3efbda68eeadb736694e094b27ad781de8700112 Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Thu, 10 Jun 2021 16:24:03 +0200 Subject: [PATCH 17/21] Add autostart for MacOS --- ScreenPlay/assets.qrc | 1 + ScreenPlay/assets/macos/app.screenplay.plist | 18 +++ ScreenPlay/src/settings.cpp | 117 ++++++++++--------- ScreenPlay/src/settings.h | 51 ++++++-- 4 files changed, 125 insertions(+), 62 deletions(-) create mode 100644 ScreenPlay/assets/macos/app.screenplay.plist diff --git a/ScreenPlay/assets.qrc b/ScreenPlay/assets.qrc index 9f5594df..bc4034ee 100644 --- a/ScreenPlay/assets.qrc +++ b/ScreenPlay/assets.qrc @@ -129,5 +129,6 @@ assets/icons/icon_sort-down-solid.svg assets/icons/brand_reddit.svg assets/icons/steam_default_avatar.png + assets/macos/app.screenplay.plist diff --git a/ScreenPlay/assets/macos/app.screenplay.plist b/ScreenPlay/assets/macos/app.screenplay.plist new file mode 100644 index 00000000..228bf652 --- /dev/null +++ b/ScreenPlay/assets/macos/app.screenplay.plist @@ -0,0 +1,18 @@ + + + + + Label + app.screenplay + ProgramArguments + + {{SCREENPLAY_PATH}} + + ProcessType + Interactive + RunAtLoad + <{{SCREENPLAY_AUTOSTART}}/> + KeepAlive + + + diff --git a/ScreenPlay/src/settings.cpp b/ScreenPlay/src/settings.cpp index e32ba403..67315b9e 100644 --- a/ScreenPlay/src/settings.cpp +++ b/ScreenPlay/src/settings.cpp @@ -39,6 +39,16 @@ Settings::Settings(const std::shared_ptr& globalVariables, : QObject(parent) , m_globalVariables { globalVariables } { +#ifdef Q_OS_WIN + setDesktopEnvironment(DesktopEnvironment::Windows); +#endif +#ifdef Q_OS_OSX + setDesktopEnvironment(DesktopEnvironment::OSX); +#endif +#ifdef Q_OS_LINUX + // We only support KDE for now + setDesktopEnvironment(DesktopEnvironment::KDE); +#endif qRegisterMetaType("Settings::Language"); qRegisterMetaType("Settings::Theme"); @@ -47,15 +57,15 @@ Settings::Settings(const std::shared_ptr& globalVariables, qmlRegisterUncreatableType("Settings", 1, 0, "Settings", "Error only for enums"); if (!m_qSettings.contains("Autostart")) { -#ifdef Q_OS_WIN - QSettings settings("HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", QSettings::NativeFormat); - if (!m_qSettings.value("Autostart").toBool()) { - if (!settings.contains("ScreenPlay")) { + if (desktopEnvironment() == DesktopEnvironment::Windows) { + QSettings settings("HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", QSettings::NativeFormat); + if (!m_qSettings.value("Autostart").toBool()) { + if (!settings.contains("ScreenPlay")) { + } } + settings.setValue("ScreenPlay", QDir::toNativeSeparators(QCoreApplication::applicationFilePath()) + " -silent"); + settings.sync(); } - settings.setValue("ScreenPlay", QDir::toNativeSeparators(QCoreApplication::applicationFilePath()) + " -silent"); - settings.sync(); -#endif m_qSettings.setValue("Autostart", true); m_qSettings.sync(); } else { @@ -87,54 +97,10 @@ Settings::Settings(const std::shared_ptr& globalVariables, writeJsonFileFromResource("profiles"); } - //If empty use steam workshop location - if (QString(m_qSettings.value("ScreenPlayContentPath").toString()).isEmpty()) { - - /* - * ! We must use this (ugly) method, because to stay FOSS we cannot call the steamAPI here ! - * - * We start with the assumption that when we go up 2 folder. - * So that there must be at least a common folder: - * Windows example: - * From -> C:\Program Files (x86)\Steam\steamapps\common\ScreenPlay - * To -> C:\Program Files (x86)\Steam\steamapps\ - * Dest.-> C:\Program Files (x86)\Steam\steamapps\workshop\content\672870 - * - * When we reach the folder it _can_ contain a workshop folder when the user - * previously installed any workshop content. If the folder does not exsist we - * need to create it by hand. Normally Steam will create this folder but we need to - * set it here at this point so that the QFileSystemWatcher in InstalledListModel does - * not generate warnings. - */ - QDir dir; - QString path = QApplication::instance()->applicationDirPath() + "/../../workshop/content/672870"; - if (!dir.mkpath(path)) { - qWarning() << "Could not create steam workshop path for path: " << path; - } else { - m_globalVariables->setLocalStoragePath(QUrl::fromUserInput(path)); - m_qSettings.setValue("ScreenPlayContentPath", dir.cleanPath(path)); - m_qSettings.sync(); - } - - } else { - m_globalVariables->setLocalStoragePath(QUrl::fromUserInput(m_qSettings.value("ScreenPlayContentPath").toString())); - } + initInstalledPath(); setupWidgetAndWindowPaths(); setGitBuildHash(COMPILE_INFO); - -#ifdef Q_OS_WIN - setDesktopEnvironment(DesktopEnvironment::Windows); -#endif - -#ifdef Q_OS_OSX - setDesktopEnvironment(DesktopEnvironment::OSX); -#endif - -#ifdef Q_OS_LINUX - // We only support KDE for now - setDesktopEnvironment(DesktopEnvironment::KDE); -#endif } /*! @@ -204,6 +170,53 @@ void Settings::restoreDefault(const QString& appConfigLocation, const QString& s writeJsonFileFromResource(settingsFileType); } +void Settings::initInstalledPath() +{ + //If empty use steam workshop location + qInfo() << m_qSettings.value("ScreenPlayContentPath").toString(); + if (QString(m_qSettings.value("ScreenPlayContentPath").toString()).isEmpty()) { + + /* + * ! We must use this (ugly) method, because to stay FOSS we cannot call the steamAPI here ! + * + * We start with the assumption that when we go up 2 folder. + * So that there must be at least a common folder: + * Windows example: + * From -> C:\Program Files (x86)\Steam\steamapps\common\ScreenPlay + * To -> C:\Program Files (x86)\Steam\steamapps\ + * Dest.-> C:\Program Files (x86)\Steam\steamapps\workshop\content\672870 + * + * When we reach the folder it _can_ contain a workshop folder when the user + * previously installed any workshop content. If the folder does not exsist we + * need to create it by hand. Normally Steam will create this folder but we need to + * set it here at this point so that the QFileSystemWatcher in InstalledListModel does + * not generate warnings. + */ + QDir dir; + QString appBasePath = QApplication::instance()->applicationDirPath(); + if (desktopEnvironment() == DesktopEnvironment::OSX) { + appBasePath += "/../../.."; + } + QString path = appBasePath + "/../../workshop/content/672870"; + qInfo() << path; + + if (!dir.mkpath(path)) { + qWarning() << "Could not create steam workshop path for path: " << path; + } + + if (QDir(path).exists()) { + m_globalVariables->setLocalStoragePath(QUrl::fromUserInput(path)); + m_qSettings.setValue("ScreenPlayContentPath", dir.cleanPath(path)); + m_qSettings.sync(); + } else { + qWarning() << "The following path could not be resolved to search for workshop content: " << path; + } + + } else { + m_globalVariables->setLocalStoragePath(QUrl::fromUserInput(m_qSettings.value("ScreenPlayContentPath").toString())); + } +} + /*! \brief Checks if there is already a saved language. If not we try to use the system langauge. If we do not support the system language we use english. diff --git a/ScreenPlay/src/settings.h b/ScreenPlay/src/settings.h index 48c48b27..2ca8ec6f 100644 --- a/ScreenPlay/src/settings.h +++ b/ScreenPlay/src/settings.h @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -185,19 +186,48 @@ public slots: void setAutostart(bool autostart) { - if (m_autostart == autostart) - return; + if (desktopEnvironment() == DesktopEnvironment::Windows) { -#ifdef Q_OS_WIN - QSettings settings("HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", QSettings::NativeFormat); - if (autostart) { - settings.setValue("ScreenPlay", QDir::toNativeSeparators(QCoreApplication::applicationFilePath()) + " -silent"); - settings.sync(); - } else { - settings.remove("ScreenPlay"); + QSettings settings("HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", QSettings::NativeFormat); + if (autostart) { + settings.setValue("ScreenPlay", QDir::toNativeSeparators(QCoreApplication::applicationFilePath()) + " -silent"); + settings.sync(); + } else { + settings.remove("ScreenPlay"); + } } -#endif + if (desktopEnvironment() == DesktopEnvironment::OSX) { + const QString plistFileName = "app.screenplay.plist"; + QFile defaultPListFile(":/assets/macos/" + plistFileName); + defaultPListFile.open(QIODevice::ReadOnly); + QString settingsPlistContent = defaultPListFile.readAll(); + if(!settingsPlistContent.contains("{{SCREENPLAY_PATH}}")){ + qCritical() << "Unable to load plist settings template from qrc to set autostart!"; + } + QDir workingDir(QGuiApplication::applicationDirPath()); + workingDir.cdUp(); + workingDir.cdUp(); + workingDir.cdUp(); + const QString screenPlayPath = QUrl::fromUserInput(workingDir.path() + "/ScreenPlay.app/Contents/MacOS/ScreenPlay").toLocalFile(); + settingsPlistContent.replace("{{SCREENPLAY_PATH}}", screenPlayPath); + settingsPlistContent.replace("{{SCREENPLAY_AUTOSTART}}", autostart ? "true":"false"); + + const QString homePath = QDir::homePath(); + QFile settingsPlist(homePath + "/Library/LaunchAgents/" + plistFileName); + if (settingsPlist.exists()) { + if(!settingsPlist.remove()){ + qCritical() << "Unable to remove: " << settingsPlist; + } + } + + settingsPlist.open(QIODevice::WriteOnly | QIODevice::Truncate); + QTextStream out(&settingsPlist); + out.setCodec("UTF-8"); + out << settingsPlistContent; + settingsPlist.flush(); + settingsPlist.close(); + } setqSetting("Autostart", autostart); m_autostart = autostart; @@ -371,6 +401,7 @@ public slots: private: void restoreDefault(const QString& appConfigLocation, const QString& settingsFileType); + void initInstalledPath(); private: QSettings m_qSettings; From 5add9d869e5b12d1a87e5878c7a2c2a5cd680614 Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Sat, 12 Jun 2021 14:42:55 +0200 Subject: [PATCH 18/21] Fix setup script for macos and linux --- Tools/setup.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/Tools/setup.py b/Tools/setup.py index e4f6a27d..b43e9b6c 100644 --- a/Tools/setup.py +++ b/Tools/setup.py @@ -30,7 +30,7 @@ if __name__ == "__main__": vcpkg_path = os.path.join(project_source_parent_path, "ScreenPlay-vcpkg") print("vcpkg_path: ", vcpkg_path) - vcpkg_version = "5568f11" # https://github.com/microsoft/vcpkg/releases/tag/2021.05.12 + vcpkg_version = "680b27d15f4d62bc6181fd33dc5259482b0890b1" # Master 10.06.2021 print("Build vcpkg ", vcpkg_version) execute("git fetch", vcpkg_path) execute("git checkout {}".format(vcpkg_version), vcpkg_path) @@ -39,7 +39,6 @@ if __name__ == "__main__": "openssl-unix", "sentry-native", "doctest", - "benchmark", ] vcpkg_triplet = "" @@ -53,18 +52,20 @@ if __name__ == "__main__": vcpkg_triplet = "x64-windows" elif sys.platform == "darwin": vcpkg_packages_list.append("infoware[opencl]") - execute("bootstrap-vcpkg.sh", vcpkg_path, False) - execute("chmod +x vcpkg", vcpkg_path) - vcpkg_triplet = "x64-linux" - elif sys.platform == "linux": - vcpkg_packages_list.append("infoware[opencl]") - execute("bootstrap-vcpkg.sh", vcpkg_path, False) + execute("chmod +x bootstrap-vcpkg.sh", vcpkg_path) + execute("./bootstrap-vcpkg.sh", vcpkg_path, False) execute("chmod +x vcpkg", vcpkg_path) vcpkg_triplet = "x64-osx" + elif sys.platform == "linux": + vcpkg_packages_list.append("infoware[opencl]") + execute("chmod +x bootstrap-vcpkg.sh", vcpkg_path) + execute("./bootstrap-vcpkg.sh", vcpkg_path, False) + execute("chmod +x vcpkg", vcpkg_path) + vcpkg_triplet = "x64-linux" vcpkg_packages = " ".join(vcpkg_packages_list) - execute("vcpkg{} update".format(executable_file_suffix), vcpkg_path, False) - execute("vcpkg{} upgrade --no-dry-run".format(executable_file_suffix), + execute("./vcpkg{} update".format(executable_file_suffix), vcpkg_path, False) + execute("./vcpkg{} upgrade --no-dry-run".format(executable_file_suffix), vcpkg_path, False) - execute("vcpkg{} install {} --triplet {} --recurse".format(executable_file_suffix, + execute("./vcpkg{} install {} --triplet {} --recurse".format(executable_file_suffix, vcpkg_packages, vcpkg_triplet), vcpkg_path, False) From dd1e5e614db3f4996b6f129ab690c2817db6bd86 Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Sat, 12 Jun 2021 14:43:11 +0200 Subject: [PATCH 19/21] Add missing silent parameter for autostart --- ScreenPlay/assets/macos/app.screenplay.plist | 1 + 1 file changed, 1 insertion(+) diff --git a/ScreenPlay/assets/macos/app.screenplay.plist b/ScreenPlay/assets/macos/app.screenplay.plist index 228bf652..40befa52 100644 --- a/ScreenPlay/assets/macos/app.screenplay.plist +++ b/ScreenPlay/assets/macos/app.screenplay.plist @@ -7,6 +7,7 @@ ProgramArguments {{SCREENPLAY_PATH}} + -silent ProcessType Interactive From e118fa235c69c5b30a0ffe775a024fa1ec81ffa1 Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Sat, 12 Jun 2021 15:17:38 +0200 Subject: [PATCH 20/21] Add sentry support for macos Fix cmake apple define because apple is a unix system. --- CMakeLists.txt | 2 +- ScreenPlay/CMakeLists.txt | 57 ++++++++++++++++++++------------------- ScreenPlay/app.cpp | 8 +++--- ScreenPlay/app.h | 3 --- ScreenPlay/main.cpp | 6 ----- ScreenPlay/src/util.cpp | 2 -- Tools/setup.py | 1 + 7 files changed, 36 insertions(+), 43 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 99c3ae62..4e826243 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,7 @@ set(CMAKE_CXX_STANDARD 20) if(WIN32) set(VCPKG_ARCH "x64-windows") -elseif(UNIX) +elseif(UNIX AND NOT APPLE) set(VCPKG_ARCH "x64-linux") elseif(APPLE) set(VCPKG_ARCH "x64-osx") diff --git a/ScreenPlay/CMakeLists.txt b/ScreenPlay/CMakeLists.txt index c5cd7336..0d055c27 100644 --- a/ScreenPlay/CMakeLists.txt +++ b/ScreenPlay/CMakeLists.txt @@ -16,13 +16,16 @@ find_package( WebSockets REQUIRED) + find_package(OpenSSL REQUIRED) find_package(benchmark CONFIG REQUIRED) find_package(doctest CONFIG REQUIRED) -if(WIN32) - find_package(sentry CONFIG REQUIRED) -endif() +# 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(sentry CONFIG REQUIRED) set(src main.cpp @@ -74,8 +77,8 @@ set(l10n translations/ScreenPlay_vi.ts) set_source_files_properties(${l10n} PROPERTIES OUTPUT_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/translations") -qt5_add_translation(qmFiles ${l10n}) +qt5_add_translation(qmFiles ${l10n}) qt5_add_big_resources(fonts fonts.qrc) if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo") @@ -86,25 +89,6 @@ endif() add_executable(${PROJECT_NAME} ${src} ${headers} ${resources} ${qml} ${fonts}) -if(WIN32) - # Icon - target_sources(${PROJECT_NAME} PRIVATE ScreenPlay.rc) - target_link_libraries(${PROJECT_NAME} PRIVATE sentry::sentry) - - # 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) - - # Copy ffmpeg. If the ffmpeg files are missing, start the install_dependencies_XXX for your system! - file(GLOB files "${CMAKE_CURRENT_SOURCE_DIR}/../Common/ffmpeg/*") - foreach(filename ${files}) - configure_file(${filename} ${CMAKE_BINARY_DIR}/bin/ COPYONLY) - endforeach() - - configure_file(${VCPKG_INSTALLED_PATH}/tools/sentry-native/crashpad_handler.exe ${CMAKE_BINARY_DIR}/bin/ COPYONLY) - -endif() - target_compile_definitions(${PROJECT_NAME} PRIVATE "GIT_VERSION=${GIT_VERSION}") target_link_libraries( @@ -120,16 +104,28 @@ target_link_libraries( ScreenPlayUtil benchmark::benchmark benchmark::benchmark_main - doctest::doctest) + doctest::doctest + sentry::sentry) if(WIN32) - target_link_libraries(${PROJECT_NAME} PRIVATE sentry::sentry) + # 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) + + # Copy ffmpeg. If the ffmpeg files are missing, start the install_dependencies_XXX for your system! + file(GLOB files "${CMAKE_CURRENT_SOURCE_DIR}/../Common/ffmpeg/*") + foreach(filename ${files}) + configure_file(${filename} ${CMAKE_BINARY_DIR}/bin/ COPYONLY) + endforeach() + + configure_file(${VCPKG_INSTALLED_PATH}/tools/sentry-native/crashpad_handler.exe ${CMAKE_BINARY_DIR}/bin/ COPYONLY) + endif() if(APPLE) - - - # Creates a ScreenPlay.app set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME ${PROJECT_NAME} @@ -158,5 +154,10 @@ if(APPLE) ${CMAKE_CURRENT_SOURCE_DIR}/../Common/ffmpeg/ffprobe ${CMAKE_BINARY_DIR}/bin/ScreenPlay.app/Contents/MacOS/ ) + add_custom_command( + TARGET ${PROJECT_NAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${VCPKG_INSTALLED_PATH}/tools/sentry-native/crashpad_handler + ${CMAKE_BINARY_DIR}/bin/ScreenPlay.app/Contents/MacOS/ ) endif() diff --git a/ScreenPlay/app.cpp b/ScreenPlay/app.cpp index 139dd8aa..eea20dd8 100644 --- a/ScreenPlay/app.cpp +++ b/ScreenPlay/app.cpp @@ -156,18 +156,20 @@ void App::init() // Only create anonymousTelemetry if user did not disallow! if (m_settings->anonymousTelemetry()) { -#ifdef Q_OS_WIN sentry_options_t* options = sentry_options_new(); sentry_options_set_dsn(options, "https://425ea0b77def4f91a5a9decc01b36ff4@o428218.ingest.sentry.io/5373419"); const QString appPath = QGuiApplication::applicationDirPath(); - sentry_options_set_handler_path(options, QString(appPath + "/crashpad_handler.exe").toStdString().c_str()); + QString exectuableFileEnding = ""; +#ifdef Q_OS_WIN + exectuableFileEnding = ".exe"; +#endif + sentry_options_set_handler_path(options, QString(appPath + "/crashpad_handler" + exectuableFileEnding).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; } -#endif } m_create = make_unique(m_globalVariables); diff --git a/ScreenPlay/app.h b/ScreenPlay/app.h index b0b8c465..6091ba9e 100644 --- a/ScreenPlay/app.h +++ b/ScreenPlay/app.h @@ -62,10 +62,7 @@ #include "src/wizards.h" #include - -#ifdef Q_OS_WIN #include -#endif class ScreenPlayWorkshopPlugin; diff --git a/ScreenPlay/main.cpp b/ScreenPlay/main.cpp index 2808d062..012ccea0 100644 --- a/ScreenPlay/main.cpp +++ b/ScreenPlay/main.cpp @@ -36,9 +36,7 @@ #include #include #include -#ifdef Q_OS_WIN #include -#endif #define DOCTEST_CONFIG_IMPLEMENT #define DOCTEST_CONFIG_SUPER_FAST_ASSERTS #include @@ -67,13 +65,9 @@ int main(int argc, char* argv[]) if (app.m_isAnotherScreenPlayInstanceRunning) { return 0; } else { - app.init(); const int status = qtGuiApp.exec(); -#ifdef Q_OS_WIN sentry_shutdown(); -#endif - return status; } } diff --git a/ScreenPlay/src/util.cpp b/ScreenPlay/src/util.cpp index 6188326f..b9968c68 100644 --- a/ScreenPlay/src/util.cpp +++ b/ScreenPlay/src/util.cpp @@ -221,7 +221,6 @@ void Util::logToGui(QtMsgType type, const QMessageLogContext& context, const QSt if (utilPointer != nullptr) utilPointer->appendDebugMessages(log); -#ifdef Q_OS_WIN sentry_value_t crumb = sentry_value_new_breadcrumb("default", qUtf8Printable(msg)); @@ -239,7 +238,6 @@ void Util::logToGui(QtMsgType type, const QMessageLogContext& context, const QSt sentry_value_set_by_key(crumb, "data", location); sentry_add_breadcrumb(crumb); -#endif } /*! diff --git a/Tools/setup.py b/Tools/setup.py index b43e9b6c..99e1f53d 100644 --- a/Tools/setup.py +++ b/Tools/setup.py @@ -52,6 +52,7 @@ if __name__ == "__main__": vcpkg_triplet = "x64-windows" elif sys.platform == "darwin": vcpkg_packages_list.append("infoware[opencl]") + vcpkg_packages_list.append("curl") # Hidden dependency from sentry execute("chmod +x bootstrap-vcpkg.sh", vcpkg_path) execute("./bootstrap-vcpkg.sh", vcpkg_path, False) execute("chmod +x vcpkg", vcpkg_path) From 30d05aa5e9d9fea72d0b06a8691623704210be5e Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Thu, 17 Jun 2021 15:50:33 +0200 Subject: [PATCH 21/21] Fix sentry and ffmpeg --- ScreenPlay/app.cpp | 10 +--- ScreenPlay/src/createimportvideo.cpp | 48 ++++++++++++++----- ScreenPlay/src/settings.cpp | 13 ++++- .../inc/public/ScreenPlayUtil/util.h | 3 +- ScreenPlayUtil/src/util.cpp | 13 ++++- 5 files changed, 63 insertions(+), 24 deletions(-) diff --git a/ScreenPlay/app.cpp b/ScreenPlay/app.cpp index eea20dd8..20339a2c 100644 --- a/ScreenPlay/app.cpp +++ b/ScreenPlay/app.cpp @@ -158,14 +158,8 @@ void App::init() sentry_options_t* options = sentry_options_new(); sentry_options_set_dsn(options, "https://425ea0b77def4f91a5a9decc01b36ff4@o428218.ingest.sentry.io/5373419"); - - const QString appPath = QGuiApplication::applicationDirPath(); - QString exectuableFileEnding = ""; -#ifdef Q_OS_WIN - exectuableFileEnding = ".exe"; -#endif - sentry_options_set_handler_path(options, QString(appPath + "/crashpad_handler" + exectuableFileEnding).toStdString().c_str()); - sentry_options_set_database_path(options, appPath.toStdString().c_str()); + sentry_options_set_handler_path(options, QString(QGuiApplication::applicationDirPath() + "/crashpad_handler" + ScreenPlayUtil::executableBinEnding()).toStdString().c_str()); + sentry_options_set_database_path(options, QGuiApplication::applicationDirPath().toStdString().c_str()); const int sentryInitStatus = sentry_init(options); if (sentryInitStatus != 0) { qWarning() << "Unable to inti sentry crashhandler with statuscode: " << sentryInitStatus; diff --git a/ScreenPlay/src/createimportvideo.cpp b/ScreenPlay/src/createimportvideo.cpp index 0c60835d..2e0cb1ab 100644 --- a/ScreenPlay/src/createimportvideo.cpp +++ b/ScreenPlay/src/createimportvideo.cpp @@ -33,18 +33,19 @@ CreateImportVideo::CreateImportVideo(const QString& videoPath, const QString& ex : QObject(parent) , m_quality(quality) { - m_videoPath = videoPath; m_exportPath = exportPath; m_codec = codec; - m_process = std::make_unique(this); + m_ffprobeExecutable = QApplication::applicationDirPath() + "/ffprobe" + ScreenPlayUtil::executableBinEnding(); + m_ffmpegExecutable = QApplication::applicationDirPath() + "/ffmpeg" + ScreenPlayUtil::executableBinEnding(); - QString fileEnding ; -#ifdef Q_OS_WIN - fileEnding = ScreenPlayUtil::executableEnding(); -#endif - m_ffprobeExecutable = QApplication::applicationDirPath() + "/ffprobe" + fileEnding; - m_ffmpegExecutable = QApplication::applicationDirPath() + "/ffmpeg" + fileEnding ; + if (!QFileInfo::exists(m_ffprobeExecutable)) { + qFatal("FFPROBE executable not found!"); + } + + if (!QFileInfo::exists(m_ffmpegExecutable)) { + qFatal("FFMPEG executable not found!"); + } } /*! @@ -62,7 +63,7 @@ CreateImportVideo::CreateImportVideo(const QString& videoPath, const QString& ex void CreateImportVideo::process() { - qInfo() << "createWallpaperInfo()"; + qInfo() << "createWallpaperInfo()" << m_videoPath << m_exportPath << m_codec << m_ffmpegExecutable << m_ffprobeExecutable; if (!createWallpaperInfo() || QThread::currentThread()->isInterruptionRequested()) { emit abortAndCleanup(); return; @@ -268,7 +269,7 @@ bool CreateImportVideo::analyzeVideo(const QJsonObject& obj) QJsonObject videoStream; - for (const auto stream : arrayStream) { + for (const auto& stream : arrayStream) { QString codec_type = stream.toObject().value("codec_type").toString(); if (codec_type == "video") { videoStream = stream.toObject(); @@ -751,19 +752,42 @@ QString CreateImportVideo::waitForFinished( const Executable executable) { + m_process = std::make_unique(); + QObject::connect(m_process.get(), &QProcess::errorOccurred, [=](QProcess::ProcessError error) { + qDebug() << "error enum val = " << error << m_process->errorString(); + emit createWallpaperStateChanged(ImportVideoState::AnalyseVideoError); + m_process->terminate(); + if (!m_process->waitForFinished(1000)) { + m_process->kill(); + } + }); if (executable == Executable::FFMPEG) { m_process->setProgram(m_ffmpegExecutable); } else { m_process->setProgram(m_ffprobeExecutable); } + +#ifdef Q_OS_OSX + QProcess changeChmod; + changeChmod.setProgram("chmod"); + changeChmod.setArguments({ "+x", m_process->program() }); + changeChmod.start(); + if (!changeChmod.waitForFinished()) { + qCritical() << "Unable to change permission " << m_process->program() << " to be exectuable"; + } +#endif + m_process->setProcessChannelMode(processChannelMode); m_process->setArguments(args); + m_process->setWorkingDirectory(QApplication::applicationDirPath()); m_process->start(); - while (!m_process->waitForFinished(100)) //Wake up every 10ms and check if we must exit + qInfo() << m_process->workingDirectory() << m_process->program() << m_process->arguments(); + + while (!m_process->waitForFinished(10)) //Wake up every 10ms and check if we must exit { if (QThread::currentThread()->isInterruptionRequested()) { - qDebug() << "Interrupt thread"; + qInfo() << "Interrupt thread"; m_process->terminate(); if (!m_process->waitForFinished(1000)) { m_process->kill(); diff --git a/ScreenPlay/src/settings.cpp b/ScreenPlay/src/settings.cpp index 67315b9e..8f4c0472 100644 --- a/ScreenPlay/src/settings.cpp +++ b/ScreenPlay/src/settings.cpp @@ -1,6 +1,7 @@ #include "settings.h" #include "ScreenPlayUtil/util.h" +#include namespace ScreenPlay { @@ -140,8 +141,8 @@ void Settings::setupWidgetAndWindowPaths() { QDir workingDir(QGuiApplication::applicationDirPath()); #ifdef Q_OS_WIN - m_globalVariables->setWidgetExecutablePath(QUrl(workingDir.path() + "/ScreenPlayWidget" + ScreenPlayUtil::executableEnding())); - m_globalVariables->setWallpaperExecutablePath(QUrl(workingDir.path() + "/ScreenPlayWallpaper" + ScreenPlayUtil::executableEnding())); + m_globalVariables->setWidgetExecutablePath(QUrl(workingDir.path() + "/ScreenPlayWidget" + ScreenPlayUtil::executableBinEnding())); + m_globalVariables->setWallpaperExecutablePath(QUrl(workingDir.path() + "/ScreenPlayWallpaper" + ScreenPlayUtil::executableBinEnding())); #endif #ifdef Q_OS_OSX @@ -152,7 +153,15 @@ void Settings::setupWidgetAndWindowPaths() m_globalVariables->setWidgetExecutablePath(QUrl::fromUserInput(workingDir.path() + "/ScreenPlayWidget.app/Contents/MacOS/ScreenPlayWidget").toLocalFile()); m_globalVariables->setWallpaperExecutablePath(QUrl::fromUserInput(workingDir.path() + "/ScreenPlayWallpaper.app/Contents/MacOS/ScreenPlayWallpaper").toLocalFile()); + #endif + + if (!QFileInfo::exists(m_globalVariables->widgetExecutablePath().toString())) { + qFatal("widget executable not found!"); + } + if (!QFileInfo::exists(m_globalVariables->wallpaperExecutablePath().toString())) { + qFatal("wallpaper executable not found!"); + } } /*! diff --git a/ScreenPlayUtil/inc/public/ScreenPlayUtil/util.h b/ScreenPlayUtil/inc/public/ScreenPlayUtil/util.h index fcd691b2..bf9acc11 100644 --- a/ScreenPlayUtil/inc/public/ScreenPlayUtil/util.h +++ b/ScreenPlayUtil/inc/public/ScreenPlayUtil/util.h @@ -56,7 +56,8 @@ bool copyPreviewThumbnail(QJsonObject& obj, const QString& previewThumbnail, con QString toString(const QStringList& list); QString toLocal(const QString& url); QString generateRandomString(quint32 length = 32); -QString executableEnding(); +QString executableAppEnding(); +QString executableBinEnding(); QStringList getAvailableWallpaper(); QStringList getAvailableWidgets(); QStringList getAvailableTypes(); diff --git a/ScreenPlayUtil/src/util.cpp b/ScreenPlayUtil/src/util.cpp index 4df0b32c..5f92d39b 100644 --- a/ScreenPlayUtil/src/util.cpp +++ b/ScreenPlayUtil/src/util.cpp @@ -114,7 +114,18 @@ QString generateRandomString(quint32 length) /*! \brief Return .exe on windows otherwise empty string. */ -QString executableEnding() +QString executableBinEnding() +{ +#ifdef Q_OS_WIN + return ".exe"; +#endif + return ""; +} + +/*! + \brief Return .exe on windows, .app on osx otherwise empty string. +*/ +QString executableAppEnding() { #ifdef Q_OS_WIN return ".exe";