Fix Qt6 resource compilation so LogView icons are embedded at runtime

- QT5_ADD_RESOURCES was a no-op stub under Qt6, silently dropping .qrc
  files: LogView's :/image/* icons were never compiled into the binary.
  Map the stub onto qt6_add_resources() (outfiles-variable form, which
  appends the generated qrc_*.cpp to the source list). LogView is the
  only caller of the stub.
- nglwidgets' Qt6 branch only processed rme_light_style.qrc;
  nglresources.qrc (which provides :icons/16x16/* toolbar/window icons)
  was left as a raw file in the source list and never compiled
  (CMAKE_AUTORCC is off). Process both qrcs.
- LogView never loads libnglwidgets.so at runtime (--as-needed drops it:
  the code uses no nglwidgets symbols), so its :icons/16x16 resources
  were never registered for the app. Embed the 20 icons LogView actually
  uses directly into LogViewResources.qrc with explicit aliases (rcc
  rejects XML comments in .qrc and, without an alias, registers the full
  relative path as the resource name).
This commit is contained in:
berrux-dev committed 2026-11-03 13:31:02 +01:00
1 parent 0e2100f383
commit d130c55be5
3 files changed
+40 -7

No files matched your search

@@ -15,4 +15,26 @@
<file>image/ShowSend.png</file>
<file>image/Wls.png</file>
</qresource>
<qresource prefix="/icons/16x16">
<file alias="configure.png">../../Z/src/nglwidgets/icons/16x16/configure.png</file>
<file alias="dialog-ok-apply.png">../../Z/src/nglwidgets/icons/16x16/dialog-ok-apply.png</file>
<file alias="document-edit.png">../../Z/src/nglwidgets/icons/16x16/document-edit.png</file>
<file alias="document-import.png">../../Z/src/nglwidgets/icons/16x16/document-import.png</file>
<file alias="document-new.png">../../Z/src/nglwidgets/icons/16x16/document-new.png</file>
<file alias="document-open-data.png">../../Z/src/nglwidgets/icons/16x16/document-open-data.png</file>
<file alias="document-save.png">../../Z/src/nglwidgets/icons/16x16/document-save.png</file>
<file alias="edit-copy.png">../../Z/src/nglwidgets/icons/16x16/edit-copy.png</file>
<file alias="edit-delete.png">../../Z/src/nglwidgets/icons/16x16/edit-delete.png</file>
<file alias="edit-paste.png">../../Z/src/nglwidgets/icons/16x16/edit-paste.png</file>
<file alias="edit-redo.png">../../Z/src/nglwidgets/icons/16x16/edit-redo.png</file>
<file alias="go-down.png">../../Z/src/nglwidgets/icons/16x16/go-down.png</file>
<file alias="go-up.png">../../Z/src/nglwidgets/icons/16x16/go-up.png</file>
<file alias="list-add.png">../../Z/src/nglwidgets/icons/16x16/list-add.png</file>
<file alias="list-remove.png">../../Z/src/nglwidgets/icons/16x16/list-remove.png</file>
<file alias="mail-send.png">../../Z/src/nglwidgets/icons/16x16/mail-send.png</file>
<file alias="media-play-normal.png">../../Z/src/nglwidgets/icons/16x16/media-play-normal.png</file>
<file alias="media-playback-start.png">../../Z/src/nglwidgets/icons/16x16/media-playback-start.png</file>
<file alias="media-playback-stop.png">../../Z/src/nglwidgets/icons/16x16/media-playback-stop.png</file>
<file alias="rde_16x16.png">../../Z/src/nglwidgets/icons/16x16/rde_16x16.png</file>
</qresource>
</RCC>
@@ -83,11 +83,13 @@ NGL_WRAP_UI(nglwidgets_SRCS
)
# Collect big resource QRCs
set(oxygen_SRCS nglresources.qrc)
set(oxygen_SRCS)
if(TARGET Qt6::Core)
# Use Qt6's CMake helper to generate resource sources so resources are available at runtime
qt_add_resources(RME_LIGHT_RCC rme_light_style.qrc)
list(APPEND oxygen_SRCS ${RME_LIGHT_RCC})
# Use Qt6's CMake helper to generate resource sources so resources are available at runtime.
# Both qrcs MUST go through qt_add_resources: a raw .qrc left in the source list is not
# compiled (CMAKE_AUTORCC is off), so its resources would be missing at runtime
# (e.g. :icons/16x16/* toolbar/window icons used by LogView).
qt_add_resources(oxygen_SRCS nglresources.qrc rme_light_style.qrc)
else()
NGL_ADD_BIG_RESOURCES(oxygen_SRCS nglresources.qrc rme_light_style.qrc)
endif()
@@ -38,11 +38,20 @@ if(POLICY CMP0177)
cmake_policy(SET CMP0177 OLD)
endif()
# Compatibility stubs for Qt5 CMake macros when Qt6 is used.
# These stubs allow configure to succeed; actual resource/ui generation should be addressed during source migration.
# Compatibility stubs for Qt5 CMake macros when Qt6 is used (UI/CPP wrapping
# still no-op; resource handling is implemented below).
# QT5_ADD_RESOURCES maps onto Qt6's qt6_add_resources() in the outfiles-variable
# form: the generated qrc_<name>.cpp sources are appended to the given source
# list, so .qrc files are compiled into the targets that reference them
# (e.g. TetraIF/LogView). Without this the resources are silently dropped and
# ":/..." icons render empty at runtime.
if(NOT COMMAND QT5_ADD_RESOURCES)
macro(QT5_ADD_RESOURCES _out)
set(${_out} "" PARENT_SCOPE)
if(TARGET Qt6::Core)
qt6_add_resources(${_out} ${ARGN})
else()
message(WARNING "QT5_ADD_RESOURCES stub: Qt6::Core not found, skipping resources: ${ARGN}")
endif()
endmacro()
endif()
if(NOT COMMAND QT5_ADD_BIG_RESOURCES)