From 30420902278217c7d85fe217300d2b57d29ca2a6 Mon Sep 17 00:00:00 2001 From: OpenSauce04 Date: Wed, 23 Oct 2024 18:21:40 +0100 Subject: [PATCH] lime_qt: Fixed Qt resources (.qrc) not linking correctly after the change to a static library --- CMakeLists.txt | 5 ++++- .../colorful/{style.qrc => theme_colorful.qrc} | 0 .../{style.qrc => theme_colorful_dark.qrc} | 0 .../{style.qrc => theme_colorful_midnight_blue.qrc} | 0 .../default/{default.qrc => theme_default.qrc} | 0 .../qdarkstyle/{style.qrc => theme_qdarkstyle.qrc} | 0 ...style.qrc => theme_qdarkstyle_midnight_blue.qrc} | 0 src/lime_qt/lime_qt.cpp | 13 +++++++++++++ 8 files changed, 17 insertions(+), 1 deletion(-) rename dist/qt_themes/colorful/{style.qrc => theme_colorful.qrc} (100%) rename dist/qt_themes/colorful_dark/{style.qrc => theme_colorful_dark.qrc} (100%) rename dist/qt_themes/colorful_midnight_blue/{style.qrc => theme_colorful_midnight_blue.qrc} (100%) rename dist/qt_themes/default/{default.qrc => theme_default.qrc} (100%) rename dist/qt_themes/qdarkstyle/{style.qrc => theme_qdarkstyle.qrc} (100%) rename dist/qt_themes/qdarkstyle_midnight_blue/{style.qrc => theme_qdarkstyle_midnight_blue.qrc} (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2356fd3ee..e724bc4e6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -88,10 +88,13 @@ option(ENABLE_LTO "Enable link time optimization" ${DEFAULT_ENABLE_LTO}) option(LIME3DS_USE_PRECOMPILED_HEADERS "Use precompiled headers" ON) option(LIME3DS_WARNINGS_AS_ERRORS "Enable warnings as errors" ON) -# Pass ENABLE_QT and ENABLE_SDL2_FRONTEND to C++ land +# Pass the following values to C++ land if (ENABLE_QT) add_definitions(-DENABLE_QT) endif() +if (ENABLE_QT_TRANSLATION) + add_definitions(-DENABLE_QT_TRANSLATION) +endif() if (ENABLE_SDL2_FRONTEND) add_definitions(-DENABLE_SDL2_FRONTEND) endif() diff --git a/dist/qt_themes/colorful/style.qrc b/dist/qt_themes/colorful/theme_colorful.qrc similarity index 100% rename from dist/qt_themes/colorful/style.qrc rename to dist/qt_themes/colorful/theme_colorful.qrc diff --git a/dist/qt_themes/colorful_dark/style.qrc b/dist/qt_themes/colorful_dark/theme_colorful_dark.qrc similarity index 100% rename from dist/qt_themes/colorful_dark/style.qrc rename to dist/qt_themes/colorful_dark/theme_colorful_dark.qrc diff --git a/dist/qt_themes/colorful_midnight_blue/style.qrc b/dist/qt_themes/colorful_midnight_blue/theme_colorful_midnight_blue.qrc similarity index 100% rename from dist/qt_themes/colorful_midnight_blue/style.qrc rename to dist/qt_themes/colorful_midnight_blue/theme_colorful_midnight_blue.qrc diff --git a/dist/qt_themes/default/default.qrc b/dist/qt_themes/default/theme_default.qrc similarity index 100% rename from dist/qt_themes/default/default.qrc rename to dist/qt_themes/default/theme_default.qrc diff --git a/dist/qt_themes/qdarkstyle/style.qrc b/dist/qt_themes/qdarkstyle/theme_qdarkstyle.qrc similarity index 100% rename from dist/qt_themes/qdarkstyle/style.qrc rename to dist/qt_themes/qdarkstyle/theme_qdarkstyle.qrc diff --git a/dist/qt_themes/qdarkstyle_midnight_blue/style.qrc b/dist/qt_themes/qdarkstyle_midnight_blue/theme_qdarkstyle_midnight_blue.qrc similarity index 100% rename from dist/qt_themes/qdarkstyle_midnight_blue/style.qrc rename to dist/qt_themes/qdarkstyle_midnight_blue/theme_qdarkstyle_midnight_blue.qrc diff --git a/src/lime_qt/lime_qt.cpp b/src/lime_qt/lime_qt.cpp index 401c4a5be..52f3cf89c 100644 --- a/src/lime_qt/lime_qt.cpp +++ b/src/lime_qt/lime_qt.cpp @@ -3755,6 +3755,19 @@ void LaunchQtFrontend(int argc, char* argv[]) { QApplication app(argc, argv); + // Required when using .qrc resources from within a static library. + // See https://doc.qt.io/qt-5/resources.html#using-resources-in-a-library + Q_INIT_RESOURCE(compatibility_list); + Q_INIT_RESOURCE(theme_colorful); + Q_INIT_RESOURCE(theme_colorful_dark); + Q_INIT_RESOURCE(theme_colorful_midnight_blue); + Q_INIT_RESOURCE(theme_default); + Q_INIT_RESOURCE(theme_qdarkstyle); + Q_INIT_RESOURCE(theme_qdarkstyle_midnight_blue); +#ifdef ENABLE_QT_TRANSLATION + Q_INIT_RESOURCE(languages); +#endif + // Qt changes the locale and causes issues in float conversion using std::to_string() when // generating shaders setlocale(LC_ALL, "C");