Consolidate play/pause buttons in replays (#5131)

* Consolidate play/pause buttons in replays

* always enable fast forward button

* run formatter
This commit is contained in:
RickyRister 2024-10-19 17:18:01 -07:00 committed by GitHub
parent 4865269a73
commit 2d86938375
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 19 additions and 33 deletions

View file

@ -600,27 +600,16 @@ void TabGame::replayNextEvent()
void TabGame::replayFinished()
{
replayStartButton->setEnabled(true);
replayPauseButton->setEnabled(false);
replayFastForwardButton->setEnabled(false);
replayPlayButton->setChecked(false);
}
void TabGame::replayStartButtonClicked()
void TabGame::replayPlayButtonToggled(bool checked)
{
replayStartButton->setEnabled(false);
replayPauseButton->setEnabled(true);
replayFastForwardButton->setEnabled(true);
timelineWidget->startReplay();
}
void TabGame::replayPauseButtonClicked()
{
replayStartButton->setEnabled(true);
replayPauseButton->setEnabled(false);
replayFastForwardButton->setEnabled(false);
timelineWidget->stopReplay();
if (checked) { // start replay
timelineWidget->startReplay();
} else { // pause replay
timelineWidget->stopReplay();
}
}
void TabGame::replayFastForwardButtonToggled(bool checked)
@ -1710,26 +1699,24 @@ void TabGame::createReplayDock()
connect(timelineWidget, SIGNAL(replayFinished()), this, SLOT(replayFinished()));
connect(timelineWidget, &ReplayTimelineWidget::rewound, messageLog, &ChatView::clearChat);
replayStartButton = new QToolButton;
replayStartButton->setIconSize(QSize(32, 32));
replayStartButton->setIcon(QPixmap("theme:replay/start"));
connect(replayStartButton, SIGNAL(clicked()), this, SLOT(replayStartButtonClicked()));
replayPauseButton = new QToolButton;
replayPauseButton->setIconSize(QSize(32, 32));
replayPauseButton->setEnabled(false);
replayPauseButton->setIcon(QPixmap("theme:replay/pause"));
connect(replayPauseButton, SIGNAL(clicked()), this, SLOT(replayPauseButtonClicked()));
replayPlayButton = new QToolButton;
replayPlayButton->setIconSize(QSize(32, 32));
QIcon playButtonIcon = QIcon();
playButtonIcon.addPixmap(QPixmap("theme:replay/start"), QIcon::Normal, QIcon::Off);
playButtonIcon.addPixmap(QPixmap("theme:replay/pause"), QIcon::Normal, QIcon::On);
replayPlayButton->setIcon(playButtonIcon);
replayPlayButton->setCheckable(true);
connect(replayPlayButton, SIGNAL(toggled(bool)), this, SLOT(replayPlayButtonToggled(bool)));
replayFastForwardButton = new QToolButton;
replayFastForwardButton->setIconSize(QSize(32, 32));
replayFastForwardButton->setEnabled(false);
replayFastForwardButton->setIcon(QPixmap("theme:replay/fastforward"));
replayFastForwardButton->setCheckable(true);
connect(replayFastForwardButton, SIGNAL(toggled(bool)), this, SLOT(replayFastForwardButtonToggled(bool)));
replayControlLayout = new QHBoxLayout;
replayControlLayout->addWidget(timelineWidget, 10);
replayControlLayout->addWidget(replayStartButton);
replayControlLayout->addWidget(replayPauseButton);
replayControlLayout->addWidget(replayPlayButton);
replayControlLayout->addWidget(replayFastForwardButton);
replayControlWidget = new QWidget();

View file

@ -146,7 +146,7 @@ private:
int currentReplayStep;
QList<int> replayTimeline;
ReplayTimelineWidget *timelineWidget;
QToolButton *replayStartButton, *replayPauseButton, *replayFastForwardButton;
QToolButton *replayPlayButton, *replayFastForwardButton;
CardFrame *cardInfo;
PlayerListWidget *playerListWidget;
@ -220,8 +220,7 @@ signals:
private slots:
void replayNextEvent();
void replayFinished();
void replayStartButtonClicked();
void replayPauseButtonClicked();
void replayPlayButtonToggled(bool checked);
void replayFastForwardButtonToggled(bool checked);
void incrementGameTime();