diff --git a/CMakeLists.txt b/CMakeLists.txt index 3f0baa97f301e8863b5974e9070d1abca989859a..3fb265b36080197d7f6cab1ebae3fc59e20327c3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -819,12 +819,20 @@ else() "-framework Security" compression resolv - ) + ) + + set(APP_CONTAINER "${CMAKE_BINARY_DIR}/${PROJECT_NAME}.app/Contents") + + # ringtones. Copy the entire directory to the app bundle. + # daemon/ringtones -> Jami.app/Contents/Resources/ringtones + execute_process( + COMMAND ${CMAKE_COMMAND} -E copy_directory + ${DAEMON_DIR}/ringtones + ${APP_CONTAINER}/Resources/ringtones + ) # translations if(Qt${QT_VERSION_MAJOR}LinguistTools_FOUND) - set(APP_CONTAINER - "${CMAKE_BINARY_DIR}/${PROJECT_NAME}.app/Contents") file(GLOB TS_FILES ${PROJECT_SOURCE_DIR}/translations/*.ts) # Generate lproj folders. @@ -864,7 +872,6 @@ else() XCODE_ATTRIBUTE_ENABLE_HARDENED_RUNTIME TRUE) endif() if(DEPLOY) - message("Qt deploying in dir " ${QML_SRC_DIR}) execute_process(COMMAND "${CMAKE_PREFIX_PATH}/bin/macdeployqt" "${CMAKE_BINARY_DIR}/${PROJECT_NAME}.app" diff --git a/src/libclient/qtwrapper/instancemanager.cpp b/src/libclient/qtwrapper/instancemanager.cpp index da9dd021cd82ed2d00b3440ed1d09dedae454e0c..58983c189b9dfdf2f26cb2296ac88090d8381f4b 100644 --- a/src/libclient/qtwrapper/instancemanager.cpp +++ b/src/libclient/qtwrapper/instancemanager.cpp @@ -24,11 +24,27 @@ #ifdef ENABLE_VIDEO #include "videomanager.h" #endif // ENABLE_VIDEO +#include <QDir> static int ringFlags = 0; InstanceManagerInterface::InstanceManagerInterface(bool muteDaemon) { + // The following code is used to set the resource directory for libjami, and is required + // for the ringtones to work properly on platforms where the resource directory path is not + // fixed (e.g. macOS). +#if defined(Q_OS_WIN) + // On Windows, the resource directory is set to the application's directory. + libjami::setResourceDirPath(QCoreApplication::applicationDirPath().toStdString()); +#elif defined(Q_OS_MAC) + // On macOS, the resource directory is set to the application bundle's path + "/Resources". + // The application bundle's path is the application's directory. + QDir execDir(qApp->applicationDirPath()); // executable directory points to the app bundle + /Contents/MacOS/ + execDir.cdUp(); // navigate up to add resources to /Contents + auto resourceDir = execDir.absolutePath() + QDir::separator() + "Resources"; + libjami::setResourceDirPath(resourceDir.toStdString()); +#endif + using namespace std::placeholders; using std::bind;