Skip to content

Commit 0b6a29e

Browse files
committed
fix key repeat for Previous/Next Frame
https://forum.shotcut.org/t/keyboard-repeat-ignored/47633
1 parent 0a65995 commit 0b6a29e

File tree

3 files changed

+27
-16
lines changed

3 files changed

+27
-16
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->seek(m_player->position() - 1);
2589+
m_player->nextFrame();
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->seek(m_player->position() + 1);
2600+
m_player->previousFrame();
26012601
else
26022602
m_player->fastForward(false);
26032603
}

src/player.cpp

+21-13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2012-2024 Meltytech, LLC
2+
* Copyright (c) 2012-2025 Meltytech, LLC
33
*
44
* This program is free software: you can redistribute it and/or modify
55
* it under the terms of the GNU General Public License as published by
@@ -628,23 +628,13 @@ void Player::setupActions()
628628
action = new QAction(tr("Next Frame"), this);
629629
action->setProperty(Actions.hardKeyProperty, "K+L");
630630
action->setShortcut(QKeySequence(Qt::Key_Right));
631-
connect(action, &QAction::triggered, this, [&]() {
632-
if (MLT.producer()) {
633-
pause(position() + 1);
634-
seek(position() + 1);
635-
}
636-
});
631+
connect(action, &QAction::triggered, this, &Player::nextFrame);
637632
Actions.add("playerNextFrameAction", action);
638633

639634
action = new QAction(tr("Previous Frame"), this);
640635
action->setProperty(Actions.hardKeyProperty, "K+J");
641636
action->setShortcut(QKeySequence(Qt::Key_Left));
642-
connect(action, &QAction::triggered, this, [&]() {
643-
if (MLT.producer()) {
644-
pause(position() - 1);
645-
seek(position() - 1);
646-
}
647-
});
637+
connect(action, &QAction::triggered, this, &Player::previousFrame);
648638
Actions.add("playerPreviousFrameAction", action);
649639

650640
action = new QAction(tr("Forward One Second"), this);
@@ -1442,6 +1432,24 @@ void Player::onMuteButtonToggled(bool checked)
14421432
m_volumePopup->hide();
14431433
}
14441434

1435+
void Player::nextFrame()
1436+
{
1437+
if (MLT.producer() && m_requestedPosition != position() + 1) {
1438+
m_requestedPosition = position() + 1;
1439+
pause(m_requestedPosition);
1440+
seek(m_requestedPosition);
1441+
}
1442+
}
1443+
1444+
void Player::previousFrame()
1445+
{
1446+
if (MLT.producer() && m_requestedPosition != position() - 1) {
1447+
m_requestedPosition = position() - 1;
1448+
pause(m_requestedPosition);
1449+
seek(m_requestedPosition);
1450+
}
1451+
}
1452+
14451453
void Player::setZoom(float factor, const QIcon &icon)
14461454
{
14471455
emit zoomChanged(factor);

src/player.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2012-2024 Meltytech, LLC
2+
* Copyright (c) 2012-2025 Meltytech, LLC
33
*
44
* This program is free software: you can redistribute it and/or modify
55
* it under the terms of the GNU General Public License as published by
@@ -113,6 +113,8 @@ public slots:
113113
void showIdleStatus();
114114
void focusPositionSpinner() const;
115115
void onMuteButtonToggled(bool checked);
116+
void nextFrame();
117+
void previousFrame();
116118

117119
protected:
118120
void resizeEvent(QResizeEvent *event) override;
@@ -172,6 +174,7 @@ public slots:
172174
DockToolBar *m_inSelectedToolBar;
173175
QHBoxLayout *m_toolRow1;
174176
QHBoxLayout *m_toolRow2;
177+
int m_requestedPosition{0};
175178

176179
private slots:
177180
void updateSelection();

0 commit comments

Comments
 (0)