mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-21 17:15:09 -07:00
[Replay] Make fast forward speed configurable (#7037)
* [Replay] Make fast forward speed configurable * fix settings widget * clamp interval
This commit is contained in:
parent
ae37762ee1
commit
b70f770633
9 changed files with 102 additions and 7 deletions
|
|
@ -1,6 +1,7 @@
|
|||
#include "replay_manager.h"
|
||||
|
||||
#include "../interface/widgets/tabs/tab_game.h"
|
||||
#include "replay_quick_settings_widget.h"
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QToolButton>
|
||||
|
|
@ -78,13 +79,19 @@ ReplayManager::ReplayManager(TabGame *parent, GameReplay *_replay)
|
|||
replayFastForwardButton->setIconSize(QSize(32, 32));
|
||||
replayFastForwardButton->setIcon(QPixmap("theme:replay/fastforward"));
|
||||
replayFastForwardButton->setCheckable(true);
|
||||
connect(replayFastForwardButton, &QToolButton::toggled, this, &ReplayManager::replayFastForwardButtonToggled);
|
||||
connect(replayFastForwardButton, &QToolButton::toggled, this, &ReplayManager::updateTimeScaleFactor);
|
||||
|
||||
settingsWidget = new ReplayQuickSettingsWidget(this);
|
||||
settingsWidget->setFixedSize(QSize(32, 32));
|
||||
connect(settingsWidget, &ReplayQuickSettingsWidget::fastForwardSpeedChanged, this,
|
||||
[this] { updateTimeScaleFactor(replayFastForwardButton->isChecked()); });
|
||||
|
||||
// putting everything together
|
||||
auto replayControlLayout = new QHBoxLayout;
|
||||
replayControlLayout->addWidget(timelineWidget, 10);
|
||||
replayControlLayout->addWidget(replayPlayButton);
|
||||
replayControlLayout->addWidget(replayFastForwardButton);
|
||||
replayControlLayout->addWidget(settingsWidget);
|
||||
|
||||
setObjectName("replayControlWidget");
|
||||
setLayout(replayControlLayout);
|
||||
|
|
@ -115,9 +122,10 @@ void ReplayManager::replayPlayButtonToggled(bool checked)
|
|||
}
|
||||
}
|
||||
|
||||
void ReplayManager::replayFastForwardButtonToggled(bool checked)
|
||||
void ReplayManager::updateTimeScaleFactor(bool isFastForward)
|
||||
{
|
||||
timelineWidget->setTimeScaleFactor(checked ? ReplayTimelineWidget::FAST_FORWARD_SCALE_FACTOR : 1.0);
|
||||
qreal factor = isFastForward ? SettingsCache::instance().getFastForwardSpeed() : 1.0;
|
||||
timelineWidget->setTimeScaleFactor(factor);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue