diff --git a/rpcs3/Crypto/unself.cpp b/rpcs3/Crypto/unself.cpp index 2d345349cd..19ecdaf56d 100644 --- a/rpcs3/Crypto/unself.cpp +++ b/rpcs3/Crypto/unself.cpp @@ -1,6 +1,5 @@ #include "stdafx.h" #include "aes.h" -#include "sha1.h" #include "utils.h" #include "unself.h" #include "Emu/VFS.h" diff --git a/rpcs3/Emu/Cell/Modules/cellSaveData.cpp b/rpcs3/Emu/Cell/Modules/cellSaveData.cpp index 92907e483a..d0247c017b 100644 --- a/rpcs3/Emu/Cell/Modules/cellSaveData.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSaveData.cpp @@ -16,7 +16,6 @@ #include "Utilities/StrUtil.h" #include "Utilities/span.h" -#include #include #include diff --git a/rpcs3/Emu/Cell/PPUThread.cpp b/rpcs3/Emu/Cell/PPUThread.cpp index c71a85d390..6769c0b801 100644 --- a/rpcs3/Emu/Cell/PPUThread.cpp +++ b/rpcs3/Emu/Cell/PPUThread.cpp @@ -21,7 +21,6 @@ #include "lv2/sys_prx.h" #include "lv2/sys_overlay.h" #include "lv2/sys_process.h" -#include "lv2/sys_memory.h" #ifdef LLVM_AVAILABLE #ifdef _MSC_VER @@ -37,28 +36,14 @@ #pragma GCC diagnostic ignored "-Wmissing-noreturn" #endif #include "llvm/Support/FormattedStream.h" -#include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Host.h" #include "llvm/Object/ObjectFile.h" #include "llvm/ADT/Triple.h" -#include "llvm/IR/LLVMContext.h" -//#include "llvm/IR/Dominators.h" #include "llvm/IR/Verifier.h" #include "llvm/IR/InstIterator.h" #include "llvm/IR/LegacyPassManager.h" -//#include "llvm/IR/Module.h" -//#include "llvm/IR/Function.h" -//#include "llvm/Analysis/Passes.h" -//#include "llvm/Analysis/BasicAliasAnalysis.h" -//#include "llvm/Analysis/TargetTransformInfo.h" -//#include "llvm/Analysis/MemoryDependenceAnalysis.h" -//#include "llvm/Analysis/LoopInfo.h" -//#include "llvm/Analysis/ScalarEvolution.h" -#include "llvm/Analysis/Lint.h" #include "llvm/Transforms/Utils/BasicBlockUtils.h" #include "llvm/Transforms/Scalar.h" -#include "llvm/Transforms/IPO.h" -#include "llvm/Transforms/Vectorize.h" #ifdef _MSC_VER #pragma warning(pop) #else @@ -3014,7 +2999,7 @@ bool ppu_initialize(const ppu_module& info, bool check_only) // Create worker threads for compilation (TODO: how many threads) { - u32 thread_count = Emu.GetMaxThreads(); + u32 thread_count = Emulator::GetMaxThreads(); if (workload.size() < thread_count) { diff --git a/rpcs3/Emu/Cell/SPURecompiler.cpp b/rpcs3/Emu/Cell/SPURecompiler.cpp index 27807f6f22..906212caa7 100644 --- a/rpcs3/Emu/Cell/SPURecompiler.cpp +++ b/rpcs3/Emu/Cell/SPURecompiler.cpp @@ -425,7 +425,7 @@ void spu_cache::initialize() g_progr_ptotal += ::size32(func_list); progr.emplace("Building SPU cache..."); - worker_count = Emu.GetMaxThreads(); + worker_count = Emulator::GetMaxThreads(); } named_thread_group workers("SPU Worker ", worker_count, [&]() -> uint diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index 423521eb2e..2dd5ab992f 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -7,19 +7,14 @@ #include "Emu/Cell/ErrorCodes.h" #include "Emu/Cell/PPUThread.h" -#include "Emu/Cell/PPUCallback.h" -#include "Emu/Cell/PPUOpcodes.h" #include "Emu/Cell/PPUDisAsm.h" #include "Emu/Cell/PPUAnalyser.h" #include "Emu/Cell/SPUThread.h" -#include "Emu/Cell/RawSPUThread.h" #include "Emu/RSX/RSXThread.h" #include "Emu/Cell/lv2/sys_process.h" -#include "Emu/Cell/lv2/sys_memory.h" #include "Emu/Cell/lv2/sys_sync.h" #include "Emu/Cell/lv2/sys_prx.h" #include "Emu/Cell/lv2/sys_overlay.h" -#include "Emu/Cell/lv2/sys_rsx.h" #include "Emu/Cell/Modules/cellMsgDialog.h" #include "Emu/title.h" @@ -40,7 +35,6 @@ #include "util/cereal.hpp" #include -#include #include #include #include @@ -558,7 +552,7 @@ void Emulator::SetUsr(const std::string& user) std::string Emulator::GetBackgroundPicturePath() const { // Try to find a custom icon first - std::string path = fs::get_config_dir() + "/Icons/game_icons/" + Emu.GetTitleID() + "/PIC1.PNG"; + std::string path = fs::get_config_dir() + "/Icons/game_icons/" + GetTitleID() + "/PIC1.PNG"; if (fs::is_file(path)) { @@ -646,8 +640,8 @@ bool Emulator::BootRsxCapture(const std::string& path) m_state = system_state::ready; GetCallbacks().on_ready(); - Emu.GetCallbacks().init_gs_render(); - Emu.GetCallbacks().init_pad_handler(""); + GetCallbacks().init_gs_render(); + GetCallbacks().init_pad_handler(""); GetCallbacks().on_run(false); m_state = system_state::running; @@ -661,7 +655,7 @@ bool Emulator::BootRsxCapture(const std::string& path) void Emulator::LimitCacheSize() { - const std::string cache_location = Emulator::GetHdd1Dir() + "/caches"; + const std::string cache_location = GetHdd1Dir() + "/caches"; if (!fs::is_dir(cache_location)) { @@ -877,7 +871,7 @@ std::string Emulator::GetExeDir() } #endif -std::string Emulator::GetSfoDirFromGamePath(const std::string& game_path, const std::string& user, const std::string& title_id) +std::string Emulator::GetSfoDirFromGamePath(const std::string& game_path, const std::string& title_id) { if (fs::is_file(game_path + "/PS3_DISC.SFB")) { @@ -1042,7 +1036,7 @@ game_boot_result Emulator::Load(const std::string& title_id, bool add_only, bool if (fs::is_dir(m_path)) { // Special case (directory scan) - m_sfo_dir = GetSfoDirFromGamePath(m_path, GetUsr(), m_title_id); + m_sfo_dir = GetSfoDirFromGamePath(m_path, m_title_id); } else if (!disc.empty()) { @@ -1057,12 +1051,12 @@ game_boot_result Emulator::Load(const std::string& title_id, bool add_only, bool } else { - m_sfo_dir = GetSfoDirFromGamePath(disc, GetUsr(), m_title_id); + m_sfo_dir = GetSfoDirFromGamePath(disc, m_title_id); } } else { - m_sfo_dir = GetSfoDirFromGamePath(elf_dir + "/../", GetUsr(), m_title_id); + m_sfo_dir = GetSfoDirFromGamePath(elf_dir + "/../", m_title_id); } _psf = psf::load_object(fs::file(m_sfo_dir + "/PARAM.SFO")); @@ -1268,7 +1262,7 @@ game_boot_result Emulator::Load(const std::string& title_id, bool add_only, bool ensure(vm::falloc(0x10000, 0xf0000, vm::main)); } - if (Emu.IsStopped()) + if (IsStopped()) { return; } @@ -1276,7 +1270,7 @@ game_boot_result Emulator::Load(const std::string& title_id, bool add_only, bool ppu_precompile(dir_queue, nullptr); // Exit "process" - Emu.CallAfter([] + CallAfter([] { Emu.SetForceBoot(true); Emu.Stop(); @@ -1336,11 +1330,9 @@ game_boot_result Emulator::Load(const std::string& title_id, bool add_only, bool sys_log.success("Disc game %s moved to special location /dev_hdd0/disc/", m_title_id); return m_path = hdd0_disc + m_path.substr(hdd0_game.size()), Load(m_title_id, add_only, force_global_config); } - else - { - sys_log.error("Failed to move disc game %s to /dev_hdd0/disc/ (%s)", m_title_id, fs::g_tls_error); - return game_boot_result::wrong_disc_location; - } + + sys_log.error("Failed to move disc game %s to /dev_hdd0/disc/ (%s)", m_title_id, fs::g_tls_error); + return game_boot_result::wrong_disc_location; } bdvd_dir = sfb_dir + "/"; @@ -1739,10 +1731,10 @@ game_boot_result Emulator::Load(const std::string& title_id, bool add_only, bool ConfigurePPUCache(); g_fxo->init(false); - Emu.GetCallbacks().init_gs_render(); - Emu.GetCallbacks().init_pad_handler(m_title_id); - Emu.GetCallbacks().init_kb_handler(); - Emu.GetCallbacks().init_mouse_handler(); + GetCallbacks().init_gs_render(); + GetCallbacks().init_pad_handler(m_title_id); + GetCallbacks().init_kb_handler(); + GetCallbacks().init_mouse_handler(); } // Overlay (OVL) executable (only load it) else if (vm::map(0x3000'0000, 0x1000'0000, 0x200); !ppu_load_overlay(ppu_exec, m_path).first) @@ -2140,7 +2132,7 @@ std::string Emulator::GetFormattedTitle(double fps) const return rpcs3::get_formatted_title(title_data); } -u32 Emulator::GetMaxThreads() const +u32 Emulator::GetMaxThreads() { const u32 max_threads = static_cast(g_cfg.core.llvm_threads); const u32 hw_threads = utils::get_thread_count(); @@ -2239,7 +2231,7 @@ void Emulator::ConfigurePPUCache() if (!m_title_id.empty() && m_cat != "1P") { - _main.cache += Emu.GetTitleID(); + _main.cache += GetTitleID(); _main.cache += '/'; } diff --git a/rpcs3/Emu/System.h b/rpcs3/Emu/System.h index a8beec82b6..dc3927523f 100644 --- a/rpcs3/Emu/System.h +++ b/rpcs3/Emu/System.h @@ -220,7 +220,7 @@ public: game_boot_result BootGame(const std::string& path, const std::string& title_id = "", bool direct = false, bool add_only = false, bool force_global_config = false); bool BootRsxCapture(const std::string& path); - bool InstallPkg(const std::string& path); + static bool InstallPkg(const std::string& path); #ifdef _WIN32 static std::string GetExeDir(); @@ -230,7 +230,7 @@ public: static std::string GetHddDir(); static std::string GetHdd1Dir(); static std::string GetCacheDir(); - static std::string GetSfoDirFromGamePath(const std::string& game_path, const std::string& user, const std::string& title_id = ""); + static std::string GetSfoDirFromGamePath(const std::string& game_path, const std::string& title_id = ""); static std::string GetRapFilePath(const std::string& rap); static std::string GetCustomConfigDir(); @@ -264,15 +264,15 @@ public: std::string GetFormattedTitle(double fps) const; - u32 GetMaxThreads() const; + static u32 GetMaxThreads(); - void ConfigureLogs(); + static void ConfigureLogs(); void ConfigurePPUCache(); std::set GetGameDirs() const; private: - void LimitCacheSize(); + static void LimitCacheSize(); }; extern Emulator Emu; diff --git a/rpcs3/Input/basic_keyboard_handler.cpp b/rpcs3/Input/basic_keyboard_handler.cpp index c35adb89aa..6c5f35117e 100644 --- a/rpcs3/Input/basic_keyboard_handler.cpp +++ b/rpcs3/Input/basic_keyboard_handler.cpp @@ -15,7 +15,7 @@ void basic_keyboard_handler::Init(const u32 max_connect) { for (u32 i = 0; i < max_connect; i++) { - Keyboard kb = Keyboard(); + Keyboard kb; kb.m_config.arrange = g_cfg.sys.keyboard_type; @@ -51,24 +51,24 @@ void basic_keyboard_handler::SetTargetWindow(QWindow* target) } } -bool basic_keyboard_handler::eventFilter(QObject* target, QEvent* ev) +bool basic_keyboard_handler::eventFilter(QObject* watched, QEvent* event) { - if (!ev || input::g_intercepted) + if (!event || input::g_intercepted) { return false; } // !m_target is for future proofing when gsrender isn't automatically initialized on load. // !m_target->isVisible() is a hack since currently a guiless application will STILL inititialize a gsrender (providing a valid target) - if (!m_target || !m_target->isVisible() || target == m_target) + if (!m_target || !m_target->isVisible() || watched == m_target) { - if (ev->type() == QEvent::KeyPress) + if (event->type() == QEvent::KeyPress) { - keyPressEvent(static_cast(ev)); + keyPressEvent(static_cast(event)); } - else if (ev->type() == QEvent::KeyRelease) + else if (event->type() == QEvent::KeyRelease) { - keyReleaseEvent(static_cast(ev)); + keyReleaseEvent(static_cast(event)); } } return false; @@ -137,7 +137,7 @@ s32 basic_keyboard_handler::getUnmodifiedKey(QKeyEvent* keyEvent) #ifdef _WIN32 if (keyEvent->modifiers() != Qt::NoModifier && !keyEvent->text().isEmpty()) { - u32 mapped_key = (u32)MapVirtualKeyA((UINT)keyEvent->nativeVirtualKey(), MAPVK_VK_TO_CHAR); + u32 mapped_key = static_cast(MapVirtualKeyA(static_cast(keyEvent->nativeVirtualKey()), MAPVK_VK_TO_CHAR)); if (raw_key != mapped_key) { diff --git a/rpcs3/Input/basic_keyboard_handler.h b/rpcs3/Input/basic_keyboard_handler.h index 232a4abebc..52d0608bce 100644 --- a/rpcs3/Input/basic_keyboard_handler.h +++ b/rpcs3/Input/basic_keyboard_handler.h @@ -9,15 +9,15 @@ class basic_keyboard_handler final : public KeyboardHandlerBase, public QObject { public: - virtual void Init(const u32 max_connect) override; + void Init(const u32 max_connect) override; explicit basic_keyboard_handler(); void SetTargetWindow(QWindow* target); - bool eventFilter(QObject* obj, QEvent* ev) override; + bool eventFilter(QObject* watched, QEvent* event) override; void keyPressEvent(QKeyEvent* event); void keyReleaseEvent(QKeyEvent* event); - s32 getUnmodifiedKey(QKeyEvent* event); + static s32 getUnmodifiedKey(QKeyEvent* event); void LoadSettings(); private: QWindow* m_target = nullptr; diff --git a/rpcs3/Input/basic_mouse_handler.cpp b/rpcs3/Input/basic_mouse_handler.cpp index c640ee1675..e6a11a7736 100644 --- a/rpcs3/Input/basic_mouse_handler.cpp +++ b/rpcs3/Input/basic_mouse_handler.cpp @@ -82,16 +82,16 @@ bool basic_mouse_handler::eventFilter(QObject* target, QEvent* ev) void basic_mouse_handler::MouseButtonDown(QMouseEvent* event) { - if (event->button() == Qt::LeftButton) MouseHandlerBase::Button(CELL_MOUSE_BUTTON_1, 1); - else if (event->button() == Qt::RightButton) MouseHandlerBase::Button(CELL_MOUSE_BUTTON_2, 1); - else if (event->button() == Qt::MiddleButton) MouseHandlerBase::Button(CELL_MOUSE_BUTTON_3, 1); + if (event->button() == Qt::LeftButton) MouseHandlerBase::Button(CELL_MOUSE_BUTTON_1, true); + else if (event->button() == Qt::RightButton) MouseHandlerBase::Button(CELL_MOUSE_BUTTON_2, true); + else if (event->button() == Qt::MiddleButton) MouseHandlerBase::Button(CELL_MOUSE_BUTTON_3, true); } void basic_mouse_handler::MouseButtonUp(QMouseEvent* event) { - if (event->button() == Qt::LeftButton) MouseHandlerBase::Button(CELL_MOUSE_BUTTON_1, 0); - else if (event->button() == Qt::RightButton) MouseHandlerBase::Button(CELL_MOUSE_BUTTON_2, 0); - else if (event->button() == Qt::MiddleButton) MouseHandlerBase::Button(CELL_MOUSE_BUTTON_3, 0); + if (event->button() == Qt::LeftButton) MouseHandlerBase::Button(CELL_MOUSE_BUTTON_1, false); + else if (event->button() == Qt::RightButton) MouseHandlerBase::Button(CELL_MOUSE_BUTTON_2, false); + else if (event->button() == Qt::MiddleButton) MouseHandlerBase::Button(CELL_MOUSE_BUTTON_3, false); } void basic_mouse_handler::MouseScroll(QWheelEvent* event) @@ -99,7 +99,7 @@ void basic_mouse_handler::MouseScroll(QWheelEvent* event) MouseHandlerBase::Scroll(event->angleDelta().y()); } -bool basic_mouse_handler::get_mouse_lock_state() +bool basic_mouse_handler::get_mouse_lock_state() const { if (auto game_frame = dynamic_cast(m_target)) return game_frame->get_mouse_lock_state(); diff --git a/rpcs3/Input/basic_mouse_handler.h b/rpcs3/Input/basic_mouse_handler.h index 79cf1bd005..9dbd169a04 100644 --- a/rpcs3/Input/basic_mouse_handler.h +++ b/rpcs3/Input/basic_mouse_handler.h @@ -10,7 +10,7 @@ class basic_mouse_handler final : public MouseHandlerBase, public QObject { public: - virtual void Init(const u32 max_connect) override; + void Init(const u32 max_connect) override; basic_mouse_handler(); @@ -23,5 +23,5 @@ public: bool eventFilter(QObject* obj, QEvent* ev) override; private: QWindow* m_target = nullptr; - bool get_mouse_lock_state(); + bool get_mouse_lock_state() const; }; diff --git a/rpcs3/Input/ds3_pad_handler.cpp b/rpcs3/Input/ds3_pad_handler.cpp index fd3e029bbc..a740bf3866 100644 --- a/rpcs3/Input/ds3_pad_handler.cpp +++ b/rpcs3/Input/ds3_pad_handler.cpp @@ -109,7 +109,7 @@ ds3_pad_handler::~ds3_pad_handler() u32 ds3_pad_handler::get_battery_level(const std::string& padId) { - std::shared_ptr device = get_hid_device(padId); + const std::shared_ptr device = get_hid_device(padId); if (!device || !device->hidDevice) { return 0; diff --git a/rpcs3/Input/ds4_pad_handler.cpp b/rpcs3/Input/ds4_pad_handler.cpp index 2c2673f1eb..044a8c45f2 100644 --- a/rpcs3/Input/ds4_pad_handler.cpp +++ b/rpcs3/Input/ds4_pad_handler.cpp @@ -186,7 +186,7 @@ void ds4_pad_handler::init_config(pad_config* cfg, const std::string& name) u32 ds4_pad_handler::get_battery_level(const std::string& padId) { - std::shared_ptr device = get_hid_device(padId); + const std::shared_ptr device = get_hid_device(padId); if (device == nullptr || device->hidDevice == nullptr) { return 0; @@ -266,7 +266,7 @@ std::unordered_map ds4_pad_handler::get_button_values(const std::share keyBuffer[DS4KeyCodes::RSYPos] = Clamp0To255((127.5f - buf[4]) * 2.0f); // bleh, dpad in buffer is stored in a different state - u8 dpadState = buf[5] & 0xf; + const u8 dpadState = buf[5] & 0xf; switch (dpadState) { case 0x08: // none pressed @@ -366,7 +366,7 @@ pad_preview_values ds4_pad_handler::get_preview_values(const std::unordered_map< }; } -bool ds4_pad_handler::GetCalibrationData(DS4Device* ds4Dev) +bool ds4_pad_handler::GetCalibrationData(DS4Device* ds4Dev) const { if (!ds4Dev || !ds4Dev->hidDevice) { @@ -601,7 +601,7 @@ int ds4_pad_handler::send_output_report(DS4Device* device) if (!device || !device->hidDevice) return -2; - auto config = device->config; + const auto config = device->config; if (config == nullptr) return -2; // hid_write and hid_write_control return -1 on error @@ -682,7 +682,7 @@ ds4_pad_handler::DataStatus ds4_pad_handler::get_data(DS4Device* device) return DataStatus::NoNewData; } - int offset = 0; + int offset; // check report and set offset if (device->bt_controller && buf[0] == 0x11 && res == 78) { diff --git a/rpcs3/Input/ds4_pad_handler.h b/rpcs3/Input/ds4_pad_handler.h index 8b767dc7f7..0c2d2681cb 100644 --- a/rpcs3/Input/ds4_pad_handler.h +++ b/rpcs3/Input/ds4_pad_handler.h @@ -1,7 +1,6 @@ #pragma once #include "hid_pad_handler.h" -#include "Utilities/CRC.h" #include @@ -63,7 +62,7 @@ public: private: // This function gets us usuable buffer from the rawbuffer of padData - bool GetCalibrationData(DS4Device* ds4Device); + bool GetCalibrationData(DS4Device* ds4Device) const; // Copies data into padData if status is NewData, otherwise buffer is untouched DataStatus get_data(DS4Device* ds4Device) override; diff --git a/rpcs3/Input/dualsense_pad_handler.cpp b/rpcs3/Input/dualsense_pad_handler.cpp index 7c9afa9553..1e9011c493 100644 --- a/rpcs3/Input/dualsense_pad_handler.cpp +++ b/rpcs3/Input/dualsense_pad_handler.cpp @@ -398,7 +398,7 @@ dualsense_pad_handler::DataStatus dualsense_pad_handler::get_data(DualSenseDevic return DataStatus::NewData; } -bool dualsense_pad_handler::get_calibration_data(DualSenseDevice* dualsense_device) +bool dualsense_pad_handler::get_calibration_data(DualSenseDevice* dualsense_device) const { if (!dualsense_device || !dualsense_device->hidDevice) { @@ -899,7 +899,7 @@ int dualsense_pad_handler::send_output_report(DualSenseDevice* device) if (!device || !device->hidDevice) return -2; - auto config = device->config; + const auto config = device->config; if (config == nullptr) return -2; // hid_write and hid_write_control return -1 on error @@ -976,7 +976,7 @@ int dualsense_pad_handler::send_output_report(DualSenseDevice* device) report.report_id = 0x31; // report id for bluetooth report.seq_tag = seq_tag; report.tag = 0x10; // magic number - report.common = std::move(common); + report.common = common; const u8 btHdr = 0xA2; const u32 crcHdr = CRCPP::CRC::Calculate(&btHdr, 1, crcTable); @@ -993,7 +993,7 @@ int dualsense_pad_handler::send_output_report(DualSenseDevice* device) { output_report_usb report{}; report.report_id = 0x02; // report id for usb - report.common = std::move(common); + report.common = common; return hid_write(device->hidDevice, &report.report_id, DUALSENSE_USB_REPORT_SIZE); } @@ -1040,7 +1040,7 @@ void dualsense_pad_handler::apply_pad_data(const std::shared_ptr& dev // Turn lightbar on and off in an interval. I wanted to do an automatic pulse, but I haven't found out how to do that yet. if (dualsense_dev->led_delay_on > 0) { - if (steady_clock::time_point now = steady_clock::now(); (now - dualsense_dev->last_lightbar_time) > 500ms) + if (const steady_clock::time_point now = steady_clock::now(); (now - dualsense_dev->last_lightbar_time) > 500ms) { dualsense_dev->lightbar_on = !dualsense_dev->lightbar_on; dualsense_dev->last_lightbar_time = now; @@ -1138,7 +1138,7 @@ void dualsense_pad_handler::SetPadData(const std::string& padId, u32 largeMotor, u32 dualsense_pad_handler::get_battery_level(const std::string& padId) { - std::shared_ptr device = get_hid_device(padId); + const std::shared_ptr device = get_hid_device(padId); if (device == nullptr || device->hidDevice == nullptr) { return 0; diff --git a/rpcs3/Input/dualsense_pad_handler.h b/rpcs3/Input/dualsense_pad_handler.h index 9b7ffa307f..b19eac0edb 100644 --- a/rpcs3/Input/dualsense_pad_handler.h +++ b/rpcs3/Input/dualsense_pad_handler.h @@ -1,7 +1,6 @@ #pragma once #include "hid_pad_handler.h" -#include "Utilities/CRC.h" #include @@ -75,9 +74,9 @@ public: void init_config(pad_config* cfg, const std::string& name) override; private: - bool get_calibration_data(DualSenseDevice* dualsense_device); + bool get_calibration_data(DualSenseDevice* dualsense_device) const; - DataStatus get_data(DualSenseDevice* dualsenseDevice) override; + DataStatus get_data(DualSenseDevice* device) override; void check_add_device(hid_device* hidDevice, std::string_view path, std::wstring_view wide_serial) override; int send_output_report(DualSenseDevice* device) override; diff --git a/rpcs3/Input/hid_pad_handler.cpp b/rpcs3/Input/hid_pad_handler.cpp index a42845c346..467fa81f39 100644 --- a/rpcs3/Input/hid_pad_handler.cpp +++ b/rpcs3/Input/hid_pad_handler.cpp @@ -204,7 +204,7 @@ std::shared_ptr hid_pad_handler::get_device(const std::string } template -u32 hid_pad_handler::get_battery_color(u8 battery_level, int brightness) const +u32 hid_pad_handler::get_battery_color(u8 battery_level, int brightness) { static const std::array battery_level_clr = {0xff00, 0xff33, 0xff66, 0xff99, 0xffcc, 0xffff, 0xccff, 0x99ff, 0x66ff, 0x33ff, 0x00ff, 0x00ff}; diff --git a/rpcs3/Input/hid_pad_handler.h b/rpcs3/Input/hid_pad_handler.h index beab62f7a0..c71cf526ba 100644 --- a/rpcs3/Input/hid_pad_handler.h +++ b/rpcs3/Input/hid_pad_handler.h @@ -82,7 +82,7 @@ protected: virtual int send_output_report(Device* device) = 0; virtual DataStatus get_data(Device* device) = 0; - inline s16 apply_calibration(s32 rawValue, const CalibData& calibData) + static s16 apply_calibration(s32 rawValue, const CalibData& calibData) { const s32 biased = rawValue - calibData.bias; const s32 quot = calibData.sens_numer / calibData.sens_denom; @@ -92,17 +92,17 @@ protected: return static_cast(std::clamp(output, INT16_MIN, INT16_MAX)); } - inline s16 read_s16(const void* buf) + static s16 read_s16(const void* buf) { - return *reinterpret_cast(buf); + return *static_cast(buf); } - inline u32 read_u32(const void* buf) + static u32 read_u32(const void* buf) { - return *reinterpret_cast(buf); + return *static_cast(buf); } - u32 get_battery_color(u8 battery_level, int brightness) const; + static u32 get_battery_color(u8 battery_level, int brightness); private: std::shared_ptr get_device(const std::string& device) override; diff --git a/rpcs3/Input/keyboard_pad_handler.cpp b/rpcs3/Input/keyboard_pad_handler.cpp index 56ffff1230..8c356fd05b 100644 --- a/rpcs3/Input/keyboard_pad_handler.cpp +++ b/rpcs3/Input/keyboard_pad_handler.cpp @@ -78,7 +78,7 @@ void keyboard_pad_handler::Key(const u32 code, bool pressed, u16 value) value = Clamp0To255(value); - for (auto pad : bindings) + for (const auto& pad : m_bindings) { for (Button& button : pad->m_buttons) { @@ -316,7 +316,7 @@ void keyboard_pad_handler::mouseReleaseEvent(QMouseEvent* event) event->ignore(); } -bool keyboard_pad_handler::get_mouse_lock_state() +bool keyboard_pad_handler::get_mouse_lock_state() const { if (auto game_frame = dynamic_cast(m_target)) return game_frame->get_mouse_lock_state(); @@ -388,7 +388,7 @@ void keyboard_pad_handler::mouseMoveEvent(QMouseEvent* event) const double a = m_deadzone_x; const double b = m_deadzone_y; - const double m = double(movement_y) / double(movement_x); + const double m = static_cast(movement_y) / static_cast(movement_x); deadzone_x = a * b / std::sqrt(std::pow(a, 2) * std::pow(m, 2) + std::pow(b, 2)); deadzone_y = std::abs(m * deadzone_x); @@ -473,14 +473,14 @@ std::vector keyboard_pad_handler::ListDevices() return list_devices; } -std::string keyboard_pad_handler::GetMouseName(const QMouseEvent* event) +std::string keyboard_pad_handler::GetMouseName(const QMouseEvent* event) const { return GetMouseName(event->button()); } -std::string keyboard_pad_handler::GetMouseName(u32 button) +std::string keyboard_pad_handler::GetMouseName(u32 button) const { - if (auto it = mouse_list.find(button); it != mouse_list.end()) + if (const auto it = mouse_list.find(button); it != mouse_list.cend()) return it->second; return "FAIL"; } @@ -550,7 +550,7 @@ QStringList keyboard_pad_handler::GetKeyNames(const QKeyEvent* keyEvent) std::string keyboard_pad_handler::GetKeyName(const QKeyEvent* keyEvent) { // Handle special cases first - if (const std::string name = native_scan_code_to_string(keyEvent->nativeScanCode()); !name.empty()) + if (std::string name = native_scan_code_to_string(keyEvent->nativeScanCode()); !name.empty()) { return name; } @@ -602,7 +602,7 @@ u32 keyboard_pad_handler::GetKeyCode(const QString& keyName) else if (keyName == "Meta") return Qt::Key_Meta; - QKeySequence seq(keyName); + const QKeySequence seq(keyName); u32 key_code = 0; if (seq.count() == 1) @@ -660,7 +660,7 @@ bool keyboard_pad_handler::bindPadToDevice(std::shared_ptr pad, const std:: if (device != pad::keyboard_device_name) return false; - const int index = static_cast(bindings.size()); + const int index = static_cast(m_bindings.size()); m_pad_configs[index].load(); pad_config* p_profile = &m_pad_configs[index]; if (p_profile == nullptr) @@ -742,7 +742,7 @@ bool keyboard_pad_handler::bindPadToDevice(std::shared_ptr pad, const std:: pad->m_vibrateMotors.emplace_back(true, 0); pad->m_vibrateMotors.emplace_back(false, 0); - bindings.push_back(pad); + m_bindings.push_back(pad); return true; } @@ -806,12 +806,12 @@ void keyboard_pad_handler::ThreadProc() return (v0 <= v1) ? std::ceil(res) : std::floor(res); }; - for (uint i = 0; i < bindings.size(); i++) + for (uint i = 0; i < m_bindings.size(); i++) { if (last_connection_status[i] == false) { - bindings[i]->m_port_status |= CELL_PAD_STATUS_CONNECTED; - bindings[i]->m_port_status |= CELL_PAD_STATUS_ASSIGN_CHANGES; + m_bindings[i]->m_port_status |= CELL_PAD_STATUS_CONNECTED; + m_bindings[i]->m_port_status |= CELL_PAD_STATUS_ASSIGN_CHANGES; last_connection_status[i] = true; connected_devices++; } @@ -819,25 +819,25 @@ void keyboard_pad_handler::ThreadProc() { if (update_sticks) { - for (int j = 0; j < static_cast(bindings[i]->m_sticks.size()); j++) + for (int j = 0; j < static_cast(m_bindings[i]->m_sticks.size()); j++) { const f32 stick_lerp_factor = (j < 2) ? m_l_stick_lerp_factor : m_r_stick_lerp_factor; // we already applied the following values on keypress if we used factor 1 if (stick_lerp_factor < 1.0f) { - const f32 v0 = static_cast(bindings[i]->m_sticks[j].m_value); + const f32 v0 = static_cast(m_bindings[i]->m_sticks[j].m_value); const f32 v1 = static_cast(m_stick_val[j]); const f32 res = get_lerped(v0, v1, stick_lerp_factor); - bindings[i]->m_sticks[j].m_value = static_cast(res); + m_bindings[i]->m_sticks[j].m_value = static_cast(res); } } } if (update_buttons) { - for (auto& button : bindings[i]->m_buttons) + for (auto& button : m_bindings[i]->m_buttons) { if (button.m_analog) { diff --git a/rpcs3/Input/keyboard_pad_handler.h b/rpcs3/Input/keyboard_pad_handler.h index addfaebf0c..496b055321 100644 --- a/rpcs3/Input/keyboard_pad_handler.h +++ b/rpcs3/Input/keyboard_pad_handler.h @@ -80,21 +80,21 @@ public: void mouseMoveEvent(QMouseEvent* event); void mouseWheelEvent(QWheelEvent* event); - bool eventFilter(QObject* obj, QEvent* ev) override; + bool eventFilter(QObject* target, QEvent* ev) override; void init_config(pad_config* cfg, const std::string& name) override; std::vector ListDevices() override; - void get_next_button_press(const std::string& /*padId*/, const pad_callback& /*callback*/, const pad_fail_callback& /*fail_callback*/, bool /*get_blacklist*/ = false, const std::vector& /*buttons*/ = {}) override {}; + void get_next_button_press(const std::string& /*padId*/, const pad_callback& /*callback*/, const pad_fail_callback& /*fail_callback*/, bool /*get_blacklist*/ = false, const std::vector& /*buttons*/ = {}) override {} bool bindPadToDevice(std::shared_ptr pad, const std::string& device) override; void ThreadProc() override; - std::string GetMouseName(const QMouseEvent* event); - std::string GetMouseName(u32 button); - QStringList GetKeyNames(const QKeyEvent* keyEvent); - std::string GetKeyName(const QKeyEvent* keyEvent); - std::string GetKeyName(const u32& keyCode); - u32 GetKeyCode(const std::string& keyName); - u32 GetKeyCode(const QString& keyName); + std::string GetMouseName(const QMouseEvent* event) const; + std::string GetMouseName(u32 button) const; + static QStringList GetKeyNames(const QKeyEvent* keyEvent); + static std::string GetKeyName(const QKeyEvent* keyEvent); + static std::string GetKeyName(const u32& keyCode); + static u32 GetKeyCode(const std::string& keyName); + static u32 GetKeyCode(const QString& keyName); static int native_scan_code_from_string(const std::string& key); static std::string native_scan_code_to_string(int native_scan_code); @@ -105,9 +105,9 @@ protected: private: QWindow* m_target = nullptr; bool m_mouse_move_used = false; - bool get_mouse_lock_state(); + bool get_mouse_lock_state() const; - std::vector> bindings; + std::vector> m_bindings; // Button Movements steady_clock::time_point m_button_time; diff --git a/rpcs3/Input/mm_joystick_handler.cpp b/rpcs3/Input/mm_joystick_handler.cpp index d35208829b..dcff6e6a86 100644 --- a/rpcs3/Input/mm_joystick_handler.cpp +++ b/rpcs3/Input/mm_joystick_handler.cpp @@ -26,10 +26,6 @@ mm_joystick_handler::mm_joystick_handler() : PadHandlerBase(pad_handler::mm) m_thumb_threshold = thumb_max / 2; } -mm_joystick_handler::~mm_joystick_handler() -{ -} - void mm_joystick_handler::init_config(pad_config* cfg, const std::string& name) { if (!cfg) return; @@ -82,8 +78,8 @@ bool mm_joystick_handler::Init() return true; m_devices.clear(); - u32 supported_joysticks = joyGetNumDevs(); + const u32 supported_joysticks = joyGetNumDevs(); if (supported_joysticks <= 0) { input_log.error("mmjoy: Driver doesn't support Joysticks"); @@ -113,7 +109,7 @@ std::vector mm_joystick_handler::ListDevices() if (!Init()) return devices; - for (auto dev : m_devices) + for (const auto& dev : m_devices) { devices.emplace_back(dev.second.device_name); } @@ -129,7 +125,7 @@ std::array mm_joystick_handler::get_m if (!joy_device) return mapping; - auto find_key = [=](const cfg::string& name) + auto find_key = [this](const cfg::string& name) { long key = FindKeyCode(button_list, name, false); if (key < 0) @@ -191,7 +187,7 @@ void mm_joystick_handler::get_next_button_press(const std::string& padId, const return; } - static std::string cur_pad = ""; + static std::string cur_pad; static int id = -1; if (cur_pad != padId) @@ -213,7 +209,7 @@ void mm_joystick_handler::get_next_button_press(const std::string& padId, const js_info.dwFlags = JOY_RETURNALL; joyGetDevCaps(id, &js_caps, sizeof(js_caps)); - MMRESULT status = joyGetPosEx(id, &js_info); + const MMRESULT status = joyGetPosEx(id, &js_info); switch (status) { @@ -299,7 +295,7 @@ void mm_joystick_handler::get_next_button_press(const std::string& padId, const return; } - auto find_key = [=](const std::string& name) + auto find_key = [this](const std::string& name) { long key = FindKeyCodeByString(axis_list, name, false); if (key < 0) @@ -339,7 +335,7 @@ std::unordered_map mm_joystick_handler::GetButtonValues(const JOYINFOE { std::unordered_map button_values; - for (auto entry : button_list) + for (const auto& entry : button_list) { button_values.emplace(entry.first, js_info.dwButtons & entry.first ? 255 : 0); } @@ -371,19 +367,19 @@ std::unordered_map mm_joystick_handler::GetButtonValues(const JOYINFOE } }; - float rad = static_cast(js_info.dwPOV / 100 * acos(-1) / 180); + const float rad = static_cast(js_info.dwPOV / 100 * acos(-1) / 180); emplacePOVs(cosf(rad) * 255.0f, JOY_POVBACKWARD, JOY_POVFORWARD); emplacePOVs(sinf(rad) * 255.0f, JOY_POVLEFT, JOY_POVRIGHT); } } else if (js_caps.wCaps & JOYCAPS_POV4DIR) { - int val = static_cast(js_info.dwPOV); + const int val = static_cast(js_info.dwPOV); auto emplacePOV = [&button_values, &val](int pov) { - int cw = pov + 4500, ccw = pov - 4500; - bool pressed = (val == pov) || (val == cw) || (ccw < 0 ? val == 36000 - std::abs(ccw) : val == ccw); + const int cw = pov + 4500, ccw = pov - 4500; + const bool pressed = (val == pov) || (val == cw) || (ccw < 0 ? val == 36000 - std::abs(ccw) : val == ccw); button_values.emplace(pov, pressed ? 255 : 0); }; @@ -396,7 +392,7 @@ std::unordered_map mm_joystick_handler::GetButtonValues(const JOYINFOE auto add_axis_value = [&](DWORD axis, UINT min, UINT max, u64 pos, u64 neg) { - float val = ScaledInput2(axis, min, max); + const float val = ScaledInput2(axis, min, max); if (val < 0) { button_values.emplace(pos, 0); @@ -437,7 +433,7 @@ std::unordered_map mm_joystick_handler::get_button_values(const std::s int mm_joystick_handler::GetIDByName(const std::string& name) { - for (auto dev : m_devices) + for (const auto& dev : m_devices) { if (dev.second.device_name == name) return dev.first; @@ -445,7 +441,7 @@ int mm_joystick_handler::GetIDByName(const std::string& name) return -1; } -bool mm_joystick_handler::GetMMJOYDevice(int index, MMJOYDevice* dev) +bool mm_joystick_handler::GetMMJOYDevice(int index, MMJOYDevice* dev) const { if (!dev) return false; @@ -478,7 +474,7 @@ std::shared_ptr mm_joystick_handler::get_device(const std::string& de if (!Init()) return nullptr; - int id = GetIDByName(device); + const int id = GetIDByName(device); if (id < 0) return nullptr; diff --git a/rpcs3/Input/mm_joystick_handler.h b/rpcs3/Input/mm_joystick_handler.h index 52080ea916..caa6786893 100644 --- a/rpcs3/Input/mm_joystick_handler.h +++ b/rpcs3/Input/mm_joystick_handler.h @@ -110,7 +110,6 @@ class mm_joystick_handler final : public PadHandlerBase public: mm_joystick_handler(); - ~mm_joystick_handler(); bool Init() override; @@ -121,7 +120,7 @@ public: private: std::unordered_map GetButtonValues(const JOYINFOEX& js_info, const JOYCAPS& js_caps); int GetIDByName(const std::string& name); - bool GetMMJOYDevice(int index, MMJOYDevice* dev); + bool GetMMJOYDevice(int index, MMJOYDevice* dev) const; bool is_init = false; diff --git a/rpcs3/Input/pad_thread.cpp b/rpcs3/Input/pad_thread.cpp index a8f7e1afe7..ce3be8bb5e 100644 --- a/rpcs3/Input/pad_thread.cpp +++ b/rpcs3/Input/pad_thread.cpp @@ -140,7 +140,7 @@ void pad_thread::Init() cur_pad_handler = std::make_shared(); break; #endif - default: + case pad_handler::null: break; } handlers.emplace(handler_type, cur_pad_handler); diff --git a/rpcs3/Input/product_info.h b/rpcs3/Input/product_info.h index 16485cf02a..dfa30d189a 100644 --- a/rpcs3/Input/product_info.h +++ b/rpcs3/Input/product_info.h @@ -49,11 +49,6 @@ namespace input { switch (type) { - default: - case product_type::playstation_3_controller: - { - return product_info{ type, vendor_id::sony_corp, product_id::playstation_3_controller, 0x0 }; - } case product_type::dance_dance_revolution_mat: { return product_info{ type, vendor_id::konami_de, product_id::dance_dance_revolution_mat, 0x000000FF }; @@ -86,6 +81,11 @@ namespace input { return product_info{ type, vendor_id::sony_cea, product_id::rock_revolution_drum_kit, 0x000000FB }; } + case product_type::playstation_3_controller: + default: // GCC doesn't like it when there is no return value if if all enum values are covered + { + return product_info{ type, vendor_id::sony_corp, product_id::playstation_3_controller, 0x0 }; + } } } diff --git a/rpcs3/Input/xinput_pad_handler.cpp b/rpcs3/Input/xinput_pad_handler.cpp index f661f12165..c141b2bc1f 100644 --- a/rpcs3/Input/xinput_pad_handler.cpp +++ b/rpcs3/Input/xinput_pad_handler.cpp @@ -188,7 +188,7 @@ int xinput_pad_handler::GetDeviceNumber(const std::string& padId) if (pos == umax) return -1; - int device_number = std::stoul(padId.substr(pos + 12)) - 1; // Controllers 1-n in GUI + const int device_number = std::stoul(padId.substr(pos + 12)) - 1; // Controllers 1-n in GUI if (device_number >= XUSER_MAX_COUNT) return -1; @@ -242,7 +242,7 @@ xinput_pad_handler::PadButtonValues xinput_pad_handler::get_button_values_base(c values[XInputKeyCodes::RSYPos] = ry > 0 ? ry : 0; // Buttons - WORD buttons = state.Gamepad.wButtons; + const WORD buttons = state.Gamepad.wButtons; // A, B, X, Y values[XInputKeyCodes::A] = buttons & XINPUT_GAMEPAD_A ? 255 : 0; @@ -518,16 +518,16 @@ void xinput_pad_handler::apply_pad_data(const std::shared_ptr& device if (!dev || !pad) return; - auto padnum = dev->deviceNumber; - auto profile = dev->config; + const auto padnum = dev->deviceNumber; + const auto profile = dev->config; // The left motor is the low-frequency rumble motor. The right motor is the high-frequency rumble motor. // The two motors are not the same, and they create different vibration effects. Values range between 0 to 65535. - usz idx_l = profile->switch_vibration_motors ? 1 : 0; - usz idx_s = profile->switch_vibration_motors ? 0 : 1; + const usz idx_l = profile->switch_vibration_motors ? 1 : 0; + const usz idx_s = profile->switch_vibration_motors ? 0 : 1; - u16 speed_large = profile->enable_vibration_motor_large ? pad->m_vibrateMotors[idx_l].m_value : static_cast(vibration_min); - u16 speed_small = profile->enable_vibration_motor_small ? pad->m_vibrateMotors[idx_s].m_value : static_cast(vibration_min); + const u16 speed_large = profile->enable_vibration_motor_large ? pad->m_vibrateMotors[idx_l].m_value : static_cast(vibration_min); + const u16 speed_small = profile->enable_vibration_motor_small ? pad->m_vibrateMotors[idx_s].m_value : static_cast(vibration_min); dev->newVibrateData |= dev->largeVibrate != speed_large || dev->smallVibrate != speed_small; diff --git a/rpcs3/Input/xinput_pad_handler.h b/rpcs3/Input/xinput_pad_handler.h index d5ee07076c..0b71d32142 100644 --- a/rpcs3/Input/xinput_pad_handler.h +++ b/rpcs3/Input/xinput_pad_handler.h @@ -10,7 +10,6 @@ #include #include #include -#include // ScpToolkit defined structure for pressure sensitive button query struct SCP_EXTN @@ -100,8 +99,8 @@ class xinput_pad_handler final : public PadHandlerBase steady_clock::time_point last_vibration; bool is_scp_device{ false }; DWORD state{ ERROR_NOT_CONNECTED }; // holds internal controller state change - SCP_EXTN state_scp{ 0 }; - XINPUT_STATE state_base{ 0 }; + SCP_EXTN state_scp{}; + XINPUT_STATE state_base{}; }; public: @@ -124,8 +123,8 @@ private: private: int GetDeviceNumber(const std::string& padId); - PadButtonValues get_button_values_base(const XINPUT_STATE& state); - PadButtonValues get_button_values_scp(const SCP_EXTN& state); + static PadButtonValues get_button_values_base(const XINPUT_STATE& state); + static PadButtonValues get_button_values_scp(const SCP_EXTN& state); bool is_init{ false }; HMODULE library{ nullptr }; diff --git a/rpcs3/headless_application.cpp b/rpcs3/headless_application.cpp index bc59c4e9d9..591f6ee270 100644 --- a/rpcs3/headless_application.cpp +++ b/rpcs3/headless_application.cpp @@ -32,7 +32,7 @@ bool headless_application::Init() return true; } -void headless_application::InitializeConnects() +void headless_application::InitializeConnects() const { qRegisterMetaType>("std::function"); connect(this, &headless_application::RequestCallAfter, this, &headless_application::HandleCallAfter); @@ -58,14 +58,14 @@ void headless_application::InitializeCallbacks() return false; }; - callbacks.call_after = [=, this](std::function func) + callbacks.call_after = [this](std::function func) { RequestCallAfter(std::move(func)); }; callbacks.init_gs_render = []() { - switch (video_renderer type = g_cfg.video.renderer) + switch (const video_renderer type = g_cfg.video.renderer) { case video_renderer::null: { @@ -78,6 +78,7 @@ void headless_application::InitializeCallbacks() #endif { fmt::throw_exception("Headless mode can only be used with the %s video renderer. Current renderer: %s", video_renderer::null, type); + [[fallthrough]]; } default: { diff --git a/rpcs3/headless_application.h b/rpcs3/headless_application.h index a16ed33f7f..9caa06a4e9 100644 --- a/rpcs3/headless_application.h +++ b/rpcs3/headless_application.h @@ -21,16 +21,16 @@ public: private: void InitializeCallbacks(); - void InitializeConnects(); + void InitializeConnects() const; QThread* get_thread() override { return thread(); - }; + } Q_SIGNALS: - void RequestCallAfter(const std::function& func); + void RequestCallAfter(std::function func); private Q_SLOTS: - void HandleCallAfter(const std::function& func); + static void HandleCallAfter(const std::function& func); }; diff --git a/rpcs3/main.cpp b/rpcs3/main.cpp index a8811ce3ec..ccde02866a 100644 --- a/rpcs3/main.cpp +++ b/rpcs3/main.cpp @@ -137,47 +137,44 @@ LOG_CHANNEL(q_debug, "QDEBUG"); show_report(text); std::exit(0); } + +#ifdef _WIN32 + wchar_t buffer[32767]; + GetModuleFileNameW(nullptr, buffer, sizeof(buffer) / 2); + const std::wstring arg(text.cbegin(), text.cend()); // ignore unicode for now + _wspawnl(_P_WAIT, buffer, buffer, L"--error", arg.c_str(), nullptr); +#else + pid_t pid; + std::vector data(text.data(), text.data() + text.size() + 1); + std::string run_arg = +s_argv0; + std::string err_arg = "--error"; + + if (run_arg.find_first_of('/') == umax) + { + // AppImage has "rpcs3" in argv[0], can't just execute it +#ifdef __linux__ + char buffer[PATH_MAX]{}; + if (::readlink("/proc/self/exe", buffer, sizeof(buffer) - 1) > 0) + { + printf("Found exec link: %s\n", buffer); + run_arg = buffer; + } +#endif + } + + char* argv[] = {run_arg.data(), err_arg.data(), data.data(), nullptr}; + int ret = posix_spawn(&pid, run_arg.c_str(), nullptr, nullptr, argv, environ); + + if (ret == 0) + { + int status; + waitpid(pid, &status, 0); + } else { -#ifdef _WIN32 - wchar_t buffer[32767]; - GetModuleFileNameW(nullptr, buffer, sizeof(buffer) / 2); - std::wstring arg(text.cbegin(), text.cend()); // ignore unicode for now - _wspawnl(_P_WAIT, buffer, buffer, L"--error", arg.c_str(), nullptr); -#else - pid_t pid; - std::vector data(text.data(), text.data() + text.size() + 1); - std::string run_arg = +s_argv0; - std::string err_arg = "--error"; - - if (run_arg.find_first_of('/') == umax) - { - // AppImage has "rpcs3" in argv[0], can't just execute it -#ifdef __linux__ - char buffer[PATH_MAX]{}; - if (::readlink("/proc/self/exe", buffer, sizeof(buffer) - 1) > 0) - { - printf("Found exec link: %s\n", buffer); - run_arg = buffer; - } -#endif - } - - char* argv[] = {run_arg.data(), err_arg.data(), data.data(), nullptr}; - int ret = posix_spawn(&pid, run_arg.c_str(), nullptr, nullptr, argv, environ); - - if (ret == 0) - { - int status; - waitpid(pid, &status, 0); - } - else - { - std::fprintf(stderr, "posix_spawn() failed: %d\n", ret); - } -#endif - std::abort(); + std::fprintf(stderr, "posix_spawn() failed: %d\n", ret); } +#endif } std::abort(); @@ -339,7 +336,7 @@ QCoreApplication* createApplication(int& argc, char* argv[]) void log_q_debug(QtMsgType type, const QMessageLogContext& context, const QString& msg) { - Q_UNUSED(context); + Q_UNUSED(context) switch (type) { @@ -402,30 +399,23 @@ int main(int argc, char** argv) { report_fatal_error("Another instance of RPCS3 is running. Close it or kill its process, if necessary."); } - else - { - report_fatal_error("Cannot create RPCS3.log (access denied)." + + report_fatal_error("Cannot create RPCS3.log (access denied)." #ifdef _WIN32 "\nNote that RPCS3 cannot be installed in Program Files or similar directories with limited permissions." #else "\nPlease, check RPCS3 permissions in '~/.config/rpcs3'." #endif - ); - } - } - else - { - report_fatal_error(fmt::format("Cannot create RPCS3.log (error %s)", fs::g_tls_error)); + ); } - return 1; + report_fatal_error(fmt::format("Cannot create RPCS3.log (error %s)", fs::g_tls_error)); } #ifdef _WIN32 if (!SetProcessWorkingSetSize(GetCurrentProcess(), 0x80000000, 0xC0000000)) // 2-3 GiB { report_fatal_error("Not enough memory for RPCS3 process."); - return 2; } #endif @@ -444,7 +434,6 @@ int main(int argc, char** argv) if (!fs::statfs(fs::get_cache_dir(), stats) || stats.avail_free < 128 * 1024 * 1024) { report_fatal_error(fmt::format("Not enough free space (%f KB)", stats.avail_free / 1000000.)); - return 1; } // Limit log size to ~25% of free space @@ -613,7 +602,7 @@ int main(int argc, char** argv) curl_easy_setopt(curl, CURLOPT_HTTPHEADER, hhdr); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, +[](const char* ptr, usz, usz size, void* json) -> usz { - reinterpret_cast(json)->append(ptr, size); + static_cast(json)->append(ptr, size); return size; }); curl_easy_setopt(curl, CURLOPT_WRITEDATA, &buf); @@ -760,7 +749,6 @@ int main(int argc, char** argv) if (Emulator::CheckUsr(active_user) == 0) { report_fatal_error(fmt::format("Failed to set user ID '%s'.\nThe user ID must consist of 8 digits and cannot be 00000000.", active_user)); - return 1; } } @@ -799,7 +787,6 @@ int main(int argc, char** argv) { // Should be unreachable report_fatal_error("RPCS3 initialization failed!"); - return 1; } #ifdef _WIN32 @@ -816,16 +803,13 @@ int main(int argc, char** argv) } #endif - std::string config_override_path; - if (parser.isSet(arg_config)) { - config_override_path = parser.value(config_option).toStdString(); + const std::string config_override_path = parser.value(config_option).toStdString(); if (!fs::is_file(config_override_path)) { report_fatal_error(fmt::format("No config file found: %s", config_override_path)); - return 1; } Emu.SetConfigOverride(config_override_path); @@ -839,7 +823,6 @@ int main(int argc, char** argv) if (s_no_gui) { report_fatal_error("Cannot perform installation in no-gui mode!"); - return 1; } if (gui_app->m_main_window) @@ -860,13 +843,11 @@ int main(int argc, char** argv) else { report_fatal_error("Cannot perform installation. No main window found!"); - return 1; } } else { report_fatal_error("Cannot perform installation in headless mode!"); - return 1; } } @@ -880,24 +861,24 @@ int main(int argc, char** argv) sys_log.notice("Booting application from command line: %s", args.at(0).toStdString()); // Propagate command line arguments - std::vector argv; + std::vector rpcs3_argv; if (args.length() > 1) { - argv.emplace_back(); + rpcs3_argv.emplace_back(); for (int i = 1; i < args.length(); i++) { const std::string arg = args[i].toStdString(); - argv.emplace_back(arg); + rpcs3_argv.emplace_back(arg); sys_log.notice("Optional command line argument %d: %s", i, arg); } } // Postpone startup to main event loop - Emu.CallAfter([config_override_path, path = sstr(QFileInfo(args.at(0)).absoluteFilePath()), argv = std::move(argv)]() mutable + Emu.CallAfter([path = sstr(QFileInfo(args.at(0)).absoluteFilePath()), rpcs3_argv = std::move(rpcs3_argv)]() mutable { - Emu.argv = std::move(argv); + Emu.argv = std::move(rpcs3_argv); Emu.SetForceBoot(true); if (const game_boot_result error = Emu.BootGame(path, ""); error != game_boot_result::no_errors) @@ -946,6 +927,7 @@ extern "C" size--; continue; } + default: break; } break; diff --git a/rpcs3/main_application.cpp b/rpcs3/main_application.cpp index 8b46e610a6..ba8215b478 100644 --- a/rpcs3/main_application.cpp +++ b/rpcs3/main_application.cpp @@ -2,7 +2,6 @@ #include "util/types.hpp" #include "util/logs.hpp" -#include "util/atomic.hpp" #include "Input/pad_thread.h" #include "Emu/System.h" @@ -48,7 +47,7 @@ EmuCallbacks main_application::CreateCallbacks() callbacks.init_kb_handler = [this]() { - switch (keyboard_handler type = g_cfg.io.keyboard) + switch (g_cfg.io.keyboard.get()) { case keyboard_handler::null: { @@ -62,13 +61,12 @@ EmuCallbacks main_application::CreateCallbacks() ret->SetTargetWindow(m_game_window); break; } - default: fmt::throw_exception("Invalid keyboard handler: %s", type); } }; callbacks.init_mouse_handler = [this]() { - switch (mouse_handler type = g_cfg.io.mouse) + switch (g_cfg.io.mouse.get()) { case mouse_handler::null: { @@ -90,7 +88,6 @@ EmuCallbacks main_application::CreateCallbacks() ret->SetTargetWindow(m_game_window); break; } - default: fmt::throw_exception("Invalid mouse handler: %s", type); } }; @@ -102,7 +99,7 @@ EmuCallbacks main_application::CreateCallbacks() callbacks.get_audio = []() -> std::shared_ptr { std::shared_ptr result; - switch (audio_renderer type = g_cfg.audio.renderer) + switch (g_cfg.audio.renderer.get()) { case audio_renderer::null: result = std::make_shared(); break; #ifdef _WIN32 @@ -119,7 +116,6 @@ EmuCallbacks main_application::CreateCallbacks() #ifdef HAVE_FAUDIO case audio_renderer::faudio: result = std::make_shared(); break; #endif - default: fmt::throw_exception("Invalid audio renderer: %s", type); } if (!result->Initialized()) diff --git a/rpcs3/main_application.h b/rpcs3/main_application.h index b207976bcb..71f8e90430 100644 --- a/rpcs3/main_application.h +++ b/rpcs3/main_application.h @@ -12,7 +12,7 @@ public: static void InitializeEmulator(const std::string& user, bool show_gui); - void SetActiveUser(std::string user) + void SetActiveUser(const std::string& user) { m_active_user = user; } diff --git a/rpcs3/rpcs3qt/_discord_utils.cpp b/rpcs3/rpcs3qt/_discord_utils.cpp index 2337d12c57..68bdac6916 100644 --- a/rpcs3/rpcs3qt/_discord_utils.cpp +++ b/rpcs3/rpcs3qt/_discord_utils.cpp @@ -1,7 +1,6 @@ #ifdef WITH_DISCORD_RPC #include "_discord_utils.h" #include "discord_rpc.h" -#include "discord_register.h" #include #include @@ -11,7 +10,7 @@ namespace discord void initialize(const std::string& application_id) { DiscordEventHandlers handlers = {}; - Discord_Initialize(application_id.c_str(), &handlers, 1, NULL); + Discord_Initialize(application_id.c_str(), &handlers, 1, nullptr); } void shutdown() @@ -29,7 +28,7 @@ namespace discord if (reset_timer) { - discordPresence.startTimestamp = std::time(0); + discordPresence.startTimestamp = std::time(nullptr); } Discord_UpdatePresence(&discordPresence); diff --git a/rpcs3/rpcs3qt/auto_pause_settings_dialog.cpp b/rpcs3/rpcs3qt/auto_pause_settings_dialog.cpp index 245972274d..97d1f36098 100644 --- a/rpcs3/rpcs3qt/auto_pause_settings_dialog.cpp +++ b/rpcs3/rpcs3qt/auto_pause_settings_dialog.cpp @@ -71,12 +71,12 @@ auto_pause_settings_dialog::auto_pause_settings_dialog(QWidget *parent) : QDialo } // Copied some from AutoPause. -void auto_pause_settings_dialog::LoadEntries(void) +void auto_pause_settings_dialog::LoadEntries() { m_entries.clear(); m_entries.reserve(16); - fs::file list(fs::get_config_dir() + "pause.bin"); + const fs::file list(fs::get_config_dir() + "pause.bin"); if (list) { @@ -99,7 +99,7 @@ void auto_pause_settings_dialog::LoadEntries(void) // Copied some from AutoPause. // Tip: This one doesn't check for the file is being read or not. // This would always use a 0xFFFFFFFF as end of the pause.bin -void auto_pause_settings_dialog::SaveEntries(void) +void auto_pause_settings_dialog::SaveEntries() { fs::file list(fs::get_config_dir() + "pause.bin", fs::rewrite); //System calls ID and Function calls ID are all u32 iirc. @@ -115,7 +115,7 @@ void auto_pause_settings_dialog::SaveEntries(void) list.write(&num, sizeof(u32)); } -void auto_pause_settings_dialog::UpdateList(void) +void auto_pause_settings_dialog::UpdateList() { const int entries_size = static_cast(m_entries.size()); m_pause_list->clearContents(); @@ -179,7 +179,7 @@ void auto_pause_settings_dialog::ShowContextMenu(const QPoint &pos) { m_entries.emplace_back(0xFFFFFFFF); UpdateList(); - int idx = static_cast(m_entries.size()) - 1; + const int idx = static_cast(m_entries.size()) - 1; m_pause_list->selectRow(idx); OnEntryConfig(idx, true); }); @@ -257,7 +257,7 @@ AutoPauseConfigDialog::AutoPauseConfigDialog(QWidget* parent, auto_pause_setting void AutoPauseConfigDialog::OnOk() { bool ok; - ullong value = m_id->text().toULongLong(&ok, 16); + const ullong value = m_id->text().toULongLong(&ok, 16); m_entry = value; *m_presult = m_entry; @@ -274,7 +274,7 @@ void AutoPauseConfigDialog::OnCancel() close(); } -void AutoPauseConfigDialog::OnUpdateValue() +void AutoPauseConfigDialog::OnUpdateValue() const { bool ok; const ullong value = m_id->text().toULongLong(&ok, 16); diff --git a/rpcs3/rpcs3qt/auto_pause_settings_dialog.h b/rpcs3/rpcs3qt/auto_pause_settings_dialog.h index 91a600f907..f3f9850a54 100644 --- a/rpcs3/rpcs3qt/auto_pause_settings_dialog.h +++ b/rpcs3/rpcs3qt/auto_pause_settings_dialog.h @@ -24,9 +24,9 @@ class auto_pause_settings_dialog : public QDialog public: explicit auto_pause_settings_dialog(QWidget* parent); - void UpdateList(void); - void LoadEntries(void); - void SaveEntries(void); + void UpdateList(); + void LoadEntries(); + void SaveEntries(); public Q_SLOTS: void OnRemove(); @@ -52,5 +52,5 @@ public: private Q_SLOTS: void OnOk(); void OnCancel(); - void OnUpdateValue(); + void OnUpdateValue() const; }; diff --git a/rpcs3/rpcs3qt/breakpoint_handler.cpp b/rpcs3/rpcs3qt/breakpoint_handler.cpp index 51333b545a..00ea81531a 100644 --- a/rpcs3/rpcs3qt/breakpoint_handler.cpp +++ b/rpcs3/rpcs3qt/breakpoint_handler.cpp @@ -2,14 +2,6 @@ extern void ppu_breakpoint(u32 loc, bool is_adding); -breakpoint_handler::breakpoint_handler() -{ -} - -breakpoint_handler::~breakpoint_handler() -{ -} - bool breakpoint_handler::HasBreakpoint(u32 loc) const { return m_breakpoints.contains(loc); diff --git a/rpcs3/rpcs3qt/breakpoint_handler.h b/rpcs3/rpcs3qt/breakpoint_handler.h index 948d506125..4794fd1d83 100644 --- a/rpcs3/rpcs3qt/breakpoint_handler.h +++ b/rpcs3/rpcs3qt/breakpoint_handler.h @@ -17,8 +17,8 @@ class breakpoint_handler { public: - breakpoint_handler(); - ~breakpoint_handler(); + breakpoint_handler() = default; + ~breakpoint_handler() = default; /** * Returns true iff breakpoint exists at loc. diff --git a/rpcs3/rpcs3qt/breakpoint_list.cpp b/rpcs3/rpcs3qt/breakpoint_list.cpp index ca6818d2cb..9e9f004fbf 100644 --- a/rpcs3/rpcs3qt/breakpoint_list.cpp +++ b/rpcs3/rpcs3qt/breakpoint_list.cpp @@ -2,7 +2,6 @@ #include "breakpoint_handler.h" #include "Emu/CPU/CPUDisAsm.h" -#include "Emu/Cell/SPUThread.h" #include "Emu/Cell/PPUThread.h" #include @@ -39,7 +38,7 @@ void breakpoint_list::ClearBreakpoints() while (count()) { auto* currentItem = takeItem(0); - u32 loc = currentItem->data(Qt::UserRole).value(); + const u32 loc = currentItem->data(Qt::UserRole).value(); m_breakpoint_handler->RemoveBreakpoint(loc); delete currentItem; } diff --git a/rpcs3/rpcs3qt/breakpoint_list.h b/rpcs3/rpcs3qt/breakpoint_list.h index fc3c6f498c..b30bdd7e77 100644 --- a/rpcs3/rpcs3qt/breakpoint_list.h +++ b/rpcs3/rpcs3qt/breakpoint_list.h @@ -3,7 +3,6 @@ #include "util/types.hpp" #include -#include class CPUDisAsm; class cpu_thread; @@ -17,7 +16,7 @@ public: breakpoint_list(QWidget* parent, breakpoint_handler* handler); void UpdateCPUData(cpu_thread* cpu, CPUDisAsm* disasm); void ClearBreakpoints(); - void AddBreakpoint(u32 addr); + void AddBreakpoint(u32 pc); void RemoveBreakpoint(u32 addr); QColor m_text_color_bp; @@ -25,7 +24,7 @@ public: Q_SIGNALS: void RequestShowAddress(u32 addr, bool select_addr = true, bool force = false); public Q_SLOTS: - void HandleBreakpointRequest(u32 addr); + void HandleBreakpointRequest(u32 loc); private Q_SLOTS: void OnBreakpointListDoubleClicked(); void OnBreakpointListRightClicked(const QPoint &pos); @@ -34,6 +33,6 @@ private: breakpoint_handler* m_breakpoint_handler; QMenu* m_context_menu = nullptr; QAction* m_delete_action; - cpu_thread* m_cpu; - CPUDisAsm* m_disasm; + cpu_thread* m_cpu = nullptr; + CPUDisAsm* m_disasm = nullptr; }; diff --git a/rpcs3/rpcs3qt/call_stack_list.cpp b/rpcs3/rpcs3qt/call_stack_list.cpp index 43df4bd4d7..90638e1b85 100644 --- a/rpcs3/rpcs3qt/call_stack_list.cpp +++ b/rpcs3/rpcs3qt/call_stack_list.cpp @@ -14,7 +14,7 @@ call_stack_list::call_stack_list(QWidget* parent) : QListWidget(parent) connect(this, &QListWidget::itemDoubleClicked, this, &call_stack_list::OnCallStackListDoubleClicked); } -void call_stack_list::HandleUpdate(std::vector> call_stack) +void call_stack_list::HandleUpdate(const std::vector>& call_stack) { clear(); diff --git a/rpcs3/rpcs3qt/call_stack_list.h b/rpcs3/rpcs3qt/call_stack_list.h index 211ba0ccad..bdae7a434c 100644 --- a/rpcs3/rpcs3qt/call_stack_list.h +++ b/rpcs3/rpcs3qt/call_stack_list.h @@ -13,12 +13,12 @@ class call_stack_list : public QListWidget Q_OBJECT public: - call_stack_list(QWidget* parent); + explicit call_stack_list(QWidget* parent); Q_SIGNALS: void RequestShowAddress(u32 addr, bool select_addr = true, bool force = false); public Q_SLOTS: - void HandleUpdate(std::vector> call_stack); + void HandleUpdate(const std::vector>& call_stack); private Q_SLOTS: void OnCallStackListDoubleClicked(); }; diff --git a/rpcs3/rpcs3qt/category.h b/rpcs3/rpcs3qt/category.h index 17058d4011..7f94fb765b 100644 --- a/rpcs3/rpcs3qt/category.h +++ b/rpcs3/rpcs3qt/category.h @@ -17,7 +17,7 @@ enum Category Others, }; -namespace category +namespace cat { const QString cat_app_music = "AM"; const QString cat_app_photo = "AP"; diff --git a/rpcs3/rpcs3qt/cg_disasm_window.cpp b/rpcs3/rpcs3qt/cg_disasm_window.cpp index 18a568a6c4..a052ff3480 100644 --- a/rpcs3/rpcs3qt/cg_disasm_window.cpp +++ b/rpcs3/rpcs3qt/cg_disasm_window.cpp @@ -16,8 +16,8 @@ LOG_CHANNEL(gui_log, "GUI"); constexpr auto qstr = QString::fromStdString; inline std::string sstr(const QString& _in) { return _in.toStdString(); } -cg_disasm_window::cg_disasm_window(std::shared_ptr xSettings) - : m_gui_settings(xSettings) +cg_disasm_window::cg_disasm_window(std::shared_ptr gui_settings) + : m_gui_settings(std::move(gui_settings)) { setWindowTitle(tr("Cg Disasm")); setObjectName("cg_disasm"); @@ -107,7 +107,7 @@ void cg_disasm_window::ShowContextMenu(const QPoint &pos) menu.exec(origin); } -void cg_disasm_window::ShowDisasm() +void cg_disasm_window::ShowDisasm() const { if (QFileInfo(m_path_last).isFile()) { diff --git a/rpcs3/rpcs3qt/cg_disasm_window.h b/rpcs3/rpcs3qt/cg_disasm_window.h index 3b336766c9..f1df84e507 100644 --- a/rpcs3/rpcs3qt/cg_disasm_window.h +++ b/rpcs3/rpcs3qt/cg_disasm_window.h @@ -19,7 +19,7 @@ private Q_SLOTS: void ShowContextMenu(const QPoint &pos); private: - void ShowDisasm(); + void ShowDisasm() const; bool IsValidFile(const QMimeData& md, bool save = false); QString m_path_last; diff --git a/rpcs3/rpcs3qt/cheat_manager.cpp b/rpcs3/rpcs3qt/cheat_manager.cpp index 51e7760a40..3520bd591a 100644 --- a/rpcs3/rpcs3qt/cheat_manager.cpp +++ b/rpcs3/rpcs3qt/cheat_manager.cpp @@ -9,7 +9,6 @@ #include "cheat_manager.h" #include "Emu/System.h" -#include "Emu/system_config.h" #include "Emu/Memory/vm.h" #include "Emu/CPU/CPUThread.h" @@ -88,8 +87,6 @@ cheat_engine::cheat_engine() for (const auto& yml_offset : yml_cheat.second) { - std::string error; - const u32 offset = get_yaml_node_value(yml_offset.first, error); if (!error.empty()) { @@ -179,12 +176,9 @@ std::string cheat_engine::export_cheats_to_str() const return cheats_str; } -bool cheat_engine::exist(const std::string& name, const u32 offset) const +bool cheat_engine::exist(const std::string& game, const u32 offset) const { - if (cheats.count(name) && cheats.at(name).count(offset)) - return true; - - return false; + return cheats.contains(game) && cheats.at(game).contains(offset); } void cheat_engine::add(const std::string& game, const std::string& description, const cheat_type type, const u32 offset, const std::string& red_script) @@ -246,7 +240,7 @@ bool cheat_engine::resolve_script(u32& final_offset, const u32 offset, const std num_string += red_script[index]; } - u32 num_value = std::stoul(num_string); + const u32 num_value = std::stoul(num_string); do_operation(cur_op, final_offset, num_value); } else @@ -288,7 +282,7 @@ bool cheat_engine::resolve_script(u32& final_offset, const u32 offset, const std // Tries to get value at resolved address bool success; - u32 res_value = get_value(res_addr, success); + const u32 res_value = get_value(res_addr, success); if (!success) return false; @@ -482,8 +476,6 @@ bool cheat_engine::is_addr_safe(const u32 offset) u32 cheat_engine::reverse_lookup(const u32 addr, const u32 max_offset, const u32 max_depth, const u32 cur_depth) { - u32 result; - for (u32 index = 0; index <= max_offset; index += 4) { std::vector ptrs = search(addr - index, {}); @@ -501,7 +493,7 @@ u32 cheat_engine::reverse_lookup(const u32 addr, const u32 max_offset, const u32 { for (const auto& ptr : ptrs) { - result = reverse_lookup(ptr, max_offset, max_depth, cur_depth + 1); + const u32 result = reverse_lookup(ptr, max_offset, max_depth, cur_depth + 1); if (result) return result; } @@ -683,7 +675,7 @@ cheat_manager_dialog::cheat_manager_dialog(QWidget* parent) connect(tbl_cheats, &QTableWidget::customContextMenuRequested, [this](const QPoint& loc) { - QPoint globalPos = tbl_cheats->mapToGlobal(loc); + const QPoint globalPos = tbl_cheats->mapToGlobal(loc); QMenu* menu = new QMenu(); QAction* delete_cheats = new QAction(tr("Delete"), menu); QAction* import_cheats = new QAction(tr("Import Cheats")); @@ -855,9 +847,8 @@ cheat_manager_dialog::cheat_manager_dialog(QWidget* parent) const u32 offset = offsets_found[current_row]; const cheat_type type = static_cast(cbx_cheat_search_type->currentIndex()); - const std::string name = Emu.GetTitle(); - connect(add_to_cheat_list, &QAction::triggered, [name, offset, type, this]() + connect(add_to_cheat_list, &QAction::triggered, [name = Emu.GetTitle(), offset, type, this]() { if (g_cheat.exist(name, offset)) { @@ -1073,9 +1064,7 @@ QString cheat_manager_dialog::get_localized_cheat_type(cheat_type type) case cheat_type::signed_16_cheat: return tr("Signed 16 bits"); case cheat_type::signed_32_cheat: return tr("Signed 32 bits"); case cheat_type::signed_64_cheat: return tr("Signed 64 bits"); - case cheat_type::max: - default: - break; + case cheat_type::max: break; } std::string type_formatted; fmt::append(type_formatted, "%s", type); diff --git a/rpcs3/rpcs3qt/cheat_manager.h b/rpcs3/rpcs3qt/cheat_manager.h index 0a428399f6..458c7400b9 100644 --- a/rpcs3/rpcs3qt/cheat_manager.h +++ b/rpcs3/rpcs3qt/cheat_manager.h @@ -43,7 +43,6 @@ public: static bool is_addr_safe(const u32 offset); static u32 reverse_lookup(const u32 addr, const u32 max_offset, const u32 max_depth, const u32 cur_depth = 0); -public: std::map> cheats; private: diff --git a/rpcs3/rpcs3qt/config_adapter.cpp b/rpcs3/rpcs3qt/config_adapter.cpp index cb65fc3f11..1ff8b6a82e 100644 --- a/rpcs3/rpcs3qt/config_adapter.cpp +++ b/rpcs3/rpcs3qt/config_adapter.cpp @@ -1,5 +1,3 @@ -#include - #include "config_adapter.h" #include "Emu/system_config.h" @@ -24,12 +22,12 @@ namespace cfg_adapter fmt::throw_exception("Node not found: %s", name); } - static cfg::_base& get_cfg(cfg::_base& root, cfg_location::const_iterator begin, cfg_location::const_iterator end) + static cfg::_base& get_cfg(cfg::_base& root, const cfg_location::const_iterator begin, const cfg_location::const_iterator end) { return begin == end ? root : get_cfg(get_cfg(root, *begin), begin + 1, end); } - YAML::Node get_node(const YAML::Node& node, cfg_location::const_iterator begin, cfg_location::const_iterator end) + YAML::Node get_node(const YAML::Node& node, const cfg_location::const_iterator begin, const cfg_location::const_iterator end) { if (begin == end) { @@ -45,28 +43,24 @@ namespace cfg_adapter return get_node(node[*begin], begin + 1, end); // TODO } - YAML::Node get_node(const YAML::Node& node, cfg_location loc) + YAML::Node get_node(const YAML::Node& node, const cfg_location& location) { - return get_node(node, loc.cbegin(), loc.cend()); + return get_node(node, location.cbegin(), location.cend()); } - QStringList get_options(cfg_location location) + QStringList get_options(const cfg_location& location) { QStringList values; - auto begin = location.cbegin(); - auto end = location.cend(); - for (const auto& v : cfg_adapter::get_cfg(g_cfg, begin, end).to_list()) + for (const auto& v : cfg_adapter::get_cfg(g_cfg, location.cbegin(), location.cend()).to_list()) { values.append(QString::fromStdString(v)); } return values; } - static bool get_is_dynamic(cfg_location location) + static bool get_is_dynamic(const cfg_location& location) { - auto begin = location.cbegin(); - auto end = location.cend(); - return cfg_adapter::get_cfg(g_cfg, begin, end).get_is_dynamic(); + return cfg_adapter::get_cfg(g_cfg, location.cbegin(), location.cend()).get_is_dynamic(); } bool get_is_dynamic(emu_settings_type type) diff --git a/rpcs3/rpcs3qt/config_adapter.h b/rpcs3/rpcs3qt/config_adapter.h index 3d7ab21f48..f808b58f97 100644 --- a/rpcs3/rpcs3qt/config_adapter.h +++ b/rpcs3/rpcs3qt/config_adapter.h @@ -8,13 +8,13 @@ // Helper methods to interact with YAML and the config settings. namespace cfg_adapter { - YAML::Node get_node(const YAML::Node& node, cfg_location::const_iterator begin, cfg_location::const_iterator end); + YAML::Node get_node(const YAML::Node& node, const cfg_location::const_iterator begin, const cfg_location::const_iterator end); /** Syntactic sugar to get a setting at a given config location. */ - YAML::Node get_node(const YAML::Node& node, cfg_location loc); + YAML::Node get_node(const YAML::Node& node, const cfg_location& location); /** Returns possible options for values for some particular setting.*/ - QStringList get_options(cfg_location location); + QStringList get_options(const cfg_location& location); /** Returns dynamic property for some particular setting.*/ bool get_is_dynamic(emu_settings_type type); diff --git a/rpcs3/rpcs3qt/curl_handle.cpp b/rpcs3/rpcs3qt/curl_handle.cpp index 4051fe9c76..280fa36d49 100644 --- a/rpcs3/rpcs3qt/curl_handle.cpp +++ b/rpcs3/rpcs3qt/curl_handle.cpp @@ -23,7 +23,7 @@ curl_handle::~curl_handle() curl_easy_cleanup(m_curl); } -CURL* curl_handle::get_curl() +CURL* curl_handle::get_curl() const { return m_curl; } diff --git a/rpcs3/rpcs3qt/curl_handle.h b/rpcs3/rpcs3qt/curl_handle.h index fc4502e7f1..65abee5978 100644 --- a/rpcs3/rpcs3qt/curl_handle.h +++ b/rpcs3/rpcs3qt/curl_handle.h @@ -13,12 +13,12 @@ private: CURL* m_curl = nullptr; public: - curl_handle(QObject* parent = nullptr); + explicit curl_handle(QObject* parent = nullptr); ~curl_handle(); - CURL* get_curl(); + CURL* get_curl() const; - operator CURL*() + operator CURL*() const { return get_curl(); } diff --git a/rpcs3/rpcs3qt/custom_table_widget_item.h b/rpcs3/rpcs3qt/custom_table_widget_item.h index 4dede4c910..e15fc9d16f 100644 --- a/rpcs3/rpcs3qt/custom_table_widget_item.h +++ b/rpcs3/rpcs3qt/custom_table_widget_item.h @@ -10,7 +10,7 @@ private: public: using QTableWidgetItem::setData; - custom_table_widget_item(){} + custom_table_widget_item() = default; custom_table_widget_item(const std::string& text, int sort_role = Qt::DisplayRole, const QVariant& sort_value = 0); custom_table_widget_item(const QString& text, int sort_role = Qt::DisplayRole, const QVariant& sort_value = 0); diff --git a/rpcs3/rpcs3qt/debugger_frame.cpp b/rpcs3/rpcs3qt/debugger_frame.cpp index b3aa8ccd64..9871aee198 100644 --- a/rpcs3/rpcs3qt/debugger_frame.cpp +++ b/rpcs3/rpcs3qt/debugger_frame.cpp @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -40,8 +39,9 @@ constexpr auto s_pause_flags = cpu_flag::dbg_pause + cpu_flag::dbg_global_pause; extern atomic_t g_debugger_pause_all_threads_on_bp; -debugger_frame::debugger_frame(std::shared_ptr settings, QWidget *parent) - : custom_dock_widget(tr("Debugger"), parent), xgui_settings(settings) +debugger_frame::debugger_frame(std::shared_ptr gui_settings, QWidget *parent) + : custom_dock_widget(tr("Debugger"), parent) + , m_gui_settings(std::move(gui_settings)) { setContentsMargins(0, 0, 0, 0); @@ -61,7 +61,7 @@ debugger_frame::debugger_frame(std::shared_ptr settings, QWidget * m_breakpoint_handler = new breakpoint_handler(); m_breakpoint_list = new breakpoint_list(this, m_breakpoint_handler); - m_debugger_list = new debugger_list(this, settings, m_breakpoint_handler); + m_debugger_list = new debugger_list(this, m_gui_settings, m_breakpoint_handler); m_debugger_list->installEventFilter(this); m_call_stack_list = new call_stack_list(this); @@ -181,8 +181,8 @@ debugger_frame::debugger_frame(std::shared_ptr settings, QWidget * m_choice_units->clearFocus(); }); - connect(m_choice_units, static_cast(&QComboBox::activated), this, &debugger_frame::UpdateUI); - connect(m_choice_units, static_cast(&QComboBox::currentIndexChanged), this, &debugger_frame::OnSelectUnit); + connect(m_choice_units, QOverload::of(&QComboBox::activated), this, &debugger_frame::UpdateUI); + connect(m_choice_units, QOverload::of(&QComboBox::currentIndexChanged), this, &debugger_frame::OnSelectUnit); connect(this, &QDockWidget::visibilityChanged, this, &debugger_frame::EnableUpdateTimer); connect(m_debugger_list, &debugger_list::BreakpointRequested, m_breakpoint_list, &breakpoint_list::HandleBreakpointRequest); @@ -195,28 +195,28 @@ debugger_frame::debugger_frame(std::shared_ptr settings, QWidget * UpdateUnitList(); } -void debugger_frame::SaveSettings() +void debugger_frame::SaveSettings() const { - xgui_settings->SetValue(gui::d_splitterState, m_splitter->saveState()); + m_gui_settings->SetValue(gui::d_splitterState, m_splitter->saveState()); } -void debugger_frame::ChangeColors() +void debugger_frame::ChangeColors() const { if (m_debugger_list) { m_debugger_list->m_color_bp = m_breakpoint_list->m_color_bp = gui::utils::get_label_color("debugger_frame_breakpoint", QPalette::Window); m_debugger_list->m_color_pc = gui::utils::get_label_color("debugger_frame_pc", QPalette::Window); - m_debugger_list->m_text_color_bp = m_breakpoint_list->m_text_color_bp = gui::utils::get_label_color("debugger_frame_breakpoint");; - m_debugger_list->m_text_color_pc = gui::utils::get_label_color("debugger_frame_pc");; + m_debugger_list->m_text_color_bp = m_breakpoint_list->m_text_color_bp = gui::utils::get_label_color("debugger_frame_breakpoint"); + m_debugger_list->m_text_color_pc = gui::utils::get_label_color("debugger_frame_pc"); } } -bool debugger_frame::eventFilter(QObject* object, QEvent* ev) +bool debugger_frame::eventFilter(QObject* object, QEvent* event) { // There's no overlap between keys so returning true wouldn't matter. - if (object == m_debugger_list && ev->type() == QEvent::KeyPress) + if (object == m_debugger_list && event->type() == QEvent::KeyPress) { - keyPressEvent(static_cast(ev)); + keyPressEvent(static_cast(event)); } return false; } @@ -230,7 +230,7 @@ void debugger_frame::closeEvent(QCloseEvent *event) void debugger_frame::showEvent(QShowEvent * event) { // resize splitter widgets - if (!m_splitter->restoreState(xgui_settings->GetValue(gui::d_splitterState).toByteArray())) + if (!m_splitter->restoreState(m_gui_settings->GetValue(gui::d_splitterState).toByteArray())) { const int width_right = width() / 3; const int width_left = width() - width_right; @@ -243,7 +243,7 @@ void debugger_frame::showEvent(QShowEvent * event) void debugger_frame::hideEvent(QHideEvent * event) { // save splitter state or it will resume its initial state on next show - xgui_settings->SetValue(gui::d_splitterState, m_splitter->saveState()); + m_gui_settings->SetValue(gui::d_splitterState, m_splitter->saveState()); QDockWidget::hideEvent(event); } @@ -280,7 +280,7 @@ void debugger_frame::keyPressEvent(QKeyEvent* event) } const auto cpu = get_cpu(); - int i = m_debugger_list->currentRow(); + const int row = m_debugger_list->currentRow(); switch (event->key()) { @@ -320,6 +320,7 @@ void debugger_frame::keyPressEvent(QKeyEvent* event) dlg->exec(); return; } + default: break; } if (!cpu) @@ -328,7 +329,7 @@ void debugger_frame::keyPressEvent(QKeyEvent* event) } const u32 address_limits = (cpu->id_type() == 2 ? 0x3fffc : ~3); - const u32 pc = (i >= 0 ? m_debugger_list->m_pc + i * 4 : cpu->get_pc()) & address_limits; + const u32 pc = (row >= 0 ? m_debugger_list->m_pc + row * 4 : cpu->get_pc()) & address_limits; const auto modifiers = QApplication::keyboardModifiers(); @@ -346,6 +347,7 @@ void debugger_frame::keyPressEvent(QKeyEvent* event) open_breakpoints_settings(); return; } + default: break; } } else @@ -386,9 +388,9 @@ void debugger_frame::keyPressEvent(QKeyEvent* event) max = 0; } - auto spu = static_cast(cpu); + const auto spu = static_cast(cpu); - auto ptr = reinterpret_cast(vm::g_stat_addr + spu->vm_offset()); + const auto ptr = reinterpret_cast(vm::g_stat_addr + spu->vm_offset()); std::string ret; @@ -497,8 +499,8 @@ void debugger_frame::keyPressEvent(QKeyEvent* event) default: break; } - if (auto pos = std::basic_string_view(res.data(), 2).find_last_not_of(UINT32_MAX); pos != umax) - m_debugger_list->ShowAddress(res[pos] - std::max(i, 0) * 4, true, true); + if (const size_t pos = std::basic_string_view(res.data(), 2).find_last_not_of(UINT32_MAX); pos != umax) + m_debugger_list->ShowAddress(res[pos] - std::max(row, 0) * 4, true, true); return; } @@ -518,6 +520,7 @@ void debugger_frame::keyPressEvent(QKeyEvent* event) DoStep(false); return; } + default: break; } } } @@ -670,7 +673,7 @@ void debugger_frame::UpdateUnitList() { if (emu_state == system_state::stopped) return; - QVariant var_cpu = QVariant::fromValue>(std::make_pair(&cpu, id)); + const QVariant var_cpu = QVariant::fromValue>(std::make_pair(&cpu, id)); m_choice_units->addItem(qstr(id >> 24 == 0x55 ? "RSX[0x55555555]" : cpu.get_name()), var_cpu); if (!reselected && old_cpu == var_cpu) @@ -689,7 +692,7 @@ void debugger_frame::UpdateUnitList() idm::select>(on_select); idm::select>(on_select); - if (auto render = g_fxo->try_get(); emu_state != system_state::stopped && render && render->ctrl) + if (const auto render = g_fxo->try_get(); emu_state != system_state::stopped && render && render->ctrl) { on_select(render->id, *render); } @@ -800,7 +803,7 @@ void debugger_frame::OnSelectUnit() void debugger_frame::DoUpdate() { // Check if we need to disable a step over bp - if (auto cpu0 = get_cpu(); cpu0 && m_last_step_over_breakpoint != umax && cpu0->get_pc() == m_last_step_over_breakpoint) + if (const auto cpu0 = get_cpu(); cpu0 && m_last_step_over_breakpoint != umax && cpu0->get_pc() == m_last_step_over_breakpoint) { m_breakpoint_handler->RemoveBreakpoint(m_last_step_over_breakpoint); m_last_step_over_breakpoint = -1; @@ -821,9 +824,7 @@ void debugger_frame::WritePanels() return; } - int loc; - - loc = m_misc_state->verticalScrollBar()->value(); + int loc = m_misc_state->verticalScrollBar()->value(); m_misc_state->clear(); m_misc_state->setText(qstr(cpu->dump_misc())); m_misc_state->verticalScrollBar()->setValue(loc); @@ -852,7 +853,7 @@ void debugger_frame::ShowGotoAddressDialog() expression_input->setFont(m_mono); expression_input->setMaxLength(18); - if (auto thread = get_cpu(); !thread || thread->id_type() != 2) + if (const auto thread = get_cpu(); !thread || thread->id_type() != 2) { expression_input->setValidator(new QRegExpValidator(QRegExp("^(0[xX])?0*[a-fA-F0-9]{0,8}$"))); } @@ -907,11 +908,11 @@ u64 debugger_frame::EvaluateExpression(const QString& expression) const u64 res = static_cast(fixed_expression.toULong(&ok, 16)); if (ok) return res; - if (auto thread = get_cpu()) return thread->get_pc(); + if (const auto thread = get_cpu()) return thread->get_pc(); return 0; } -void debugger_frame::ClearBreakpoints() +void debugger_frame::ClearBreakpoints() const { m_breakpoint_list->ClearBreakpoints(); } @@ -936,14 +937,14 @@ void debugger_frame::DoStep(bool step_over) { bool should_step_over = step_over && cpu->id_type() == 1; - if (auto _state = +cpu->state; _state & s_pause_flags && _state & cpu_flag::wait && !(_state & cpu_flag::dbg_step)) + if (const auto _state = +cpu->state; _state & s_pause_flags && _state & cpu_flag::wait && !(_state & cpu_flag::dbg_step)) { if (should_step_over) { - u32 current_instruction_pc = cpu->get_pc(); + const u32 current_instruction_pc = cpu->get_pc(); // Set breakpoint on next instruction - u32 next_instruction_pc = current_instruction_pc + 4; + const u32 next_instruction_pc = current_instruction_pc + 4; m_breakpoint_handler->AddBreakpoint(next_instruction_pc); // Undefine previous step over breakpoint if it hasnt been already @@ -977,7 +978,7 @@ void debugger_frame::DoStep(bool step_over) UpdateUI(); } -void debugger_frame::EnableUpdateTimer(bool enable) +void debugger_frame::EnableUpdateTimer(bool enable) const { enable ? m_update->start(50) : m_update->stop(); } diff --git a/rpcs3/rpcs3qt/debugger_frame.h b/rpcs3/rpcs3qt/debugger_frame.h index 7fe9fcdb5b..fb2a8403ed 100644 --- a/rpcs3/rpcs3qt/debugger_frame.h +++ b/rpcs3/rpcs3qt/debugger_frame.h @@ -69,17 +69,17 @@ class debugger_frame : public custom_dock_widget instruction_editor_dialog* m_inst_editor = nullptr; register_editor_dialog* m_reg_editor = nullptr; - std::shared_ptr xgui_settings; + std::shared_ptr m_gui_settings; cpu_thread* get_cpu(); std::function make_check_cpu(cpu_thread* cpu); void open_breakpoints_settings(); public: - explicit debugger_frame(std::shared_ptr settings, QWidget *parent = 0); + explicit debugger_frame(std::shared_ptr settings, QWidget *parent = nullptr); - void SaveSettings(); - void ChangeColors(); + void SaveSettings() const; + void ChangeColors() const; void UpdateUI(); void UpdateUnitList(); @@ -89,7 +89,7 @@ public: void EnableButtons(bool enable); void ShowGotoAddressDialog(); u64 EvaluateExpression(const QString& expression); - void ClearBreakpoints(); // Fallthrough method into breakpoint_list. + void ClearBreakpoints() const; // Fallthrough method into breakpoint_list. void ClearCallStack(); /** Needed so key press events work when other objects are selected in debugger_frame. */ @@ -103,7 +103,7 @@ protected: Q_SIGNALS: void DebugFrameClosed(); - void CallStackUpdateRequested(std::vector> call_stack); + void CallStackUpdateRequested(const std::vector>& call_stack); public Q_SLOTS: void DoStep(bool step_over = false); @@ -111,7 +111,7 @@ public Q_SLOTS: private Q_SLOTS: void OnSelectUnit(); void ShowPC(); - void EnableUpdateTimer(bool state); + void EnableUpdateTimer(bool enable) const; }; Q_DECLARE_METATYPE(u32) diff --git a/rpcs3/rpcs3qt/debugger_list.cpp b/rpcs3/rpcs3qt/debugger_list.cpp index 95084b1807..46463931d3 100644 --- a/rpcs3/rpcs3qt/debugger_list.cpp +++ b/rpcs3/rpcs3qt/debugger_list.cpp @@ -19,9 +19,9 @@ constexpr auto qstr = QString::fromStdString; -debugger_list::debugger_list(QWidget* parent, std::shared_ptr settings, breakpoint_handler* handler) +debugger_list::debugger_list(QWidget* parent, std::shared_ptr gui_settings, breakpoint_handler* handler) : QListWidget(parent) - , m_gui_settings(settings) + , m_gui_settings(std::move(gui_settings)) , m_breakpoint_handler(handler) { setWindowTitle(tr("ASM")); @@ -189,7 +189,6 @@ void debugger_list::keyPressEvent(QKeyEvent* event) } return; } - default: break; } } @@ -281,7 +280,7 @@ void debugger_list::wheelEvent(QWheelEvent* event) void debugger_list::resizeEvent(QResizeEvent* event) { - Q_UNUSED(event); + Q_UNUSED(event) if (count() < 1 || visualItemRect(item(0)).height() < 1) { diff --git a/rpcs3/rpcs3qt/debugger_list.h b/rpcs3/rpcs3qt/debugger_list.h index 63a2ba08a1..8fe7c24a12 100644 --- a/rpcs3/rpcs3qt/debugger_list.h +++ b/rpcs3/rpcs3qt/debugger_list.h @@ -50,7 +50,7 @@ private: breakpoint_handler* m_breakpoint_handler; cpu_thread* m_cpu = nullptr; - CPUDisAsm* m_disasm; + CPUDisAsm* m_disasm = nullptr; QDialog* m_cmd_detail = nullptr; QLabel* m_detail_label = nullptr; }; diff --git a/rpcs3/rpcs3qt/downloader.cpp b/rpcs3/rpcs3qt/downloader.cpp index 571aeccc0e..e286559a61 100644 --- a/rpcs3/rpcs3qt/downloader.cpp +++ b/rpcs3/rpcs3qt/downloader.cpp @@ -12,7 +12,7 @@ LOG_CHANNEL(network_log, "NETWORK"); usz curl_write_cb_compat(char* ptr, usz /*size*/, usz nmemb, void* userdata) { - downloader* download = reinterpret_cast(userdata); + downloader* download = static_cast(userdata); return download->update_buffer(ptr, nmemb); } @@ -32,7 +32,7 @@ downloader::~downloader() } } -void downloader::start(const std::string& url, bool follow_location, bool show_progress_dialog, const QString& progress_dialog_title, bool keep_progress_dialog_open, int exptected_size) +void downloader::start(const std::string& url, bool follow_location, bool show_progress_dialog, const QString& progress_dialog_title, bool keep_progress_dialog_open, int expected_size) { if (m_thread) { @@ -91,7 +91,7 @@ void downloader::start(const std::string& url, bool follow_location, bool show_p if (show_progress_dialog) { - const int maximum = exptected_size > 0 ? exptected_size : 100; + const int maximum = expected_size > 0 ? expected_size : 100; if (m_progress_dialog) { @@ -121,7 +121,7 @@ void downloader::start(const std::string& url, bool follow_location, bool show_p m_thread->start(); } -void downloader::update_progress_dialog(const QString& title) +void downloader::update_progress_dialog(const QString& title) const { if (m_progress_dialog) { @@ -191,7 +191,7 @@ usz downloader::update_buffer(char* data, usz size) return size; } -void downloader::handle_buffer_update(int size, int max) +void downloader::handle_buffer_update(int size, int max) const { if (m_curl_abort) { diff --git a/rpcs3/rpcs3qt/downloader.h b/rpcs3/rpcs3qt/downloader.h index 168ac2a88c..cde365f653 100644 --- a/rpcs3/rpcs3qt/downloader.h +++ b/rpcs3/rpcs3qt/downloader.h @@ -17,7 +17,7 @@ public: void start(const std::string& url, bool follow_location, bool show_progress_dialog, const QString& progress_dialog_title = "", bool keep_progress_dialog_open = false, int expected_size = -1); usz update_buffer(char* data, usz size); - void update_progress_dialog(const QString& title); + void update_progress_dialog(const QString& title) const; void close_progress_dialog(); progress_dialog* get_progress_dialog() const; @@ -25,7 +25,7 @@ public: static std::string get_hash(const char* data, usz size, bool lower_case); private Q_SLOTS: - void handle_buffer_update(int size, int max); + void handle_buffer_update(int size, int max) const; Q_SIGNALS: void signal_download_error(const QString& error); diff --git a/rpcs3/rpcs3qt/emu_settings.cpp b/rpcs3/rpcs3qt/emu_settings.cpp index 23e95588b2..e02e275013 100644 --- a/rpcs3/rpcs3qt/emu_settings.cpp +++ b/rpcs3/rpcs3qt/emu_settings.cpp @@ -67,10 +67,6 @@ emu_settings::emu_settings() { } -emu_settings::~emu_settings() -{ -} - bool emu_settings::Init() { m_render_creator = new render_creator(this); @@ -265,7 +261,7 @@ bool emu_settings::ValidateSettings(bool cleanup) return is_clean; } -void emu_settings::SaveSettings() +void emu_settings::SaveSettings() const { YAML::Emitter out; emit_data(out, m_current_settings); @@ -342,7 +338,7 @@ void emu_settings::EnhanceComboBox(QComboBox* combobox, emu_settings_type type, } // Since the QComboBox has localised strings, we can't just findText / findData, so we need to manually iterate through it to find our index - auto find_index = [&](const QString& value) + const auto find_index = [&](const QString& value) { for (int i = 0; i < combobox->count(); i++) { @@ -359,7 +355,7 @@ void emu_settings::EnhanceComboBox(QComboBox* combobox, emu_settings_type type, const std::string selected = GetSetting(type); const QString selected_q = qstr(selected); - int index = -1; + int index; if (is_ranged) { @@ -389,7 +385,7 @@ void emu_settings::EnhanceComboBox(QComboBox* combobox, emu_settings_type type, combobox->setCurrentIndex(index); - connect(combobox, static_cast(&QComboBox::currentIndexChanged), [=, this](int index) + connect(combobox, QOverload::of(&QComboBox::currentIndexChanged), combobox, [this, is_ranged, combobox, type](int index) { if (is_ranged) { @@ -765,14 +761,14 @@ void emu_settings::SaveSelectedLibraries(const std::vector& libs) m_current_settings["Core"]["Libraries Control"] = libs; } -QStringList emu_settings::GetSettingOptions(emu_settings_type type) const +QStringList emu_settings::GetSettingOptions(emu_settings_type type) { return cfg_adapter::get_options(const_cast(settings_location[type])); } std::string emu_settings::GetSettingDefault(emu_settings_type type) const { - if (auto node = cfg_adapter::get_node(m_default_settings, settings_location[type]); node && node.IsScalar()) + if (const auto node = cfg_adapter::get_node(m_default_settings, settings_location[type]); node && node.IsScalar()) { return node.Scalar(); } @@ -783,7 +779,7 @@ std::string emu_settings::GetSettingDefault(emu_settings_type type) const std::string emu_settings::GetSetting(emu_settings_type type) const { - if (auto node = cfg_adapter::get_node(m_current_settings, settings_location[type]); node && node.IsScalar()) + if (const auto node = cfg_adapter::get_node(m_current_settings, settings_location[type]); node && node.IsScalar()) { return node.Scalar(); } @@ -792,7 +788,7 @@ std::string emu_settings::GetSetting(emu_settings_type type) const return ""; } -void emu_settings::SetSetting(emu_settings_type type, const std::string& val) +void emu_settings::SetSetting(emu_settings_type type, const std::string& val) const { cfg_adapter::get_node(m_current_settings, settings_location[type]) = val; } diff --git a/rpcs3/rpcs3qt/emu_settings.h b/rpcs3/rpcs3qt/emu_settings.h index bebacb2e67..f901b0bc2c 100644 --- a/rpcs3/rpcs3qt/emu_settings.h +++ b/rpcs3/rpcs3qt/emu_settings.h @@ -32,7 +32,6 @@ public: * Settings are only written when SaveSettings is called. */ emu_settings(); - ~emu_settings(); bool Init(); @@ -49,10 +48,10 @@ public: void EnhanceSlider(QSlider* slider, emu_settings_type type); /** Connects an integer spin box with the target settings type*/ - void EnhanceSpinBox(QSpinBox* slider, emu_settings_type type, const QString& prefix = "", const QString& suffix = ""); + void EnhanceSpinBox(QSpinBox* spinbox, emu_settings_type type, const QString& prefix = "", const QString& suffix = ""); /** Connects a double spin box with the target settings type*/ - void EnhanceDoubleSpinBox(QDoubleSpinBox* slider, emu_settings_type type, const QString& prefix = "", const QString& suffix = ""); + void EnhanceDoubleSpinBox(QDoubleSpinBox* spinbox, emu_settings_type type, const QString& prefix = "", const QString& suffix = ""); /** Connects a line edit with the target settings type*/ void EnhanceLineEdit(QLineEdit* edit, emu_settings_type type); @@ -64,7 +63,7 @@ public: void SaveSelectedLibraries(const std::vector& libs); /** Returns the valid options for a given setting.*/ - QStringList GetSettingOptions(emu_settings_type type) const; + static QStringList GetSettingOptions(emu_settings_type type); /** Returns the default value of the setting type.*/ std::string GetSettingDefault(emu_settings_type type) const; @@ -73,7 +72,7 @@ public: std::string GetSetting(emu_settings_type type) const; /** Sets the setting type to a given value.*/ - void SetSetting(emu_settings_type type, const std::string& val); + void SetSetting(emu_settings_type type, const std::string& val) const; /** Gets all the renderer info for gpu settings.*/ render_creator* m_render_creator = nullptr; @@ -95,7 +94,7 @@ public: public Q_SLOTS: /** Writes the unsaved settings to file. Used in settings dialog on accept.*/ - void SaveSettings(); + void SaveSettings() const; private: YAML::Node m_default_settings; // The default settings as a YAML node. YAML::Node m_current_settings; // The current settings as a YAML node. diff --git a/rpcs3/rpcs3qt/fatal_error_dialog.h b/rpcs3/rpcs3qt/fatal_error_dialog.h index f7b4586c4e..69f7d09cc9 100644 --- a/rpcs3/rpcs3qt/fatal_error_dialog.h +++ b/rpcs3/rpcs3qt/fatal_error_dialog.h @@ -9,5 +9,5 @@ class fatal_error_dialog : public QMessageBox Q_OBJECT public: - fatal_error_dialog(std::string_view text); + explicit fatal_error_dialog(std::string_view text); }; diff --git a/rpcs3/rpcs3qt/find_dialog.cpp b/rpcs3/rpcs3qt/find_dialog.cpp index ce8ef6b4af..69b7a2f1f4 100644 --- a/rpcs3/rpcs3qt/find_dialog.cpp +++ b/rpcs3/rpcs3qt/find_dialog.cpp @@ -54,16 +54,15 @@ int find_dialog::count_all() return 0; } - QTextCursor old_cursor = m_text_edit->textCursor(); + const QTextCursor old_cursor = m_text_edit->textCursor(); m_text_edit->moveCursor(QTextCursor::Start); int old_line_index = -1; - int new_line_index = 0; while (m_text_edit->find(m_find_bar->text())) { m_count_total++; - new_line_index = m_text_edit->textCursor().blockNumber(); + const int new_line_index = m_text_edit->textCursor().blockNumber(); if (new_line_index != old_line_index) { @@ -111,7 +110,7 @@ void find_dialog::find_previous() m_text_edit->find(m_find_bar->text(), QTextDocument::FindBackward); } -void find_dialog::show_count() +void find_dialog::show_count() const { m_label_count_lines->setText(tr("Counted in lines: %0").arg(m_count_lines)); m_label_count_total->setText(tr("Counted in total: %0").arg(m_count_total)); diff --git a/rpcs3/rpcs3qt/find_dialog.h b/rpcs3/rpcs3qt/find_dialog.h index a1de7a0dd8..d99363b654 100644 --- a/rpcs3/rpcs3qt/find_dialog.h +++ b/rpcs3/rpcs3qt/find_dialog.h @@ -31,5 +31,5 @@ private Q_SLOTS: void find_last(); void find_next(); void find_previous(); - void show_count(); + void show_count() const; }; diff --git a/rpcs3/rpcs3qt/game_compatibility.cpp b/rpcs3/rpcs3qt/game_compatibility.cpp index 2860132047..b58d9ca850 100644 --- a/rpcs3/rpcs3qt/game_compatibility.cpp +++ b/rpcs3/rpcs3qt/game_compatibility.cpp @@ -16,9 +16,9 @@ LOG_CHANNEL(compat_log, "Compat"); constexpr auto qstr = QString::fromStdString; inline std::string sstr(const QString& _in) { return _in.toStdString(); } -game_compatibility::game_compatibility(std::shared_ptr settings, QWidget* parent) +game_compatibility::game_compatibility(std::shared_ptr gui_settings, QWidget* parent) : QObject(parent) - , m_gui_settings(settings) + , m_gui_settings(std::move(gui_settings)) { m_filepath = m_gui_settings->GetSettingsDir() + "/compat_database.dat"; m_downloader = new downloader(parent); @@ -33,12 +33,12 @@ void game_compatibility::handle_download_error(const QString& error) Q_EMIT DownloadError(error); } -void game_compatibility::handle_download_finished(const QByteArray& data) +void game_compatibility::handle_download_finished(const QByteArray& content) { compat_log.notice("Database download finished"); // Create new map from database and write database to file if database was valid - if (ReadJSON(QJsonDocument::fromJson(data).object(), true)) + if (ReadJSON(QJsonDocument::fromJson(content).object(), true)) { // We have a new database in map, therefore refresh gamelist to new state Q_EMIT DownloadFinished(); @@ -57,7 +57,7 @@ void game_compatibility::handle_download_finished(const QByteArray& data) return; } - file.write(data); + file.write(content); file.close(); compat_log.success("Wrote database to file: %s", sstr(m_filepath)); @@ -206,13 +206,13 @@ void game_compatibility::RequestCompatibility(bool online) return; } - const QByteArray data = file.readAll(); + const QByteArray content = file.readAll(); file.close(); compat_log.notice("Finished reading database from file: %s", sstr(m_filepath)); // Create new map from database - ReadJSON(QJsonDocument::fromJson(data).object(), online); + ReadJSON(QJsonDocument::fromJson(content).object(), online); return; } @@ -240,7 +240,7 @@ compat::status game_compatibility::GetCompatibility(const std::string& title_id) return Status_Data.at("NoResult"); } -compat::status game_compatibility::GetStatusData(const QString& status) +compat::status game_compatibility::GetStatusData(const QString& status) const { return Status_Data.at(status); } @@ -249,18 +249,18 @@ compat::package_info game_compatibility::GetPkgInfo(const QString& pkg_path, gam { compat::package_info info; - package_reader reader(pkg_path.toStdString()); + const package_reader reader(pkg_path.toStdString()); if (!reader.is_valid()) { info.is_valid = false; return info; } - psf::registry psf = reader.get_psf(); + const psf::registry psf = reader.get_psf(); // TODO: localization of title and changelog - std::string title_key = "TITLE"; - std::string changelog_key = "paramhip"; + const std::string title_key = "TITLE"; + const std::string changelog_key = "paramhip"; info.path = pkg_path; info.title = qstr(std::string(psf::get_string(psf, title_key))); // Let's read this from the psf first diff --git a/rpcs3/rpcs3qt/game_compatibility.h b/rpcs3/rpcs3qt/game_compatibility.h index 9d73521b34..2572dcd4a3 100644 --- a/rpcs3/rpcs3qt/game_compatibility.h +++ b/rpcs3/rpcs3qt/game_compatibility.h @@ -37,13 +37,13 @@ namespace compat std::string get_changelog(const std::string& type) const { - if (auto it = std::find_if(changelogs.begin(), changelogs.end(), [type](const pkg_changelog& cl) { return cl.type == type; }); - it != changelogs.end()) + if (const auto it = std::find_if(changelogs.cbegin(), changelogs.cend(), [type](const pkg_changelog& cl) { return cl.type == type; }); + it != changelogs.cend()) { return it->content; } - if (auto it = std::find_if(changelogs.begin(), changelogs.end(), [](const pkg_changelog& cl) { return cl.type == "paramhip"; }); - it != changelogs.end()) + if (const auto it = std::find_if(changelogs.cbegin(), changelogs.cend(), [](const pkg_changelog& cl) { return cl.type == "paramhip"; }); + it != changelogs.cend()) { return it->content; } @@ -52,12 +52,12 @@ namespace compat std::string get_title(const std::string& type) const { - if (auto it = std::find_if(titles.begin(), titles.end(), [type](const pkg_title& t) { return t.type == type; }); - it != titles.end()) + if (const auto it = std::find_if(titles.cbegin(), titles.cend(), [type](const pkg_title& t) { return t.type == type; }); + it != titles.cend()) { return it->title; } - if (auto it = std::find_if(titles.begin(), titles.end(), [](const pkg_title& t) { return t.type == "TITLE"; }); + if (const auto it = std::find_if(titles.cbegin(), titles.cend(), [](const pkg_title& t) { return t.type == "TITLE"; }); it != titles.end()) { return it->title; @@ -80,7 +80,7 @@ namespace compat /** Represents the json object that contains an app's information and some additional info that is used in the GUI */ struct status { - int index; + int index = 0; QString date; QString color; QString text; @@ -149,7 +149,7 @@ public: compat::status GetCompatibility(const std::string& title_id); /** Returns the data for the requested status */ - compat::status GetStatusData(const QString& status); + compat::status GetStatusData(const QString& status) const; /** Returns package information like title, version, changelog etc. */ static compat::package_info GetPkgInfo(const QString& pkg_path, game_compatibility* compat); @@ -161,13 +161,13 @@ Q_SIGNALS: private Q_SLOTS: void handle_download_error(const QString& error); - void handle_download_finished(const QByteArray& data); + void handle_download_finished(const QByteArray& content); }; class compat_pixmap : public QPixmap { public: - compat_pixmap(const QColor& color, qreal pixel_ratio) : QPixmap(16 * pixel_ratio, 16 * pixel_ratio) + compat_pixmap(const QColor& color, qreal pixel_ratio) : QPixmap(pixel_ratio * 16, pixel_ratio * 16) { fill(Qt::transparent); diff --git a/rpcs3/rpcs3qt/game_list_frame.cpp b/rpcs3/rpcs3qt/game_list_frame.cpp index 065a9311dc..c698e56b0e 100644 --- a/rpcs3/rpcs3qt/game_list_frame.cpp +++ b/rpcs3/rpcs3qt/game_list_frame.cpp @@ -24,7 +24,6 @@ #include "Input/pad_thread.h" #include -#include #include #include #include @@ -37,7 +36,6 @@ #include #include #include -#include #include #include #include @@ -49,9 +47,9 @@ inline std::string sstr(const QString& _in) { return _in.toStdString(); } game_list_frame::game_list_frame(std::shared_ptr gui_settings, std::shared_ptr emu_settings, std::shared_ptr persistent_settings, QWidget* parent) : custom_dock_widget(tr("Game List"), parent) - , m_gui_settings(gui_settings) - , m_emu_settings(emu_settings) - , m_persistent_settings(persistent_settings) + , m_gui_settings(std::move(gui_settings)) + , m_emu_settings(std::move(emu_settings)) + , m_persistent_settings(std::move(persistent_settings)) { m_icon_size = gui::gl_icon_size_min; // ensure a valid size m_is_list_layout = m_gui_settings->GetValue(gui::gl_listMode).toBool(); @@ -239,7 +237,7 @@ game_list_frame::~game_list_frame() SaveSettings(); } -void game_list_frame::FixNarrowColumns() +void game_list_frame::FixNarrowColumns() const { qApp->processEvents(); @@ -258,7 +256,7 @@ void game_list_frame::FixNarrowColumns() } } -void game_list_frame::ResizeColumnsToContents(int spacing) +void game_list_frame::ResizeColumnsToContents(int spacing) const { if (!m_game_list) { @@ -316,11 +314,11 @@ bool game_list_frame::IsEntryVisible(const game_info& game) }; const QString serial = qstr(game->info.serial); - bool is_visible = m_show_hidden || !m_hidden_list.contains(serial); + const bool is_visible = m_show_hidden || !m_hidden_list.contains(serial); return is_visible && matches_category() && SearchMatchesApp(qstr(game->info.name), serial); } -void game_list_frame::SortGameList() +void game_list_frame::SortGameList() const { // Back-up old header sizes to handle unwanted column resize in case of zero search results QList column_widths; @@ -387,14 +385,14 @@ void game_list_frame::SortGameList() m_game_list->resizeColumnToContents(gui::column_count - 1); } -QString game_list_frame::GetLastPlayedBySerial(const QString& serial) +QString game_list_frame::GetLastPlayedBySerial(const QString& serial) const { return m_persistent_settings->GetLastPlayed(serial); } std::string game_list_frame::GetCacheDirBySerial(const std::string& serial) { - return Emu.GetCacheDir() + serial; + return Emulator::GetCacheDir() + serial; } std::string game_list_frame::GetDataDirBySerial(const std::string& serial) @@ -414,7 +412,7 @@ void game_list_frame::Refresh(const bool from_drive, const bool scroll_after) m_notes.clear(); const std::string _hdd = Emulator::GetHddDir(); - const std::string cat_unknown = sstr(category::cat_unknown); + const std::string cat_unknown = sstr(cat::cat_unknown); const std::string cat_unknown_localized = sstr(localized.category.unknown); std::vector path_list; @@ -476,9 +474,7 @@ void game_list_frame::Refresh(const bool from_drive, const bool scroll_after) auto get_games = []() -> YAML::Node { - fs::file games(fs::get_config_dir() + "/games.yml", fs::read + fs::create); - - if (games) + if (const fs::file games = fs::file(fs::get_config_dir() + "/games.yml", fs::read + fs::create)) { auto [result, error] = yaml_load(games.to_string()); @@ -490,12 +486,8 @@ void game_list_frame::Refresh(const bool from_drive, const bool scroll_after) return result; } - else - { - game_list_log.error("Failed to load games.yml, check permissions."); - return {}; - } + game_list_log.error("Failed to load games.yml, check permissions."); return {}; }; @@ -549,7 +541,7 @@ void game_list_frame::Refresh(const bool from_drive, const bool scroll_after) const Localized thread_localized; { - const std::string sfo_dir = Emulator::GetSfoDirFromGamePath(dir, Emu.GetUsr()); + const std::string sfo_dir = Emulator::GetSfoDirFromGamePath(dir); const psf::registry psf = psf::load_object(fs::file(sfo_dir + "/PARAM.SFO")); @@ -696,7 +688,7 @@ void game_list_frame::Refresh(const bool from_drive, const bool scroll_after) for (auto&& g : games.pop_all()) { - m_game_data.push_back(std::move(g)); + m_game_data.push_back(g); } // Try to update the app version for disc games if there is a patch @@ -1090,9 +1082,9 @@ void game_list_frame::ShowContextMenu(const QPoint &pos) if (action != icon_action::remove) { - if (QFile file(icon_path); !file.copy(icon_path, game_icon_path)) + if (!QFile::copy(icon_path, game_icon_path)) { - game_list_log.error("Could not import image '%s' to '%s'. %s", sstr(icon_path), sstr(game_icon_path), sstr(file.errorString())); + game_list_log.error("Could not import image '%s' to '%s'.", sstr(icon_path), sstr(game_icon_path)); QMessageBox::warning(this, tr("Warning!"), tr("Failed to import the new image!")); } else @@ -1315,11 +1307,11 @@ void game_list_frame::ShowContextMenu(const QPoint &pos) // Disable options depending on software category const QString category = qstr(current_game.category); - if (category == cat_disc_game) + if (category == cat::cat_disc_game) { remove_game->setEnabled(false); } - else if (category != cat_hdd_game) + else if (category != cat::cat_hdd_game) { check_compat->setEnabled(false); } @@ -1342,7 +1334,7 @@ bool game_list_frame::CreatePPUCache(const game_info& game) return true; } -bool game_list_frame::RemoveCustomConfiguration(const std::string& title_id, game_info game, bool is_interactive) +bool game_list_frame::RemoveCustomConfiguration(const std::string& title_id, const game_info& game, bool is_interactive) { const std::string config_path_new = Emulator::GetCustomConfigPath(title_id); const std::string config_path_old = Emulator::GetCustomConfigPath(title_id, true); @@ -1384,7 +1376,7 @@ bool game_list_frame::RemoveCustomConfiguration(const std::string& title_id, gam return result; } -bool game_list_frame::RemoveCustomPadConfiguration(const std::string& title_id, game_info game, bool is_interactive) +bool game_list_frame::RemoveCustomPadConfiguration(const std::string& title_id, const game_info& game, bool is_interactive) { const std::string config_dir = Emulator::GetCustomInputConfigDir(title_id); @@ -1411,7 +1403,8 @@ bool game_list_frame::RemoveCustomPadConfiguration(const std::string& title_id, game_list_log.notice("Removed pad configuration directory: %s", config_dir); return true; } - else if (is_interactive) + + if (is_interactive) { QMessageBox::warning(this, tr("Warning!"), tr("Failed to completely remove pad configuration directory!")); game_list_log.fatal("Failed to completely remove pad configuration directory: %s\nError: %s", config_dir, fs::g_tls_error); @@ -1803,7 +1796,7 @@ void game_list_frame::BatchRemoveShaderCaches() QApplication::beep(); } -QPixmap game_list_frame::PaintedPixmap(QPixmap icon, bool paint_config_icon, bool paint_pad_config_icon, const QColor& compatibility_color) +QPixmap game_list_frame::PaintedPixmap(const QPixmap& icon, bool paint_config_icon, bool paint_pad_config_icon, const QColor& compatibility_color) const { const qreal device_pixel_ratio = devicePixelRatioF(); QSize canvas_size(320, 176); @@ -1900,7 +1893,7 @@ QPixmap game_list_frame::PaintedPixmap(QPixmap icon, bool paint_config_icon, boo return canvas.scaled(m_icon_size * device_pixel_ratio, Qt::KeepAspectRatio, Qt::TransformationMode::SmoothTransformation); } -void game_list_frame::ShowCustomConfigIcon(game_info game) +void game_list_frame::ShowCustomConfigIcon(const game_info& game) { if (!game) { @@ -1911,7 +1904,7 @@ void game_list_frame::ShowCustomConfigIcon(game_info game) const bool has_custom_config = game->hasCustomConfig; const bool has_custom_pad_config = game->hasCustomPadConfig; - for (auto other_game : m_game_data) + for (const auto& other_game : m_game_data) { if (other_game->info.serial == serial) { @@ -2001,7 +1994,7 @@ bool game_list_frame::eventFilter(QObject *object, QEvent *event) if (wheel_event->modifiers() & Qt::ControlModifier) { - QPoint num_steps = wheel_event->angleDelta() / 8 / 15; // http://doc.qt.io/qt-5/qwheelevent.html#pixelDelta + const QPoint num_steps = wheel_event->angleDelta() / 8 / 15; // http://doc.qt.io/qt-5/qwheelevent.html#pixelDelta const int value = num_steps.y(); Q_EMIT RequestIconSizeChange(value); return true; @@ -2038,7 +2031,7 @@ bool game_list_frame::eventFilter(QObject *object, QEvent *event) if (!item || !item->isSelected()) return false; - game_info gameinfo = GetGameInfoFromItem(item); + const game_info gameinfo = GetGameInfoFromItem(item); if (!gameinfo) return false; @@ -2061,7 +2054,7 @@ void game_list_frame::PopulateGameList() { int selected_row = -1; - std::string selected_item = CurrentSelectionPath(); + const std::string selected_item = CurrentSelectionPath(); m_game_list->clearSelection(); m_game_list->clearContents(); @@ -2115,7 +2108,7 @@ void game_list_frame::PopulateGameList() } // Move Support (http://www.psdevwiki.com/ps3/PARAM.SFO#ATTRIBUTE) - bool supports_move = game->info.attr & 0x800000; + const bool supports_move = game->info.attr & 0x800000; // Compatibility custom_table_widget_item* compat_item = new custom_table_widget_item; @@ -2316,8 +2309,7 @@ std::string game_list_frame::CurrentSelectionPath() if (var.canConvert()) { - auto game = var.value(); - if (game) + if (const game_info game = var.value()) { selection = game->info.path + game->info.icon_path; } @@ -2359,7 +2351,7 @@ std::string game_list_frame::GetStringFromU32(const u32& key, const std::map(); } -QColor game_list_frame::getGridCompatibilityColor(const QString& string) +QColor game_list_frame::getGridCompatibilityColor(const QString& string) const { if (m_draw_compat_status_to_grid && !m_is_list_layout) { diff --git a/rpcs3/rpcs3qt/game_list_frame.h b/rpcs3/rpcs3qt/game_list_frame.h index cda85a8906..35504080ee 100644 --- a/rpcs3/rpcs3qt/game_list_frame.h +++ b/rpcs3/rpcs3qt/game_list_frame.h @@ -44,10 +44,10 @@ public: ~game_list_frame(); /** Fix columns with width smaller than the minimal section size */ - void FixNarrowColumns(); + void FixNarrowColumns() const; /** Resizes the columns to their contents and adds a small spacing */ - void ResizeColumnsToContents(int spacing = 20); + void ResizeColumnsToContents(int spacing = 20) const; /** Refresh the gamelist with/without loading game data from files. Public so that main frame can refresh after vfs or install */ void Refresh(const bool from_drive = false, const bool scroll_after = true); @@ -69,7 +69,7 @@ public: void SetShowHidden(bool show); - game_compatibility* GetGameCompatibility() const { return m_game_compat; }; + game_compatibility* GetGameCompatibility() const { return m_game_compat; } QList GetGameInfo() const; @@ -105,30 +105,30 @@ protected: void resizeEvent(QResizeEvent *event) override; bool eventFilter(QObject *object, QEvent *event) override; private: - QPixmap PaintedPixmap(QPixmap icon, bool paint_config_icon = false, bool paint_pad_config_icon = false, const QColor& color = QColor()); - QColor getGridCompatibilityColor(const QString& string); - void ShowCustomConfigIcon(game_info game); + QPixmap PaintedPixmap(const QPixmap& icon, bool paint_config_icon = false, bool paint_pad_config_icon = false, const QColor& color = QColor()) const; + QColor getGridCompatibilityColor(const QString& string) const; + void ShowCustomConfigIcon(const game_info& game); void PopulateGameList(); void PopulateGameGrid(int maxCols, const QSize& image_size, const QColor& image_color); bool IsEntryVisible(const game_info& game); - void SortGameList(); + void SortGameList() const; bool SearchMatchesApp(const QString& name, const QString& serial) const; - bool RemoveCustomConfiguration(const std::string& title_id, game_info game = nullptr, bool is_interactive = false); - bool RemoveCustomPadConfiguration(const std::string& title_id, game_info game = nullptr, bool is_interactive = false); + bool RemoveCustomConfiguration(const std::string& title_id, const game_info& game = nullptr, bool is_interactive = false); + bool RemoveCustomPadConfiguration(const std::string& title_id, const game_info& game = nullptr, bool is_interactive = false); bool RemoveShadersCache(const std::string& base_dir, bool is_interactive = false); bool RemovePPUCache(const std::string& base_dir, bool is_interactive = false); bool RemoveSPUCache(const std::string& base_dir, bool is_interactive = false); - bool CreatePPUCache(const game_info& game); + static bool CreatePPUCache(const game_info& game); - QString GetLastPlayedBySerial(const QString& serial); - std::string GetCacheDirBySerial(const std::string& serial); - std::string GetDataDirBySerial(const std::string& serial); + QString GetLastPlayedBySerial(const QString& serial) const; + static std::string GetCacheDirBySerial(const std::string& serial); + static std::string GetDataDirBySerial(const std::string& serial); std::string CurrentSelectionPath(); - std::string GetStringFromU32(const u32& key, const std::map& map, bool combined = false); + static std::string GetStringFromU32(const u32& key, const std::map& map, bool combined = false); - game_info GetGameInfoByMode(const QTableWidgetItem* item); - game_info GetGameInfoFromItem(const QTableWidgetItem* item); + game_info GetGameInfoByMode(const QTableWidgetItem* item) const; + static game_info GetGameInfoFromItem(const QTableWidgetItem* item); // Which widget we are displaying depends on if we are in grid or list mode. QMainWindow* m_game_dock = nullptr; diff --git a/rpcs3/rpcs3qt/game_list_grid.cpp b/rpcs3/rpcs3qt/game_list_grid.cpp index ddf6e46d9c..c42fdb2a7d 100644 --- a/rpcs3/rpcs3qt/game_list_grid.cpp +++ b/rpcs3/rpcs3qt/game_list_grid.cpp @@ -5,8 +5,13 @@ #include #include -game_list_grid::game_list_grid(const QSize& icon_size, const QColor& icon_color, const qreal& margin_factor, const qreal& text_factor, const bool& showText) - : game_list(), m_icon_size(icon_size), m_icon_color(icon_color), m_margin_factor(margin_factor), m_text_factor(text_factor), m_text_enabled(showText) +game_list_grid::game_list_grid(const QSize& icon_size, QColor icon_color, const qreal& margin_factor, const qreal& text_factor, const bool& showText) + : game_list() + , m_icon_size(icon_size) + , m_icon_color(std::move(icon_color)) + , m_margin_factor(margin_factor) + , m_text_factor(text_factor) + , m_text_enabled(showText) { setObjectName("game_grid"); @@ -35,16 +40,12 @@ game_list_grid::game_list_grid(const QSize& icon_size, const QColor& icon_color, setShowGrid(false); } -game_list_grid::~game_list_grid() -{ -} - void game_list_grid::enableText(const bool& enabled) { m_text_enabled = enabled; } -void game_list_grid::setIconSize(const QSize& size) +void game_list_grid::setIconSize(const QSize& size) const { if (m_text_enabled) { @@ -72,7 +73,7 @@ void game_list_grid::addItem(const QPixmap& img, const QString& name, const int& } // define offset for raw image placement - QPoint offset = QPoint(m_icon_size.width() * m_margin_factor, m_icon_size.height() * m_margin_factor); + const QPoint offset = QPoint(m_icon_size.width() * m_margin_factor, m_icon_size.height() * m_margin_factor); // create empty canvas for expanded image QImage exp_img = QImage((exp_size * device_pixel_ratio).toSize(), QImage::Format_ARGB32); @@ -103,7 +104,7 @@ void game_list_grid::addItem(const QPixmap& img, const QString& name, const int& setItem(row, col, item); } -qreal game_list_grid::getMarginFactor() +qreal game_list_grid::getMarginFactor() const { return m_margin_factor; } diff --git a/rpcs3/rpcs3qt/game_list_grid.h b/rpcs3/rpcs3qt/game_list_grid.h index 5984e860f7..7d526eb7c9 100644 --- a/rpcs3/rpcs3qt/game_list_grid.h +++ b/rpcs3/rpcs3qt/game_list_grid.h @@ -15,14 +15,13 @@ class game_list_grid : public game_list bool m_text_enabled = true; public: - explicit game_list_grid(const QSize& icon_size, const QColor& icon_color, const qreal& margin_factor, const qreal& text_factor, const bool& showText); - ~game_list_grid(); + explicit game_list_grid(const QSize& icon_size, QColor icon_color, const qreal& margin_factor, const qreal& text_factor, const bool& showText); void enableText(const bool& enabled); - void setIconSize(const QSize& size); + void setIconSize(const QSize& size) const; void addItem(const QPixmap& img, const QString& name, const int& row, const int& col); - qreal getMarginFactor(); + qreal getMarginFactor() const; private: game_list_grid_delegate* grid_item_delegate; diff --git a/rpcs3/rpcs3qt/game_list_grid_delegate.cpp b/rpcs3/rpcs3qt/game_list_grid_delegate.cpp index 69a8859ff6..4af228931d 100644 --- a/rpcs3/rpcs3qt/game_list_grid_delegate.cpp +++ b/rpcs3/rpcs3qt/game_list_grid_delegate.cpp @@ -5,13 +5,9 @@ game_list_grid_delegate::game_list_grid_delegate(const QSize& size, const qreal& { } -game_list_grid_delegate::~game_list_grid_delegate() -{ -} - void game_list_grid_delegate::initStyleOption(QStyleOptionViewItem * option, const QModelIndex & index) const { - Q_UNUSED(index); + Q_UNUSED(index) // Remove the focus frame around selected items option->state &= ~QStyle::State_HasFocus; @@ -22,13 +18,13 @@ void game_list_grid_delegate::initStyleOption(QStyleOptionViewItem * option, con void game_list_grid_delegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { - QRect r = option.rect; + const QRect r = option.rect; painter->setRenderHints(QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform); painter->eraseRect(r); // Get title and image - QPixmap image = qvariant_cast(index.data(Qt::DecorationRole)); + const QPixmap image = qvariant_cast(index.data(Qt::DecorationRole)); const QString title = index.data(Qt::DisplayRole).toString(); // Paint from our stylesheet @@ -60,8 +56,8 @@ void game_list_grid_delegate::paint(QPainter *painter, const QStyleOptionViewIte QSize game_list_grid_delegate::sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const { - Q_UNUSED(option); - Q_UNUSED(index); + Q_UNUSED(option) + Q_UNUSED(index) return m_size; } diff --git a/rpcs3/rpcs3qt/game_list_grid_delegate.h b/rpcs3/rpcs3qt/game_list_grid_delegate.h index 8dc485fe4a..7ec6ecde76 100644 --- a/rpcs3/rpcs3qt/game_list_grid_delegate.h +++ b/rpcs3/rpcs3qt/game_list_grid_delegate.h @@ -6,13 +6,12 @@ class game_list_grid_delegate : public QStyledItemDelegate { public: - game_list_grid_delegate(const QSize& imageSize, const qreal& margin_factor, const qreal& margin_ratio, QObject *parent = 0); + game_list_grid_delegate(const QSize& imageSize, const qreal& margin_factor, const qreal& margin_ratio, QObject *parent = nullptr); - virtual void initStyleOption(QStyleOptionViewItem *option, const QModelIndex &index) const override; + void initStyleOption(QStyleOptionViewItem *option, const QModelIndex &index) const override; void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override; QSize sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const override; void setItemSize(const QSize& size); - virtual ~game_list_grid_delegate(); private: QSize m_size; qreal m_margin_factor; diff --git a/rpcs3/rpcs3qt/gl_gs_frame.cpp b/rpcs3/rpcs3qt/gl_gs_frame.cpp index 81e4ec1e97..e1f48ba6c4 100644 --- a/rpcs3/rpcs3qt/gl_gs_frame.cpp +++ b/rpcs3/rpcs3qt/gl_gs_frame.cpp @@ -5,8 +5,8 @@ #include #include -gl_gs_frame::gl_gs_frame(QScreen* screen, const QRect& geometry, const QIcon& appIcon, const std::shared_ptr& gui_settings) - : gs_frame(screen, geometry, appIcon, gui_settings) +gl_gs_frame::gl_gs_frame(QScreen* screen, const QRect& geometry, const QIcon& appIcon, std::shared_ptr gui_settings) + : gs_frame(screen, geometry, appIcon, std::move(gui_settings)) { setSurfaceType(QSurface::OpenGLSurface); diff --git a/rpcs3/rpcs3qt/gl_gs_frame.h b/rpcs3/rpcs3qt/gl_gs_frame.h index a0a5c21271..ab42e660bc 100644 --- a/rpcs3/rpcs3qt/gl_gs_frame.h +++ b/rpcs3/rpcs3qt/gl_gs_frame.h @@ -1,7 +1,5 @@ #pragma once -#include "util/types.hpp" - #include "gs_frame.h" #include @@ -20,10 +18,10 @@ private: GLContext *m_primary_context = nullptr; public: - explicit gl_gs_frame(QScreen* screen, const QRect& geometry, const QIcon& appIcon, const std::shared_ptr& gui_settings); + explicit gl_gs_frame(QScreen* screen, const QRect& geometry, const QIcon& appIcon, std::shared_ptr gui_settings); draw_context_t make_context() override; - void set_current(draw_context_t context) override; - void delete_context(draw_context_t context) override; + void set_current(draw_context_t ctx) override; + void delete_context(draw_context_t ctx) override; void flip(draw_context_t context, bool skip_frame=false) override; }; diff --git a/rpcs3/rpcs3qt/gs_frame.cpp b/rpcs3/rpcs3qt/gs_frame.cpp index e9ba0daa26..f570810bf4 100644 --- a/rpcs3/rpcs3qt/gs_frame.cpp +++ b/rpcs3/rpcs3qt/gs_frame.cpp @@ -38,7 +38,6 @@ #endif #ifdef _WIN32 -#include #include #elif HAVE_QTDBUS #include @@ -52,18 +51,18 @@ extern atomic_t g_user_asked_for_frame_capture; constexpr auto qstr = QString::fromStdString; -gs_frame::gs_frame(QScreen* screen, const QRect& geometry, const QIcon& appIcon, const std::shared_ptr& gui_settings) +gs_frame::gs_frame(QScreen* screen, const QRect& geometry, const QIcon& appIcon, std::shared_ptr gui_settings) : QWindow() , m_initial_geometry(geometry) - , m_gui_settings(gui_settings) + , m_gui_settings(std::move(gui_settings)) { - m_disable_mouse = gui_settings->GetValue(gui::gs_disableMouse).toBool(); - m_disable_kb_hotkeys = gui_settings->GetValue(gui::gs_disableKbHotkeys).toBool(); - m_show_mouse_in_fullscreen = gui_settings->GetValue(gui::gs_showMouseFs).toBool(); - m_hide_mouse_after_idletime = gui_settings->GetValue(gui::gs_hideMouseIdle).toBool(); - m_hide_mouse_idletime = gui_settings->GetValue(gui::gs_hideMouseIdleTime).toUInt(); + m_disable_mouse = m_gui_settings->GetValue(gui::gs_disableMouse).toBool(); + m_disable_kb_hotkeys = m_gui_settings->GetValue(gui::gs_disableKbHotkeys).toBool(); + m_show_mouse_in_fullscreen = m_gui_settings->GetValue(gui::gs_showMouseFs).toBool(); + m_hide_mouse_after_idletime = m_gui_settings->GetValue(gui::gs_hideMouseIdle).toBool(); + m_hide_mouse_idletime = m_gui_settings->GetValue(gui::gs_hideMouseIdleTime).toUInt(); - m_window_title = qstr(Emu.GetFormattedTitle(0)); + m_window_title = Emu.GetFormattedTitle(0); if (!appIcon.isNull()) { @@ -80,7 +79,7 @@ gs_frame::gs_frame(QScreen* screen, const QRect& geometry, const QIcon& appIcon, setMinimumHeight(90); setScreen(screen); setGeometry(geometry); - setTitle(m_window_title); + setTitle(qstr(m_window_title)); setVisibility(Hidden); create(); @@ -131,7 +130,7 @@ gs_frame::~gs_frame() void gs_frame::paintEvent(QPaintEvent *event) { - Q_UNUSED(event); + Q_UNUSED(event) } void gs_frame::showEvent(QShowEvent *event) @@ -379,21 +378,21 @@ draw_context_t gs_frame::make_context() return nullptr; } -void gs_frame::set_current(draw_context_t ctx) +void gs_frame::set_current(draw_context_t context) { - Q_UNUSED(ctx); + Q_UNUSED(context) } -void gs_frame::delete_context(draw_context_t ctx) +void gs_frame::delete_context(draw_context_t context) { - Q_UNUSED(ctx); + Q_UNUSED(context) } int gs_frame::client_width() { #ifdef _WIN32 RECT rect; - if (GetClientRect(HWND(winId()), &rect)) + if (GetClientRect(reinterpret_cast(winId()), &rect)) { return rect.right - rect.left; } @@ -405,7 +404,7 @@ int gs_frame::client_height() { #ifdef _WIN32 RECT rect; - if (GetClientRect(HWND(winId()), &rect)) + if (GetClientRect(reinterpret_cast(winId()), &rect)) { return rect.bottom - rect.top; } @@ -429,7 +428,7 @@ void gs_frame::flip(draw_context_t, bool /*skip_frame*/) if (fps_t.GetElapsedTimeInSec() >= 0.5) { - const QString new_title = qstr(Emu.GetFormattedTitle(m_frames / fps_t.GetElapsedTimeInSec())); + std::string new_title = Emu.GetFormattedTitle(m_frames / fps_t.GetElapsedTimeInSec()); if (new_title != m_window_title) { @@ -437,7 +436,7 @@ void gs_frame::flip(draw_context_t, bool /*skip_frame*/) Emu.CallAfter([this, title = std::move(new_title)]() { - setTitle(title); + setTitle(qstr(title)); }); } @@ -446,10 +445,10 @@ void gs_frame::flip(draw_context_t, bool /*skip_frame*/) } } -void gs_frame::take_screenshot(const std::vector sshot_data, const u32 sshot_width, const u32 sshot_height, bool is_bgra) +void gs_frame::take_screenshot(std::vector data, const u32 sshot_width, const u32 sshot_height, bool is_bgra) { std::thread( - [sshot_width, sshot_height, is_bgra](const std::vector sshot_data) + [sshot_width, sshot_height, is_bgra](std::vector sshot_data) { screenshot_log.notice("Taking screenshot (%dx%d)", sshot_width, sshot_height); @@ -513,10 +512,10 @@ void gs_frame::take_screenshot(const std::vector sshot_data, const u32 sshot const QDateTime date_time = QDateTime::currentDateTime(); const std::string creation_time = date_time.toString("yyyy:MM:dd hh:mm:ss").toStdString(); - const std::string title_id = Emu.GetTitleID(); const std::string photo_title = manager.get_photo_title(); const std::string game_title = manager.get_game_title(); const std::string game_comment = manager.get_game_comment(); + const std::string& title_id = Emu.GetTitleID(); // Write tEXt chunk text[num_text].compression = PNG_TEXT_COMPRESSION_NONE; @@ -553,7 +552,7 @@ void gs_frame::take_screenshot(const std::vector sshot_data, const u32 sshot const auto write_png = [&]() { - scoped_png_ptrs ptrs; + const scoped_png_ptrs ptrs; png_set_IHDR(ptrs.write_ptr, ptrs.info_ptr, sshot_width, sshot_height, 8, PNG_COLOR_TYPE_RGBA, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); png_set_text(ptrs.write_ptr, ptrs.info_ptr, text, 6); png_set_rows(ptrs.write_ptr, ptrs.info_ptr, &rows[0]); @@ -648,7 +647,7 @@ void gs_frame::take_screenshot(const std::vector sshot_data, const u32 sshot return; }, - std::move(sshot_data)) + std::move(data)) .detach(); } diff --git a/rpcs3/rpcs3qt/gs_frame.h b/rpcs3/rpcs3qt/gs_frame.h index 484ad1acaf..2c94677649 100644 --- a/rpcs3/rpcs3qt/gs_frame.h +++ b/rpcs3/rpcs3qt/gs_frame.h @@ -39,7 +39,7 @@ private: QTimer m_mousehide_timer; u64 m_frames = 0; - QString m_window_title; + std::string m_window_title; atomic_t m_show_mouse = true; bool m_disable_mouse = false; bool m_disable_kb_hotkeys = false; @@ -50,7 +50,7 @@ private: bool m_flip_showed_frame = false; public: - explicit gs_frame(QScreen* screen, const QRect& geometry, const QIcon& appIcon, const std::shared_ptr& gui_settings); + explicit gs_frame(QScreen* screen, const QRect& geometry, const QIcon& appIcon, std::shared_ptr gui_settings); ~gs_frame(); draw_context_t make_context() override; @@ -70,11 +70,11 @@ public: */ bool get_mouse_lock_state(); - void take_screenshot(const std::vector sshot_data, const u32 sshot_width, const u32 sshot_height, bool is_bgra) override; + void take_screenshot(std::vector data, const u32 sshot_width, const u32 sshot_height, bool is_bgra) override; protected: virtual void paintEvent(QPaintEvent *event); - virtual void showEvent(QShowEvent *event) override; + void showEvent(QShowEvent *event) override; void keyPressEvent(QKeyEvent *keyEvent) override; diff --git a/rpcs3/rpcs3qt/gui_application.cpp b/rpcs3/rpcs3qt/gui_application.cpp index 1a9b9d8366..febe8b3b65 100644 --- a/rpcs3/rpcs3qt/gui_application.cpp +++ b/rpcs3/rpcs3qt/gui_application.cpp @@ -266,9 +266,9 @@ std::unique_ptr gui_application::get_gs_frame() const auto frame_geometry = gui::utils::create_centered_window_geometry(screen, source_geometry, w, h); const auto app_icon = m_main_window ? m_main_window->GetAppIcon() : gui::utils::get_app_icon_from_path(Emu.GetBoot(), Emu.GetTitleID()); - gs_frame* frame; + gs_frame* frame = nullptr; - switch (video_renderer type = g_cfg.video.renderer) + switch (g_cfg.video.renderer.get()) { case video_renderer::opengl: { @@ -281,7 +281,6 @@ std::unique_ptr gui_application::get_gs_frame() frame = new gs_frame(screen, frame_geometry, app_icon, m_gui_settings); break; } - default: fmt::throw_exception("Invalid video renderer: %s", type); } m_game_window = frame; @@ -322,7 +321,7 @@ void gui_application::InitializeCallbacks() callbacks.init_gs_render = []() { - switch (video_renderer type = g_cfg.video.renderer) + switch (g_cfg.video.renderer.get()) { case video_renderer::null: { @@ -341,10 +340,6 @@ void gui_application::InitializeCallbacks() break; } #endif - default: - { - fmt::throw_exception("Invalid video renderer: %s", type); - } } }; @@ -565,7 +560,7 @@ void gui_application::OnEmuSettingsChange() } } - Emu.ConfigureLogs(); + Emulator::ConfigureLogs(); audio::configure_audio(); rsx::overlays::reset_performance_overlay(); } diff --git a/rpcs3/rpcs3qt/gui_application.h b/rpcs3/rpcs3qt/gui_application.h index ec0329223a..979e4cbd90 100644 --- a/rpcs3/rpcs3qt/gui_application.h +++ b/rpcs3/rpcs3qt/gui_application.h @@ -58,7 +58,7 @@ private: void SwitchTranslator(QTranslator& translator, const QString& filename, const QString& language_code); void LoadLanguage(const QString& language_code); - QStringList GetAvailableLanguageCodes(); + static QStringList GetAvailableLanguageCodes(); void InitializeCallbacks(); void InitializeConnects(); @@ -84,7 +84,7 @@ private: private Q_SLOTS: void OnChangeStyleSheetRequest(); - void OnEmuSettingsChange(); + static void OnEmuSettingsChange(); Q_SIGNALS: void OnEmulatorRun(bool start_playtime); @@ -96,5 +96,5 @@ Q_SIGNALS: void RequestCallAfter(const std::function& func); private Q_SLOTS: - void HandleCallAfter(const std::function& func); + static void HandleCallAfter(const std::function& func); }; diff --git a/rpcs3/rpcs3qt/gui_settings.cpp b/rpcs3/rpcs3qt/gui_settings.cpp index 6eacf35f0f..9eaf43d443 100644 --- a/rpcs3/rpcs3qt/gui_settings.cpp +++ b/rpcs3/rpcs3qt/gui_settings.cpp @@ -54,7 +54,7 @@ bool gui_settings::ChangeToConfig(const QString& config_name) return true; } -void gui_settings::Reset(bool remove_meta) +void gui_settings::Reset(bool remove_meta) const { if (remove_meta) { @@ -68,25 +68,25 @@ void gui_settings::Reset(bool remove_meta) } } -QStringList gui_settings::GetGameListCategoryFilters() +QStringList gui_settings::GetGameListCategoryFilters() const { QStringList filterList; - if (GetCategoryVisibility(Category::HDD_Game)) filterList.append(category::cat_hdd_game); - if (GetCategoryVisibility(Category::Disc_Game)) filterList.append(category::cat_disc_game); - if (GetCategoryVisibility(Category::PS1_Game)) filterList.append(category::cat_ps1_game); - if (GetCategoryVisibility(Category::PS2_Game)) filterList.append(category::ps2_games); - if (GetCategoryVisibility(Category::PSP_Game)) filterList.append(category::psp_games); - if (GetCategoryVisibility(Category::Home)) filterList.append(category::cat_home); - if (GetCategoryVisibility(Category::Media)) filterList.append(category::media); - if (GetCategoryVisibility(Category::Data)) filterList.append(category::data); - if (GetCategoryVisibility(Category::Unknown_Cat)) filterList.append(category::cat_unknown); - if (GetCategoryVisibility(Category::Others)) filterList.append(category::others); + if (GetCategoryVisibility(Category::HDD_Game)) filterList.append(cat::cat_hdd_game); + if (GetCategoryVisibility(Category::Disc_Game)) filterList.append(cat::cat_disc_game); + if (GetCategoryVisibility(Category::PS1_Game)) filterList.append(cat::cat_ps1_game); + if (GetCategoryVisibility(Category::PS2_Game)) filterList.append(cat::ps2_games); + if (GetCategoryVisibility(Category::PSP_Game)) filterList.append(cat::psp_games); + if (GetCategoryVisibility(Category::Home)) filterList.append(cat::cat_home); + if (GetCategoryVisibility(Category::Media)) filterList.append(cat::media); + if (GetCategoryVisibility(Category::Data)) filterList.append(cat::data); + if (GetCategoryVisibility(Category::Unknown_Cat)) filterList.append(cat::cat_unknown); + if (GetCategoryVisibility(Category::Others)) filterList.append(cat::others); return filterList; } -bool gui_settings::GetCategoryVisibility(int cat) +bool gui_settings::GetCategoryVisibility(int cat) const { gui_save value; @@ -120,7 +120,7 @@ bool gui_settings::GetCategoryVisibility(int cat) return GetValue(value).toBool(); } -void gui_settings::SetCategoryVisibility(int cat, const bool& val) +void gui_settings::SetCategoryVisibility(int cat, const bool& val) const { gui_save value; @@ -211,7 +211,6 @@ bool gui_settings::GetBootConfirmation(QWidget* parent, const gui_save& gui_save { QString title = tr("Close Running Game?"); QString message = tr("Performing this action will close the current game.\nDo you really want to continue?\n\nAny unsaved progress will be lost!\n"); - auto icon = QMessageBox::Question; if (gui_save_entry == gui::ib_confirm_boot) { @@ -225,7 +224,7 @@ bool gui_settings::GetBootConfirmation(QWidget* parent, const gui_save& gui_save int result = QMessageBox::Yes; - ShowBox(icon, title, message, gui_save_entry, &result, parent); + ShowBox(QMessageBox::Question, title, message, gui_save_entry, &result, parent); if (result != QMessageBox::Yes) { @@ -236,12 +235,12 @@ bool gui_settings::GetBootConfirmation(QWidget* parent, const gui_save& gui_save return true; } -void gui_settings::SetGamelistColVisibility(int col, bool val) +void gui_settings::SetGamelistColVisibility(int col, bool val) const { SetValue(GetGuiSaveForColumn(col), val); } -void gui_settings::SetCustomColor(int col, const QColor& val) +void gui_settings::SetCustomColor(int col, const QColor& val) const { SetValue(gui_save(gui::meta, "CustomColor" + QString::number(col), gui::gl_icon_color), val); } @@ -253,22 +252,22 @@ void gui_settings::SaveCurrentConfig(const QString& config_name) ChangeToConfig(config_name); } -logs::level gui_settings::GetLogLevel() +logs::level gui_settings::GetLogLevel() const { return logs::level{GetValue(gui::l_level).toUInt()}; } -bool gui_settings::GetGamelistColVisibility(int col) +bool gui_settings::GetGamelistColVisibility(int col) const { return GetValue(GetGuiSaveForColumn(col)).toBool(); } -QColor gui_settings::GetCustomColor(int col) +QColor gui_settings::GetCustomColor(int col) const { return GetValue(gui_save(gui::meta, "CustomColor" + QString::number(col), gui::gl_icon_color)).value(); } -QStringList gui_settings::GetConfigEntries() +QStringList gui_settings::GetConfigEntries() const { const QStringList name_filter = QStringList("*.ini"); const QFileInfoList entries = m_settings_dir.entryInfoList(name_filter, QDir::Files); @@ -284,7 +283,7 @@ QStringList gui_settings::GetConfigEntries() } // Save the name of the used config to the default settings file -void gui_settings::SaveConfigNameToDefault(const QString& config_name) +void gui_settings::SaveConfigNameToDefault(const QString& config_name) const { if (m_current_name == gui::Settings) { @@ -300,7 +299,7 @@ void gui_settings::SaveConfigNameToDefault(const QString& config_name) } } -void gui_settings::BackupSettingsToTarget(const QString& config_name) +void gui_settings::BackupSettingsToTarget(const QString& config_name) const { QSettings target(ComputeSettingsDir() + config_name + ".ini", QSettings::Format::IniFormat); @@ -315,7 +314,7 @@ void gui_settings::BackupSettingsToTarget(const QString& config_name) target.sync(); } -QStringList gui_settings::GetStylesheetEntries() +QStringList gui_settings::GetStylesheetEntries() const { const QStringList name_filter = QStringList("*.qss"); QStringList res = gui::utils::get_dir_entries(m_settings_dir, name_filter); diff --git a/rpcs3/rpcs3qt/gui_settings.h b/rpcs3/rpcs3qt/gui_settings.h index ba77755ff6..308d288759 100644 --- a/rpcs3/rpcs3qt/gui_settings.h +++ b/rpcs3/rpcs3qt/gui_settings.h @@ -70,9 +70,10 @@ namespace gui case column_compat: return "column_compat"; case column_count: - default: return ""; } + + fmt::throw_exception("get_game_list_column_name: Invalid column"); } const QSize gl_icon_size_min = QSize(40, 22); @@ -84,8 +85,8 @@ namespace gui inline int get_Index(const QSize& current) { - int size_delta = gl_icon_size_max.width() - gl_icon_size_min.width(); - int current_delta = current.width() - gl_icon_size_min.width(); + const int size_delta = gl_icon_size_max.width() - gl_icon_size_min.width(); + const int current_delta = current.width() - gl_icon_size_min.width(); return gl_max_slider_pos * current_delta / size_delta; } @@ -248,28 +249,28 @@ public: /** Changes the settings file to the destination preset*/ bool ChangeToConfig(const QString& config_name); - bool GetCategoryVisibility(int cat); + bool GetCategoryVisibility(int cat) const; void ShowConfirmationBox(const QString& title, const QString& text, const gui_save& entry, int* result, QWidget* parent); void ShowInfoBox(const QString& title, const QString& text, const gui_save& entry, QWidget* parent); bool GetBootConfirmation(QWidget* parent, const gui_save& gui_save_entry = gui_save()); - logs::level GetLogLevel(); - bool GetGamelistColVisibility(int col); - QColor GetCustomColor(int col); - QStringList GetConfigEntries(); - QStringList GetStylesheetEntries(); - QStringList GetGameListCategoryFilters(); + logs::level GetLogLevel() const; + bool GetGamelistColVisibility(int col) const; + QColor GetCustomColor(int col) const; + QStringList GetConfigEntries() const; + QStringList GetStylesheetEntries() const; + QStringList GetGameListCategoryFilters() const; public Q_SLOTS: - void Reset(bool remove_meta = false); + void Reset(bool remove_meta = false) const; /** Sets the visibility of the chosen category. */ - void SetCategoryVisibility(int cat, const bool& val); + void SetCategoryVisibility(int cat, const bool& val) const; - void SetGamelistColVisibility(int col, bool val); + void SetGamelistColVisibility(int col, bool val) const; - void SetCustomColor(int col, const QColor& val); + void SetCustomColor(int col, const QColor& val) const; void SaveCurrentConfig(const QString& config_name); @@ -277,9 +278,7 @@ public Q_SLOTS: static gui_save GetGuiSaveForColumn(int col); private: - void SaveConfigNameToDefault(const QString& config_name); - void BackupSettingsToTarget(const QString& config_name); + void SaveConfigNameToDefault(const QString& config_name) const; + void BackupSettingsToTarget(const QString& config_name) const; void ShowBox(QMessageBox::Icon icon, const QString& title, const QString& text, const gui_save& entry, int* result, QWidget* parent, bool always_on_top); - - QString m_current_name; }; diff --git a/rpcs3/rpcs3qt/input_dialog.cpp b/rpcs3/rpcs3qt/input_dialog.cpp index 0e75a104cd..532c8ea3bb 100644 --- a/rpcs3/rpcs3qt/input_dialog.cpp +++ b/rpcs3/rpcs3qt/input_dialog.cpp @@ -41,14 +41,14 @@ input_dialog::~input_dialog() { } -void input_dialog::set_clear_button_enabled(bool enabled) +void input_dialog::set_clear_button_enabled(bool enabled) const { m_input->setClearButtonEnabled(enabled); } -void input_dialog::set_input_font(const QFont& font, bool fix_width, char sample) +void input_dialog::set_input_font(const QFont& font, bool fix_width, char sample) const { - if (int max = m_input->maxLength(); max > 0 && fix_width && std::isprint(static_cast(sample))) + if (const int max = m_input->maxLength(); max > 0 && fix_width && std::isprint(static_cast(sample))) { const QString str = qstr(std::string(static_cast(max), sample)); m_input->setFixedWidth(gui::utils::get_label_width(str, &font)); @@ -57,12 +57,12 @@ void input_dialog::set_input_font(const QFont& font, bool fix_width, char sample m_input->setFont(font); } -void input_dialog::set_validator(const QValidator* validator) +void input_dialog::set_validator(const QValidator* validator) const { m_input->setValidator(validator); } -void input_dialog::set_button_enabled(QDialogButtonBox::StandardButton id, bool enabled) +void input_dialog::set_button_enabled(QDialogButtonBox::StandardButton id, bool enabled) const { if (QPushButton* button = m_button_box->button(id)) { @@ -70,7 +70,7 @@ void input_dialog::set_button_enabled(QDialogButtonBox::StandardButton id, bool } } -void input_dialog::set_label_text(const QString& text) +void input_dialog::set_label_text(const QString& text) const { m_label->setText(text); } diff --git a/rpcs3/rpcs3qt/input_dialog.h b/rpcs3/rpcs3qt/input_dialog.h index cf5d2401fd..c524728a3d 100644 --- a/rpcs3/rpcs3qt/input_dialog.h +++ b/rpcs3/rpcs3qt/input_dialog.h @@ -15,11 +15,11 @@ public: input_dialog(int max_length, const QString& text, const QString& title, const QString& label, const QString& placeholder, QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags()); ~input_dialog(); - void set_label_text(const QString& text); - void set_validator(const QValidator* validator); - void set_clear_button_enabled(bool enable); - void set_input_font(const QFont& font, bool fix_width, char sample = '\0'); - void set_button_enabled(QDialogButtonBox::StandardButton id, bool enabled); + void set_label_text(const QString& text) const; + void set_validator(const QValidator* validator) const; + void set_clear_button_enabled(bool enable) const; + void set_input_font(const QFont& font, bool fix_width, char sample = '\0') const; + void set_button_enabled(QDialogButtonBox::StandardButton id, bool enabled) const; QString get_input_text() const; private: diff --git a/rpcs3/rpcs3qt/instruction_editor_dialog.cpp b/rpcs3/rpcs3qt/instruction_editor_dialog.cpp index 23906934b5..43dbcc063f 100644 --- a/rpcs3/rpcs3qt/instruction_editor_dialog.cpp +++ b/rpcs3/rpcs3qt/instruction_editor_dialog.cpp @@ -26,7 +26,7 @@ instruction_editor_dialog::instruction_editor_dialog(QWidget *parent, u32 _pc, C const auto cpu = m_get_cpu(); m_cpu_offset = cpu && cpu->id_type() == 2 ? static_cast(*cpu).ls : vm::g_sudo_addr; - QString instruction = qstr(fmt::format("%08x", *reinterpret_cast*>(m_cpu_offset + m_pc))); + const QString instruction = qstr(fmt::format("%08x", *reinterpret_cast*>(m_cpu_offset + m_pc))); QVBoxLayout* vbox_panel(new QVBoxLayout()); QHBoxLayout* hbox_panel(new QHBoxLayout()); @@ -72,7 +72,7 @@ instruction_editor_dialog::instruction_editor_dialog(QWidget *parent, u32 _pc, C setLayout(vbox_panel); // Events - connect(button_ok, &QAbstractButton::clicked, [=, this]() + connect(button_ok, &QAbstractButton::clicked, [this]() { const auto cpu = m_get_cpu(); @@ -83,13 +83,14 @@ instruction_editor_dialog::instruction_editor_dialog(QWidget *parent, u32 _pc, C } bool ok; - ulong opcode = m_instr->text().toULong(&ok, 16); + const ulong opcode = m_instr->text().toULong(&ok, 16); if (!ok || opcode > UINT32_MAX) { QMessageBox::critical(this, tr("Error"), tr("Failed to parse PPU instruction.")); return; } - else if (cpu->id_type() == 1) + + if (cpu->id_type() == 1) { if (!ppu_patch(m_pc, static_cast(opcode))) { @@ -111,11 +112,11 @@ instruction_editor_dialog::instruction_editor_dialog(QWidget *parent, u32 _pc, C updatePreview(); } -void instruction_editor_dialog::updatePreview() +void instruction_editor_dialog::updatePreview() const { bool ok; ulong opcode = m_instr->text().toULong(&ok, 16); - Q_UNUSED(opcode); + Q_UNUSED(opcode) if (ok) { diff --git a/rpcs3/rpcs3qt/instruction_editor_dialog.h b/rpcs3/rpcs3qt/instruction_editor_dialog.h index 88e47f3cb6..27c15ac066 100644 --- a/rpcs3/rpcs3qt/instruction_editor_dialog.h +++ b/rpcs3/rpcs3qt/instruction_editor_dialog.h @@ -25,5 +25,5 @@ private: public: instruction_editor_dialog(QWidget *parent, u32 _pc, CPUDisAsm* _disasm, std::function func); - void updatePreview(); + void updatePreview() const; }; diff --git a/rpcs3/rpcs3qt/kernel_explorer.cpp b/rpcs3/rpcs3qt/kernel_explorer.cpp index 9c65732f45..dbdc6411d8 100644 --- a/rpcs3/rpcs3qt/kernel_explorer.cpp +++ b/rpcs3/rpcs3qt/kernel_explorer.cpp @@ -9,7 +9,6 @@ #include "Emu/IdManager.h" #include "Emu/Cell/PPUThread.h" #include "Emu/Cell/SPUThread.h" -#include "Emu/Cell/RawSPUThread.h" #include "Emu/Cell/lv2/sys_lwmutex.h" #include "Emu/Cell/lv2/sys_lwcond.h" #include "Emu/Cell/lv2/sys_mutex.h" @@ -304,7 +303,7 @@ void kernel_explorer::Update() idm::select([&](u32 id, lv2_obj& obj) { - auto node = find_node(m_tree, id >> 24); + const auto node = find_node(m_tree, id >> 24); if (!node) { return; @@ -705,7 +704,7 @@ void kernel_explorer::Update() } } } - while (0); + while (false); idm::select([&](u32 id, lv2_fs_object& fo) { @@ -726,7 +725,7 @@ void kernel_explorer::Update() continue; } - switch (int type = node->data(0, kernel_item_role::type_role).toInt()) + switch (const int type = node->data(0, kernel_item_role::type_role).toInt()) { case kernel_item_type::leaf: { diff --git a/rpcs3/rpcs3qt/kernel_explorer.h b/rpcs3/rpcs3qt/kernel_explorer.h index 7da464aef0..608c76bb91 100644 --- a/rpcs3/rpcs3qt/kernel_explorer.h +++ b/rpcs3/rpcs3qt/kernel_explorer.h @@ -26,7 +26,7 @@ class kernel_explorer : public QDialog }; public: - kernel_explorer(QWidget* parent); + explicit kernel_explorer(QWidget* parent); private: QTreeWidget* m_tree; diff --git a/rpcs3/rpcs3qt/localized.cpp b/rpcs3/rpcs3qt/localized.cpp index eae089ca61..2cd89a33ea 100644 --- a/rpcs3/rpcs3qt/localized.cpp +++ b/rpcs3/rpcs3qt/localized.cpp @@ -1,9 +1,5 @@ #include "localized.h" -Localized::Localized() -{ -} - QString Localized::GetVerboseTimeByMs(quint64 elapsed_ms, bool show_days) const { const quint64 elapsed_seconds = (elapsed_ms / 1000) + ((elapsed_ms % 1000) > 0 ? 1 : 0); @@ -18,40 +14,34 @@ QString Localized::GetVerboseTimeByMs(quint64 elapsed_ms, bool show_days) const const quint64 minutes = (elapsed_seconds % 3600) / 60; const quint64 seconds = (elapsed_seconds % 3600) % 60; - const QString str_days = tr("%Ln day(s)", "", days); - const QString str_hours = tr("%Ln hour(s)", "", hours); - const QString str_minutes = tr("%Ln minute(s)", "", minutes); - const QString str_seconds = tr("%Ln second(s)", "", seconds); + QString str_days = tr("%Ln day(s)", "", days); + QString str_hours = tr("%Ln hour(s)", "", hours); + QString str_minutes = tr("%Ln minute(s)", "", minutes); + QString str_seconds = tr("%Ln second(s)", "", seconds); if (days != 0) { if (hours == 0) return str_days; - else - return tr("%0 and %1", "Days and hours").arg(str_days).arg(str_hours); + + return tr("%0 and %1", "Days and hours").arg(str_days).arg(str_hours); } - else + + if (hours != 0) { - if (hours != 0) - { - if (minutes == 0) - return str_hours; - else - return tr("%0 and %1", "Hours and minutes").arg(str_hours).arg(str_minutes); - } - else - { - if (minutes != 0) - { - if (seconds != 0) - return tr("%0 and %1", "Minutes and seconds").arg(str_minutes).arg(str_seconds); - else - return str_minutes; - } - else - { - return str_seconds; - } - } + if (minutes == 0) + return str_hours; + + return tr("%0 and %1", "Hours and minutes").arg(str_hours).arg(str_minutes); } + + if (minutes != 0) + { + if (seconds != 0) + return tr("%0 and %1", "Minutes and seconds").arg(str_minutes).arg(str_seconds); + + return str_minutes; + } + + return str_seconds; } diff --git a/rpcs3/rpcs3qt/localized.h b/rpcs3/rpcs3qt/localized.h index 34cce73299..543f0c2fd5 100644 --- a/rpcs3/rpcs3qt/localized.h +++ b/rpcs3/rpcs3qt/localized.h @@ -9,15 +9,12 @@ typedef std::map localized_cat; -using namespace category; - class Localized : public QObject { Q_OBJECT public: - - Localized(); + Localized() {} QString GetVerboseTimeByMs(quint64 elapsed_ms, bool show_days = false) const; @@ -63,31 +60,31 @@ public: const localized_cat cat_boot = { - { cat_app_music, app_music }, // media - { cat_app_photo, app_photo }, // media - { cat_app_tv , app_tv }, // media - { cat_app_video, app_video }, // media - { cat_bc_video , bc_video }, // media - { cat_web_tv , web_tv }, // media - { cat_home , home }, // home - { cat_network , network }, // other - { cat_store_fe , store_fe }, // other - { cat_disc_game, disc_game }, // disc_game - { cat_hdd_game , hdd_game }, // hdd_game - { cat_ps2_game , ps2_game }, // ps2_games - { cat_ps2_inst , ps2_inst }, // ps2_games - { cat_ps1_game , ps1_game }, // ps1_game - { cat_psp_game , psp_game }, // psp_games - { cat_psp_mini , psp_mini }, // psp_games - { cat_psp_rema , psp_rema }, // psp_games + { cat::cat_app_music, app_music }, // media + { cat::cat_app_photo, app_photo }, // media + { cat::cat_app_tv , app_tv }, // media + { cat::cat_app_video, app_video }, // media + { cat::cat_bc_video , bc_video }, // media + { cat::cat_web_tv , web_tv }, // media + { cat::cat_home , home }, // home + { cat::cat_network , network }, // other + { cat::cat_store_fe , store_fe }, // other + { cat::cat_disc_game, disc_game }, // disc_game + { cat::cat_hdd_game , hdd_game }, // hdd_game + { cat::cat_ps2_game , ps2_game }, // ps2_games + { cat::cat_ps2_inst , ps2_inst }, // ps2_games + { cat::cat_ps1_game , ps1_game }, // ps1_game + { cat::cat_psp_game , psp_game }, // psp_games + { cat::cat_psp_mini , psp_mini }, // psp_games + { cat::cat_psp_rema , psp_rema }, // psp_games }; const localized_cat cat_data = { - { cat_ps3_data, ps3_data }, // data - { cat_ps2_data, ps2_data }, // data - { cat_ps3_save, ps3_save }, // data - { cat_psp_save, psp_save } // data + { cat::cat_ps3_data, ps3_data }, // data + { cat::cat_ps2_data, ps2_data }, // data + { cat::cat_ps3_save, ps3_save }, // data + { cat::cat_psp_save, psp_save } // data }; } category; diff --git a/rpcs3/rpcs3qt/log_frame.cpp b/rpcs3/rpcs3qt/log_frame.cpp index 2aca9ce716..fdee34e5ef 100644 --- a/rpcs3/rpcs3qt/log_frame.cpp +++ b/rpcs3/rpcs3qt/log_frame.cpp @@ -17,8 +17,6 @@ #include #include -#include "util/sysinfo.hpp" - extern fs::file g_tty; extern atomic_t g_tty_size; extern std::array, 16> g_tty_input; @@ -55,7 +53,7 @@ struct gui_listener : logs::listener void log(u64 stamp, const logs::message& msg, const std::string& prefix, const std::string& text) override { - Q_UNUSED(stamp); + Q_UNUSED(stamp) if (msg.sev <= enabled) { @@ -164,7 +162,7 @@ log_frame::log_frame(std::shared_ptr guiSettings, QWidget *parent) timer->start(10); } -void log_frame::SetLogLevel(logs::level lev) +void log_frame::SetLogLevel(logs::level lev) const { switch (lev) { @@ -204,12 +202,10 @@ void log_frame::SetLogLevel(logs::level lev) m_trace_act->trigger(); break; } - default: - m_warning_act->trigger(); } } -void log_frame::SetTTYLogging(bool val) +void log_frame::SetTTYLogging(bool val) const { m_tty_act->setChecked(val); } @@ -450,6 +446,7 @@ void log_frame::RepaintTextColors() QTextCursor tty_cursor = m_tty->textCursor(); QTextCharFormat text_format = tty_cursor.charFormat(); text_format.setForeground(gui::utils::get_label_color("tty_text")); + tty_cursor.setCharFormat(text_format); m_tty->setTextCursor(tty_cursor); // Repaint log with new colors @@ -601,7 +598,6 @@ void log_frame::UpdateUI() case logs::level::warning: text = QStringLiteral("W "); break; case logs::level::notice: text = QStringLiteral("! "); break; case logs::level::trace: text = QStringLiteral("T "); break; - default: continue; } // Print UTF-8 text. diff --git a/rpcs3/rpcs3qt/log_frame.h b/rpcs3/rpcs3qt/log_frame.h index 423c07ee14..c51ff8e896 100644 --- a/rpcs3/rpcs3qt/log_frame.h +++ b/rpcs3/rpcs3qt/log_frame.h @@ -37,8 +37,8 @@ protected: private Q_SLOTS: void UpdateUI(); private: - void SetLogLevel(logs::level lev); - void SetTTYLogging(bool val); + void SetLogLevel(logs::level lev) const; + void SetTTYLogging(bool val) const; void CreateAndConnectActions(); diff --git a/rpcs3/rpcs3qt/log_viewer.cpp b/rpcs3/rpcs3qt/log_viewer.cpp index 35fa02dbf5..f07a163a0d 100644 --- a/rpcs3/rpcs3qt/log_viewer.cpp +++ b/rpcs3/rpcs3qt/log_viewer.cpp @@ -22,8 +22,8 @@ inline std::string sstr(const QString& _in) return _in.toStdString(); } -log_viewer::log_viewer(std::shared_ptr settings) - : m_gui_settings(settings) +log_viewer::log_viewer(std::shared_ptr gui_settings) + : m_gui_settings(std::move(gui_settings)) { setWindowTitle(tr("Log Viewer")); setObjectName("log_viewer"); @@ -95,7 +95,7 @@ void log_viewer::show_context_menu(const QPoint& pos) menu.exec(origin); } -void log_viewer::show_log() +void log_viewer::show_log() const { if (m_path_last.isEmpty()) { diff --git a/rpcs3/rpcs3qt/log_viewer.h b/rpcs3/rpcs3qt/log_viewer.h index 27fe840983..9b18cf6fe3 100644 --- a/rpcs3/rpcs3qt/log_viewer.h +++ b/rpcs3/rpcs3qt/log_viewer.h @@ -17,7 +17,7 @@ private Q_SLOTS: void show_context_menu(const QPoint& pos); private: - void show_log(); + void show_log() const; bool is_valid_file(const QMimeData& md, bool save = false); std::shared_ptr m_gui_settings; diff --git a/rpcs3/rpcs3qt/main_window.cpp b/rpcs3/rpcs3qt/main_window.cpp index c9cfb69a21..4f056a164c 100644 --- a/rpcs3/rpcs3qt/main_window.cpp +++ b/rpcs3/rpcs3qt/main_window.cpp @@ -66,9 +66,9 @@ inline std::string sstr(const QString& _in) { return _in.toStdString(); } main_window::main_window(std::shared_ptr gui_settings, std::shared_ptr emu_settings, std::shared_ptr persistent_settings, QWidget *parent) : QMainWindow(parent) , ui(new Ui::main_window) - , m_gui_settings(gui_settings) - , m_emu_settings(emu_settings) - , m_persistent_settings(persistent_settings) + , m_gui_settings(std::move(gui_settings)) + , m_emu_settings(std::move(emu_settings)) + , m_persistent_settings(std::move(persistent_settings)) { Q_INIT_RESOURCE(resources); @@ -248,7 +248,7 @@ QString main_window::GetCurrentTitle() } // returns appIcon -QIcon main_window::GetAppIcon() +QIcon main_window::GetAppIcon() const { return m_app_icon; } @@ -349,11 +349,13 @@ void main_window::show_boot_error(game_boot_result status) case game_boot_result::file_creation_error: message = tr("The emulator could not create files required for booting."); break; + case game_boot_result::unsupported_disc_type: + message = tr("This disc type is not supported yet."); + break; case game_boot_result::firmware_missing: // Handled elsewhere case game_boot_result::no_errors: return; case game_boot_result::generic_error: - default: message = tr("Unknown error."); break; } @@ -517,7 +519,7 @@ bool main_window::InstallRapFile(const QString& path, const std::string& filenam // Copy file atomically with thread/process-safe error checking for file size fs::pending_file to(Emulator::GetHddDir() + "/home/" + Emu.GetUsr() + "/exdata/" + filename.substr(0, filename.find_last_of('.')) + ".rap"); - fs::file from(sstr(path)); + const fs::file from(sstr(path)); if (!to.file || !from) { @@ -736,8 +738,10 @@ void main_window::HandlePackageInstallation(QStringList file_paths) }); // Wait for the completion - while (std::this_thread::sleep_for(5ms), worker <= thread_state::aborting) + while (worker <= thread_state::aborting) { + std::this_thread::sleep_for(5ms); + if (pdlg.wasCanceled()) { cancelled = true; @@ -802,14 +806,14 @@ void main_window::HandlePackageInstallation(QStringList file_paths) void main_window::ExtractMSELF() { const QString path_last_mself = m_gui_settings->GetValue(gui::fd_ext_mself).toString(); - QString file_path = QFileDialog::getOpenFileName(this, tr("Select MSELF To extract"), path_last_mself, tr("All mself files (*.mself);;All files (*.*)")); + const QString file_path = QFileDialog::getOpenFileName(this, tr("Select MSELF To extract"), path_last_mself, tr("All mself files (*.mself);;All files (*.*)")); if (file_path.isEmpty()) { return; } - QString dir = QFileDialog::getExistingDirectory(this, tr("Extraction Directory"), QString{}, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); + const QString dir = QFileDialog::getExistingDirectory(this, tr("Extraction Directory"), QString{}, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); if (!dir.isEmpty()) { @@ -848,14 +852,14 @@ void main_window::InstallPup(QString file_path) void main_window::ExtractPup() { const QString path_last_pup = m_gui_settings->GetValue(gui::fd_install_pup).toString(); - QString file_path = QFileDialog::getOpenFileName(this, tr("Select PS3UPDAT.PUP To extract"), path_last_pup, tr("PS3 update file (PS3UPDAT.PUP);;All pup files (*.pup);;All files (*.*)")); + const QString file_path = QFileDialog::getOpenFileName(this, tr("Select PS3UPDAT.PUP To extract"), path_last_pup, tr("PS3 update file (PS3UPDAT.PUP);;All pup files (*.pup);;All files (*.*)")); if (file_path.isEmpty()) { return; } - QString dir = QFileDialog::getExistingDirectory(this, tr("Extraction Directory"), QString{}, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); + const QString dir = QFileDialog::getExistingDirectory(this, tr("Extraction Directory"), QString{}, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); if (!dir.isEmpty()) { @@ -881,7 +885,7 @@ void main_window::ExtractTar() return; } - QString dir = QFileDialog::getExistingDirectory(this, tr("Extraction Directory"), QString{}, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); + const QString dir = QFileDialog::getExistingDirectory(this, tr("Extraction Directory"), QString{}, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); if (dir.isEmpty()) { @@ -925,7 +929,7 @@ void main_window::ExtractTar() } } -void main_window::HandlePupInstallation(QString file_path, QString dir_path) +void main_window::HandlePupInstallation(const QString& file_path, const QString& dir_path) { const auto critical = [this](QString str) { @@ -986,7 +990,7 @@ void main_window::HandlePupInstallation(QString file_path, QString dir_path) } case pup_error::header_file_count: case pup_error::file_entries: - default: + case pup_error::stream: { std::string error = "Error while installing firmware: PUP file is invalid."; @@ -1046,7 +1050,7 @@ void main_window::HandlePupInstallation(QString file_path, QString dir_path) auto update_filenames = update_files.get_filenames(); update_filenames.erase(std::remove_if( - update_filenames.begin(), update_filenames.end(), [](std::string s) { return s.find("dev_flash_") == umax; }), + update_filenames.begin(), update_filenames.end(), [](const std::string& s) { return s.find("dev_flash_") == umax; }), update_filenames.end()); if (update_filenames.empty()) @@ -1344,7 +1348,7 @@ void main_window::DecryptSPRXLibraries() /** Needed so that when a backup occurs of window state in gui_settings, the state is current. * Also, so that on close, the window state is preserved. */ -void main_window::SaveWindowState() +void main_window::SaveWindowState() const { // Save gui settings m_gui_settings->SetValue(gui::mw_geometry, saveGeometry()); @@ -1455,7 +1459,7 @@ void main_window::RepaintToolBarIcons() ui->mw_searchbar->setFixedWidth(tool_bar_height * 5); } -void main_window::OnEmuRun(bool /*start_playtime*/) +void main_window::OnEmuRun(bool /*start_playtime*/) const { const QString title = GetCurrentTitle(); const QString restart_tooltip = tr("Restart %0").arg(title); @@ -1480,7 +1484,7 @@ void main_window::OnEmuRun(bool /*start_playtime*/) EnableMenus(true); } -void main_window::OnEmuResume() +void main_window::OnEmuResume() const { const QString title = GetCurrentTitle(); const QString restart_tooltip = tr("Restart %0").arg(title); @@ -1501,7 +1505,7 @@ void main_window::OnEmuResume() ui->toolbar_stop->setToolTip(stop_tooltip); } -void main_window::OnEmuPause() +void main_window::OnEmuPause() const { const QString title = GetCurrentTitle(); const QString resume_tooltip = tr("Resume %0").arg(title); @@ -1579,7 +1583,7 @@ void main_window::OnEmuStop() } } -void main_window::OnEmuReady() +void main_window::OnEmuReady() const { const QString title = GetCurrentTitle(); const QString play_tooltip = Emu.IsReady() ? tr("Play %0").arg(title) : tr("Resume %0").arg(title); @@ -1600,7 +1604,7 @@ void main_window::OnEmuReady() ui->actionManage_Users->setEnabled(false); } -void main_window::EnableMenus(bool enabled) +void main_window::EnableMenus(bool enabled) const { // Thumbnail Buttons #ifdef _WIN32 @@ -1660,9 +1664,9 @@ void main_window::BootRecentAction(const QAction* act) if (contains_path) { // clear menu of actions - for (auto act : m_recent_game_acts) + for (auto action : m_recent_game_acts) { - ui->bootRecentMenu->removeAction(act); + ui->bootRecentMenu->removeAction(action); } // remove action from list @@ -1751,9 +1755,9 @@ void main_window::AddRecentAction(const q_string_pair& entry) } // clear menu of actions - for (auto act : m_recent_game_acts) + for (auto action : m_recent_game_acts) { - ui->bootRecentMenu->removeAction(act); + ui->bootRecentMenu->removeAction(action); } // If path already exists, remove it in order to get it to beginning. Also remove duplicates. @@ -1856,7 +1860,7 @@ void main_window::RetranslateUI(const QStringList& language_codes, const QString } } -void main_window::ShowTitleBars(bool show) +void main_window::ShowTitleBars(bool show) const { m_game_list_frame->SetTitleBarVisible(show); m_debugger_frame->SetTitleBarVisible(show); @@ -2193,16 +2197,16 @@ void main_window::CreateConnects() int id = 0; const bool checked = act->isChecked(); - if (act == ui->showCatHDDGameAct) categories += category::cat_hdd_game, id = Category::HDD_Game; - else if (act == ui->showCatDiscGameAct) categories += category::cat_disc_game, id = Category::Disc_Game; - else if (act == ui->showCatPS1GamesAct) categories += category::cat_ps1_game, id = Category::PS1_Game; - else if (act == ui->showCatPS2GamesAct) categories += category::ps2_games, id = Category::PS2_Game; - else if (act == ui->showCatPSPGamesAct) categories += category::psp_games, id = Category::PSP_Game; - else if (act == ui->showCatHomeAct) categories += category::cat_home, id = Category::Home; - else if (act == ui->showCatAudioVideoAct) categories += category::media, id = Category::Media; - else if (act == ui->showCatGameDataAct) categories += category::data, id = Category::Data; - else if (act == ui->showCatUnknownAct) categories += category::cat_unknown, id = Category::Unknown_Cat; - else if (act == ui->showCatOtherAct) categories += category::others, id = Category::Others; + if (act == ui->showCatHDDGameAct) { categories += cat::cat_hdd_game; id = Category::HDD_Game; } + else if (act == ui->showCatDiscGameAct) { categories += cat::cat_disc_game; id = Category::Disc_Game; } + else if (act == ui->showCatPS1GamesAct) { categories += cat::cat_ps1_game; id = Category::PS1_Game; } + else if (act == ui->showCatPS2GamesAct) { categories += cat::ps2_games; id = Category::PS2_Game; } + else if (act == ui->showCatPSPGamesAct) { categories += cat::psp_games; id = Category::PSP_Game; } + else if (act == ui->showCatHomeAct) { categories += cat::cat_home; id = Category::Home; } + else if (act == ui->showCatAudioVideoAct) { categories += cat::media; id = Category::Media; } + else if (act == ui->showCatGameDataAct) { categories += cat::data; id = Category::Data; } + else if (act == ui->showCatUnknownAct) { categories += cat::cat_unknown; id = Category::Unknown_Cat; } + else if (act == ui->showCatOtherAct) { categories += cat::others; id = Category::Others; } else gui_log.warning("categoryVisibleActGroup: category action not found"); if (!categories.isEmpty()) @@ -2399,7 +2403,7 @@ void main_window::CreateDockWindows() ui->toolbar_start->setIcon(m_icon_play); } - else if (const auto path = Emu.GetBoot(); !path.empty()) // Restartable games + else if (const auto& path = Emu.GetBoot(); !path.empty()) // Restartable games { tooltip = tr("Restart %0").arg(GetCurrentTitle()); @@ -2543,7 +2547,7 @@ void main_window::ConfigureGuiFromSettings(bool configure_all) } } -void main_window::SetIconSizeActions(int idx) +void main_window::SetIconSizeActions(int idx) const { static const int threshold_tiny = gui::get_Index((gui::gl_icon_size_small + gui::gl_icon_size_min) / 2); static const int threshold_small = gui::get_Index((gui::gl_icon_size_medium + gui::gl_icon_size_small) / 2); @@ -2575,7 +2579,7 @@ void main_window::RemoveDiskCache() void main_window::RemoveFirmwareCache() { - const std::string cache_dir = Emu.GetCacheDir(); + const std::string cache_dir = Emulator::GetCacheDir(); if (!fs::is_dir(cache_dir)) return; @@ -2711,11 +2715,11 @@ void main_window::AddGamesFromDir(const QString& path) QDirIterator dir_iter(path, QDir::Dirs | QDir::NoDotAndDotDot); while (dir_iter.hasNext()) { - const std::string path = sstr(dir_iter.next()); + const std::string dir_path = sstr(dir_iter.next()); - if (const auto error = Emu.BootGame(path, "", false, true); error == game_boot_result::no_errors) + if (const auto error = Emu.BootGame(dir_path, "", false, true); error == game_boot_result::no_errors) { - gui_log.notice("Returned from game addition by drag and drop: %s", path); + gui_log.notice("Returned from game addition by drag and drop: %s", dir_path); } } } @@ -2723,7 +2727,7 @@ void main_window::AddGamesFromDir(const QString& path) /** Check data for valid file types and cache their paths if necessary @param md = data containing file urls -@param savePaths = flag for path caching +@param drop_paths = flag for path caching @returns validity of file type */ main_window::drop_type main_window::IsValidFile(const QMimeData& md, QStringList* drop_paths) @@ -2882,11 +2886,6 @@ void main_window::dropEvent(QDropEvent* event) BootRsxCapture(sstr(drop_paths.first())); break; } - default: - { - gui_log.warning("Invalid dropType in gamelist dropEvent"); - break; - } } } diff --git a/rpcs3/rpcs3qt/main_window.h b/rpcs3/rpcs3qt/main_window.h index 2a5006746d..b08f18d10e 100644 --- a/rpcs3/rpcs3qt/main_window.h +++ b/rpcs3/rpcs3qt/main_window.h @@ -80,13 +80,13 @@ class main_window : public QMainWindow }; public: - explicit main_window(std::shared_ptr gui_settings, std::shared_ptr emu_settings, std::shared_ptr persistent_settings, QWidget *parent = 0); + explicit main_window(std::shared_ptr gui_settings, std::shared_ptr emu_settings, std::shared_ptr persistent_settings, QWidget *parent = nullptr); ~main_window(); bool Init(bool with_cli_boot); - QIcon GetAppIcon(); + QIcon GetAppIcon() const; bool OnMissingFw(); void InstallPackages(QStringList file_paths = QStringList()); - void InstallPup(QString filePath = ""); + void InstallPup(QString file_path = ""); Q_SIGNALS: void RequestLanguageChange(const QString& language); @@ -96,10 +96,10 @@ Q_SIGNALS: public Q_SLOTS: void OnEmuStop(); - void OnEmuRun(bool start_playtime); - void OnEmuResume(); - void OnEmuPause(); - void OnEmuReady(); + void OnEmuRun(bool start_playtime) const; + void OnEmuResume() const; + void OnEmuPause() const; + void OnEmuReady() const; void RepaintGui(); void RetranslateUI(const QStringList& language_codes, const QString& language); @@ -111,11 +111,11 @@ private Q_SLOTS: void BootGame(); void BootRsxCapture(std::string path = ""); void DecryptSPRXLibraries(); - void show_boot_error(game_boot_result result); + static void show_boot_error(game_boot_result status); - void SaveWindowState(); + void SaveWindowState() const; void ConfigureGuiFromSettings(bool configure_all = false); - void SetIconSizeActions(int idx); + void SetIconSizeActions(int idx) const; void ResizeIcons(int index); void RemoveDiskCache(); @@ -137,21 +137,21 @@ private: void CreateActions(); void CreateConnects(); void CreateDockWindows(); - void EnableMenus(bool enabled); - void ShowTitleBars(bool show); + void EnableMenus(bool enabled) const; + void ShowTitleBars(bool show) const; static bool InstallRapFile(const QString& path, const std::string& filename); void HandlePackageInstallation(QStringList file_paths); - void HandlePupInstallation(QString file_path, QString dir_path = ""); + void HandlePupInstallation(const QString& file_path, const QString& dir_path = ""); void ExtractPup(); void ExtractTar(); void ExtractMSELF(); - drop_type IsValidFile(const QMimeData& md, QStringList* drop_paths = nullptr); - void AddGamesFromDir(const QString& path); + static drop_type IsValidFile(const QMimeData& md, QStringList* drop_paths = nullptr); + static void AddGamesFromDir(const QString& path); QAction* CreateRecentAction(const q_string_pair& entry, const uint& sc_idx); void BootRecentAction(const QAction* act); @@ -159,7 +159,7 @@ private: void UpdateLanguageActions(const QStringList& language_codes, const QString& language); - QString GetCurrentTitle(); + static QString GetCurrentTitle(); q_pair_list m_rg_entries; QList m_recent_game_acts; diff --git a/rpcs3/rpcs3qt/memory_string_searcher.cpp b/rpcs3/rpcs3qt/memory_string_searcher.cpp index 4235a15126..4c7fedf370 100644 --- a/rpcs3/rpcs3qt/memory_string_searcher.cpp +++ b/rpcs3/rpcs3qt/memory_string_searcher.cpp @@ -132,10 +132,10 @@ void memory_string_searcher::OnSearch() wstr += part; } - if (usz pos = wstr.find_first_not_of(hex_chars); pos != umax) + if (const usz pos = wstr.find_first_not_of(hex_chars); pos != umax) { - gui_log.error("String '%s' cannot be interpreted as hexadecimal byte string due to unknown character '%s'." - , m_addr_line->text().toStdString(), std::string_view{&wstr[pos], 1}); + gui_log.error("String '%s' cannot be interpreted as hexadecimal byte string due to unknown character '%s'.", + m_addr_line->text().toStdString(), std::string_view{&wstr[pos], 1}); return; } @@ -196,7 +196,7 @@ void memory_string_searcher::OnSearch() vm::reader_lock rlock; - named_thread_group workers("String Searcher "sv, max_threads, [&]() + const named_thread_group workers("String Searcher "sv, max_threads, [&]() { u32 local_found = 0; diff --git a/rpcs3/rpcs3qt/memory_string_searcher.h b/rpcs3/rpcs3qt/memory_string_searcher.h index d246d1688e..73c2876b49 100644 --- a/rpcs3/rpcs3qt/memory_string_searcher.h +++ b/rpcs3/rpcs3qt/memory_string_searcher.h @@ -10,12 +10,12 @@ class memory_string_searcher : public QDialog { Q_OBJECT - QLineEdit* m_addr_line; + QLineEdit* m_addr_line = nullptr; QCheckBox* m_chkbox_case_insensitive = nullptr; QComboBox* m_cbox_input_mode = nullptr; public: - memory_string_searcher(QWidget* parent); + explicit memory_string_searcher(QWidget* parent); private Q_SLOTS: void OnSearch(); diff --git a/rpcs3/rpcs3qt/memory_viewer_panel.cpp b/rpcs3/rpcs3qt/memory_viewer_panel.cpp index 76a2d54045..a34c053c6f 100644 --- a/rpcs3/rpcs3qt/memory_viewer_panel.cpp +++ b/rpcs3/rpcs3qt/memory_viewer_panel.cpp @@ -55,7 +55,7 @@ memory_viewer_panel::memory_viewer_panel(QWidget* parent, u32 addr, std::functio setObjectName("memory_viewer"); m_colcount = 4; m_rowcount = 16; - int pSize = 10; + const int pSize = 10; // Font QFont mono = QFontDatabase::systemFont(QFontDatabase::FixedFont); @@ -93,7 +93,7 @@ memory_viewer_panel::memory_viewer_panel(QWidget* parent, u32 addr, std::functio { public: words_spin_box(QWidget* parent = nullptr) : QSpinBox(parent) {} - ~words_spin_box() override {}; + ~words_spin_box() override {} private: int valueFromText(const QString &text) const override @@ -142,7 +142,7 @@ memory_viewer_panel::memory_viewer_panel(QWidget* parent, u32 addr, std::functio // Tools: Raw Image Preview Options QGroupBox* tools_img = new QGroupBox(tr("Raw Image Preview Options")); - QHBoxLayout* hbox_tools_img = new QHBoxLayout();; + QHBoxLayout* hbox_tools_img = new QHBoxLayout(); // Tools: Raw Image Preview Options : Size QGroupBox* tools_img_size = new QGroupBox(tr("Size")); @@ -300,13 +300,13 @@ memory_viewer_panel::~memory_viewer_panel() void memory_viewer_panel::wheelEvent(QWheelEvent *event) { // Set some scrollspeed modifiers: - u32 stepSize = 1; + u32 step_size = 1; if (event->modifiers().testFlag(Qt::ControlModifier)) - stepSize *= m_rowcount; + step_size *= m_rowcount; - QPoint numSteps = event->angleDelta() / 8 / 15; // http://doc.qt.io/qt-5/qwheelevent.html#pixelDelta + const QPoint num_steps = event->angleDelta() / 8 / 15; // http://doc.qt.io/qt-5/qwheelevent.html#pixelDelta - scroll(stepSize * (0 - numSteps.y())); + scroll(step_size * (0 - num_steps.y())); } void memory_viewer_panel::scroll(s32 steps) @@ -345,7 +345,7 @@ void memory_viewer_panel::resizeEvent(QResizeEvent *event) } } -std::string memory_viewer_panel::getHeaderAtAddr(u32 addr) +std::string memory_viewer_panel::getHeaderAtAddr(u32 addr) const { if (m_type == thread_type::spu) return {}; @@ -356,7 +356,7 @@ std::string memory_viewer_panel::getHeaderAtAddr(u32 addr) { std::shared_ptr> spu; - if (u32 raw_spu_index = (spu_boundary - RAW_SPU_BASE_ADDR) / SPU_LS_SIZE; raw_spu_index < 5) + if (const u32 raw_spu_index = (spu_boundary - RAW_SPU_BASE_ADDR) / SPU_LS_SIZE; raw_spu_index < 5) { spu = idm::get>(spu_thread::find_raw_spu(raw_spu_index)); @@ -365,7 +365,7 @@ std::string memory_viewer_panel::getHeaderAtAddr(u32 addr) spu.reset(); } } - else if (u32 spu_index = (spu_boundary - SPU_FAKE_BASE_ADDR) / SPU_LS_SIZE; spu_index < spu_thread::id_count) + else if (const u32 spu_index = (spu_boundary - SPU_FAKE_BASE_ADDR) / SPU_LS_SIZE; spu_index < spu_thread::id_count) { spu = idm::get>(spu_thread::id_base | spu_index); @@ -384,7 +384,7 @@ std::string memory_viewer_panel::getHeaderAtAddr(u32 addr) return {}; } -void* memory_viewer_panel::to_ptr(u32 addr, u32 size) +void* memory_viewer_panel::to_ptr(u32 addr, u32 size) const { if (m_type >= thread_type::spu && !m_get_cpu()) { @@ -436,7 +436,8 @@ void* memory_viewer_panel::to_ptr(u32 addr, u32 size) final_addr = 0; break; } - else if (!final_addr) + + if (!final_addr) { // First time, save starting address for later checks final_addr = temp; @@ -456,7 +457,6 @@ void* memory_viewer_panel::to_ptr(u32 addr, u32 size) break; } - default: break; } return nullptr; @@ -534,11 +534,11 @@ void memory_viewer_panel::ShowMemory() t_mem_hex_str += " "; } - u32 addr = (m_addr + (row - spu_passed) * m_colcount * 4 + col * 4) & m_addr_mask; + const u32 addr = (m_addr + (row - spu_passed) * m_colcount * 4 + col * 4) & m_addr_mask; - if (auto ptr = this->to_ptr(addr)) + if (const auto ptr = this->to_ptr(addr)) { - const be_t rmem = *reinterpret_cast*>(ptr); + const be_t rmem = *static_cast*>(ptr); t_mem_hex_str += qstr(fmt::format("%02x %02x %02x %02x", static_cast(rmem >> 24), static_cast(rmem >> 16), @@ -582,10 +582,14 @@ void memory_viewer_panel::SetPC(const uint pc) m_addr = pc; } -void memory_viewer_panel::ShowImage(QWidget* parent, u32 addr, color_format format, u32 width, u32 height, bool flipv) +void memory_viewer_panel::ShowImage(QWidget* parent, u32 addr, color_format format, u32 width, u32 height, bool flipv) const { // If exceeds 32-bits it is invalid as well, UINT32_MAX always fails checks const u32 memsize = static_cast(std::min(4ull * width * height, UINT32_MAX)); + if (memsize == 0) + { + return; + } std::shared_lock rlock(vm::g_mutex); @@ -671,7 +675,7 @@ void memory_viewer_panel::ShowImage(QWidget* parent, u32 addr, color_format form rlock.unlock(); // Flip vertically - if (flipv && height > 1) + if (flipv && height > 1 && memsize > 1) { const u32 pitch = width * 4; for (u32 y = 0; y < height / 2; y++) @@ -687,7 +691,7 @@ void memory_viewer_panel::ShowImage(QWidget* parent, u32 addr, color_format form } } - QImage image(convertedBuffer, width, height, QImage::Format_ARGB32, [](void* buffer){ delete[] static_cast(buffer); }, convertedBuffer); + const QImage image(convertedBuffer, width, height, QImage::Format_ARGB32, [](void* buffer){ delete[] static_cast(buffer); }, convertedBuffer); if (image.isNull()) return; QLabel* canvas = new QLabel(); diff --git a/rpcs3/rpcs3qt/memory_viewer_panel.h b/rpcs3/rpcs3qt/memory_viewer_panel.h index 32b2140b78..ca8fbf28ad 100644 --- a/rpcs3/rpcs3qt/memory_viewer_panel.h +++ b/rpcs3/rpcs3qt/memory_viewer_panel.h @@ -70,14 +70,14 @@ private: const std::shared_ptr m_spu_shm; const u32 m_addr_mask; - std::string getHeaderAtAddr(u32 addr); + std::string getHeaderAtAddr(u32 addr) const; void scroll(s32 steps); - void* to_ptr(u32 addr, u32 size = 1); + void* to_ptr(u32 addr, u32 size = 1) const; void SetPC(const uint pc); virtual void ShowMemory(); - void ShowImage(QWidget* parent, u32 addr, color_format format, u32 sizex, u32 sizey, bool flipv); + void ShowImage(QWidget* parent, u32 addr, color_format format, u32 width, u32 height, bool flipv) const; }; // Lifetime management with IDM diff --git a/rpcs3/rpcs3qt/microphone_creator.cpp b/rpcs3/rpcs3qt/microphone_creator.cpp index 94d554973a..1eea5130d2 100644 --- a/rpcs3/rpcs3qt/microphone_creator.cpp +++ b/rpcs3/rpcs3qt/microphone_creator.cpp @@ -24,9 +24,9 @@ void microphone_creator::refresh_list() m_microphone_list.clear(); m_microphone_list.append(get_none()); - if (alcIsExtensionPresent(NULL, "ALC_ENUMERATION_EXT") == AL_TRUE) + if (alcIsExtensionPresent(nullptr, "ALC_ENUMERATION_EXT") == AL_TRUE) { - if (const char* devices = alcGetString(NULL, ALC_CAPTURE_DEVICE_SPECIFIER); devices != nullptr) + if (const char* devices = alcGetString(nullptr, ALC_CAPTURE_DEVICE_SPECIFIER); devices != nullptr) { while (*devices != 0) { @@ -38,19 +38,19 @@ void microphone_creator::refresh_list() else { // Without enumeration we can only use one device - if (const char* device = alcGetString(NULL, ALC_DEFAULT_DEVICE_SPECIFIER); device != nullptr) + if (const char* device = alcGetString(nullptr, ALC_DEFAULT_DEVICE_SPECIFIER); device != nullptr) { m_microphone_list.append(qstr(device)); } } } -QStringList microphone_creator::get_microphone_list() +QStringList microphone_creator::get_microphone_list() const { return m_microphone_list; } -std::array microphone_creator::get_selection_list() +std::array microphone_creator::get_selection_list() const { return m_sel_list; } @@ -62,8 +62,7 @@ std::string microphone_creator::set_device(u32 num, const QString& text) else m_sel_list[num - 1] = text.toStdString(); - const std::string final_list = m_sel_list[0] + "@@@" + m_sel_list[1] + "@@@" + m_sel_list[2] + "@@@" + m_sel_list[3] + "@@@"; - return final_list; + return m_sel_list[0] + "@@@" + m_sel_list[1] + "@@@" + m_sel_list[2] + "@@@" + m_sel_list[3] + "@@@"; } void microphone_creator::parse_devices(const std::string& list) diff --git a/rpcs3/rpcs3qt/microphone_creator.h b/rpcs3/rpcs3qt/microphone_creator.h index 0e8e1613fe..95a3827c93 100644 --- a/rpcs3/rpcs3qt/microphone_creator.h +++ b/rpcs3/rpcs3qt/microphone_creator.h @@ -19,8 +19,8 @@ public: std::string set_device(u32 num, const QString& text); void parse_devices(const std::string& list); void refresh_list(); - QStringList get_microphone_list(); - std::array get_selection_list(); + QStringList get_microphone_list() const; + std::array get_selection_list() const; private: QStringList m_microphone_list; diff --git a/rpcs3/rpcs3qt/msg_dialog_frame.cpp b/rpcs3/rpcs3qt/msg_dialog_frame.cpp index ae3e773175..f7ac3a6658 100644 --- a/rpcs3/rpcs3qt/msg_dialog_frame.cpp +++ b/rpcs3/rpcs3qt/msg_dialog_frame.cpp @@ -6,7 +6,6 @@ #include #ifdef _WIN32 -#include #include #elif HAVE_QTDBUS #include @@ -35,7 +34,7 @@ void msg_dialog_frame::Create(const std::string& msg, const std::string& title) layout->setFormAlignment(Qt::AlignHCenter); layout->addRow(m_text); - auto l_AddGauge = [=, this](QProgressBar* &bar, QLabel* &text) + auto l_AddGauge = [this, layout](QProgressBar* &bar, QLabel* &text) { text = new QLabel("", m_dialog); bar = new QProgressBar(m_dialog); @@ -169,8 +168,6 @@ void msg_dialog_frame::Close(bool success) } } -msg_dialog_frame::msg_dialog_frame() {} - msg_dialog_frame::~msg_dialog_frame() { #ifdef _WIN32 diff --git a/rpcs3/rpcs3qt/msg_dialog_frame.h b/rpcs3/rpcs3qt/msg_dialog_frame.h index 7027875bf8..c51cb07806 100644 --- a/rpcs3/rpcs3qt/msg_dialog_frame.h +++ b/rpcs3/rpcs3qt/msg_dialog_frame.h @@ -36,16 +36,16 @@ private: int m_gauge_max = 0; public: - msg_dialog_frame(); + msg_dialog_frame() = default; ~msg_dialog_frame(); - virtual void Create(const std::string& msg, const std::string& title = "") override; - virtual void Close(bool success) override; - virtual void SetMsg(const std::string& msg) override; - virtual void ProgressBarSetMsg(u32 progressBarIndex, const std::string& msg) override; - virtual void ProgressBarReset(u32 progressBarIndex) override; - virtual void ProgressBarInc(u32 progressBarIndex, u32 delta) override; - virtual void ProgressBarSetValue(u32 progressBarIndex, u32 value) override; - virtual void ProgressBarSetLimit(u32 index, u32 limit) override; + void Create(const std::string& msg, const std::string& title = "") override; + void Close(bool success) override; + void SetMsg(const std::string& msg) override; + void ProgressBarSetMsg(u32 progressBarIndex, const std::string& msg) override; + void ProgressBarReset(u32 progressBarIndex) override; + void ProgressBarInc(u32 progressBarIndex, u32 delta) override; + void ProgressBarSetValue(u32 progressBarIndex, u32 value) override; + void ProgressBarSetLimit(u32 index, u32 limit) override; #ifdef HAVE_QTDBUS private: void UpdateProgress(int progress, bool disable = false); diff --git a/rpcs3/rpcs3qt/osk_dialog_frame.cpp b/rpcs3/rpcs3qt/osk_dialog_frame.cpp index 2d2357e654..6019d10e24 100644 --- a/rpcs3/rpcs3qt/osk_dialog_frame.cpp +++ b/rpcs3/rpcs3qt/osk_dialog_frame.cpp @@ -14,10 +14,6 @@ constexpr auto qstr = QString::fromStdString; -osk_dialog_frame::osk_dialog_frame() -{ -} - osk_dialog_frame::~osk_dialog_frame() { if (m_dialog) @@ -48,8 +44,8 @@ void osk_dialog_frame::Create(const std::string& title, const std::u16string& me QLabel* message_label = new QLabel(QString::fromStdU16String(message)); // Text Input Counter - const QString text = QString::fromStdU16String(std::u16string(init_text)); - QLabel* input_count_label = new QLabel(QString("%1/%2").arg(text.length()).arg(charlimit)); + const QString input_text = QString::fromStdU16String(std::u16string(init_text)); + QLabel* input_count_label = new QLabel(QString("%1/%2").arg(input_text.length()).arg(charlimit)); // Button Layout QDialogButtonBox* button_box = new QDialogButtonBox(QDialogButtonBox::Ok); @@ -64,7 +60,7 @@ void osk_dialog_frame::Create(const std::string& title, const std::u16string& me QLineEdit* input = new QLineEdit(m_dialog); input->setFixedWidth(lineEditWidth()); input->setMaxLength(charlimit); - input->setText(text); + input->setText(input_text); input->setFocus(); if (prohibit_flags & CELL_OSKDIALOG_NO_SPACE) @@ -72,7 +68,7 @@ void osk_dialog_frame::Create(const std::string& title, const std::u16string& me input->setValidator(new QRegExpValidator(QRegExp("^\\S*$"), this)); } - connect(input, &QLineEdit::textChanged, [=, this](const QString& text) + connect(input, &QLineEdit::textChanged, input_count_label, [input_count_label, charlimit, this](const QString& text) { input_count_label->setText(QString("%1/%2").arg(text.length()).arg(charlimit)); SetOskText(text); @@ -86,10 +82,10 @@ void osk_dialog_frame::Create(const std::string& title, const std::u16string& me { QTextEdit* input = new QTextEdit(m_dialog); input->setFixedWidth(lineEditWidth()); - input->setText(text); + input->setText(input_text); input->setFocus(); input->moveCursor(QTextCursor::End); - m_text_old = text; + m_text_old = input_text; connect(input, &QTextEdit::textChanged, [=, this]() { diff --git a/rpcs3/rpcs3qt/osk_dialog_frame.h b/rpcs3/rpcs3qt/osk_dialog_frame.h index 084f7ae3c0..0bde9bdde7 100644 --- a/rpcs3/rpcs3qt/osk_dialog_frame.h +++ b/rpcs3/rpcs3qt/osk_dialog_frame.h @@ -14,10 +14,10 @@ class osk_dialog_frame : public QObject, public OskDialogBase Q_OBJECT public: - osk_dialog_frame(); + osk_dialog_frame() = default; ~osk_dialog_frame(); - virtual void Create(const std::string& title, const std::u16string& message, char16_t* init_text, u32 charlimit, u32 prohibit_flags, u32 panel_flag, u32 first_view_panel) override; - virtual void Close(bool accepted) override; + void Create(const std::string& title, const std::u16string& message, char16_t* init_text, u32 charlimit, u32 prohibit_flags, u32 panel_flag, u32 first_view_panel) override; + void Close(bool accepted) override; private: void SetOskText(const QString& text); diff --git a/rpcs3/rpcs3qt/pad_led_settings_dialog.cpp b/rpcs3/rpcs3qt/pad_led_settings_dialog.cpp index a0f46cb370..1d42daaaf1 100644 --- a/rpcs3/rpcs3qt/pad_led_settings_dialog.cpp +++ b/rpcs3/rpcs3qt/pad_led_settings_dialog.cpp @@ -74,7 +74,7 @@ pad_led_settings_dialog::~pad_led_settings_dialog() delete ui; } -void pad_led_settings_dialog::redraw_color_sample() +void pad_led_settings_dialog::redraw_color_sample() const { const qreal dpr = devicePixelRatioF(); const qreal w = ui->w_color_sample->width(); @@ -105,13 +105,13 @@ void pad_led_settings_dialog::redraw_color_sample() ui->w_color_sample->setPixmap(color_sample.scaled(w * dpr, h * dpr, Qt::KeepAspectRatio, Qt::TransformationMode::SmoothTransformation)); } -void pad_led_settings_dialog::update_slider_label(int val) +void pad_led_settings_dialog::update_slider_label(int val) const { const QString label = QString::number(val) + QStringLiteral("%"); ui->l_indicator_brightness->setText(label); } -void pad_led_settings_dialog::battery_indicator_checked(bool checked) +void pad_led_settings_dialog::battery_indicator_checked(bool checked) const { ui->gb_indicator_brightness->setEnabled(checked); } diff --git a/rpcs3/rpcs3qt/pad_led_settings_dialog.h b/rpcs3/rpcs3qt/pad_led_settings_dialog.h index 79c8fa383b..e9bf9ff4b2 100644 --- a/rpcs3/rpcs3qt/pad_led_settings_dialog.h +++ b/rpcs3/rpcs3qt/pad_led_settings_dialog.h @@ -21,11 +21,11 @@ Q_SIGNALS: void pass_led_settings(int m_cR, int m_cG, int m_cB, bool m_low_battery_blink, bool m_battery_indicator, int m_battery_indicator_brightness); private Q_SLOTS: - void update_slider_label(int val); - void battery_indicator_checked(bool checked); + void update_slider_label(int val) const; + void battery_indicator_checked(bool checked) const; private: - void redraw_color_sample(); + void redraw_color_sample() const; void read_form_values(); Ui::pad_led_settings_dialog *ui; struct led_settings diff --git a/rpcs3/rpcs3qt/pad_settings_dialog.cpp b/rpcs3/rpcs3qt/pad_settings_dialog.cpp index fce27169b8..2ef85e7dbd 100644 --- a/rpcs3/rpcs3qt/pad_settings_dialog.cpp +++ b/rpcs3/rpcs3qt/pad_settings_dialog.cpp @@ -1,12 +1,9 @@ #include -#include #include -#include #include #include #include #include -#include #include "qt_utils.h" #include "pad_settings_dialog.h" @@ -59,7 +56,9 @@ inline bool CreateConfigFile(const QString& dir, const QString& name) } pad_settings_dialog::pad_settings_dialog(std::shared_ptr gui_settings, QWidget *parent, const GameInfo *game) - : QDialog(parent), ui(new Ui::pad_settings_dialog), m_gui_settings(gui_settings) + : QDialog(parent) + , ui(new Ui::pad_settings_dialog) + , m_gui_settings(std::move(gui_settings)) { pad::set_enabled(false); @@ -402,12 +401,14 @@ void pad_settings_dialog::InitButtons() if (m_lx != preview_values[2] || m_ly != preview_values[3]) { - m_lx = preview_values[2], m_ly = preview_values[3]; + m_lx = preview_values[2]; + m_ly = preview_values[3]; RepaintPreviewLabel(ui->preview_stick_left, ui->slider_stick_left->value(), ui->slider_stick_left->size().width(), m_lx, m_ly, ui->squircle_left->value(), ui->stick_multi_left->value()); } if (m_rx != preview_values[4] || m_ry != preview_values[5]) { - m_rx = preview_values[4], m_ry = preview_values[5]; + m_rx = preview_values[4]; + m_ry = preview_values[5]; RepaintPreviewLabel(ui->preview_stick_right, ui->slider_stick_right->value(), ui->slider_stick_right->size().width(), m_rx, m_ry, ui->squircle_right->value(), ui->stick_multi_right->value()); } } @@ -448,12 +449,14 @@ void pad_settings_dialog::InitButtons() if (m_lx != 0 || m_ly != 0) { - m_lx = 0, m_ly = 0; + m_lx = 0; + m_ly = 0; RepaintPreviewLabel(ui->preview_stick_left, ui->slider_stick_left->value(), ui->slider_stick_left->size().width(), m_lx, m_ly, ui->squircle_left->value(), ui->stick_multi_left->value()); } if (m_rx != 0 || m_ry != 0) { - m_rx = 0, m_ry = 0; + m_rx = 0; + m_ry = 0; RepaintPreviewLabel(ui->preview_stick_right, ui->slider_stick_right->value(), ui->slider_stick_right->size().width(), m_rx, m_ry, ui->squircle_right->value(), ui->stick_multi_right->value()); } } @@ -627,7 +630,7 @@ void pad_settings_dialog::ReactivateButtons() ui->chooseProduct->setFocusPolicy(Qt::WheelFocus); } -void pad_settings_dialog::RepaintPreviewLabel(QLabel* l, int deadzone, int desired_width, int x, int y, int squircle, double multiplier) +void pad_settings_dialog::RepaintPreviewLabel(QLabel* l, int deadzone, int desired_width, int x, int y, int squircle, double multiplier) const { const int deadzone_max = m_handler ? m_handler->thumb_max : 255; // 255 used as fallback. The deadzone circle shall be small. @@ -644,8 +647,8 @@ void pad_settings_dialog::RepaintPreviewLabel(QLabel* l, int deadzone, int desir const bool show_emulated_values = ui->chb_show_emulated_values->isChecked(); - qreal ingame_x; - qreal ingame_y; + [[maybe_unused]] qreal ingame_x = 0.0; + [[maybe_unused]] qreal ingame_y = 0.0; // Set up the canvas for our work of art QPixmap pixmap(scaled_width, scaled_width); @@ -728,7 +731,7 @@ void pad_settings_dialog::keyPressEvent(QKeyEvent *keyEvent) } else { - m_cfg_entries[m_button_id].key = (static_cast(m_handler.get()))->GetKeyName(keyEvent); + m_cfg_entries[m_button_id].key = keyboard_pad_handler::GetKeyName(keyEvent); m_cfg_entries[m_button_id].text = qstr(m_cfg_entries[m_button_id].key); } @@ -844,9 +847,9 @@ void pad_settings_dialog::mouseMoveEvent(QMouseEvent* event) } else { - QPoint mouse_pos = QCursor::pos(); - int delta_x = mouse_pos.x() - m_last_pos.x(); - int delta_y = mouse_pos.y() - m_last_pos.y(); + const QPoint mouse_pos = QCursor::pos(); + const int delta_x = mouse_pos.x() - m_last_pos.x(); + const int delta_y = mouse_pos.y() - m_last_pos.y(); u32 key = 0; @@ -1118,7 +1121,7 @@ void pad_settings_dialog::OnTabChanged(int index) RefreshInputTypes(); } -std::shared_ptr pad_settings_dialog::GetHandler(pad_handler type) +std::shared_ptr pad_settings_dialog::GetHandler(pad_handler type) const { switch (type) { @@ -1187,7 +1190,7 @@ void pad_settings_dialog::ChangeInputType() const auto device_list = m_handler->ListDevices(); // Localized tooltips - Tooltips tooltips; + const Tooltips tooltips; // Change the description switch (m_handler->m_type) @@ -1230,8 +1233,6 @@ void pad_settings_dialog::ChangeInputType() case pad_handler::evdev: m_description = tooltips.gamepad_settings.evdev; break; #endif - default: - m_description = ""; } ui->l_description->setText(m_description); @@ -1269,9 +1270,9 @@ void pad_settings_dialog::ChangeInputType() } default: { - for (usz i = 0; i < device_list.size(); i++) + for (const auto& device_name : device_list) { - ui->chooseDevice->addItem(qstr(device_list[i]), QVariant::fromValue(pad_device_info{ device_list[i], true })); + ui->chooseDevice->addItem(qstr(device_name), QVariant::fromValue(pad_device_info{ device_name, true })); } break; } @@ -1401,8 +1402,6 @@ void pad_settings_dialog::ChangeProfile() static_cast(m_handler.get())->init_config(&m_handler_cfg, cfg_name); break; #endif - default: - break; } // Load new config @@ -1423,7 +1422,7 @@ void pad_settings_dialog::ChangeProfile() } } -void pad_settings_dialog::HandleDeviceClassChange(int index) +void pad_settings_dialog::HandleDeviceClassChange(int index) const { if (index < 0) { @@ -1436,7 +1435,6 @@ void pad_settings_dialog::HandleDeviceClassChange(int index) { switch (product.type) { - default: case input::product_type::playstation_3_controller: { ui->chooseProduct->addItem(tr("PS3 Controller", "PlayStation 3 Controller"), static_cast(product.type)); @@ -1501,10 +1499,10 @@ void pad_settings_dialog::RefreshInputTypes() else { const std::vector str_inputs = g_cfg_input.player[0]->handler.to_list(); - for (usz index = 0; index < str_inputs.size(); index++) + for (usz i = 0; i < str_inputs.size(); i++) { - const QString item_data = qstr(str_inputs[index]); - ui->chooseHandler->addItem(GetLocalizedPadHandler(item_data, static_cast(index)), QVariant(item_data)); + const QString item_data = qstr(str_inputs[i]); + ui->chooseHandler->addItem(GetLocalizedPadHandler(item_data, static_cast(i)), QVariant(item_data)); } const auto& handler = g_cfg_input.player[index]->handler; @@ -1613,8 +1611,6 @@ QString pad_settings_dialog::GetLocalizedPadHandler(const QString& original, pad #ifdef HAVE_LIBEVDEV case pad_handler::evdev: return tr("Evdev"); #endif - default: - break; } return original; } @@ -1662,7 +1658,7 @@ void pad_settings_dialog::SubscribeTooltip(QObject* object, const QString& toolt void pad_settings_dialog::SubscribeTooltips() { // Localized tooltips - Tooltips tooltips; + const Tooltips tooltips; SubscribeTooltip(ui->gb_squircle, tooltips.gamepad_settings.squircle_factor); SubscribeTooltip(ui->gb_stick_multi, tooltips.gamepad_settings.stick_multiplier); diff --git a/rpcs3/rpcs3qt/pad_settings_dialog.h b/rpcs3/rpcs3qt/pad_settings_dialog.h index 194137f083..bbeb61532a 100644 --- a/rpcs3/rpcs3qt/pad_settings_dialog.h +++ b/rpcs3/rpcs3qt/pad_settings_dialog.h @@ -3,7 +3,6 @@ #include #include #include -#include #include #include "Emu/Io/pad_config.h" @@ -99,7 +98,7 @@ private Q_SLOTS: void OnTabChanged(int index); void RefreshInputTypes(); void ChangeInputType(); - void HandleDeviceClassChange(int index); + void HandleDeviceClassChange(int index) const; /** Save the Pad Configuration to the current Pad Handler Config File */ void SaveProfile(); @@ -177,9 +176,9 @@ private: void ChangeProfile(); /** Repaints a stick deadzone preview label */ - void RepaintPreviewLabel(QLabel* l, int deadzone, int desired_width, int x, int y, int squircle, double multiplier); + void RepaintPreviewLabel(QLabel* l, int deadzone, int desired_width, int x, int y, int squircle, double multiplier) const; - std::shared_ptr GetHandler(pad_handler type); + std::shared_ptr GetHandler(pad_handler type) const; QString GetLocalizedPadHandler(const QString& original, pad_handler handler); diff --git a/rpcs3/rpcs3qt/patch_manager_dialog.cpp b/rpcs3/rpcs3qt/patch_manager_dialog.cpp index 19ae06e27c..34ac3d47a8 100644 --- a/rpcs3/rpcs3qt/patch_manager_dialog.cpp +++ b/rpcs3/rpcs3qt/patch_manager_dialog.cpp @@ -54,7 +54,7 @@ enum node_level : int patch_manager_dialog::patch_manager_dialog(std::shared_ptr gui_settings, std::unordered_map> games, const std::string& title_id, const std::string& version, QWidget* parent) : QDialog(parent) - , m_gui_settings(gui_settings) + , m_gui_settings(std::move(gui_settings)) , m_expand_current_match(!title_id.empty() && !version.empty()) // Expand first search results , m_search_version(QString::fromStdString(version)) , m_owned_games(std::move(games)) @@ -224,7 +224,7 @@ void patch_manager_dialog::populate_tree() QTreeWidgetItem* title_level_item = nullptr; // Find top level item for this title - if (const auto list = ui->patch_tree->findItems(visible_title, Qt::MatchFlag::MatchExactly, 0); list.size() > 0) + if (const auto list = ui->patch_tree->findItems(visible_title, Qt::MatchFlag::MatchExactly, 0); !list.empty()) { title_level_item = list[0]; } @@ -320,7 +320,7 @@ void patch_manager_dialog::populate_tree() for (int i = ui->patch_tree->topLevelItemCount() - 1; i >= 0; i--) { - if (auto title_level_item = ui->patch_tree->topLevelItem(i)) + if (const auto title_level_item = ui->patch_tree->topLevelItem(i)) { if (!title_level_item->data(0, persistance_role).toBool()) { @@ -337,7 +337,7 @@ void patch_manager_dialog::populate_tree() // Move "All titles" to the top // NOTE: "All serials" is only allowed as the only node in "All titles", so there is no need to move it up // NOTE: "All versions" will be above valid numerical versions through sorting anyway - if (const auto all_title_items = ui->patch_tree->findItems(tr_all_titles, Qt::MatchExactly); all_title_items.size() > 0) + if (const auto all_title_items = ui->patch_tree->findItems(tr_all_titles, Qt::MatchExactly); !all_title_items.empty()) { const auto item = all_title_items[0]; ensure(item && all_title_items.size() == 1); @@ -361,7 +361,7 @@ void patch_manager_dialog::populate_tree() } } -void patch_manager_dialog::save_config() +void patch_manager_dialog::save_config() const { patch_engine::save_config(m_map); } @@ -475,7 +475,7 @@ void patch_manager_dialog::filter_patches(const QString& term) m_expand_current_match = false; } -void patch_manager_dialog::update_patch_info(const patch_manager_dialog::gui_patch_info& info) +void patch_manager_dialog::update_patch_info(const patch_manager_dialog::gui_patch_info& info) const { ui->label_hash->setText(info.hash); ui->label_author->setText(info.author); @@ -540,10 +540,6 @@ void patch_manager_dialog::handle_item_selected(QTreeWidgetItem *current, QTreeW const QString title = current->data(0, title_role).toString(); info.title = title.toStdString() == patch_key::all ? tr_all_titles : title; - [[fallthrough]]; - } - default: - { break; } } @@ -865,7 +861,7 @@ void patch_manager_dialog::dragLeaveEvent(QDragLeaveEvent* event) event->accept(); } -void patch_manager_dialog::download_update() +void patch_manager_dialog::download_update() const { patch_log.notice("Patch download triggered"); @@ -874,7 +870,7 @@ void patch_manager_dialog::download_update() if (fs::is_file(path)) { - if (fs::file patch_file{path}) + if (const fs::file patch_file{path}) { const std::string hash = downloader::get_hash(patch_file.to_string().c_str(), patch_file.size(), true); url += "&sha256=" + hash; diff --git a/rpcs3/rpcs3qt/patch_manager_dialog.h b/rpcs3/rpcs3qt/patch_manager_dialog.h index 29807bd1b9..17dee70720 100644 --- a/rpcs3/rpcs3qt/patch_manager_dialog.h +++ b/rpcs3/rpcs3qt/patch_manager_dialog.h @@ -53,10 +53,10 @@ private: void refresh(bool restore_layout = false); void load_patches(bool show_error); void populate_tree(); - void save_config(); - void update_patch_info(const gui_patch_info& info); - bool is_valid_file(const QMimeData& md, QStringList* drop_paths = nullptr); - void download_update(); + void save_config() const; + void update_patch_info(const gui_patch_info& info) const; + static bool is_valid_file(const QMimeData& md, QStringList* drop_paths = nullptr); + void download_update() const; bool handle_json(const QByteArray& data); std::shared_ptr m_gui_settings; diff --git a/rpcs3/rpcs3qt/pkg_install_dialog.cpp b/rpcs3/rpcs3qt/pkg_install_dialog.cpp index 8ca5d6e782..185bf4d6fc 100644 --- a/rpcs3/rpcs3qt/pkg_install_dialog.cpp +++ b/rpcs3/rpcs3qt/pkg_install_dialog.cpp @@ -166,7 +166,7 @@ pkg_install_dialog::pkg_install_dialog(const QStringList& paths, game_compatibil setObjectName("pkg_install_dialog"); } -void pkg_install_dialog::MoveItem(int offset) +void pkg_install_dialog::MoveItem(int offset) const { const int src_index = m_dir_list->currentRow(); const int dest_index = src_index + offset; diff --git a/rpcs3/rpcs3qt/pkg_install_dialog.h b/rpcs3/rpcs3qt/pkg_install_dialog.h index f8a4c3d0b6..bb566b1b67 100644 --- a/rpcs3/rpcs3qt/pkg_install_dialog.h +++ b/rpcs3/rpcs3qt/pkg_install_dialog.h @@ -19,7 +19,7 @@ public: std::vector GetPathsToInstall() const; private: - void MoveItem(int offset); + void MoveItem(int offset) const; QListWidget* m_dir_list; }; diff --git a/rpcs3/rpcs3qt/progress_dialog.cpp b/rpcs3/rpcs3qt/progress_dialog.cpp index 95d0db6941..1003b221de 100644 --- a/rpcs3/rpcs3qt/progress_dialog.cpp +++ b/rpcs3/rpcs3qt/progress_dialog.cpp @@ -4,7 +4,6 @@ #include #ifdef _WIN32 -#include #include #elif HAVE_QTDBUS #include @@ -61,7 +60,7 @@ void progress_dialog::SetValue(int progress) QProgressDialog::setValue(value); } -void progress_dialog::SignalFailure() +void progress_dialog::SignalFailure() const { #ifdef _WIN32 m_tb_progress->stop(); diff --git a/rpcs3/rpcs3qt/progress_dialog.h b/rpcs3/rpcs3qt/progress_dialog.h index dc29b981f5..549373dad7 100644 --- a/rpcs3/rpcs3qt/progress_dialog.h +++ b/rpcs3/rpcs3qt/progress_dialog.h @@ -13,7 +13,7 @@ public: progress_dialog(const QString &windowTitle, const QString &labelText, const QString &cancelButtonText, int minimum, int maximum, bool delete_on_close, QWidget *parent = Q_NULLPTR, Qt::WindowFlags flags = Qt::WindowFlags()); ~progress_dialog(); void SetValue(int progress); - void SignalFailure(); + void SignalFailure() const; private: #ifdef _WIN32 diff --git a/rpcs3/rpcs3qt/qt_utils.cpp b/rpcs3/rpcs3qt/qt_utils.cpp index 887ab5c440..8a0829ac81 100644 --- a/rpcs3/rpcs3qt/qt_utils.cpp +++ b/rpcs3/rpcs3qt/qt_utils.cpp @@ -47,13 +47,13 @@ namespace gui if (colorize_all) { - QBitmap mask = pixmap.createMaskFromColor(Qt::transparent, Qt::MaskInColor); + const QBitmap mask = pixmap.createMaskFromColor(Qt::transparent, Qt::MaskInColor); pixmap.fill(new_color); pixmap.setMask(mask); return pixmap; } - QBitmap mask = pixmap.createMaskFromColor(old_color, Qt::MaskOutColor); + const QBitmap mask = pixmap.createMaskFromColor(old_color, Qt::MaskOutColor); pixmap.fill(new_color); pixmap.setMask(mask); @@ -76,9 +76,9 @@ namespace gui //test_pixmap.fill(saturatedColor(new_color, 0.6f)); //test_pixmap.setMask(test_mask); - QColor white_color(Qt::white); + const QColor white_color(Qt::white); QPixmap white_pixmap = old_pixmap; - QBitmap white_mask = white_pixmap.createMaskFromColor(white_color, Qt::MaskOutColor); + const QBitmap white_mask = white_pixmap.createMaskFromColor(white_color, Qt::MaskOutColor); white_pixmap.fill(white_color); white_pixmap.setMask(white_mask); @@ -174,7 +174,7 @@ namespace gui void resize_combo_box_view(QComboBox* combo) { int max_width = 0; - QFontMetrics font_metrics(combo->font()); + const QFontMetrics font_metrics(combo->font()); for (int i = 0; i < combo->count(); ++i) { @@ -261,7 +261,7 @@ namespace gui continue; } - const std::string sfo_dir = Emulator::GetSfoDirFromGamePath(pth, Emu.GetUsr(), title_id); + const std::string sfo_dir = Emulator::GetSfoDirFromGamePath(pth, title_id); icon_path = sfo_dir + "/ICON0.PNG"; found_file = fs::is_file(icon_path); @@ -275,12 +275,12 @@ namespace gui if (found_file) { // load the image from path. It will most likely be a rectangle - QImage source = QImage(qstr(icon_path)); + const QImage source = QImage(qstr(icon_path)); const int edge_max = std::max(source.width(), source.height()); // create a new transparent image with square size and same format as source (maybe handle other formats than RGB32 as well?) - QImage::Format format = source.format() == QImage::Format_RGB32 ? QImage::Format_ARGB32 : source.format(); - QImage dest = QImage(edge_max, edge_max, format); + const QImage::Format format = source.format() == QImage::Format_RGB32 ? QImage::Format_ARGB32 : source.format(); + QImage dest(edge_max, edge_max, format); dest.fill(Qt::transparent); // get the location to draw the source image centered within the dest image. @@ -409,7 +409,7 @@ namespace gui { for (int i = parent->childCount() - 1; i >= 0; i--) { - if (auto item = parent->child(i)) + if (const auto item = parent->child(i)) { bool match = true; diff --git a/rpcs3/rpcs3qt/register_editor_dialog.cpp b/rpcs3/rpcs3qt/register_editor_dialog.cpp index 2656a51840..14073c587d 100644 --- a/rpcs3/rpcs3qt/register_editor_dialog.cpp +++ b/rpcs3/rpcs3qt/register_editor_dialog.cpp @@ -147,7 +147,7 @@ register_editor_dialog::register_editor_dialog(QWidget *parent, CPUDisAsm* _disa connect(button_cancel, &QAbstractButton::clicked, this, ®ister_editor_dialog::reject); connect(m_register_combo, &QComboBox::currentTextChanged, this, [this](const QString&) { - if (auto qvar = m_register_combo->currentData(); qvar.canConvert(QMetaType::Int)) + if (const auto qvar = m_register_combo->currentData(); qvar.canConvert(QMetaType::Int)) { updateRegister(qvar.toInt()); } @@ -156,7 +156,7 @@ register_editor_dialog::register_editor_dialog(QWidget *parent, CPUDisAsm* _disa updateRegister(m_register_combo->currentData().toInt()); } -void register_editor_dialog::updateRegister(int reg) +void register_editor_dialog::updateRegister(int reg) const { std::string str = sstr(tr("Error parsing register value!")); @@ -178,7 +178,7 @@ void register_editor_dialog::updateRegister(int reg) else if (reg >= ppu_f0 && reg <= ppu_f31) str = fmt::format("%016llx", std::bit_cast(ppu.fpr[reg_index])); else if (reg >= ppu_v0 && reg <= ppu_v31) { - const auto r = ppu.vr[reg_index]; + const v128 r = ppu.vr[reg_index]; str = !r._u ? fmt::format("%08x$", r._u32[0]) : fmt::format("%08x %08x %08x %08x", r.u32r[0], r.u32r[1], r.u32r[2], r.u32r[3]); } } @@ -197,7 +197,7 @@ void register_editor_dialog::updateRegister(int reg) if (reg >= spu_r0 && reg <= spu_r127) { const u32 reg_index = reg % 128; - const auto r = spu.gpr[reg_index]; + const v128 r = spu.gpr[reg_index]; str = !r._u ? fmt::format("%08x$", r._u32[0]) : fmt::format("%08x %08x %08x %08x", r.u32r[0], r.u32r[1], r.u32r[2], r.u32r[3]); } else if (reg == MFC_PEVENTS) str = fmt::format("%08x", +spu.ch_events.load().events); @@ -276,7 +276,7 @@ void register_editor_dialog::OnOkay() else if (reg >= ppu_ff0 && reg <= ppu_ff31) { char* end{}; - if (double reg_value = std::strtod(value.c_str(), &end); end != value.c_str()) + if (const double reg_value = std::strtod(value.c_str(), &end); end != value.c_str()) { ppu.fpr[reg_index] = static_cast(reg_value); return; @@ -337,7 +337,7 @@ void register_editor_dialog::OnOkay() } else if (reg == RESERVATION_LOST) { - if (u32 raddr = ppu.raddr) vm::reservation_update(raddr); + if (const u32 raddr = ppu.raddr) vm::reservation_update(raddr); return; } } @@ -378,9 +378,9 @@ void register_editor_dialog::OnOkay() if (u32 reg_value; check_res(std::from_chars(value.c_str() + 24, value.c_str() + 32, reg_value, 16), value.c_str() + 32)) { bool ok = true; - if (reg == MFC_PEVENTS && !(reg_value & ~SPU_EVENT_IMPLEMENTED)) spu.ch_events.atomic_op([&](typename spu_thread::ch_events_t& events){ events.events = reg_value; }); - else if (reg == MFC_EVENTS_MASK && !(reg_value & ~SPU_EVENT_IMPLEMENTED)) spu.ch_events.atomic_op([&](typename spu_thread::ch_events_t& events){ events.mask = reg_value; }); - else if (reg == MFC_EVENTS_COUNT && reg_value <= 1u) spu.ch_events.atomic_op([&](typename spu_thread::ch_events_t& events){ events.count = reg_value; }); + if (reg == MFC_PEVENTS && !(reg_value & ~SPU_EVENT_IMPLEMENTED)) spu.ch_events.atomic_op([&](spu_thread::ch_events_t& events){ events.events = reg_value; }); + else if (reg == MFC_EVENTS_MASK && !(reg_value & ~SPU_EVENT_IMPLEMENTED)) spu.ch_events.atomic_op([&](spu_thread::ch_events_t& events){ events.mask = reg_value; }); + else if (reg == MFC_EVENTS_COUNT && reg_value <= 1u) spu.ch_events.atomic_op([&](spu_thread::ch_events_t& events){ events.count = reg_value; }); else if (reg == MFC_TAG_MASK) spu.ch_tag_mask = reg_value; else if (reg == SPU_SRR0 && !(reg_value & ~0x3fffc)) spu.srr0 = reg_value; else if (reg == PC && !(reg_value & ~0x3fffc)) spu.pc = reg_value; @@ -410,7 +410,7 @@ void register_editor_dialog::OnOkay() } else if (reg == RESERVATION_LOST) { - if (u32 raddr = spu.raddr) vm::reservation_update(raddr); + if (const u32 raddr = spu.raddr) vm::reservation_update(raddr); return; } } diff --git a/rpcs3/rpcs3qt/register_editor_dialog.h b/rpcs3/rpcs3qt/register_editor_dialog.h index 542c9551a6..814d64cf39 100644 --- a/rpcs3/rpcs3qt/register_editor_dialog.h +++ b/rpcs3/rpcs3qt/register_editor_dialog.h @@ -6,8 +6,6 @@ #include #include -#include - class CPUDisAsm; class cpu_thread; @@ -28,5 +26,5 @@ private: void OnOkay(); private Q_SLOTS: - void updateRegister(int reg); + void updateRegister(int reg) const; }; diff --git a/rpcs3/rpcs3qt/richtext_item_delegate.h b/rpcs3/rpcs3qt/richtext_item_delegate.h index e7dffc8167..523c728aa0 100644 --- a/rpcs3/rpcs3qt/richtext_item_delegate.h +++ b/rpcs3/rpcs3qt/richtext_item_delegate.h @@ -11,7 +11,7 @@ private: QTextDocument* m_document; public: - explicit richtext_item_delegate(QObject* parent = 0) + explicit richtext_item_delegate(QObject* parent = nullptr) : QStyledItemDelegate(parent) , m_document(new QTextDocument(this)) { @@ -51,7 +51,7 @@ public: painter->setClipRect(text_rect.translated(-text_rect.topLeft())); // Create a context for our painter - QAbstractTextDocumentLayout::PaintContext context; + const QAbstractTextDocumentLayout::PaintContext context; // We can change the text color based on state (Unused because it didn't look good) //context.palette.setColor(QPalette::Text, option.palette.color(QPalette::Active, (option.state & QStyle::State_Selected) ? QPalette::HighlightedText : QPalette::Text)); diff --git a/rpcs3/rpcs3qt/rpcn_settings_dialog.cpp b/rpcs3/rpcs3qt/rpcn_settings_dialog.cpp index a61aadbc06..9ea5f26afa 100644 --- a/rpcs3/rpcs3qt/rpcn_settings_dialog.cpp +++ b/rpcs3/rpcs3qt/rpcn_settings_dialog.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -85,8 +84,8 @@ rpcn_settings_dialog::rpcn_settings_dialog(QWidget* parent) } } - std::string pass_str = password.toStdString(); - std::string salt_str = "No matter where you go, everybody's connected."; + const std::string pass_str = password.toStdString(); + const std::string salt_str = "No matter where you go, everybody's connected."; u8 salted_pass[SHA_DIGEST_SIZE]; @@ -129,12 +128,7 @@ bool rpcn_settings_dialog::save_config() if (input.length() < 3 || input.length() > 16) return false; - for (const auto c : input) - { - if (!std::isalnum(c) && c != '-' && c != '_') - return false; - } - return true; + return std::all_of(input.cbegin(), input.cend(), [](const char c) { return std::isalnum(c) || c == '-' || c == '_'; }); }; if (host.empty()) @@ -177,7 +171,7 @@ bool rpcn_settings_dialog::create_account() return false; QString email; - QRegExpValidator simple_email_validator(QRegExp("^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*$")); + const QRegExpValidator simple_email_validator(QRegExp("^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*$")); while (true) { diff --git a/rpcs3/rpcs3qt/rpcn_settings_dialog.h b/rpcs3/rpcs3qt/rpcn_settings_dialog.h index 2177a8d80a..e3298ca3c5 100644 --- a/rpcs3/rpcs3qt/rpcn_settings_dialog.h +++ b/rpcs3/rpcs3qt/rpcn_settings_dialog.h @@ -15,6 +15,4 @@ public: protected: QLineEdit *m_edit_host, *m_edit_npid, *m_edit_token; - - std::string generate_npid(); }; diff --git a/rpcs3/rpcs3qt/rsx_debugger.cpp b/rpcs3/rpcs3qt/rsx_debugger.cpp index 63ebadec3a..1057258b9e 100644 --- a/rpcs3/rpcs3qt/rsx_debugger.cpp +++ b/rpcs3/rpcs3qt/rsx_debugger.cpp @@ -32,7 +32,7 @@ namespace rsx_debugger::rsx_debugger(std::shared_ptr gui_settings, QWidget* parent) : QDialog(parent) - , m_gui_settings(gui_settings) + , m_gui_settings(std::move(gui_settings)) { setWindowTitle(tr("RSX Debugger")); setObjectName("rsx_debugger"); @@ -256,10 +256,6 @@ rsx_debugger::rsx_debugger(std::shared_ptr gui_settings, QWidget* UpdateInformation(); } -rsx_debugger::~rsx_debugger() -{ -} - void rsx_debugger::closeEvent(QCloseEvent* event) { // Save header states and window geometry @@ -371,7 +367,7 @@ void Buffer::showImage(const QImage& image) setLayout(new_layout); } -void Buffer::ShowWindowed() +void Buffer::ShowWindowed() const { //const auto render = rsx::get_current_renderer(); if (!g_fxo->is_init()) @@ -399,7 +395,6 @@ void Buffer::ShowWindowed() // render->textures[m_cur_texture].width(), // render->textures[m_cur_texture].height(), false); //} - return; } namespace @@ -411,8 +406,8 @@ namespace const u16 _u16 = static_cast(val); const u32 raw = ((_u16 & 0x8000) << 16) | // Sign (just moved) - (((_u16 & 0x7c00) + 0x1C000) << 13) | // Exponent ( exp - 15 + 127) - ((_u16 & 0x03FF) << 13); // Mantissa + (((_u16 & 0x7c00) + 0x1C000) << 13) | // Exponent ( exp - 15 + 127) + ((_u16 & 0x03FF) << 13); // Mantissa return std::bit_cast(raw); } @@ -451,16 +446,16 @@ namespace case rsx::surface_color_format::w16z16y16x16: { const auto ptr = as_const_span(orig_buffer); - const f16 h0 = f16(ptr[4 * idx]); - const f16 h1 = f16(ptr[4 * idx + 1]); - const f16 h2 = f16(ptr[4 * idx + 2]); + const f16 h0 = static_cast(ptr[4 * idx]); + const f16 h1 = static_cast(ptr[4 * idx + 1]); + const f16 h2 = static_cast(ptr[4 * idx + 2]); const f32 f0 = f16_to_f32(h0); const f32 f1 = f16_to_f32(h1); const f32 f2 = f16_to_f32(h2); - const u8 val0 = f0 * 255.; - const u8 val1 = f1 * 255.; - const u8 val2 = f2 * 255.; + const u8 val0 = f0 * 255.f; + const u8 val1 = f1 * 255.f; + const u8 val2 = f2 * 255.f; return{ val0, val1, val2 }; } case rsx::surface_color_format::g8b8: @@ -479,6 +474,10 @@ namespace u8* convert_to_QImage_buffer(rsx::surface_color_format format, gsl::span orig_buffer, usz width, usz height) noexcept { u8* buffer = static_cast(std::malloc(width * height * 4)); + if (!buffer || width == 0 || height == 0) + { + return nullptr; + } for (u32 i = 0; i < width * height; i++) { // depending on original buffer, the colors may need to be reversed @@ -522,7 +521,7 @@ void rsx_debugger::OnClickDrawCalls() { if (width && height && !draw_call.depth_stencil[0].empty()) { - gsl::span orig_buffer = draw_call.depth_stencil[0]; + const gsl::span orig_buffer = draw_call.depth_stencil[0]; u8* buffer = static_cast(std::malloc(4ULL * width * height)); if (draw_call.state.surface_depth_fmt() == rsx::surface_depth_format::z24s8) @@ -563,7 +562,7 @@ void rsx_debugger::OnClickDrawCalls() { if (width && height && !draw_call.depth_stencil[1].empty()) { - gsl::span orig_buffer = draw_call.depth_stencil[1]; + const gsl::span orig_buffer = draw_call.depth_stencil[1]; u8* buffer = static_cast(std::malloc(4ULL * width * height)); for (u32 row = 0; row < height; row++) @@ -607,16 +606,16 @@ void rsx_debugger::OnClickDrawCalls() } } -void rsx_debugger::UpdateInformation() +void rsx_debugger::UpdateInformation() const { m_addr_line->setText(QString("%1").arg(m_addr, 8, 16, QChar('0'))); // get 8 digits in input line GetMemory(); GetBuffers(); } -void rsx_debugger::GetMemory() +void rsx_debugger::GetMemory() const { - int item_count = m_list_commands->rowCount(); + const int item_count = m_list_commands->rowCount(); // Write information for (int i = 0, addr = m_addr; i < item_count; i++, addr += 4) @@ -656,13 +655,16 @@ void rsx_debugger::GetMemory() dump += '\n'; } - fs::file(fs::get_cache_dir() + "command_dump.log", fs::rewrite).write(dump); + if (fs::file file = fs::file(fs::get_cache_dir() + "command_dump.log", fs::rewrite)) + { + file.write(dump); + } for (u32 i = 0;i < frame_debug.draw_calls.size(); i++) m_list_captured_draw_calls->setItem(i, 0, new QTableWidgetItem(qstr(frame_debug.draw_calls[i].name))); } -void rsx_debugger::GetBuffers() +void rsx_debugger::GetBuffers() const { const auto render = rsx::get_current_renderer(); if (!render) @@ -674,7 +676,7 @@ void rsx_debugger::GetBuffers() // TODO: Currently it only supports color buffers for (u32 bufferId=0; bufferId < render->display_buffers_count; bufferId++) { - auto buffers = render->display_buffers; + const auto buffers = render->display_buffers; const u32 rsx_buffer_addr = rsx::constants::local_mem_base + buffers[bufferId].offset; const u32 width = buffers[bufferId].width; @@ -740,7 +742,7 @@ void rsx_debugger::GetBuffers() //m_buffer_tex->showImage(QImage(buffer, m_text_width, m_text_height, QImage::Format_RGB32)); } -QString rsx_debugger::DisAsmCommand(u32 cmd, u32 count, u32 ioAddr) +QString rsx_debugger::DisAsmCommand(u32 cmd, u32 count, u32 ioAddr) const { std::string disasm; @@ -750,31 +752,31 @@ QString rsx_debugger::DisAsmCommand(u32 cmd, u32 count, u32 ioAddr) { if ((cmd & RSX_METHOD_OLD_JUMP_CMD_MASK) == RSX_METHOD_OLD_JUMP_CMD) { - u32 jumpAddr = cmd & RSX_METHOD_OLD_JUMP_OFFSET_MASK; - DISASM("JUMP to 0x%07x", jumpAddr); + const u32 jump_addr = cmd & RSX_METHOD_OLD_JUMP_OFFSET_MASK; + DISASM("JUMP to 0x%07x", jump_addr) } else if ((cmd & RSX_METHOD_NEW_JUMP_CMD_MASK) == RSX_METHOD_NEW_JUMP_CMD) { - u32 jumpAddr = cmd & RSX_METHOD_NEW_JUMP_OFFSET_MASK; - DISASM("JUMP to 0x%07x", jumpAddr); + const u32 jump_addr = cmd & RSX_METHOD_NEW_JUMP_OFFSET_MASK; + DISASM("JUMP to 0x%07x", jump_addr) } else if ((cmd & RSX_METHOD_CALL_CMD_MASK) == RSX_METHOD_CALL_CMD) { - u32 callAddr = cmd & RSX_METHOD_CALL_OFFSET_MASK; - DISASM("CALL to 0x%07x", callAddr); + const u32 jump_addr = cmd & RSX_METHOD_CALL_OFFSET_MASK; + DISASM("CALL to 0x%07x", jump_addr) } else if ((cmd & RSX_METHOD_RETURN_MASK) == RSX_METHOD_RETURN_CMD) { - DISASM("RETURN"); + DISASM("RETURN") } else { - DISASM("Not a command"); + DISASM("Not a command") } } else if ((cmd & RSX_METHOD_NOP_MASK) == RSX_METHOD_NOP_CMD) { - DISASM("NOP"); + DISASM("NOP") } else { @@ -786,24 +788,24 @@ QString rsx_debugger::DisAsmCommand(u32 cmd, u32 count, u32 ioAddr) { case 0x3fead: { - DISASM("Flip and change current buffer: %d", args[0]); + DISASM("Flip and change current buffer: %d", args[0]) break; } default: { const u32 id = (cmd & 0x3ffff) >> 2; - std::string str = rsx::get_pretty_printing_function(id)(id, args[0]); - DISASM("%s", str.c_str()); + const std::string str = rsx::get_pretty_printing_function(id)(id, args[0]); + DISASM("%s", str.c_str()) break; } } if ((cmd & RSX_METHOD_NON_INCREMENT_CMD_MASK) == RSX_METHOD_NON_INCREMENT_CMD && count > 1) { - DISASM("Non Increment cmd"); + DISASM("Non Increment cmd") } - DISASM("("); + DISASM("(") for (uint i=0; i m_gui_settings; public: - rsx_debugger(std::shared_ptr gui_settings, QWidget* parent = 0); - ~rsx_debugger(); + explicit rsx_debugger(std::shared_ptr gui_settings, QWidget* parent = nullptr); + ~rsx_debugger() = default; - virtual void UpdateInformation(); - virtual void GetMemory(); - virtual void GetBuffers(); + void UpdateInformation() const; + void GetMemory() const; + void GetBuffers() const; - QString DisAsmCommand(u32 cmd, u32 count, u32 ioAddr); + QString DisAsmCommand(u32 cmd, u32 count, u32 ioAddr) const; void SetPC(const uint pc); @@ -80,9 +80,9 @@ public Q_SLOTS: virtual void OnClickDrawCalls(); protected: - virtual void closeEvent(QCloseEvent* event) override; - virtual void keyPressEvent(QKeyEvent* event) override; - virtual bool eventFilter(QObject* object, QEvent* event) override; + void closeEvent(QCloseEvent* event) override; + void keyPressEvent(QKeyEvent* event) override; + bool eventFilter(QObject* object, QEvent* event) override; private: void PerformJump(u32 address); diff --git a/rpcs3/rpcs3qt/save_data_dialog.cpp b/rpcs3/rpcs3qt/save_data_dialog.cpp index 167a4eb49b..6bc67de2f6 100644 --- a/rpcs3/rpcs3qt/save_data_dialog.cpp +++ b/rpcs3/rpcs3qt/save_data_dialog.cpp @@ -13,7 +13,7 @@ s32 save_data_dialog::ShowSaveDataList(std::vector& save_entries, // TODO: Install native shell as an Emu callback if (auto manager = g_fxo->try_get()) { - auto result = manager->create()->show(save_entries, focused, op, listSet, enable_overlay); + const s32 result = manager->create()->show(save_entries, focused, op, listSet, enable_overlay); if (result != rsx::overlays::user_interface::selection_code::error) return result; } @@ -25,7 +25,7 @@ s32 save_data_dialog::ShowSaveDataList(std::vector& save_entries, // Fall back to front-end GUI atomic_t dlg_result(false); - atomic_t selection; + atomic_t selection = 0; input::SetIntercepted(true); diff --git a/rpcs3/rpcs3qt/save_data_dialog.h b/rpcs3/rpcs3qt/save_data_dialog.h index 8cca7af6dd..fa31b1533b 100644 --- a/rpcs3/rpcs3qt/save_data_dialog.h +++ b/rpcs3/rpcs3qt/save_data_dialog.h @@ -4,10 +4,8 @@ #include "Emu/Memory/vm.h" #include "Emu/Cell/Modules/cellSaveData.h" -#include "util/types.hpp" - class save_data_dialog : public SaveDialogBase { public: - virtual s32 ShowSaveDataList(std::vector& save_entries, s32 focused, u32 op, vm::ptr listSet, bool enable_overlay) override; + s32 ShowSaveDataList(std::vector& save_entries, s32 focused, u32 op, vm::ptr listSet, bool enable_overlay) override; }; diff --git a/rpcs3/rpcs3qt/save_data_info_dialog.cpp b/rpcs3/rpcs3qt/save_data_info_dialog.cpp index 851637eebb..50f7a8e2ea 100644 --- a/rpcs3/rpcs3qt/save_data_info_dialog.cpp +++ b/rpcs3/rpcs3qt/save_data_info_dialog.cpp @@ -7,8 +7,9 @@ constexpr auto qstr = QString::fromStdString; -save_data_info_dialog::save_data_info_dialog(const SaveDataEntry& save, QWidget* parent) - : QDialog(parent), m_entry(save) +save_data_info_dialog::save_data_info_dialog(SaveDataEntry save, QWidget* parent) + : QDialog(parent) + , m_entry(std::move(save)) { setWindowTitle(tr("Save Data Information")); @@ -42,21 +43,21 @@ save_data_info_dialog::save_data_info_dialog(const SaveDataEntry& save, QWidget* m_list->horizontalHeader()->resizeSections(QHeaderView::ResizeToContents); m_list->verticalHeader()->resizeSections(QHeaderView::ResizeToContents); - QSize tableSize = QSize + const QSize table_size ( m_list->verticalHeader()->width() + m_list->horizontalHeader()->length() + m_list->frameWidth() * 2, m_list->horizontalHeader()->height() + m_list->verticalHeader()->length() + m_list->frameWidth() * 2 ); // no minimum size needed because we always have same table size and row count - resize(sizeHint() - m_list->sizeHint() + tableSize); + resize(sizeHint() - m_list->sizeHint() + table_size); } //This is intended to write the information of save data to QTableView. void save_data_info_dialog::UpdateData() { m_list->clearContents(); - int num_entries = 4; // set this to number of members in struct + const int num_entries = 4; // set this to number of members in struct m_list->setRowCount(num_entries); //Maybe there should be more details of save data. diff --git a/rpcs3/rpcs3qt/save_data_info_dialog.h b/rpcs3/rpcs3qt/save_data_info_dialog.h index 58ac385ed8..1475deeee1 100644 --- a/rpcs3/rpcs3qt/save_data_info_dialog.h +++ b/rpcs3/rpcs3qt/save_data_info_dialog.h @@ -12,7 +12,7 @@ class save_data_info_dialog :public QDialog Q_OBJECT public: - explicit save_data_info_dialog(const SaveDataEntry& save, QWidget* parent = nullptr); + explicit save_data_info_dialog(SaveDataEntry save, QWidget* parent = nullptr); private: void UpdateData(); diff --git a/rpcs3/rpcs3qt/save_data_list_dialog.cpp b/rpcs3/rpcs3qt/save_data_list_dialog.cpp index a3717ccfcb..83c7bd63b8 100644 --- a/rpcs3/rpcs3qt/save_data_list_dialog.cpp +++ b/rpcs3/rpcs3qt/save_data_list_dialog.cpp @@ -84,7 +84,7 @@ save_data_list_dialog::save_data_list_dialog(const std::vector& e { m_entry = cr; UpdateSelectionLabel(); - Q_UNUSED(cc); Q_UNUSED(pr); Q_UNUSED(pc); + Q_UNUSED(cc) Q_UNUSED(pr) Q_UNUSED(pc) }); connect(m_list->horizontalHeader(), &QHeaderView::sectionClicked, this, &save_data_list_dialog::OnSort); @@ -131,7 +131,7 @@ void save_data_list_dialog::UpdateSelectionLabel() } } -s32 save_data_list_dialog::GetSelection() +s32 save_data_list_dialog::GetSelection() const { if (result() == QDialog::Accepted) { diff --git a/rpcs3/rpcs3qt/save_data_list_dialog.h b/rpcs3/rpcs3qt/save_data_list_dialog.h index df15ddf751..ddc0388683 100644 --- a/rpcs3/rpcs3qt/save_data_list_dialog.h +++ b/rpcs3/rpcs3qt/save_data_list_dialog.h @@ -29,13 +29,13 @@ class save_data_list_dialog : public QDialog public: explicit save_data_list_dialog(const std::vector& entries, s32 focusedEntry, u32 op, vm::ptr, QWidget* parent = nullptr); - s32 GetSelection(); + s32 GetSelection() const; private Q_SLOTS: void OnEntryInfo(); void OnSort(int logicalIndex); private: - void UpdateSelectionLabel(void); - void UpdateList(void); + void UpdateSelectionLabel(); + void UpdateList(); s32 m_entry = selection_code::new_save; QLabel* m_entry_label = nullptr; diff --git a/rpcs3/rpcs3qt/save_manager_dialog.cpp b/rpcs3/rpcs3qt/save_manager_dialog.cpp index ce3a6a4f0f..ac95cba0da 100644 --- a/rpcs3/rpcs3qt/save_manager_dialog.cpp +++ b/rpcs3/rpcs3qt/save_manager_dialog.cpp @@ -6,7 +6,6 @@ #include "persistent_settings.h" #include "Emu/System.h" -#include "Emu/Memory/vm.h" #include "Loader/PSF.h" #include @@ -83,9 +82,8 @@ namespace if (fs::is_file(base_dir + entry.name + "/ICON0.PNG")) { fs::file icon = fs::file(base_dir + entry.name + "/ICON0.PNG"); - u32 iconSize = icon.size(); std::vector iconData; - icon.read(iconData, iconSize); + icon.read(iconData, icon.size()); save_entry2.iconBuf = iconData; } save_entry2.isNew = false; @@ -98,20 +96,20 @@ namespace save_manager_dialog::save_manager_dialog(std::shared_ptr gui_settings, std::shared_ptr persistent_settings, std::string dir, QWidget* parent) : QDialog(parent) , m_dir(dir) - , m_gui_settings(gui_settings) - , m_persistent_settings(persistent_settings) + , m_gui_settings(std::move(gui_settings)) + , m_persistent_settings(std::move(persistent_settings)) { setWindowTitle(tr("Save Manager")); setMinimumSize(QSize(400, 400)); setAttribute(Qt::WA_DeleteOnClose); - Init(dir); + Init(); } /* * Future proofing. Makes it easier in future if I add ability to change directories */ -void save_manager_dialog::Init(std::string /*dir*/) +void save_manager_dialog::Init() { // Table m_list = new QTableWidget(this); @@ -126,7 +124,7 @@ void save_manager_dialog::Init(std::string /*dir*/) m_list->horizontalHeader()->setStretchLastSection(true); // Bottom bar - int icon_size = m_gui_settings->GetValue(gui::sd_icon_size).toInt(); + const int icon_size = m_gui_settings->GetValue(gui::sd_icon_size).toInt(); m_icon_size = QSize(icon_size, icon_size); QLabel* label_icon_size = new QLabel(tr("Icon size:"), this); QSlider* slider_icon_size = new QSlider(Qt::Horizontal, this); @@ -231,7 +229,7 @@ void save_manager_dialog::Init(std::string /*dir*/) void save_manager_dialog::UpdateList() { - if (m_dir == "") + if (m_dir.empty()) { m_dir = Emulator::GetHddDir() + "home/" + Emu.GetUsr() + "/savedata/"; } @@ -256,7 +254,7 @@ void save_manager_dialog::UpdateList() for (usz i = 0; i < m_save_entries.size(); ++i) indices.append(static_cast(i)); - std::function get_icon = [this](const int& row) + const std::function get_icon = [this](const int& row) { const auto& entry = m_save_entries[row]; QPixmap icon = QPixmap(320, 176); @@ -310,13 +308,13 @@ void save_manager_dialog::UpdateList() m_list->horizontalHeader()->resizeSections(QHeaderView::ResizeToContents); m_list->verticalHeader()->resizeSections(QHeaderView::ResizeToContents); - QSize tableSize = QSize( + const QSize tableSize( m_list->verticalHeader()->width() + m_list->horizontalHeader()->length() + m_list->frameWidth() * 2, m_list->horizontalHeader()->height() + m_list->verticalHeader()->length() + m_list->frameWidth() * 2); - QSize preferredSize = minimumSize().expandedTo(sizeHint() - m_list->sizeHint() + tableSize); + const QSize preferredSize = minimumSize().expandedTo(sizeHint() - m_list->sizeHint() + tableSize); - QSize maxSize = QSize(preferredSize.width(), static_cast(QGuiApplication::primaryScreen()->geometry().height() * 0.6)); + const QSize maxSize(preferredSize.width(), static_cast(QGuiApplication::primaryScreen()->geometry().height() * 0.6)); resize(preferredSize.boundedTo(maxSize)); } @@ -332,7 +330,7 @@ void save_manager_dialog::HandleRepaintUiRequest() resize(window_size); } -QPixmap save_manager_dialog::GetResizedIcon(int i) +QPixmap save_manager_dialog::GetResizedIcon(int i) const { const qreal dpr = devicePixelRatioF(); const int width = m_icon_size.width() * dpr; @@ -343,7 +341,7 @@ QPixmap save_manager_dialog::GetResizedIcon(int i) { return QPixmap(); } - QPixmap data = item->data(Qt::UserRole).value(); + const QPixmap data = item->data(Qt::UserRole).value(); QPixmap icon = QPixmap(data.size() * dpr); icon.setDevicePixelRatio(dpr); @@ -361,7 +359,7 @@ void save_manager_dialog::UpdateIcons() for (int i = 0; i < m_list->rowCount(); ++i) indices.append(i); - std::function get_scaled = [this](const int& i) + const std::function get_scaled = [this](const int& i) { return GetResizedIcon(i); }; @@ -395,7 +393,7 @@ void save_manager_dialog::OnSort(int logicalIndex) m_sort_ascending = true; } m_sort_column = logicalIndex; - Qt::SortOrder sort_order = m_sort_ascending ? Qt::AscendingOrder : Qt::DescendingOrder; + const Qt::SortOrder sort_order = m_sort_ascending ? Qt::AscendingOrder : Qt::DescendingOrder; m_list->sortByColumn(m_sort_column, sort_order); } } @@ -403,7 +401,7 @@ void save_manager_dialog::OnSort(int logicalIndex) // Remove a save file, need to be confirmed. void save_manager_dialog::OnEntryRemove() { - int idx = m_list->currentRow(); + const int idx = m_list->currentRow(); if (idx != -1) { QTableWidgetItem* item = m_list->item(idx, 1); @@ -454,7 +452,7 @@ void save_manager_dialog::OnEntriesRemove() // Pop-up a small context-menu, being a replacement for save_data_manage_dialog void save_manager_dialog::ShowContextMenu(const QPoint &pos) { - int idx = m_list->currentRow(); + const int idx = m_list->currentRow(); if (idx == -1) { return; @@ -505,7 +503,7 @@ void save_manager_dialog::closeEvent(QCloseEvent *event) void save_manager_dialog::UpdateDetails() { - int selected = m_list->selectionModel()->selectedRows().size(); + const int selected = m_list->selectionModel()->selectedRows().size(); if (selected != 1) { diff --git a/rpcs3/rpcs3qt/save_manager_dialog.h b/rpcs3/rpcs3qt/save_manager_dialog.h index 6c093f7a71..2ad734158e 100644 --- a/rpcs3/rpcs3qt/save_manager_dialog.h +++ b/rpcs3/rpcs3qt/save_manager_dialog.h @@ -30,9 +30,9 @@ private Q_SLOTS: void SetIconSize(int size); void UpdateDetails(); private: - void Init(std::string dir); + void Init(); void UpdateList(); - QPixmap GetResizedIcon(int i); + QPixmap GetResizedIcon(int i) const; void UpdateIcons(); void ShowContextMenu(const QPoint &pos); diff --git a/rpcs3/rpcs3qt/screenshot_manager_dialog.cpp b/rpcs3/rpcs3qt/screenshot_manager_dialog.cpp index bd19dd9f73..613ccff4a9 100644 --- a/rpcs3/rpcs3qt/screenshot_manager_dialog.cpp +++ b/rpcs3/rpcs3qt/screenshot_manager_dialog.cpp @@ -90,7 +90,7 @@ void screenshot_manager_dialog::show_preview(QListWidgetItem* item) preview->show(); } -void screenshot_manager_dialog::update_icon(int index) +void screenshot_manager_dialog::update_icon(int index) const { const thumbnail tn = m_icon_loader->resultAt(index); @@ -141,9 +141,9 @@ void screenshot_manager_dialog::update_icons(int value) m_icon_loader->waitForFinished(); } - std::function load = [icon_size = m_icon_size](thumbnail tn) -> thumbnail + const std::function load = [icon_size = m_icon_size](thumbnail tn) -> thumbnail { - QPixmap pixmap(tn.path); + const QPixmap pixmap(tn.path); tn.icon = QIcon(pixmap.scaled(icon_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); return tn; }; diff --git a/rpcs3/rpcs3qt/screenshot_manager_dialog.h b/rpcs3/rpcs3qt/screenshot_manager_dialog.h index ca703f0277..842095f725 100644 --- a/rpcs3/rpcs3qt/screenshot_manager_dialog.h +++ b/rpcs3/rpcs3qt/screenshot_manager_dialog.h @@ -20,13 +20,13 @@ protected: void resizeEvent(QResizeEvent* event) override; private Q_SLOTS: - void update_icon(int index); + void update_icon(int index) const; Q_SIGNALS: void signal_icon_change(int index, const QString& path); private: - void show_preview(QListWidgetItem* item); + static void show_preview(QListWidgetItem* item); void update_icons(int value); enum item_role diff --git a/rpcs3/rpcs3qt/settings.cpp b/rpcs3/rpcs3qt/settings.cpp index c4e4b7ad3c..c10b76dabf 100644 --- a/rpcs3/rpcs3qt/settings.cpp +++ b/rpcs3/rpcs3qt/settings.cpp @@ -24,12 +24,12 @@ QString settings::GetSettingsDir() const return m_settings_dir.absolutePath(); } -QString settings::ComputeSettingsDir() const +QString settings::ComputeSettingsDir() { return QString::fromStdString(fs::get_config_dir()) + "/GuiConfigs/"; } -void settings::RemoveValue(const QString& key, const QString& name) +void settings::RemoveValue(const QString& key, const QString& name) const { if (m_settings) { @@ -39,7 +39,7 @@ void settings::RemoveValue(const QString& key, const QString& name) } } -void settings::RemoveValue(const gui_save& entry) +void settings::RemoveValue(const gui_save& entry) const { RemoveValue(entry.key, entry.name); } @@ -71,7 +71,7 @@ q_pair_list settings::Var2List(const QVariant& var) return list; } -void settings::SetValue(const gui_save& entry, const QVariant& value) +void settings::SetValue(const gui_save& entry, const QVariant& value) const { if (m_settings) { @@ -81,7 +81,7 @@ void settings::SetValue(const gui_save& entry, const QVariant& value) } } -void settings::SetValue(const QString& key, const QVariant& value) +void settings::SetValue(const QString& key, const QVariant& value) const { if (m_settings) { @@ -89,7 +89,7 @@ void settings::SetValue(const QString& key, const QVariant& value) } } -void settings::SetValue(const QString& key, const QString& name, const QVariant& value) +void settings::SetValue(const QString& key, const QString& name, const QVariant& value) const { if (m_settings) { diff --git a/rpcs3/rpcs3qt/settings.h b/rpcs3/rpcs3qt/settings.h index 6d24cddfe8..c8626c0ee3 100644 --- a/rpcs3/rpcs3qt/settings.h +++ b/rpcs3/rpcs3qt/settings.h @@ -38,16 +38,16 @@ public: public Q_SLOTS: /** Remove entry */ - void RemoveValue(const QString& key, const QString& name); - void RemoveValue(const gui_save& entry); + void RemoveValue(const QString& key, const QString& name) const; + void RemoveValue(const gui_save& entry) const; /** Write value to entry */ - void SetValue(const gui_save& entry, const QVariant& value); - void SetValue(const QString& key, const QVariant& value); - void SetValue(const QString& key, const QString& name, const QVariant& value); + void SetValue(const gui_save& entry, const QVariant& value) const; + void SetValue(const QString& key, const QVariant& value) const; + void SetValue(const QString& key, const QString& name, const QVariant& value) const; protected: - QString ComputeSettingsDir() const; + static QString ComputeSettingsDir(); std::unique_ptr m_settings; QDir m_settings_dir; diff --git a/rpcs3/rpcs3qt/settings_dialog.cpp b/rpcs3/rpcs3qt/settings_dialog.cpp index bcd79e0e2b..00525e9c8b 100644 --- a/rpcs3/rpcs3qt/settings_dialog.cpp +++ b/rpcs3/rpcs3qt/settings_dialog.cpp @@ -50,8 +50,8 @@ settings_dialog::settings_dialog(std::shared_ptr gui_settings, std : QDialog(parent) , m_tab_index(tab_index) , ui(new Ui::settings_dialog) - , m_gui_settings(gui_settings) - , m_emu_settings(emu_settings) + , m_gui_settings(std::move(gui_settings)) + , m_emu_settings(std::move(emu_settings)) { ui->setupUi(this); ui->buttonBox->button(QDialogButtonBox::StandardButton::Close)->setFocus(); @@ -127,7 +127,7 @@ settings_dialog::settings_dialog(std::shared_ptr gui_settings, std } } - std::vector selected_ls(selected.begin(), selected.end()); + const std::vector selected_ls(selected.begin(), selected.end()); m_emu_settings->SaveSelectedLibraries(selected_ls); m_emu_settings->SaveSettings(); @@ -556,14 +556,14 @@ settings_dialog::settings_dialog(std::shared_ptr gui_settings, std m_old_renderer = ui->renderBox->currentText(); - auto set_renderer = [r_creator, this](QString text) + const auto set_renderer = [r_creator, this](const QString& text) { if (text.isEmpty()) { return; } - auto switchTo = [r_creator, text, this](render_creator::render_info renderer) + const auto switchTo = [r_creator, text, this](const render_creator::render_info& renderer) { // Reset other adapters to old config for (const auto& render : r_creator->renderers) @@ -622,7 +622,7 @@ settings_dialog::settings_dialog(std::shared_ptr gui_settings, std } }; - auto set_adapter = [r_creator, this](QString text) + const auto set_adapter = [r_creator, this](const QString& text) { if (text.isEmpty()) { @@ -727,7 +727,6 @@ settings_dialog::settings_dialog(std::shared_ptr gui_settings, std max = 1; break; case microphone_handler::null: - default: break; } @@ -757,7 +756,7 @@ settings_dialog::settings_dialog(std::shared_ptr gui_settings, std change_microphone_type(ui->microphoneBox->currentIndex()); }; - auto change_microphone_device = [mic_none, propagate_used_devices, this](u32 next_index, QString text) + const auto change_microphone_device = [mic_none, propagate_used_devices, this](u32 next_index, const QString& text) { m_emu_settings->SetSetting(emu_settings_type::MicrophoneDevices, m_emu_settings->m_microphone_creator.set_device(next_index, text)); if (next_index < 4 && text == mic_none) @@ -1086,7 +1085,7 @@ settings_dialog::settings_dialog(std::shared_ptr gui_settings, std SubscribeTooltip(ui->hleList, tooltips.settings.hle_list); ui->searchBox->setPlaceholderText(tr("Search libraries", "Library search box")); - auto on_lib_state_changed = [this](QString text) + const auto on_lib_state_changed = [this](const QString& text) { const QString search_term = text.toLower(); std::vector items, items2; @@ -1596,7 +1595,7 @@ settings_dialog::settings_dialog(std::shared_ptr gui_settings, std ui->combo_updates->addItem(updates_background, "background"); ui->combo_updates->addItem(updates_no, "false"); ui->combo_updates->setCurrentIndex(ui->combo_updates->findData(m_gui_settings->GetValue(gui::m_check_upd_start).toString())); - connect(ui->combo_updates, static_cast(&QComboBox::currentIndexChanged), [this](int index) + connect(ui->combo_updates, QOverload::of(&QComboBox::currentIndexChanged), [this](int index) { m_gui_settings->SetValue(gui::m_check_upd_start, ui->combo_updates->itemData(index)); }); @@ -1693,15 +1692,15 @@ settings_dialog::settings_dialog(std::shared_ptr gui_settings, std QColorDialog dlg(old_color, this); dlg.setWindowTitle(title); dlg.setOptions(QColorDialog::ShowAlphaChannel); - for (int i = 0; i < dlg.customCount(); i++) + for (int i = 0; i < QColorDialog::customCount(); i++) { - dlg.setCustomColor(i, m_gui_settings->GetCustomColor(i)); + QColorDialog::setCustomColor(i, m_gui_settings->GetCustomColor(i)); } if (dlg.exec() == QColorDialog::Accepted) { - for (int i = 0; i < dlg.customCount(); i++) + for (int i = 0; i < QColorDialog::customCount(); i++) { - m_gui_settings->SetCustomColor(i, dlg.customColor(i)); + m_gui_settings->SetCustomColor(i, QColorDialog::customColor(i)); } m_gui_settings->SetValue(color, dlg.selectedColor()); button->setIcon(gui::utils::get_colorized_icon(button->icon(), old_color, dlg.selectedColor(), true)); @@ -1822,7 +1821,7 @@ settings_dialog::~settings_dialog() delete ui; } -void settings_dialog::EnhanceSlider(emu_settings_type settings_type, QSlider* slider, QLabel* label, const QString& label_text) +void settings_dialog::EnhanceSlider(emu_settings_type settings_type, QSlider* slider, QLabel* label, const QString& label_text) const { m_emu_settings->EnhanceSlider(slider, settings_type); diff --git a/rpcs3/rpcs3qt/settings_dialog.h b/rpcs3/rpcs3qt/settings_dialog.h index d2a1eeeb98..fdb327e821 100644 --- a/rpcs3/rpcs3qt/settings_dialog.h +++ b/rpcs3/rpcs3qt/settings_dialog.h @@ -21,7 +21,7 @@ class settings_dialog : public QDialog Q_OBJECT public: - explicit settings_dialog(std::shared_ptr gui_settings, std::shared_ptr emu_settings, const int& tab_index = 0, QWidget *parent = 0, const GameInfo *game = nullptr); + explicit settings_dialog(std::shared_ptr gui_settings, std::shared_ptr emu_settings, const int& tab_index = 0, QWidget *parent = nullptr, const GameInfo *game = nullptr); ~settings_dialog(); int exec() override; Q_SIGNALS: @@ -35,7 +35,7 @@ private Q_SLOTS: void OnApplyGuiConfig(); void OnApplyStylesheet(); private: - void EnhanceSlider(emu_settings_type settings_type, QSlider* slider, QLabel* label, const QString& label_text); + void EnhanceSlider(emu_settings_type settings_type, QSlider* slider, QLabel* label, const QString& label_text) const; // Snapping of sliders when moved with mouse void SnapSlider(QSlider* slider, int interval); diff --git a/rpcs3/rpcs3qt/skylander_dialog.cpp b/rpcs3/rpcs3qt/skylander_dialog.cpp index 08b5e92d5b..a13f1a960a 100644 --- a/rpcs3/rpcs3qt/skylander_dialog.cpp +++ b/rpcs3/rpcs3qt/skylander_dialog.cpp @@ -1,5 +1,4 @@ #include "stdafx.h" -#include #include "Utilities/File.h" #include "Crypto/md5.h" #include "Crypto/aes.h" @@ -519,12 +518,11 @@ u16 skylander_crc16(u16 init_value, const u8* buffer, u32 size) 0xFB1E, 0x8BF9, 0x9BD8, 0xABBB, 0xBB9A, 0x4A75, 0x5A54, 0x6A37, 0x7A16, 0x0AF1, 0x1AD0, 0x2AB3, 0x3A92, 0xFD2E, 0xED0F, 0xDD6C, 0xCD4D, 0xBDAA, 0xAD8B, 0x9DE8, 0x8DC9, 0x7C26, 0x6C07, 0x5C64, 0x4C45, 0x3CA2, 0x2C83, 0x1CE0, 0x0CC1, 0xEF1F, 0xFF3E, 0xCF5D, 0xDF7C, 0xAF9B, 0xBFBA, 0x8FD9, 0x9FF8, 0x6E17, 0x7E36, 0x4E55, 0x5E74, 0x2E93, 0x3EB2, 0x0ED1, 0x1EF0}; - u16 tmp; u16 crc = init_value; for (u32 i = 0; i < size; i++) { - tmp = (crc >> 8) ^ buffer[i]; + const u16 tmp = (crc >> 8) ^ buffer[i]; crc = (crc << 8) ^ CRC_CCITT_TABLE[tmp]; } @@ -544,7 +542,7 @@ skylander_creator_dialog::skylander_creator_dialog(QWidget* parent) QStringList filterlist; for (const auto& entry : list_skylanders) { - uint qvar = (entry.first.first << 16) | entry.first.second; + const uint qvar = (entry.first.first << 16) | entry.first.second; combo_skylist->addItem(QString::fromStdString(entry.second), QVariant(qvar)); filterlist << entry.second.c_str(); } @@ -619,7 +617,7 @@ skylander_creator_dialog::skylander_creator_dialog(QWidget* parent) } QString predef_name = last_skylander_path; - auto found_sky = list_skylanders.find(std::make_pair(sky_id, sky_var)); + const auto found_sky = list_skylanders.find(std::make_pair(sky_id, sky_var)); if (found_sky != list_skylanders.end()) { predef_name += QString::fromStdString(found_sky->second + ".sky"); @@ -643,7 +641,7 @@ skylander_creator_dialog::skylander_creator_dialog(QWidget* parent) } std::array buf{}; - auto data = buf.data(); + const auto data = buf.data(); // Set the block permissions *utils::bless>(&data[0x36]) = 0x690F0F0F; for (u32 index = 1; index < 0x10; index++) @@ -715,9 +713,9 @@ skylander_dialog::skylander_dialog(QWidget* parent) QPushButton* create_btn = new QPushButton(tr("Create")); QPushButton* load_btn = new QPushButton(tr("Load")); - connect(clear_btn, &QAbstractButton::clicked, this, [=, this]() { this->clear_skylander(i); }); - connect(create_btn, &QAbstractButton::clicked, this, [=, this]() { this->create_skylander(i); }); - connect(load_btn, &QAbstractButton::clicked, this, [=, this]() { this->load_skylander(i); }); + connect(clear_btn, &QAbstractButton::clicked, this, [this, i]() { clear_skylander(i); }); + connect(create_btn, &QAbstractButton::clicked, this, [this, i]() { create_skylander(i); }); + connect(load_btn, &QAbstractButton::clicked, this, [this, i]() { load_skylander(i); }); hbox_skylander->addWidget(label_skyname); hbox_skylander->addWidget(edit_skylanders[i]); @@ -764,8 +762,7 @@ void skylander_dialog::create_skylander(u8 slot) skylander_creator_dialog create_dlg(this); if (create_dlg.exec() == Accepted) { - QString created_path = create_dlg.get_file_path(); - load_skylander_path(slot, created_path); + load_skylander_path(slot, create_dlg.get_file_path()); } } diff --git a/rpcs3/rpcs3qt/skylander_dialog.h b/rpcs3/rpcs3qt/skylander_dialog.h index 20968f42a9..7733233d91 100644 --- a/rpcs3/rpcs3qt/skylander_dialog.h +++ b/rpcs3/rpcs3qt/skylander_dialog.h @@ -13,7 +13,7 @@ class skylander_creator_dialog : public QDialog Q_OBJECT public: - skylander_creator_dialog(QWidget* parent); + explicit skylander_creator_dialog(QWidget* parent); QString get_file_path() const; protected: @@ -25,7 +25,7 @@ class skylander_dialog : public QDialog Q_OBJECT public: - skylander_dialog(QWidget* parent); + explicit skylander_dialog(QWidget* parent); ~skylander_dialog(); static skylander_dialog* get_dlg(QWidget* parent); diff --git a/rpcs3/rpcs3qt/syntax_highlighter.cpp b/rpcs3/rpcs3qt/syntax_highlighter.cpp index f5468d6197..38ba412c13 100644 --- a/rpcs3/rpcs3qt/syntax_highlighter.cpp +++ b/rpcs3/rpcs3qt/syntax_highlighter.cpp @@ -37,7 +37,7 @@ void Highlighter::highlightBlock(const QString &text) { const QRegularExpressionMatch match = commentEndExpression.match(text, startIndex); const int endIndex = match.capturedStart(); - int commentLength = 0; + int commentLength; if (endIndex == -1) { diff --git a/rpcs3/rpcs3qt/syntax_highlighter.h b/rpcs3/rpcs3qt/syntax_highlighter.h index 8e043b9d6d..3e701ffb0e 100644 --- a/rpcs3/rpcs3qt/syntax_highlighter.h +++ b/rpcs3/rpcs3qt/syntax_highlighter.h @@ -10,7 +10,7 @@ class Highlighter : public QSyntaxHighlighter Q_OBJECT public: - Highlighter(QTextDocument *parent = 0); + explicit Highlighter(QTextDocument *parent = nullptr); protected: void highlightBlock(const QString &text) override; @@ -34,7 +34,7 @@ class LogHighlighter : public Highlighter Q_OBJECT public: - LogHighlighter(QTextDocument* parent = 0); + explicit LogHighlighter(QTextDocument* parent = nullptr); }; class AsmHighlighter : public Highlighter @@ -42,7 +42,7 @@ class AsmHighlighter : public Highlighter Q_OBJECT public: - AsmHighlighter(QTextDocument *parent = 0); + explicit AsmHighlighter(QTextDocument *parent = nullptr); }; class GlslHighlighter : public Highlighter @@ -50,5 +50,5 @@ class GlslHighlighter : public Highlighter Q_OBJECT public: - GlslHighlighter(QTextDocument *parent = 0); + explicit GlslHighlighter(QTextDocument *parent = nullptr); }; diff --git a/rpcs3/rpcs3qt/table_item_delegate.h b/rpcs3/rpcs3qt/table_item_delegate.h index b4e1c44334..88ecdff73b 100644 --- a/rpcs3/rpcs3qt/table_item_delegate.h +++ b/rpcs3/rpcs3qt/table_item_delegate.h @@ -10,9 +10,9 @@ private: bool m_has_icons; public: - explicit table_item_delegate(QObject *parent = 0, bool has_icons = false) : QStyledItemDelegate(parent), m_has_icons(has_icons) {} + explicit table_item_delegate(QObject *parent = nullptr, bool has_icons = false) : QStyledItemDelegate(parent), m_has_icons(has_icons) {} - virtual void initStyleOption(QStyleOptionViewItem *option, const QModelIndex &index) const override + void initStyleOption(QStyleOptionViewItem *option, const QModelIndex &index) const override { // Remove the focus frame around selected items option->state &= ~QStyle::State_HasFocus; @@ -30,7 +30,7 @@ public: QStyledItemDelegate::initStyleOption(option, index); } - virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override + void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override { if (index.column() == 0 && option.state & QStyle::State_Selected) { diff --git a/rpcs3/rpcs3qt/trophy_manager_dialog.cpp b/rpcs3/rpcs3qt/trophy_manager_dialog.cpp index eff2c85762..a04fbeb8ff 100644 --- a/rpcs3/rpcs3qt/trophy_manager_dialog.cpp +++ b/rpcs3/rpcs3qt/trophy_manager_dialog.cpp @@ -40,7 +40,8 @@ namespace } trophy_manager_dialog::trophy_manager_dialog(std::shared_ptr gui_settings) - : QWidget(), m_gui_settings(gui_settings) + : QWidget() + , m_gui_settings(std::move(gui_settings)) { // Nonspecific widget settings setWindowTitle(tr("Trophy Manager")); @@ -445,7 +446,7 @@ void trophy_manager_dialog::RepaintUI(bool restore_layout) PopulateTrophyTable(); - QByteArray game_table_state = m_gui_settings->GetValue(gui::tr_games_state).toByteArray(); + const QByteArray game_table_state = m_gui_settings->GetValue(gui::tr_games_state).toByteArray(); if (restore_layout && !m_game_table->horizontalHeader()->restoreState(game_table_state) && m_game_table->rowCount()) { // If no settings exist, resize to contents. (disabled) @@ -453,7 +454,7 @@ void trophy_manager_dialog::RepaintUI(bool restore_layout) //m_game_table->horizontalHeader()->resizeSections(QHeaderView::ResizeMode::ResizeToContents); } - QByteArray trophy_table_state = m_gui_settings->GetValue(gui::tr_trophy_state).toByteArray(); + const QByteArray trophy_table_state = m_gui_settings->GetValue(gui::tr_trophy_state).toByteArray(); if (restore_layout && !m_trophy_table->horizontalHeader()->restoreState(trophy_table_state) && m_trophy_table->rowCount()) { // If no settings exist, resize to contents. (disabled) @@ -485,7 +486,7 @@ void trophy_manager_dialog::HandleRepaintUiRequest() resize(window_size); } -QPixmap trophy_manager_dialog::GetResizedGameIcon(int index) +QPixmap trophy_manager_dialog::GetResizedGameIcon(int index) const { QTableWidgetItem* item = m_game_table->item(index, GameColumns::GameIcon); if (!item) @@ -519,7 +520,7 @@ void trophy_manager_dialog::ResizeGameIcons() for (int i = 0; i < m_game_table->rowCount(); ++i) indices.append(i); - std::function get_scaled = [this](const int& i) + const std::function get_scaled = [this](const int& i) { return GetResizedGameIcon(i); }; @@ -549,7 +550,7 @@ void trophy_manager_dialog::ResizeTrophyIcons() for (int i = 0; i < m_trophy_table->rowCount(); ++i) indices.append(i); - std::function get_scaled = [this, db_pos, dpr, new_height](const int& i) + const std::function get_scaled = [this, db_pos, dpr, new_height](const int& i) { QTableWidgetItem* item = m_trophy_table->item(i, TrophyColumns::Id); QTableWidgetItem* icon_item = m_trophy_table->item(i, TrophyColumns::Icon); @@ -625,22 +626,13 @@ void trophy_manager_dialog::ApplyFilter() { hide = !hidden; } - else if (trophy_unlocked && !m_show_unlocked_trophies) - { - hide = true; - } - else if (!trophy_unlocked && !m_show_locked_trophies) - { - hide = true; - } - else if (hidden && !trophy_unlocked && !m_show_hidden_trophies) - { - hide = true; - } - else if ((trophy_type == SCE_NP_TROPHY_GRADE_BRONZE && !m_show_bronze_trophies) - || (trophy_type == SCE_NP_TROPHY_GRADE_SILVER && !m_show_silver_trophies) - || (trophy_type == SCE_NP_TROPHY_GRADE_GOLD && !m_show_gold_trophies) - || (trophy_type == SCE_NP_TROPHY_GRADE_PLATINUM && !m_show_platinum_trophies)) + else if ((trophy_unlocked && !m_show_unlocked_trophies) + || (!trophy_unlocked && !m_show_locked_trophies) + || (hidden && !trophy_unlocked && !m_show_hidden_trophies) + || (trophy_type == SCE_NP_TROPHY_GRADE_BRONZE && !m_show_bronze_trophies) + || (trophy_type == SCE_NP_TROPHY_GRADE_SILVER && !m_show_silver_trophies) + || (trophy_type == SCE_NP_TROPHY_GRADE_GOLD && !m_show_gold_trophies) + || (trophy_type == SCE_NP_TROPHY_GRADE_PLATINUM && !m_show_platinum_trophies)) { hide = true; } @@ -666,7 +658,7 @@ void trophy_manager_dialog::ShowContextMenu(const QPoint& pos) connect(show_trophy_dir, &QAction::triggered, [=, this]() { - QString path = qstr(m_trophies_db[db_ind]->path); + const QString path = qstr(m_trophies_db[db_ind]->path); QDesktopServices::openUrl(QUrl::fromLocalFile(path)); }); @@ -678,7 +670,7 @@ void trophy_manager_dialog::StartTrophyLoadThreads() { m_trophies_db.clear(); - QDir trophy_dir(qstr(vfs::get(m_trophy_dir))); + const QDir trophy_dir(qstr(vfs::get(m_trophy_dir))); const auto folder_list = trophy_dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot); const int count = folder_list.count(); @@ -699,14 +691,14 @@ void trophy_manager_dialog::StartTrophyLoadThreads() connect(&futureWatcher, &QFutureWatcher::progressRangeChanged, &progressDialog, &QProgressDialog::setRange); connect(&futureWatcher, &QFutureWatcher::progressValueChanged, &progressDialog, &QProgressDialog::setValue); - connect(&futureWatcher, &QFutureWatcher::finished, [this]() { RepaintUI(true); }); - connect(&progressDialog, &QProgressDialog::canceled, [this, &futureWatcher]() + connect(&futureWatcher, &QFutureWatcher::finished, this, [this]() { RepaintUI(true); }); + connect(&progressDialog, &QProgressDialog::canceled, this, [this, &futureWatcher]() { futureWatcher.cancel(); - this->close(); // It's pointless to show an empty window + close(); // It's pointless to show an empty window }); - futureWatcher.setFuture(QtConcurrent::map(indices, [this, folder_list, &progressDialog](const int& i) + futureWatcher.setFuture(QtConcurrent::map(indices, [this, folder_list](const int& i) { const std::string dir_name = sstr(folder_list.value(i)); gui_log.trace("Loading trophy dir: %s", dir_name); @@ -737,7 +729,7 @@ void trophy_manager_dialog::PopulateGameTable() for (usz i = 0; i < m_trophies_db.size(); ++i) indices.append(static_cast(i)); - std::function get_icon = [this](const int& i) + const std::function get_icon = [this](const int& i) { // Load game icon QPixmap icon; @@ -835,6 +827,7 @@ void trophy_manager_dialog::PopulateTrophyTable() case 'S': details.trophyGrade = SCE_NP_TROPHY_GRADE_SILVER; trophy_type = tr("Silver", "Trophy type"); break; case 'G': details.trophyGrade = SCE_NP_TROPHY_GRADE_GOLD; trophy_type = tr("Gold", "Trophy type"); break; case 'P': details.trophyGrade = SCE_NP_TROPHY_GRADE_PLATINUM; trophy_type = tr("Platinum", "Trophy type"); break; + default: gui_log.warning("Unknown trophy grade %s", n->GetAttribute("ttype")); break; } // Get hidden state @@ -862,7 +855,7 @@ void trophy_manager_dialog::PopulateTrophyTable() icon_item->setData(Qt::UserRole, hidden, true); custom_table_widget_item* type_item = new custom_table_widget_item(trophy_type); - type_item->setData(Qt::UserRole, uint(details.trophyGrade), true); + type_item->setData(Qt::UserRole, static_cast(details.trophyGrade), true); m_trophy_table->setItem(i, TrophyColumns::Icon, icon_item); m_trophy_table->setItem(i, TrophyColumns::Name, new custom_table_widget_item(qstr(details.name))); @@ -880,7 +873,7 @@ void trophy_manager_dialog::PopulateTrophyTable() ResizeTrophyIcons(); } -void trophy_manager_dialog::ReadjustGameTable() +void trophy_manager_dialog::ReadjustGameTable() const { // Fixate vertical header and row height m_game_table->verticalHeader()->setMinimumSectionSize(m_game_icon_size.height()); @@ -895,7 +888,7 @@ void trophy_manager_dialog::ReadjustGameTable() m_game_table->resizeColumnToContents(GameColumns::GameColumnsCount - 1); } -void trophy_manager_dialog::ReadjustTrophyTable() +void trophy_manager_dialog::ReadjustTrophyTable() const { // Fixate vertical header and row height m_trophy_table->verticalHeader()->setMinimumSectionSize(m_icon_height); diff --git a/rpcs3/rpcs3qt/trophy_manager_dialog.h b/rpcs3/rpcs3qt/trophy_manager_dialog.h index a93fbc6680..c15b37beb6 100644 --- a/rpcs3/rpcs3qt/trophy_manager_dialog.h +++ b/rpcs3/rpcs3qt/trophy_manager_dialog.h @@ -10,6 +10,8 @@ #include #include +#include + class gui_settings; class TROPUSRLoader; @@ -57,7 +59,7 @@ public Q_SLOTS: void HandleRepaintUiRequest(); private Q_SLOTS: - QPixmap GetResizedGameIcon(int index); + QPixmap GetResizedGameIcon(int index) const; void ResizeGameIcons(); void ResizeTrophyIcons(); void ApplyFilter(); @@ -82,8 +84,8 @@ private: */ void PopulateTrophyTable(); - void ReadjustGameTable(); - void ReadjustTrophyTable(); + void ReadjustGameTable() const; + void ReadjustTrophyTable() const; void closeEvent(QCloseEvent *event) override; bool eventFilter(QObject *object, QEvent *event) override; diff --git a/rpcs3/rpcs3qt/trophy_notification_frame.cpp b/rpcs3/rpcs3qt/trophy_notification_frame.cpp index 87d302981e..f4c08b47c0 100644 --- a/rpcs3/rpcs3qt/trophy_notification_frame.cpp +++ b/rpcs3/rpcs3qt/trophy_notification_frame.cpp @@ -6,8 +6,6 @@ static const int TROPHY_TIMEOUT_MS = 7500; -//constexpr auto qstr = QString::fromStdString; - trophy_notification_frame::trophy_notification_frame(const std::vector& imgBuffer, const SceNpTrophyDetails& trophy, int height) : QWidget() { setObjectName("trophy_notification_frame"); diff --git a/rpcs3/rpcs3qt/trophy_notification_helper.h b/rpcs3/rpcs3qt/trophy_notification_helper.h index c406130046..dd6834cd91 100644 --- a/rpcs3/rpcs3qt/trophy_notification_helper.h +++ b/rpcs3/rpcs3qt/trophy_notification_helper.h @@ -9,7 +9,7 @@ class trophy_notification_helper : public TrophyNotificationBase { public: - trophy_notification_helper(QWindow* game_window) : m_game_window(game_window) { } + explicit trophy_notification_helper(QWindow* game_window) : m_game_window(game_window) { } s32 ShowTrophyNotification(const SceNpTrophyDetails& trophy, const std::vector& trophy_icon_buffer) override; private: QWindow* m_game_window; diff --git a/rpcs3/rpcs3qt/update_manager.cpp b/rpcs3/rpcs3qt/update_manager.cpp index 98a9f60c64..8f9d19e63b 100644 --- a/rpcs3/rpcs3qt/update_manager.cpp +++ b/rpcs3/rpcs3qt/update_manager.cpp @@ -23,10 +23,8 @@ #include #include <7z.h> #include <7zAlloc.h> -#include <7zBuf.h> #include <7zCrc.h> #include <7zFile.h> -#include <7zVersion.h> #define PATH_MAX MAX_PATH @@ -37,10 +35,6 @@ LOG_CHANNEL(update_log, "UPDATER"); -update_manager::update_manager() -{ -} - void update_manager::check_for_updates(bool automatic, bool check_only, QWidget* parent) { m_update_message.clear(); @@ -174,7 +168,7 @@ bool update_manager::handle_json(bool automatic, bool check_only, const QByteArr update_log.notice("Current: %s, latest: %s, difference: %lld ms", cur_str.toStdString(), lts_str.toStdString(), diff_msec); - Localized localized; + const Localized localized; if (hash_found) { @@ -274,7 +268,7 @@ bool update_manager::handle_rpcs3(const QByteArray& data) { m_downloader->update_progress_dialog(tr("Updating RPCS3")); - if (m_expected_size != data.size() + 0u) + if (m_expected_size != static_cast(data.size())) { update_log.error("Download size mismatch: %d expected: %d", data.size(), m_expected_size); return false; @@ -311,7 +305,7 @@ bool update_manager::handle_rpcs3(const QByteArray& data) update_log.error("Failed to create temporary file: %s", tmpfile_path); return false; } - if (tmpfile.write(data.data(), data.size()) != data.size()) + if (tmpfile.write(data.data(), data.size()) != static_cast(data.size())) { update_log.error("Failed to write temporary file: %s", tmpfile_path); return false; @@ -347,14 +341,14 @@ bool update_manager::handle_rpcs3(const QByteArray& data) res = SZ_OK; { - lookStream.buf = (Byte*)ISzAlloc_Alloc(&allocImp, kInputBufSize); + lookStream.buf = static_cast(ISzAlloc_Alloc(&allocImp, kInputBufSize)); if (!lookStream.buf) res = SZ_ERROR_MEM; else { lookStream.bufSize = kInputBufSize; lookStream.realStream = &archiveStream.vt; - LookToRead2_Init(&lookStream); + LookToRead2_Init(&lookStream) } } @@ -429,9 +423,7 @@ bool update_manager::handle_rpcs3(const QByteArray& data) temp_u8[index] = static_cast(temp_u16[index]); } temp_u8[len] = 0; - std::string name((char*)temp_u8); - - name = Emulator::GetEmuDir() + name; + const std::string name = Emulator::GetEmuDir() + std::string(reinterpret_cast(temp_u8)); if (!isDir) { diff --git a/rpcs3/rpcs3qt/update_manager.h b/rpcs3/rpcs3qt/update_manager.h index 00b41c2ba2..5e8b2a7bbd 100644 --- a/rpcs3/rpcs3qt/update_manager.h +++ b/rpcs3/rpcs3qt/update_manager.h @@ -27,7 +27,7 @@ private: bool handle_rpcs3(const QByteArray& data); public: - update_manager(); + update_manager() = default; void check_for_updates(bool automatic, bool check_only, QWidget* parent = nullptr); void update(); diff --git a/rpcs3/rpcs3qt/user_account.cpp b/rpcs3/rpcs3qt/user_account.cpp index 7f4c5f1464..39babb0a98 100644 --- a/rpcs3/rpcs3qt/user_account.cpp +++ b/rpcs3/rpcs3qt/user_account.cpp @@ -2,7 +2,6 @@ #include "Emu/System.h" #include "Utilities/File.h" -#include "Utilities/StrFmt.h" #include "util/logs.hpp" LOG_CHANNEL(gui_log, "GUI"); @@ -33,10 +32,6 @@ user_account::user_account(const std::string& user_id) } } -user_account::~user_account() -{ -} - std::map user_account::GetUserAccounts(const std::string& base_dir) { std::map user_list; diff --git a/rpcs3/rpcs3qt/user_account.h b/rpcs3/rpcs3qt/user_account.h index fc394f1d35..3740fd233b 100644 --- a/rpcs3/rpcs3qt/user_account.h +++ b/rpcs3/rpcs3qt/user_account.h @@ -17,7 +17,6 @@ public: std::string GetUserId() const { return m_user_id; } std::string GetUserDir() const { return m_user_dir; } std::string GetUsername() const { return m_username; } - ~user_account(); static std::map GetUserAccounts(const std::string& base_dir); diff --git a/rpcs3/rpcs3qt/user_manager_dialog.cpp b/rpcs3/rpcs3qt/user_manager_dialog.cpp index 7ee8b7f4fc..6b9eaa4c46 100644 --- a/rpcs3/rpcs3qt/user_manager_dialog.cpp +++ b/rpcs3/rpcs3qt/user_manager_dialog.cpp @@ -30,8 +30,8 @@ LOG_CHANNEL(gui_log, "GUI"); user_manager_dialog::user_manager_dialog(std::shared_ptr gui_settings, std::shared_ptr persistent_settings, QWidget* parent) : QDialog(parent) - , m_gui_settings(gui_settings) - , m_persistent_settings(persistent_settings) + , m_gui_settings(std::move(gui_settings)) + , m_persistent_settings(std::move(persistent_settings)) { setWindowTitle(tr("User Manager")); setMinimumSize(QSize(500, 400)); @@ -260,7 +260,7 @@ bool user_manager_dialog::ValidateUsername(const QString& text_to_validate) { // "Entire string (^...$) must be between 3 and 16 characters // and only consist of letters, numbers, underscores, and hyphens." - QRegExpValidator validator(QRegExp("^[A-Za-z0-9_-]{3,16}$")); + const QRegExpValidator validator(QRegExp("^[A-Za-z0-9_-]{3,16}$")); int pos = 0; QString text = text_to_validate; @@ -324,10 +324,8 @@ void user_manager_dialog::OnUserCreate() { break; } - else - { - smallest++; - } + + smallest++; } if (smallest >= 100000000) // Only 8 digits allowed @@ -444,7 +442,7 @@ void user_manager_dialog::ShowContextMenu(const QPoint &pos) } // Returns the current user's key > 0. if no user is selected, return 0 -u32 user_manager_dialog::GetUserKey() +u32 user_manager_dialog::GetUserKey() const { const int idx = m_table->currentRow(); if (idx < 0) diff --git a/rpcs3/rpcs3qt/user_manager_dialog.h b/rpcs3/rpcs3qt/user_manager_dialog.h index 90c3cfffb4..93fbc3245c 100644 --- a/rpcs3/rpcs3qt/user_manager_dialog.h +++ b/rpcs3/rpcs3qt/user_manager_dialog.h @@ -28,17 +28,17 @@ private Q_SLOTS: private: void Init(); void UpdateTable(bool mark_only = false); - void GenerateUser(const std::string& user_id, const std::string& username); - bool ValidateUsername(const QString& text_to_validate); + static void GenerateUser(const std::string& user_id, const std::string& username); + static bool ValidateUsername(const QString& text_to_validate); void ShowContextMenu(const QPoint &pos); void closeEvent(QCloseEvent* event) override; bool eventFilter(QObject* object, QEvent* event) override; - u32 GetUserKey(); + u32 GetUserKey() const; - QTableWidget* m_table; + QTableWidget* m_table = nullptr; std::string m_active_user; std::map m_user_list; diff --git a/rpcs3/rpcs3qt/vfs_dialog_tab.cpp b/rpcs3/rpcs3qt/vfs_dialog_tab.cpp index 2f64bc034f..fd0d4373d4 100644 --- a/rpcs3/rpcs3qt/vfs_dialog_tab.cpp +++ b/rpcs3/rpcs3qt/vfs_dialog_tab.cpp @@ -73,7 +73,7 @@ vfs_dialog_tab::vfs_dialog_tab(vfs_settings_info settingsInfo, std::shared_ptrcount(); ++i) @@ -87,13 +87,13 @@ void vfs_dialog_tab::SetSettings() m_emu_settings->SetSetting(m_info.settingLoc, new_dir); } -void vfs_dialog_tab::Reset() +void vfs_dialog_tab::Reset() const { m_dirList->clear(); m_dirList->setCurrentItem(new QListWidgetItem(qstr(m_info.cfg_node->def), m_dirList)); } -void vfs_dialog_tab::AddNewDirectory() +void vfs_dialog_tab::AddNewDirectory() const { QString dir = QFileDialog::getExistingDirectory(nullptr, tr("Choose a directory"), QCoreApplication::applicationDirPath(), QFileDialog::DontResolveSymlinks); @@ -106,7 +106,7 @@ void vfs_dialog_tab::AddNewDirectory() m_dirList->setCurrentItem(new QListWidgetItem(dir, m_dirList)); } -void vfs_dialog_tab::RemoveDirectory() +void vfs_dialog_tab::RemoveDirectory() const { QListWidgetItem* item = m_dirList->takeItem(m_currentRow); delete item; diff --git a/rpcs3/rpcs3qt/vfs_dialog_tab.h b/rpcs3/rpcs3qt/vfs_dialog_tab.h index 35d5b714d2..f40e164678 100644 --- a/rpcs3/rpcs3qt/vfs_dialog_tab.h +++ b/rpcs3/rpcs3qt/vfs_dialog_tab.h @@ -31,14 +31,14 @@ class vfs_dialog_tab : public QWidget public: explicit vfs_dialog_tab(vfs_settings_info info, std::shared_ptr guiSettings, std::shared_ptr emuSettings, QWidget* parent = nullptr); - void SetSettings(); + void SetSettings() const; // Reset this tab without saving the settings yet - void Reset(); + void Reset() const; private: - void AddNewDirectory(); - void RemoveDirectory(); + void AddNewDirectory() const; + void RemoveDirectory() const; void SetCurrentRow(int row) { m_currentRow = row; } const QString EmptyPath = tr("Empty Path");