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 <zephyron@citron-emu.org>
This commit is contained in:
Zephyron
2026-02-01 14:13:51 +10:00
parent 5c5baf69e2
commit 6a9c5f39e4
3 changed files with 14 additions and 3 deletions

View File

@@ -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()

View File

@@ -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

View File

@@ -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));