diff --git a/tools/chatgui/CMakeLists.txt b/tools/chatgui/CMakeLists.txt index 5b5a9f4b..cff46f16 100644 --- a/tools/chatgui/CMakeLists.txt +++ b/tools/chatgui/CMakeLists.txt @@ -136,15 +136,20 @@ target_include_directories(chatgui_stream_publish PRIVATE ${FFMPEG_INCLUDE_DIRS} if(FFMPEG_FOUND) target_compile_definitions(chatgui_stream_publish PRIVATE HAVE_FFMPEG) endif() +set(GUI_CAPTURE_ENABLED 0) if(QT_PACKAGE STREQUAL "Qt6" AND FFMPEG_FOUND) + set(GUI_BASE_QT6_FOUND ${Qt6_FOUND}) find_package(Qt6 6.6 COMPONENTS Multimedia MultimediaWidgets QUIET) + set(Qt6_FOUND ${GUI_BASE_QT6_FOUND}) if(TARGET Qt6::Multimedia AND TARGET Qt6::MultimediaWidgets) target_compile_definitions(chatgui_stream_publish PUBLIC HAVE_STREAM_CAPTURE) target_link_libraries(chatgui_stream_publish PUBLIC Qt6::Multimedia Qt6::MultimediaWidgets) + set(GUI_CAPTURE_ENABLED 1) else() message(STATUS "Qt Multimedia 6.6+ missing: stream publication unavailable") endif() endif() +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/chatgui_capture_enabled.txt" "${GUI_CAPTURE_ENABLED}\n") add_library(chatgui_notifications STATIC src/message_notification.cpp src/user_activity_monitor.cpp) target_link_libraries(chatgui_notifications PUBLIC ${QT_PACKAGE}::Widgets PRIVATE utun) diff --git a/tools/chatgui/build.sh b/tools/chatgui/build.sh index d6d62827..7cbb9618 100755 --- a/tools/chatgui/build.sh +++ b/tools/chatgui/build.sh @@ -87,6 +87,12 @@ case "$QT_PACKAGE" in *) log " ERROR: invalid configured Qt package: $QT_PACKAGE"; exit 1 ;; esac log " Runtime package: $QT_PACKAGE" +QT_COMPONENTS=(Core Gui Network Widgets) +QT_PLUGINS=(platforms/qwindows.dll imageformats/qjpeg.dll imageformats/qwebp.dll) +if [ -f "$BUILD_DIR/chatgui_capture_enabled.txt" ] && [ "$(tr -d '\r\n' < "$BUILD_DIR/chatgui_capture_enabled.txt")" = 1 ]; then + QT_COMPONENTS+=(Multimedia MultimediaWidgets) + QT_PLUGINS+=(multimedia/ffmpegmediaplugin.dll) +fi MAIN_DLLS=( "Qt${QT_MAJOR}Core.dll" "Qt${QT_MAJOR}Gui.dll" "Qt${QT_MAJOR}Network.dll" "Qt${QT_MAJOR}Widgets.dll" "platforms/qwindows.dll" "imageformats/qjpeg.dll" "imageformats/qwebp.dll" @@ -95,6 +101,8 @@ MAIN_DLLS=( if [ -d "$FFMPEG_BIN" ]; then MAIN_DLLS+=("avcodec-*.dll" "avformat-*.dll" "avutil-*.dll" "swscale-*.dll" "swresample-*.dll") fi +for component in "${QT_COMPONENTS[@]}"; do MAIN_DLLS+=("Qt${QT_MAJOR}${component}.dll"); done +MAIN_DLLS+=("${QT_PLUGINS[@]}") DLLS_PRESENT=1 for d in "${MAIN_DLLS[@]}"; do if ! compgen -G "$BUILD_DIR/$d" >/dev/null; then @@ -126,11 +134,11 @@ done fi # Основные Qt DLL и динамические плагины всегда берём из выбранного комплекта. - for component in Core Gui Network Widgets; do + for component in "${QT_COMPONENTS[@]}"; do qt_dll="Qt${QT_MAJOR}${component}.dll" cp "$RUNTIME_PREFIX/bin/$qt_dll" "$BUILD_DIR/" || { log " ERROR: cannot deploy $qt_dll from $RUNTIME_PREFIX/bin"; exit 1; } done - for plugin in platforms/qwindows.dll imageformats/qjpeg.dll imageformats/qwebp.dll; do + for plugin in "${QT_PLUGINS[@]}"; do plugin_source="" for dir in "$RUNTIME_PREFIX/share/qt${QT_MAJOR}/plugins" "$RUNTIME_PREFIX/lib/qt${QT_MAJOR}/plugins"; do [ -f "$dir/$plugin" ] && { plugin_source="$dir/$plugin"; break; } diff --git a/tools/chatgui/package_win.sh b/tools/chatgui/package_win.sh index 5e3d20b0..9a92bb3b 100644 --- a/tools/chatgui/package_win.sh +++ b/tools/chatgui/package_win.sh @@ -45,8 +45,12 @@ APP_VERSION=$(tr -d '\r\n' < "$BUILD_DIR/chatgui_version.txt") [[ "$APP_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || { echo "ERROR: invalid application version: $APP_VERSION" >&2; exit 1; } QT_PACKAGE=$(tr -d '\r\n' < "$BUILD_DIR/chatgui_qt_package.txt") [[ "$QT_PACKAGE" = Qt5 || "$QT_PACKAGE" = Qt6 ]] || { echo "ERROR: invalid Qt package: $QT_PACKAGE" >&2; exit 1; } +CAPTURE_RUNTIME=() +if [[ -f "$BUILD_DIR/chatgui_capture_enabled.txt" && "$(tr -d '\r\n' < "$BUILD_DIR/chatgui_capture_enabled.txt")" = 1 ]]; then + CAPTURE_RUNTIME=(Qt6Multimedia.dll Qt6MultimediaWidgets.dll multimedia/ffmpegmediaplugin.dll) +fi for file in "${QT_PACKAGE}Core.dll" "${QT_PACKAGE}Gui.dll" "${QT_PACKAGE}Network.dll" "${QT_PACKAGE}Widgets.dll" \ - librlottie.dll platforms/qwindows.dll imageformats/qjpeg.dll imageformats/qwebp.dll; do + librlottie.dll platforms/qwindows.dll imageformats/qjpeg.dll imageformats/qwebp.dll "${CAPTURE_RUNTIME[@]}"; do [[ -f "$BUILD_DIR/$file" ]] || { echo "ERROR: missing runtime file: $BUILD_DIR/$file" >&2; exit 1; } done @@ -67,6 +71,7 @@ source "$SRC_DIR/compiler_runtime.sh" declare -A LICENSE_PACKAGES=() declare -A INCLUDED=() FILES=(vibechat.exe platforms/qwindows.dll imageformats/qjpeg.dll imageformats/qwebp.dll) +FILES+=("${CAPTURE_RUNTIME[@]}") HAS_FFMPEG=0 for ((i = 0; i < ${#FILES[@]}; i++)); do relative=${FILES[i]} @@ -102,7 +107,7 @@ for ((i = 0; i < ${#FILES[@]}; i++)); do continue fi runtime_file="$RUNTIME_PREFIX/bin/$name" - if [[ "$file" = "$PACKAGE_DIR/platforms/"* || "$file" = "$PACKAGE_DIR/imageformats/"* ]]; then + if [[ "$file" = "$PACKAGE_DIR/platforms/"* || "$file" = "$PACKAGE_DIR/imageformats/"* || "$file" = "$PACKAGE_DIR/multimedia/"* ]]; then relative=${file#"$PACKAGE_DIR/"} runtime_file="$RUNTIME_PREFIX/share/qt${QT_PACKAGE#Qt}/plugins/$relative" [[ -f "$runtime_file" ]] || runtime_file="$RUNTIME_PREFIX/lib/qt${QT_PACKAGE#Qt}/plugins/$relative"