From 2852659e5832c2e6d69ca70d7af5dd2254f3e649 Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Fri, 12 Mar 2021 09:19:19 +0100 Subject: [PATCH] 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)