Make QGC Windows icons customizable

The QGC icon inside the app was already replaceable via the custom folder, however the QGC icon that was displayed on the Windows app bar, Windows installer, and windows shortcut icons was not able to be customized from the custom folder. This commit adds that capability.

Contribution Sponsor: Firestorm (launchfirestorm.com)
This commit is contained in:
Sam Gillam
2024-09-11 14:21:52 -04:00
committed by Don Gagne
parent 268638a177
commit 89a1c4bdc8
5 changed files with 39 additions and 6 deletions
+36 -3
View File
@@ -287,15 +287,48 @@ set_target_properties(${PROJECT_NAME}
)
if(WIN32)
set(app_icon_resource_windows "${CMAKE_SOURCE_DIR}/deploy/windows/QGroundControl.rc")
# windows installer files shared with core and custom
set(DEPLOY_WIN_FILES
"${CMAKE_SOURCE_DIR}/deploy/windows/driver.msi"
"${CMAKE_SOURCE_DIR}/deploy/windows/nullsoft_installer.nsi"
"${CMAKE_SOURCE_DIR}/deploy/windows/QGroundControl.rc"
"${CMAKE_SOURCE_DIR}/deploy/windows/resource.h"
)
# windows installer files different for core and custom
if(EXISTS ${CMAKE_SOURCE_DIR}/custom/deploy/windows/installheader.bmp)
list(APPEND DEPLOY_WIN_FILES ${CMAKE_SOURCE_DIR}/custom/deploy/windows/installheader.bmp)
else()
list(APPEND DEPLOY_WIN_FILES ${CMAKE_SOURCE_DIR}/deploy/windows/installheader.bmp)
endif()
if(EXISTS ${CMAKE_SOURCE_DIR}/custom/deploy/windows/WindowsQGC.ico)
list(APPEND DEPLOY_WIN_FILES ${CMAKE_SOURCE_DIR}/custom/deploy/windows/WindowsQGC.ico)
else()
list(APPEND DEPLOY_WIN_FILES ${CMAKE_SOURCE_DIR}/deploy/windows/WindowsQGC.ico)
endif()
# Destination directory where files will be copied
set(QGC_INSTALLER_SOURCE_WIN "${CMAKE_BINARY_DIR}/deploy/windows")
file(MAKE_DIRECTORY ${QGC_INSTALLER_SOURCE_WIN})
foreach(FILE ${DEPLOY_WIN_FILES})
# filename without the path
get_filename_component(FILE_NAME ${FILE} NAME)
# re-copy the file if it changes
add_custom_command(
OUTPUT "${QGC_INSTALLER_SOURCE_WIN}/${FILE_NAME}"
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${FILE}" "${QGC_INSTALLER_SOURCE_WIN}/${FILE_NAME}"
DEPENDS "${FILE}" # Depend on the source file so that it re-copies when it changes
)
list(APPEND QGC_INSTALLER_SOURCE_WIN_FILES "${QGC_INSTALLER_SOURCE_WIN}/${FILE_NAME}")
endforeach()
target_sources(${PROJECT_NAME}
PRIVATE
${app_icon_resource_windows}
${QGC_INSTALLER_SOURCE_WIN_FILES}
)
set_target_properties(${PROJECT_NAME}
PROPERTIES
WIN32_EXECUTABLE TRUE
QT_TARGET_RC_ICONS "${CMAKE_SOURCE_DIR}/deploy/windows/WindowsQGC.ico"
QT_TARGET_RC_ICONS "${CMAKE_BINARY_DIR}/deploy/windows/WindowsQGC.ico"
)
add_compile_definitions(_USE_MATH_DEFINES)
elseif(MACOS)
+1 -1
View File
@@ -2,7 +2,7 @@ include(CreateCPackCommon)
set(CPACK_GENERATOR "NSIS")
set(QGC_INSTALLER_SOURCE "${CMAKE_SOURCE_DIR}/deploy/windows")
set(QGC_INSTALLER_SOURCE "${CMAKE_BINARY_DIR}/deploy/windows")
set(CPACK_NSIS_INSTALL_ROOT "C:\\\\Program Files")
set(CPACK_NSIS_MUI_ICON "${QGC_INSTALLER_SOURCE}/WindowsQGC.ico")
+2 -2
View File
@@ -2,8 +2,8 @@ message(STATUS "Creating Win Installer")
include(CMakePrintHelpers)
# cmake_path(CONVERT "${CMAKE_CURRENT_LIST_DIR}/../deploy/windows" TO_CMAKE_PATH_LIST QGC_INSTALLER_SOURCE)
file(TO_NATIVE_PATH "${CMAKE_CURRENT_LIST_DIR}/../deploy/windows" QGC_INSTALLER_SOURCE)
# cmake_path(CONVERT "${CMAKE_BINARY_DIR}/../deploy/windows" TO_CMAKE_PATH_LIST QGC_INSTALLER_SOURCE)
file(TO_NATIVE_PATH "${CMAKE_BINARY_DIR}/deploy/windows" QGC_INSTALLER_SOURCE)
file(TO_NATIVE_PATH "${QGC_INSTALLER_SOURCE}/WindowsQGC.ico" QGC_INSTALLER_ICON)
file(TO_NATIVE_PATH "${QGC_INSTALLER_SOURCE}/installheader.bmp" QGC_INSTALLER_HEADER_BITMAP)
file(TO_NATIVE_PATH "${QGC_INSTALLER_SOURCE}/driver.msi" QGC_INSTALLER_DRIVER_MSI)
Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB