Add keyboard shortcuts for skipping forward/backward in replays (#5140)

* split skipToTime into own function

* implement shortcut

* fix shortcut warning bug

* check boundary conditions in skipToTime

* change default fast forward shortcut to .

* implement big skip shortcuts

* remove unnecessary arg in lambda

* change default fast forward shortcut to Ctrl+F

* rename constants

* change default fast forward shortcut to Ctrl+P

* use static const
This commit is contained in:
RickyRister 2024-10-23 05:00:23 -07:00 committed by GitHub
parent c633a792f5
commit c4c52bd8c0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 74 additions and 2 deletions

View file

@ -257,6 +257,18 @@ void TabGame::refreshShortcuts()
if (aFocusChat) {
aFocusChat->setShortcuts(shortcuts.getShortcut("tab_game/aFocusChat"));
}
if (aReplaySkipForward) {
aReplaySkipForward->setShortcuts(shortcuts.getShortcut("Replays/aSkipForward"));
}
if (aReplaySkipBackward) {
aReplaySkipBackward->setShortcuts(shortcuts.getShortcut("Replays/aSkipBackward"));
}
if (aReplaySkipForwardBig) {
aReplaySkipForwardBig->setShortcuts(shortcuts.getShortcut("Replays/aSkipForwardBig"));
}
if (aReplaySkipBackwardBig) {
aReplaySkipBackwardBig->setShortcuts(shortcuts.getShortcut("Replays/aSkipBackwardBig"));
}
if (replayPlayButton) {
replayPlayButton->setShortcut(shortcuts.getSingleShortcut("Replays/playButton"));
}
@ -1699,12 +1711,35 @@ void TabGame::createPlayAreaWidget(bool bReplay)
void TabGame::createReplayDock()
{
// timeline widget
timelineWidget = new ReplayTimelineWidget;
timelineWidget->setTimeline(replayTimeline);
connect(timelineWidget, SIGNAL(processNextEvent()), this, SLOT(replayNextEvent()));
connect(timelineWidget, SIGNAL(replayFinished()), this, SLOT(replayFinished()));
connect(timelineWidget, &ReplayTimelineWidget::rewound, messageLog, &ChatView::clearChat);
// timeline skip shortcuts
aReplaySkipForward = new QAction(timelineWidget);
timelineWidget->addAction(aReplaySkipForward);
connect(aReplaySkipForward, &QAction::triggered, this,
[=]() { timelineWidget->skipByAmount(SMALL_SKIP_AMOUNT_MS); });
aReplaySkipBackward = new QAction(timelineWidget);
timelineWidget->addAction(aReplaySkipBackward);
connect(aReplaySkipBackward, &QAction::triggered, this,
[=]() { timelineWidget->skipByAmount(-SMALL_SKIP_AMOUNT_MS); });
aReplaySkipForwardBig = new QAction(timelineWidget);
timelineWidget->addAction(aReplaySkipForwardBig);
connect(aReplaySkipForwardBig, &QAction::triggered, this,
[=]() { timelineWidget->skipByAmount(BIG_SKIP_AMOUNT_MS); });
aReplaySkipBackwardBig = new QAction(timelineWidget);
timelineWidget->addAction(aReplaySkipBackwardBig);
connect(aReplaySkipBackwardBig, &QAction::triggered, this,
[=]() { timelineWidget->skipByAmount(-BIG_SKIP_AMOUNT_MS); });
// buttons
replayPlayButton = new QToolButton;
replayPlayButton->setIconSize(QSize(32, 32));
QIcon playButtonIcon = QIcon();
@ -1720,6 +1755,7 @@ void TabGame::createReplayDock()
replayFastForwardButton->setCheckable(true);
connect(replayFastForwardButton, SIGNAL(toggled(bool)), this, SLOT(replayFastForwardButtonToggled(bool)));
// putting everything together
replayControlLayout = new QHBoxLayout;
replayControlLayout->addWidget(timelineWidget, 10);
replayControlLayout->addWidget(replayPlayButton);