From d26f96db9e13028d2fb943653e7bebd637d2f8ff Mon Sep 17 00:00:00 2001 From: RickyRister <42636155+RickyRister@users.noreply.github.com> Date: Sun, 20 Oct 2024 07:41:59 -0700 Subject: [PATCH] Add keyboard shortcuts for replays (#5136) * add keyboard shortcut for play/pause * add keyboard shortcut for fast-forward * make shortcuts rebindable * run formatter --- cockatrice/src/client/tabs/tab_game.cpp | 6 ++++++ cockatrice/src/settings/shortcuts_settings.h | 13 +++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/cockatrice/src/client/tabs/tab_game.cpp b/cockatrice/src/client/tabs/tab_game.cpp index a5f718b67..6ee2b05a0 100644 --- a/cockatrice/src/client/tabs/tab_game.cpp +++ b/cockatrice/src/client/tabs/tab_game.cpp @@ -257,6 +257,12 @@ void TabGame::refreshShortcuts() if (aFocusChat) { aFocusChat->setShortcuts(shortcuts.getShortcut("tab_game/aFocusChat")); } + if (replayPlayButton) { + replayPlayButton->setShortcut(shortcuts.getSingleShortcut("Replays/playButton")); + } + if (replayFastForwardButton) { + replayFastForwardButton->setShortcut(shortcuts.getSingleShortcut("Replays/fastForwardButton")); + } } void DeckViewContainer::loadLocalDeck() diff --git a/cockatrice/src/settings/shortcuts_settings.h b/cockatrice/src/settings/shortcuts_settings.h index fb2613d2e..98457b1c1 100644 --- a/cockatrice/src/settings/shortcuts_settings.h +++ b/cockatrice/src/settings/shortcuts_settings.h @@ -28,7 +28,8 @@ public: Drawing, Chat_room, Game_window, - Load_deck + Load_deck, + Replays }; static QString getGroupName(ShortcutGroup::Groups group) @@ -68,6 +69,8 @@ public: return QApplication::translate("shortcutsTab", "Game Window"); case Load_deck: return QApplication::translate("shortcutsTab", "Load Deck from Clipboard"); + case Replays: + return QApplication::translate("shortcutsTab", "Replays"); } return {}; @@ -586,7 +589,13 @@ private: ShortcutGroup::Game_window)}, {"DlgLoadDeckFromClipboard/refreshButton", ShortcutKey(QT_TRANSLATE_NOOP("shortcutsTab", "Refresh"), parseSequenceString("F5"), - ShortcutGroup::Load_deck)}}; + ShortcutGroup::Load_deck)}, + {"Replays/playButton", ShortcutKey(QT_TRANSLATE_NOOP("shortcutsTab", "Play/Pause"), + parseSequenceString("Space"), + ShortcutGroup::Replays)}, + {"Replays/fastForwardButton", ShortcutKey(QT_TRANSLATE_NOOP("shortcutsTab", "Toggle Fast Forward"), + parseSequenceString("Ctrl+Right"), + ShortcutGroup::Replays)}}; }; #endif // SHORTCUTSSETTINGS_H