@@ -639,81 +639,55 @@ void Player::setupActions()
639
639
640
640
action = new QAction (tr (" Forward One Second" ), this );
641
641
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 ())); });
646
643
Actions.add (" playerForwardOneSecondAction" , action);
647
644
648
645
action = new QAction (tr (" Backward One Second" ), this );
649
646
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 ())); });
654
648
Actions.add (" playerBackwardOneSecondAction" , action);
655
649
656
650
action = new QAction (tr (" Forward Two Seconds" ), this );
657
651
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 ())); });
662
653
Actions.add (" playerForwardTwoSecondsAction" , action);
663
654
664
655
action = new QAction (tr (" Backward Two Seconds" ), this );
665
656
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 ())); });
670
658
Actions.add (" playerBackwardTwoAction" , action);
671
659
672
660
action = new QAction (tr (" Forward Five Seconds" ), this );
673
661
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 ())); });
678
663
Actions.add (" playerForwardFiveSecondsAction" , action);
679
664
680
665
action = new QAction (tr (" Backward Five Seconds" ), this );
681
666
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 ())); });
686
668
Actions.add (" playerBackwardFiveSecondsAction" , action);
687
669
688
670
action = new QAction (tr (" Forward Ten Seconds" ), this );
689
671
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 ())); });
694
673
Actions.add (" playerForwardTenSecondsAction" , action);
695
674
696
675
action = new QAction (tr (" Backward Ten Seconds" ), this );
697
676
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 ())); });
702
678
Actions.add (" playerBackwardTenSecondsAction" , action);
703
679
704
680
action = new QAction (tr (" Forward Jump" ), this );
705
681
action->setShortcut (QKeySequence (Qt::ALT | Qt::Key_PageDown));
706
682
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 ()));
709
684
});
710
685
Actions.add (" playerForwardJumpAction" , action);
711
686
712
687
action = new QAction (tr (" Backward Jump" ), this );
713
688
action->setShortcut (QKeySequence (Qt::ALT | Qt::Key_PageUp));
714
689
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 ()));
717
691
});
718
692
Actions.add (" playerBackwardJumpAction" , action);
719
693
@@ -1289,6 +1263,15 @@ void Player::layoutToolbars()
1289
1263
}
1290
1264
}
1291
1265
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
+
1292
1275
void Player::showIdleStatus ()
1293
1276
{
1294
1277
if (Settings.proxyEnabled () && Settings.playerPreviewScale () > 0 ) {
@@ -1434,20 +1417,12 @@ void Player::onMuteButtonToggled(bool checked)
1434
1417
1435
1418
void Player::nextFrame ()
1436
1419
{
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 );
1442
1421
}
1443
1422
1444
1423
void Player::previousFrame ()
1445
1424
{
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 );
1451
1426
}
1452
1427
1453
1428
void Player::setZoom (float factor, const QIcon &icon)
0 commit comments