Skip to content

Commit 0e8ec55

Browse files
committed
extend the key repeat fix to other intervals
1 parent 0b6a29e commit 0e8ec55

File tree

3 files changed

+24
-48
lines changed

3 files changed

+24
-48
lines changed

src/mainwindow.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -2586,7 +2586,7 @@ void MainWindow::keyPressEvent(QKeyEvent *event)
25862586
switch (event->key()) {
25872587
case Qt::Key_J:
25882588
if (m_isKKeyPressed)
2589-
m_player->nextFrame();
2589+
m_player->previousFrame();
25902590
else
25912591
m_player->rewind(false);
25922592
break;
@@ -2597,7 +2597,7 @@ void MainWindow::keyPressEvent(QKeyEvent *event)
25972597
case Qt::Key_L:
25982598
if (event->modifiers() == Qt::NoModifier) {
25992599
if (m_isKKeyPressed)
2600-
m_player->previousFrame();
2600+
m_player->nextFrame();
26012601
else
26022602
m_player->fastForward(false);
26032603
}

src/player.cpp

+21-46
Original file line numberDiff line numberDiff line change
@@ -639,81 +639,55 @@ void Player::setupActions()
639639

640640
action = new QAction(tr("Forward One Second"), this);
641641
action->setShortcut(QKeySequence(Qt::Key_PageDown));
642-
connect(action, &QAction::triggered, this, [&]() {
643-
if (MLT.producer())
644-
seek(position() + qRound(MLT.profile().fps()));
645-
});
642+
connect(action, &QAction::triggered, this, [&]() { seekBy(qRound(MLT.profile().fps())); });
646643
Actions.add("playerForwardOneSecondAction", action);
647644

648645
action = new QAction(tr("Backward One Second"), this);
649646
action->setShortcut(QKeySequence(Qt::Key_PageUp));
650-
connect(action, &QAction::triggered, this, [&]() {
651-
if (MLT.producer())
652-
seek(position() - qRound(MLT.profile().fps()));
653-
});
647+
connect(action, &QAction::triggered, this, [&]() { seekBy(-qRound(MLT.profile().fps())); });
654648
Actions.add("playerBackwardOneSecondAction", action);
655649

656650
action = new QAction(tr("Forward Two Seconds"), this);
657651
action->setShortcut(QKeySequence(Qt::SHIFT | Qt::Key_PageDown));
658-
connect(action, &QAction::triggered, this, [&]() {
659-
if (MLT.producer())
660-
seek(position() + 2 * qRound(MLT.profile().fps()));
661-
});
652+
connect(action, &QAction::triggered, this, [&]() { seekBy(2 * qRound(MLT.profile().fps())); });
662653
Actions.add("playerForwardTwoSecondsAction", action);
663654

664655
action = new QAction(tr("Backward Two Seconds"), this);
665656
action->setShortcut(QKeySequence(Qt::SHIFT | Qt::Key_PageUp));
666-
connect(action, &QAction::triggered, this, [&]() {
667-
if (MLT.producer())
668-
seek(position() - 2 * qRound(MLT.profile().fps()));
669-
});
657+
connect(action, &QAction::triggered, this, [&]() { seekBy(-2 * qRound(MLT.profile().fps())); });
670658
Actions.add("playerBackwardTwoAction", action);
671659

672660
action = new QAction(tr("Forward Five Seconds"), this);
673661
action->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_PageDown));
674-
connect(action, &QAction::triggered, this, [&]() {
675-
if (MLT.producer())
676-
seek(position() + 5 * qRound(MLT.profile().fps()));
677-
});
662+
connect(action, &QAction::triggered, this, [&]() { seekBy(5 * qRound(MLT.profile().fps())); });
678663
Actions.add("playerForwardFiveSecondsAction", action);
679664

680665
action = new QAction(tr("Backward Five Seconds"), this);
681666
action->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_PageUp));
682-
connect(action, &QAction::triggered, this, [&]() {
683-
if (MLT.producer())
684-
seek(position() - 5 * qRound(MLT.profile().fps()));
685-
});
667+
connect(action, &QAction::triggered, this, [&]() { seekBy(-5 * qRound(MLT.profile().fps())); });
686668
Actions.add("playerBackwardFiveSecondsAction", action);
687669

688670
action = new QAction(tr("Forward Ten Seconds"), this);
689671
action->setShortcut(QKeySequence(Qt::SHIFT | Qt::CTRL | Qt::Key_PageDown));
690-
connect(action, &QAction::triggered, this, [&]() {
691-
if (MLT.producer())
692-
seek(position() + 10 * qRound(MLT.profile().fps()));
693-
});
672+
connect(action, &QAction::triggered, this, [&]() { seekBy(10 * qRound(MLT.profile().fps())); });
694673
Actions.add("playerForwardTenSecondsAction", action);
695674

696675
action = new QAction(tr("Backward Ten Seconds"), this);
697676
action->setShortcut(QKeySequence(Qt::SHIFT | Qt::CTRL | Qt::Key_PageUp));
698-
connect(action, &QAction::triggered, this, [&]() {
699-
if (MLT.producer())
700-
seek(position() - 10 * qRound(MLT.profile().fps()));
701-
});
677+
connect(action, &QAction::triggered, this, [&]() { seekBy(-10 * qRound(MLT.profile().fps())); });
702678
Actions.add("playerBackwardTenSecondsAction", action);
703679

704680
action = new QAction(tr("Forward Jump"), this);
705681
action->setShortcut(QKeySequence(Qt::ALT | Qt::Key_PageDown));
706682
connect(action, &QAction::triggered, this, [&]() {
707-
if (MLT.producer())
708-
seek(position() + qRound(MLT.profile().fps() * Settings.playerJumpSeconds()));
683+
seekBy(qRound(MLT.profile().fps() * Settings.playerJumpSeconds()));
709684
});
710685
Actions.add("playerForwardJumpAction", action);
711686

712687
action = new QAction(tr("Backward Jump"), this);
713688
action->setShortcut(QKeySequence(Qt::ALT | Qt::Key_PageUp));
714689
connect(action, &QAction::triggered, this, [&]() {
715-
if (MLT.producer())
716-
seek(position() - qRound(MLT.profile().fps() * Settings.playerJumpSeconds()));
690+
seekBy(-qRound(MLT.profile().fps() * Settings.playerJumpSeconds()));
717691
});
718692
Actions.add("playerBackwardJumpAction", action);
719693

@@ -1289,6 +1263,15 @@ void Player::layoutToolbars()
12891263
}
12901264
}
12911265

1266+
void Player::seekBy(int frames)
1267+
{
1268+
auto newPosition = position() + frames;
1269+
if (MLT.producer() && newPosition != m_requestedPosition) {
1270+
m_requestedPosition = newPosition;
1271+
seek(m_requestedPosition);
1272+
}
1273+
}
1274+
12921275
void Player::showIdleStatus()
12931276
{
12941277
if (Settings.proxyEnabled() && Settings.playerPreviewScale() > 0) {
@@ -1434,20 +1417,12 @@ void Player::onMuteButtonToggled(bool checked)
14341417

14351418
void Player::nextFrame()
14361419
{
1437-
if (MLT.producer() && m_requestedPosition != position() + 1) {
1438-
m_requestedPosition = position() + 1;
1439-
pause(m_requestedPosition);
1440-
seek(m_requestedPosition);
1441-
}
1420+
seekBy(1);
14421421
}
14431422

14441423
void Player::previousFrame()
14451424
{
1446-
if (MLT.producer() && m_requestedPosition != position() - 1) {
1447-
m_requestedPosition = position() - 1;
1448-
pause(m_requestedPosition);
1449-
seek(m_requestedPosition);
1450-
}
1425+
seekBy(-1);
14511426
}
14521427

14531428
void Player::setZoom(float factor, const QIcon &icon)

src/player.h

+1
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ public slots:
127127
double setVolume(int volume);
128128
void setLoopRange(int start, int end);
129129
void layoutToolbars();
130+
void seekBy(int frames);
130131

131132
ScrubBar *m_scrubber;
132133
TimeSpinBox *m_positionSpinner;

0 commit comments

Comments
 (0)