mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-15 03:28:49 -07:00
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:
parent
c633a792f5
commit
c4c52bd8c0
6 changed files with 74 additions and 2 deletions
|
|
@ -67,6 +67,19 @@ void ReplayTimelineWidget::mousePressEvent(QMouseEvent *event)
|
|||
#else
|
||||
int newTime = static_cast<int>((qint64)maxTime * (qint64)event->x() / width());
|
||||
#endif
|
||||
skipToTime(newTime);
|
||||
}
|
||||
|
||||
void ReplayTimelineWidget::skipToTime(int newTime)
|
||||
{
|
||||
// check boundary conditions
|
||||
if (newTime < 0) {
|
||||
newTime = 0;
|
||||
}
|
||||
if (newTime > maxTime) {
|
||||
newTime = maxTime;
|
||||
}
|
||||
|
||||
newTime -= newTime % 200; // Time should always be a multiple of 200
|
||||
if (newTime < currentTime) {
|
||||
currentTime = 0;
|
||||
|
|
@ -119,3 +132,8 @@ void ReplayTimelineWidget::stopReplay()
|
|||
{
|
||||
replayTimer->stop();
|
||||
}
|
||||
|
||||
void ReplayTimelineWidget::skipByAmount(int amount)
|
||||
{
|
||||
skipToTime(currentTime + amount);
|
||||
}
|
||||
|
|
@ -25,6 +25,8 @@ private:
|
|||
qreal timeScaleFactor;
|
||||
int currentTime;
|
||||
int currentEvent;
|
||||
|
||||
void skipToTime(int newTime);
|
||||
private slots:
|
||||
void replayTimerTimeout();
|
||||
|
||||
|
|
@ -41,6 +43,7 @@ public:
|
|||
public slots:
|
||||
void startReplay();
|
||||
void stopReplay();
|
||||
void skipByAmount(int amount); // use a negative amount to skip backwards
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue