Fix edit duration from timeline menu not connected

parent 884ad0a2
Pipeline #3571 passed with stage
in 20 minutes and 30 seconds
......@@ -2215,7 +2215,7 @@ void MainWindow::slotAddClipMarker()
std::shared_ptr<ProjectClip> clip(nullptr);
GenTime pos;
if (m_projectMonitor->isActive()) {
int selectedClip = getMainTimeline()->controller()->getMainSelectedClip();
int selectedClip = getMainTimeline()->controller()->getMainSelectedItem();
if (selectedClip > -1) {
getMainTimeline()->controller()->addMarker(selectedClip);
return;
......@@ -2237,7 +2237,7 @@ void MainWindow::slotDeleteClipMarker(bool allowGuideDeletion)
std::shared_ptr<ProjectClip> clip(nullptr);
GenTime pos;
if (m_projectMonitor->isActive()) {
int selectedClip = getMainTimeline()->controller()->getMainSelectedClip();
int selectedClip = getMainTimeline()->controller()->getMainSelectedItem();
if (selectedClip > -1) {
getMainTimeline()->controller()->deleteMarker(selectedClip);
return;
......@@ -2269,7 +2269,7 @@ void MainWindow::slotDeleteAllClipMarkers()
{
std::shared_ptr<ProjectClip> clip(nullptr);
if (m_projectMonitor->isActive()) {
int selectedClip = getMainTimeline()->controller()->getMainSelectedClip();
int selectedClip = getMainTimeline()->controller()->getMainSelectedItem();
if (selectedClip > -1) {
getMainTimeline()->controller()->deleteAllMarkers(selectedClip);
return;
......@@ -2293,7 +2293,7 @@ void MainWindow::slotEditClipMarker()
std::shared_ptr<ProjectClip> clip(nullptr);
GenTime pos;
if (m_projectMonitor->isActive()) {
int selectedClip = getMainTimeline()->controller()->getMainSelectedClip();
int selectedClip = getMainTimeline()->controller()->getMainSelectedItem();
if (selectedClip > -1) {
getMainTimeline()->controller()->editMarker(selectedClip);
return;
......@@ -2335,7 +2335,7 @@ void MainWindow::slotAddMarkerGuideQuickly()
CommentedTime marker(pos, pCore->currentDoc()->timecode().getDisplayTimecode(pos, false), KdenliveSettings::default_marker_type());
clip->getMarkerModel()->addMarker(marker.time(), marker.comment(), marker.markerType());
} else {
int selectedClip = getMainTimeline()->controller()->getMainSelectedClip();
int selectedClip = getMainTimeline()->controller()->getMainSelectedItem();
if (selectedClip == -1) {
// Add timeline guide
getMainTimeline()->controller()->switchGuide();
......@@ -2535,12 +2535,7 @@ void MainWindow::slotUnGroupClips()
void MainWindow::slotEditItemDuration()
{
// TODO refac
/*
if (pCore->projectManager()->currentTimeline()) {
pCore->projectManager()->currentTimeline()->projectView()->editItemDuration();
}
*/
getCurrentTimeline()->controller()->editItemDuration();
}
void MainWindow::slotAddProjectClip(const QUrl &url, const QString &folderInfo)
......
......@@ -411,7 +411,7 @@ void TimelineController::deleteSelectedClips()
m_model->requestItemDeletion(*sel.begin());
}
int TimelineController::getMainSelectedClip()
int TimelineController::getMainSelectedItem(bool restrictToCurrentPos, bool allowComposition)
{
auto sel = m_model->getCurrentSelection();
if (sel.empty() || sel.size() > 2) {
......@@ -424,6 +424,11 @@ int TimelineController::getMainSelectedClip()
return -1;
}
}
if (!restrictToCurrentPos) {
if (m_model->isClip(itemId) || (allowComposition && m_model->isComposition(itemId))) {
return itemId;
}
}
if (m_model->isClip(itemId)) {
int position = timelinePosition();
int start = m_model->getClipPosition(itemId);
......@@ -1914,6 +1919,13 @@ double TimelineController::fps() const
void TimelineController::editItemDuration(int id)
{
if (id == -1) {
id = getMainSelectedItem(false, true);
}
if (id == -1) {
pCore->displayMessage(i18n("No item to edit"), InformationMessage, 500);
return;
}
int start = m_model->getItemPosition(id);
int in = 0;
int duration = m_model->getItemPlaytime(id);
......@@ -2057,6 +2069,9 @@ void TimelineController::grabCurrent()
return;
}
int id = *m_model->getCurrentSelection().begin();
while (m_model->isGroup(id)) {
id = *m_model->m_groups->getLeaves(id).begin();
}
if (m_model->isClip(id)) {
std::shared_ptr<ClipModel> clip = m_model->getClipPtr(id);
clip->setGrab(!clip->isGrabbed());
......
......@@ -82,7 +82,7 @@ public:
void setRoot(QQuickItem *root);
/** @brief Edit an item's in/out points with a dialog
*/
Q_INVOKABLE void editItemDuration(int itemId);
Q_INVOKABLE void editItemDuration(int itemId = -1);
/** @brief Returns the topmost track containing a selected item (-1 if selection is embty) */
Q_INVOKABLE int selectedTrack() const;
......@@ -209,9 +209,11 @@ public:
Q_INVOKABLE void triggerAction(const QString &name);
/* @brief Returns id of the timeline selcted clip if there is only 1 clip selected
* or an AVSplit group. Returns -1 otherwise
* or an AVSplit group. If allowComposition is true, returns composition id if
* only 1 is selected, otherwise returns -1. If restrictToCurrentPos is true, it will
* only return the id if timeline cursor is inside item
*/
int getMainSelectedClip();
int getMainSelectedItem(bool restrictToCurrentPos = true, bool allowComposition = false);
/* @brief Do we want to display video thumbnails
*/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment