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

View file

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