diff --git a/CMakeLists.txt b/CMakeLists.txt index 206e4a2b3..08e697bc2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -399,7 +399,7 @@ if(USE_DISCORD_PRESENCE) # Check if the target directory exists before trying to patch if(EXISTS "${PATCH_TARGET_DIR}") execute_process( - COMMAND git apply -p0 --ignore-whitespace "${PATCH_FILE}" + COMMAND git apply --ignore-whitespace "${PATCH_FILE}" WORKING_DIRECTORY "${PATCH_TARGET_DIR}" RESULT_VARIABLE PATCH_RESULT OUTPUT_QUIET @@ -422,7 +422,7 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") if(EXISTS "${MCL_PATCH_TARGET_DIR}") execute_process( - COMMAND git apply -p0 --ignore-whitespace "${MCL_PATCH_FILE}" + COMMAND git apply --ignore-whitespace "${MCL_PATCH_FILE}" WORKING_DIRECTORY "${MCL_PATCH_TARGET_DIR}" RESULT_VARIABLE MCL_PATCH_RESULT OUTPUT_QUIET @@ -461,6 +461,30 @@ else() message(WARNING "Could not find stb_image.h to patch. It may not have been downloaded yet.") endif() +# Apply a patch to discord-rpc's CMakeLists.txt to suppress -Wclass-memaccess +message(STATUS "Applying custom patch to submodule's discord-rpc CMakeLists.txt...") + +# Define the path to the patch file and the target directory using unique names +set(DISCORD_RPC_PATCH_FILE "${CMAKE_CURRENT_SOURCE_DIR}/patches/discord-rpc-wclass-memaccess-fix.patch") +set(DISCORD_RPC_PATCH_TARGET_DIR "${CMAKE_CURRENT_SOURCE_DIR}/externals/discord-rpc") + +# Check if the target directory exists before trying to patch +if(EXISTS "${DISCORD_RPC_PATCH_TARGET_DIR}") + execute_process( + COMMAND git apply -p0 --ignore-whitespace "${DISCORD_RPC_PATCH_FILE}" + WORKING_DIRECTORY "${DISCORD_RPC_PATCH_TARGET_DIR}" + RESULT_VARIABLE PATCH_RESULT + OUTPUT_QUIET + ERROR_QUIET + ) + + if(NOT PATCH_RESULT EQUAL 0) + message(WARNING "Failed to apply discord-rpc CMakeLists.txt patch! This might be okay if it's already applied.") + endif() +else() + message(WARNING "Could not find discord-rpc directory to patch. It may not have been downloaded yet.") +endif() + if (ENABLE_QT) if (NOT USE_SYSTEM_QT) download_qt(6.7.3) diff --git a/patches/discord-rpc-wclass-memaccess-fix.patch b/patches/discord-rpc-wclass-memaccess-fix.patch new file mode 100644 index 000000000..e640611cf --- /dev/null +++ b/patches/discord-rpc-wclass-memaccess-fix.patch @@ -0,0 +1,18 @@ +diff --git CMakeLists.txt CMakeLists.txt +index 5dad9e9..972183d 100644 +--- CMakeLists.txt ++++ CMakeLists.txt +@@ -51,6 +51,13 @@ add_library(rapidjson STATIC IMPORTED ${RAPIDJSON}) + # add subdirs + + add_subdirectory(src) ++ ++# Suppress the -Wclass-memaccess warning from modern GCC/Clang in rapidjson. ++# This warning flags intentional, performance-oriented code in the library. ++if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") ++ target_compile_options(discord-rpc PRIVATE "-Wno-class-memaccess") ++endif() ++ + if (BUILD_EXAMPLES) + add_subdirectory(examples/send-presence) + endif(BUILD_EXAMPLES) diff --git a/src/citron/applets/qt_controller.cpp b/src/citron/applets/qt_controller.cpp index ab8a9cab2..97e96d90d 100644 --- a/src/citron/applets/qt_controller.cpp +++ b/src/citron/applets/qt_controller.cpp @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project +// SPDX-FileCopyrightText: Copyright 2025 citron Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #include @@ -184,7 +185,7 @@ QtControllerSelectorDialog::QtControllerSelectorDialog( CheckIfParametersMet(); }); - connect(connected_controller_checkboxes[i], &QCheckBox::stateChanged, [this, i](int state) { + connect(connected_controller_checkboxes[i], &QCheckBox::checkStateChanged, [this, i](Qt::CheckState state) { player_groupboxes[i]->setChecked(state == Qt::Checked); UpdateControllerIcon(i); UpdateControllerState(i); diff --git a/src/citron/bootmanager.cpp b/src/citron/bootmanager.cpp index 9f68f85bc..aedf3d660 100644 --- a/src/citron/bootmanager.cpp +++ b/src/citron/bootmanager.cpp @@ -998,7 +998,7 @@ void GRenderWindow::CaptureScreenshot(const QString& screenshot_path) { screenshot_image.bits(), [=, this](bool invert_y) { const std::string std_screenshot_path = screenshot_path.toStdString(); - if (screenshot_image.mirrored(false, invert_y).save(screenshot_path)) { + if ((invert_y ? screenshot_image.flipped(Qt::Vertical) : screenshot_image).save(screenshot_path)) { LOG_INFO(Frontend, "Screenshot saved to \"{}\"", std_screenshot_path); } else { LOG_ERROR(Frontend, "Failed to save screenshot to \"{}\"", std_screenshot_path); diff --git a/src/citron/configuration/configure_filesystem.cpp b/src/citron/configuration/configure_filesystem.cpp index 4b05562c7..a62c00201 100644 --- a/src/citron/configuration/configure_filesystem.cpp +++ b/src/citron/configuration/configure_filesystem.cpp @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project +// SPDX-FileCopyrightText: Copyright 2025 citron Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #include @@ -29,9 +30,9 @@ ConfigureFilesystem::ConfigureFilesystem(QWidget* parent) connect(ui->reset_game_list_cache, &QPushButton::pressed, this, &ConfigureFilesystem::ResetMetadata); - connect(ui->gamecard_inserted, &QCheckBox::stateChanged, this, + connect(ui->gamecard_inserted, &QCheckBox::checkStateChanged, this, &ConfigureFilesystem::UpdateEnabledControls); - connect(ui->gamecard_current_game, &QCheckBox::stateChanged, this, + connect(ui->gamecard_current_game, &QCheckBox::checkStateChanged, this, &ConfigureFilesystem::UpdateEnabledControls); } diff --git a/src/citron/configuration/configure_input.cpp b/src/citron/configuration/configure_input.cpp index 8b8850245..930bd88c4 100644 --- a/src/citron/configuration/configure_input.cpp +++ b/src/citron/configuration/configure_input.cpp @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: 2016 Citra Emulator Project +// SPDX-FileCopyrightText: 2025 citron Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #include @@ -121,7 +122,7 @@ void ConfigureInput::Initialize(InputCommon::InputSubsystem* input_subsystem, &ConfigureInput::UpdateAllInputDevices); connect(player_controllers[i], &ConfigureInputPlayer::RefreshInputProfiles, this, &ConfigureInput::UpdateAllInputProfiles, Qt::QueuedConnection); - connect(connected_controller_checkboxes[i], &QCheckBox::stateChanged, [this, i](int state) { + connect(connected_controller_checkboxes[i], &QCheckBox::checkStateChanged, [this, i](Qt::CheckState state) { // Keep activated controllers synced with the "Connected Controllers" checkboxes player_controllers[i]->ConnectPlayer(state == Qt::Checked); }); diff --git a/src/citron/configuration/configure_input_advanced.cpp b/src/citron/configuration/configure_input_advanced.cpp index 198719727..569a07232 100644 --- a/src/citron/configuration/configure_input_advanced.cpp +++ b/src/citron/configuration/configure_input_advanced.cpp @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project +// SPDX-FileCopyrightText: Copyright 2025 citron Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #include @@ -74,13 +75,13 @@ ConfigureInputAdvanced::ConfigureInputAdvanced(Core::HID::HIDCore& hid_core_, QW } } - connect(ui->mouse_enabled, &QCheckBox::stateChanged, this, + connect(ui->mouse_enabled, &QCheckBox::checkStateChanged, this, &ConfigureInputAdvanced::UpdateUIEnabled); - connect(ui->debug_enabled, &QCheckBox::stateChanged, this, + connect(ui->debug_enabled, &QCheckBox::checkStateChanged, this, &ConfigureInputAdvanced::UpdateUIEnabled); - connect(ui->touchscreen_enabled, &QCheckBox::stateChanged, this, + connect(ui->touchscreen_enabled, &QCheckBox::checkStateChanged, this, &ConfigureInputAdvanced::UpdateUIEnabled); - connect(ui->enable_ring_controller, &QCheckBox::stateChanged, this, + connect(ui->enable_ring_controller, &QCheckBox::checkStateChanged, this, &ConfigureInputAdvanced::UpdateUIEnabled); connect(ui->debug_configure, &QPushButton::clicked, this, diff --git a/src/citron/configuration/configure_system.cpp b/src/citron/configuration/configure_system.cpp index d50907fab..9693361af 100644 --- a/src/citron/configuration/configure_system.cpp +++ b/src/citron/configuration/configure_system.cpp @@ -85,7 +85,7 @@ ConfigureSystem::ConfigureSystem(Core::System& system_, connect(combo_language, qOverload(&QComboBox::currentIndexChanged), this, locale_check); connect(combo_region, qOverload(&QComboBox::currentIndexChanged), this, locale_check); - connect(checkbox_rtc, qOverload(&QCheckBox::stateChanged), this, update_rtc_date); + connect(checkbox_rtc, &QCheckBox::checkStateChanged, this, update_rtc_date); connect(date_rtc_offset, qOverload(&QSpinBox::valueChanged), this, update_rtc_date); connect(date_rtc, &QDateTimeEdit::dateTimeChanged, this, update_date_offset); diff --git a/src/citron/configuration/shared_widget.cpp b/src/citron/configuration/shared_widget.cpp index 34c50d31e..4d4048145 100644 --- a/src/citron/configuration/shared_widget.cpp +++ b/src/citron/configuration/shared_widget.cpp @@ -708,7 +708,7 @@ void Widget::SetupComponent(const QString& label, std::function& load_fu restore_func(); } }; - connect(checkbox, &QCheckBox::stateChanged, reset); + connect(checkbox, &QCheckBox::checkStateChanged, reset); reset(checkbox->checkState()); } } diff --git a/src/citron/main.cpp b/src/citron/main.cpp index 98dc841e6..e69d8b95d 100644 --- a/src/citron/main.cpp +++ b/src/citron/main.cpp @@ -5440,10 +5440,6 @@ static void SetHighDPIAttributes() { Qt::HighDpiScaleFactorRoundingPolicy::PassThrough); #endif - // Enable high DPI scaling and pixmaps - QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); - QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); - // Set the DPI awareness for better scaling on Windows #ifdef _WIN32 // Enable Per Monitor DPI Awareness for Windows 8.1+ diff --git a/src/common/string_util.cpp b/src/common/string_util.cpp index 1909aced5..155e3b49a 100644 --- a/src/common/string_util.cpp +++ b/src/common/string_util.cpp @@ -1,5 +1,6 @@ // SPDX-FileCopyrightText: 2013 Dolphin Emulator Project // SPDX-FileCopyrightText: 2014 Citra Emulator Project +// SPDX-FileCopyrightText: 2025 citron Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #include @@ -141,21 +142,63 @@ std::string ReplaceAll(std::string result, const std::string& src, const std::st return result; } +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable : 4996) // 'std::wstring_convert': was declared deprecated +#elif defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif + std::string UTF16ToUTF8(std::u16string_view input) { std::wstring_convert, char16_t> convert; return convert.to_bytes(input.data(), input.data() + input.size()); } +#if defined(_MSC_VER) +#pragma warning(pop) +#elif defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic pop +#endif + +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable : 4996) // 'std::wstring_convert': was declared deprecated +#elif defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif + std::u16string UTF8ToUTF16(std::string_view input) { std::wstring_convert, char16_t> convert; return convert.from_bytes(input.data(), input.data() + input.size()); } +#if defined(_MSC_VER) +#pragma warning(pop) +#elif defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic pop +#endif + +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable : 4996) // 'std::wstring_convert': was declared deprecated +#elif defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif + std::u32string UTF8ToUTF32(std::string_view input) { std::wstring_convert, char32_t> convert; return convert.from_bytes(input.data(), input.data() + input.size()); } +#if defined(_MSC_VER) +#pragma warning(pop) +#elif defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic pop +#endif + #ifdef _WIN32 static std::wstring CPToUTF16(u32 code_page, std::string_view input) { const auto size =