From 6a9c5f39e4069efaedaf02710aa118f4376b7376 Mon Sep 17 00:00:00 2001 From: Zephyron Date: Sun, 1 Feb 2026 14:13:51 +1000 Subject: [PATCH] fix(ui): Add SVG support and fallback icons for Surprise Me button Added Qt6::Svg to CMake configuration and implemented fallback icon chain. Signed-off-by: Zephyron --- CMakeLists.txt | 2 +- src/citron/CMakeLists.txt | 2 +- src/citron/game_list.cpp | 13 ++++++++++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 19fd208d3..aee1130fa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -567,7 +567,7 @@ endif() function(set_citron_qt_components) # Best practice is to ask for all components at once, so they are from the same version -set(CITRON_QT_COMPONENTS2 Core Widgets Concurrent) +set(CITRON_QT_COMPONENTS2 Core Widgets Concurrent Svg) if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") list(APPEND CITRON_QT_COMPONENTS2 DBus GuiPrivate) endif() diff --git a/src/citron/CMakeLists.txt b/src/citron/CMakeLists.txt index b8690a436..cb028c618 100644 --- a/src/citron/CMakeLists.txt +++ b/src/citron/CMakeLists.txt @@ -457,7 +457,7 @@ else() target_link_libraries(citron PRIVATE common core input_common frontend_common network video_core) endif() -target_link_libraries(citron PRIVATE Boost::headers glad Qt6::Widgets Qt6::Network) +target_link_libraries(citron PRIVATE Boost::headers glad Qt6::Widgets Qt6::Network Qt6::Svg) target_link_libraries(citron PRIVATE ${PLATFORM_LIBRARIES} Threads::Threads) # Add libarchive for updater functionality diff --git a/src/citron/game_list.cpp b/src/citron/game_list.cpp index 1c01e4111..6320ad473 100644 --- a/src/citron/game_list.cpp +++ b/src/citron/game_list.cpp @@ -892,7 +892,18 @@ play_time_manager{play_time_manager_}, system{system_} { // Surprise Me button - positioned after sort button btn_surprise_me = new QToolButton(toolbar); - btn_surprise_me->setIcon(QIcon(QStringLiteral(":/dist/dice.svg"))); + QIcon surprise_icon(QStringLiteral(":/dist/dice.svg")); + if (surprise_icon.isNull() || surprise_icon.availableSizes().isEmpty()) { + // Fallback to theme icon or standard icon on Windows where SVG may not load + surprise_icon = QIcon::fromTheme(QStringLiteral("media-playlist-shuffle")); + if (surprise_icon.isNull()) { + surprise_icon = QIcon::fromTheme(QStringLiteral("roll")); + } + if (surprise_icon.isNull()) { + surprise_icon = style()->standardIcon(QStyle::SP_BrowserReload); + } + } + btn_surprise_me->setIcon(surprise_icon); btn_surprise_me->setToolTip(tr("Surprise Me! (Choose Random Game)")); btn_surprise_me->setAutoRaise(true); btn_surprise_me->setIconSize(QSize(16, 16));