@@ -410,6 +410,7 @@ PlaylistDock::PlaylistDock(QWidget *parent)
410410 m_mainMenu->addAction (Actions[" playlistSetFileDateAction" ]);
411411 m_mainMenu->addAction (Actions[" playlistAddFilesAction" ]);
412412 m_mainMenu->addAction (Actions[" playlistAppendCutAction" ]);
413+ m_mainMenu->addAction (Actions[" playlistLogEventAction" ]);
413414 m_mainMenu->addSeparator ();
414415 QMenu *selectMenu = m_mainMenu->addMenu (tr (" Select" ));
415416 selectMenu->addAction (Actions[" playlistSelectAllAction" ]);
@@ -1199,6 +1200,12 @@ void PlaylistDock::setupActions()
11991200 }
12001201 });
12011202
1203+ action = new QAction (tr (" Log Event" ), this );
1204+ action->setShortcut (QKeySequence (Qt::SHIFT | Qt::Key_E));
1205+ action->setToolTip (tr (" Add an item at the current playback position" ));
1206+ connect (action, &QAction::triggered, this , &PlaylistDock::onLogEventActionTriggered);
1207+ Actions.add (" playlistLogEventAction" , action);
1208+
12021209 action = new QAction (tr (" Search" ), this );
12031210 action->setShortcut (QKeySequence (Qt::CTRL | Qt::ALT | Qt::Key_F));
12041211 connect (action, &QAction::triggered, this , [=]() {
@@ -1595,6 +1602,46 @@ void PlaylistDock::onRemoveActionTriggered()
15951602 }
15961603}
15971604
1605+ void PlaylistDock::onLogEventActionTriggered ()
1606+ {
1607+ Mlt::Producer producer (MLT.isClip () ? MLT.producer () : MLT.savedProducer ());
1608+ if (!producer.is_valid () || MAIN.isSourceClipMyProject ())
1609+ return ;
1610+
1611+ // Get current playback position
1612+ int currentPosition = MLT.producer () && MLT.producer ()->is_valid () ? MLT.producer ()->position ()
1613+ : 0 ;
1614+ double fps = MLT.profile ().fps ();
1615+
1616+ int inPoint = currentPosition - qFloor (3.0 * fps) - 1 ;
1617+ if (inPoint < 0 )
1618+ inPoint = 0 ;
1619+
1620+ int outPoint = currentPosition + qFloor (3.0 * fps);
1621+ int producerLength = producer.get_length ();
1622+ if (outPoint > producerLength - 1 )
1623+ outPoint = producerLength - 1 ;
1624+
1625+ show ();
1626+ raise ();
1627+
1628+ if (!MLT.isLiveProducer (&producer)) {
1629+ ProxyManager::generateIfNotExists (producer);
1630+ assignToBin (producer);
1631+ producer.set_in_and_out (inPoint, outPoint);
1632+ MAIN.undoStack ()->push (new Playlist::AppendCommand (m_model, MLT.XML (&producer)));
1633+ } else {
1634+ DurationDialog durationDialog (this );
1635+ durationDialog.setDuration (outPoint - inPoint + 1 );
1636+ if (durationDialog.exec () == QDialog::Accepted) {
1637+ producer.set (" length" , durationDialog.duration ());
1638+ producer.set_in_and_out (0 , durationDialog.duration () - 1 );
1639+ assignToBin (producer);
1640+ MAIN.undoStack ()->push (new Playlist::AppendCommand (m_model, MLT.XML (&producer)));
1641+ }
1642+ }
1643+ }
1644+
15981645void PlaylistDock::onSetFileDateActionTriggered ()
15991646{
16001647 QModelIndex index = m_proxyModel->mapToSource (m_view->currentIndex ());
0 commit comments