From 4ba4268282c853d854df1ac1df8110a500a6716f Mon Sep 17 00:00:00 2001 From: Megamouse Date: Fri, 27 Sep 2024 16:54:18 +0200 Subject: [PATCH] Qt/shortcuts: add handler id to log messages --- rpcs3/rpcs3qt/shortcut_handler.cpp | 6 +++--- rpcs3/rpcs3qt/shortcut_settings.cpp | 19 +++++++++++++++++-- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/rpcs3/rpcs3qt/shortcut_handler.cpp b/rpcs3/rpcs3qt/shortcut_handler.cpp index 8ebefaa899..a6b9bf8413 100644 --- a/rpcs3/rpcs3qt/shortcut_handler.cpp +++ b/rpcs3/rpcs3qt/shortcut_handler.cpp @@ -38,7 +38,7 @@ shortcut_handler::shortcut_handler(gui::shortcuts::shortcut_handler_id handler_i // TODO: do not allow same shortcuts and remove this connect // activatedAmbiguously will trigger if you have the same key sequence for several shortcuts const QKeySequence& key_sequence = m_shortcuts[key].key_sequence; - shortcut_log.error("Shortcut activated ambiguously: %s (%s)", key, key_sequence.toString()); + shortcut_log.error("%s: Shortcut activated ambiguously: %s (%s)", m_handler_id, key, key_sequence.toString()); handle_shortcut(key, key_sequence); }); } @@ -46,7 +46,7 @@ shortcut_handler::shortcut_handler(gui::shortcuts::shortcut_handler_id handler_i void shortcut_handler::update() { - shortcut_log.notice("Updating shortcuts"); + shortcut_log.notice("%s: Updating shortcuts", m_handler_id); shortcut_settings sc_settings{}; @@ -71,7 +71,7 @@ void shortcut_handler::update() void shortcut_handler::handle_shortcut(gui::shortcuts::shortcut shortcut_key, const QKeySequence& key_sequence) { - shortcut_log.notice("Shortcut pressed: %s (%s)", shortcut_key, key_sequence.toString()); + shortcut_log.notice("%s: Shortcut pressed: %s (%s)", m_handler_id, shortcut_key, key_sequence.toString()); Q_EMIT shortcut_activated(shortcut_key, key_sequence); } diff --git a/rpcs3/rpcs3qt/shortcut_settings.cpp b/rpcs3/rpcs3qt/shortcut_settings.cpp index d7ed07eafd..c28245bd7d 100644 --- a/rpcs3/rpcs3qt/shortcut_settings.cpp +++ b/rpcs3/rpcs3qt/shortcut_settings.cpp @@ -3,9 +3,9 @@ using namespace gui::shortcuts; template <> -void fmt_class_string::format(std::string& out, u64 arg) +void fmt_class_string::format(std::string& out, u64 arg) { - format_enum(out, arg, [](gui::shortcuts::shortcut value) + format_enum(out, arg, [](shortcut value) { switch (value) { @@ -35,6 +35,21 @@ void fmt_class_string::format(std::string& out, u64 ar }); } +template <> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](gui::shortcuts::shortcut_handler_id value) + { + switch (value) + { + case shortcut_handler_id::main_window: return "main_window"; + case shortcut_handler_id::game_window: return "game_window"; + } + + return unknown; + }); +} + shortcut_settings::shortcut_settings() : shortcut_map({ { shortcut::mw_start, shortcut_info{ "main_window_start", tr("Start"), "Ctrl+E", shortcut_handler_id::main_window } },