Focus clip monitor when adding clip to blank project

parent a08186a1
......@@ -2007,34 +2007,33 @@ void Bin::slotProducerReady(const requestClipInfo &info, std::shared_ptr<Mlt::Pr
// Start proxy
m_doc->slotProxyCurrentItem(true, {clip});
}
} else {
emit producerReady(info.clipId);
}
} else {
emit producerReady(info.clipId);
}
QString currentClip = m_monitor->activeClipId();
if (currentClip.isEmpty()) {
// No clip displayed in monitor, check if item is selected
QModelIndexList indexes = m_proxyModel->selectionModel()->selectedIndexes();
if (indexes.isEmpty()) {
// No clip selected, focus this new one
emit openClip(std::shared_ptr<ProjectClip>());
setCurrent(clip);
} else {
for (const QModelIndex &ix : indexes) {
if (!ix.isValid() || ix.column() != 0) {
continue;
}
std::shared_ptr<AbstractProjectItem> item = m_itemModel->getBinItemByIndex(m_proxyModel->mapToSource(ix));
if ((item != nullptr) && item->clipId() == info.clipId) {
// Item was selected, show it in monitor
setCurrent(item);
break;
QString currentClip = m_monitor->activeClipId();
if (currentClip.isEmpty()) {
// No clip displayed in monitor, check if item is selected
QModelIndexList indexes = m_proxyModel->selectionModel()->selectedIndexes();
if (indexes.isEmpty()) {
// No clip selected, focus this new one
selectClip(clip);
} else {
for (const QModelIndex &ix : indexes) {
if (!ix.isValid() || ix.column() != 0) {
continue;
}
std::shared_ptr<AbstractProjectItem> item = m_itemModel->getBinItemByIndex(m_proxyModel->mapToSource(ix));
if ((item != nullptr) && item->clipId() == info.clipId) {
// Item was selected, show it in monitor
setCurrent(item);
break;
}
}
}
} else if (currentClip == info.clipId) {
emit openClip(std::shared_ptr<ProjectClip>());
setCurrent(clip);
}
} else if (currentClip == info.clipId) {
emit openClip(std::shared_ptr<ProjectClip>());
setCurrent(clip);
}
} else {
// Clip not found, create it
......@@ -2066,6 +2065,21 @@ void Bin::slotProducerReady(const requestClipInfo &info, std::shared_ptr<Mlt::Pr
}
}
void Bin::selectClip(const std::shared_ptr<ProjectClip> &clip)
{
QModelIndex ix = m_itemModel->getIndexFromItem(clip);
int row = ix.row();
const QModelIndex id = m_itemModel->index(row, 0, ix.parent());
const QModelIndex id2 = m_itemModel->index(row, m_itemModel->columnCount() - 1, ix.parent());
if (id.isValid() && id2.isValid()) {
m_proxyModel->selectionModel()->select(QItemSelection(m_proxyModel->mapFromSource(id), m_proxyModel->mapFromSource(id2)), QItemSelectionModel::Select);
}
selectProxyModel(m_proxyModel->mapFromSource(ix));
m_itemView->scrollTo(m_proxyModel->mapFromSource(ix));
pCore->monitorManager()->activateMonitor(Kdenlive::ClipMonitor);
emit openClip(clip);
}
void Bin::slotOpenCurrent()
{
std::shared_ptr<ProjectClip> currentItem = getFirstSelectedClip();
......
......@@ -443,7 +443,7 @@ protected:
(for ex request to show the clip in the monitor)
*/
void setCurrent(std::shared_ptr<AbstractProjectItem> item);
void selectClip(const std::shared_ptr<ProjectClip> &clip);
void contextMenuEvent(QContextMenuEvent *event) override;
bool eventFilter(QObject *obj, QEvent *event) override;
......
......@@ -1956,6 +1956,7 @@ void MainWindow::connectDocument()
connect(project, &KdenliveDoc::startAutoSave, pCore->projectManager(), &ProjectManager::slotStartAutoSave);
connect(project, &KdenliveDoc::reloadEffects, this, &MainWindow::slotReloadEffects);
KdenliveSettings::setProject_fps(pCore->getCurrentFps());
m_clipMonitorDock->raise();
// TODO REFAC: reconnect to new timeline
/*
......
......@@ -553,8 +553,8 @@ void ClipController::loadSnapMarker(const QString &seconds, const QString &hash)
{
QLocale locale;
// Make sure to get an integer frame since markers are stored in seconds
int frame = GenTime(locale.toDouble(seconds)).frames(m_binController->fps());
GenTime markerTime(frame, m_binController->fps());
int frame = GenTime(locale.toDouble(seconds)).frames(pCore->getCurrentFps());
GenTime markerTime(frame, pCore->getCurrentFps());
CommentedTime marker(hash, markerTime);
if (m_snapMarkers.contains(marker)) {
m_snapMarkers.removeAll(marker);
......
......@@ -232,8 +232,7 @@ void ProjectManager::newFile(bool showProjectSettings, bool force)
}
}
emit docOpened(m_project);
// pCore->monitorManager()->activateMonitor(Kdenlive::ClipMonitor);
// m_trackView->projectView()->setFocus();
//pCore->monitorManager()->activateMonitor(Kdenlive::ClipMonitor);
m_lastSave.start();
}
......
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