Fix glitch in bin item selection, causing some actions to be disabled

BUG: 420628
parent 2d4f686e
Pipeline #19005 passed with stage
in 9 minutes and 10 seconds
......@@ -1515,6 +1515,7 @@ void Bin::slotDuplicateClip()
}
items << m_itemModel->getBinItemByIndex(m_proxyModel->mapToSource(ix));
}
QString lastId;
for (auto item : items) {
if (item->itemType() == AbstractProjectItem::ClipItem) {
auto currentItem = std::static_pointer_cast<ProjectClip>(item);
......@@ -1535,7 +1536,7 @@ void Bin::slotDuplicateClip()
}
QString id;
m_itemModel->requestAddBinClip(id, xml, item->parent()->clipId(), i18n("Duplicate clip"));
selectClipById(id);
lastId = id;
}
}
} else if (item->itemType() == AbstractProjectItem::SubClipItem) {
......@@ -1543,9 +1544,12 @@ void Bin::slotDuplicateClip()
QString id;
QPoint clipZone = currentItem->zone();
m_itemModel->requestAddBinSubClip(id, clipZone.x(), clipZone.y(), {}, currentItem->getMasterClip()->clipId());
selectClipById(id);
lastId = id;
}
}
if (!lastId.isEmpty()) {
selectClipById(lastId);
}
}
void Bin::setMonitor(Monitor *monitor)
......@@ -1553,7 +1557,9 @@ void Bin::setMonitor(Monitor *monitor)
m_monitor = monitor;
connect(m_monitor, &Monitor::addClipToProject, this, &Bin::slotAddClipToProject);
connect(m_monitor, &Monitor::refreshCurrentClip, this, &Bin::slotOpenCurrent);
connect(this, &Bin::openClip, [&](std::shared_ptr<ProjectClip> clip, int in, int out) { m_monitor->slotOpenClip(clip, in, out); });
connect(this, &Bin::openClip, [&](std::shared_ptr<ProjectClip> clip, int in, int out) {
m_monitor->slotOpenClip(clip, in, out);
});
}
void Bin::setDocument(KdenliveDoc *project)
......@@ -2378,7 +2384,7 @@ void Bin::reloadClip(const QString &id, bool reloadAudio)
void Bin::reloadMonitorIfActive(const QString &id)
{
if (m_monitor->activeClipId() == id) {
if (m_monitor->activeClipId() == id || m_monitor->activeClipId().isEmpty()) {
slotOpenCurrent();
}
}
......@@ -3862,18 +3868,24 @@ void Bin::setCurrent(const std::shared_ptr<AbstractProjectItem> &item)
{
switch (item->itemType()) {
case AbstractProjectItem::ClipItem: {
openProducer(std::static_pointer_cast<ProjectClip>(item));
std::shared_ptr<ProjectClip> clp = std::static_pointer_cast<ProjectClip>(item);
emit requestShowEffectStack(clp->clipName(), clp->m_effectStack, clp->getFrameSize(), false);
if (clp && clp->isReady()) {
openProducer(clp);
emit requestShowEffectStack(clp->clipName(), clp->m_effectStack, clp->getFrameSize(), false);
}
break;
}
case AbstractProjectItem::SubClipItem: {
auto subClip = std::static_pointer_cast<ProjectSubClip>(item);
QPoint zone = subClip->zone();
openProducer(subClip->getMasterClip(), zone.x(), zone.y());
std::shared_ptr<ProjectClip> master = subClip->getMasterClip();
if (master && master->isReady()) {
openProducer(master, zone.x(), zone.y());
}
break;
}
case AbstractProjectItem::FolderItem:
openProducer(nullptr);
default:
break;
}
......
......@@ -166,7 +166,7 @@ Qt::ItemFlags ProjectItemModel::flags(const QModelIndex &index) const
break;
case AbstractProjectItem::ClipItem:
if (!item->statusReady()) {
return Qt::ItemIsSelectable;
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
}
return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | Qt::ItemIsEditable;
break;
......
......@@ -1420,29 +1420,33 @@ void Monitor::slotOpenClip(const std::shared_ptr<ProjectClip> &controller, int i
// we are in record mode, don't display clip
return;
}
m_timePos->setRange(0, (int)m_controller->frameDuration() - 1);
m_glMonitor->setRulerInfo((int)m_controller->frameDuration() - 1, controller->getMarkerModel());
loadQmlScene(MonitorSceneDefault);
updateMarkers();
connect(m_glMonitor->getControllerProxy(), &MonitorProxy::addSnap, this, &Monitor::addSnapPoint, Qt::DirectConnection);
connect(m_glMonitor->getControllerProxy(), &MonitorProxy::removeSnap, this, &Monitor::removeSnapPoint, Qt::DirectConnection);
if (out == -1) {
m_glMonitor->getControllerProxy()->setZone(m_controller->zone(), false);
if (m_controller->isReady()) {
m_timePos->setRange(0, (int)m_controller->frameDuration() - 1);
m_glMonitor->setRulerInfo((int)m_controller->frameDuration() - 1, controller->getMarkerModel());
loadQmlScene(MonitorSceneDefault);
updateMarkers();
connect(m_glMonitor->getControllerProxy(), &MonitorProxy::addSnap, this, &Monitor::addSnapPoint, Qt::DirectConnection);
connect(m_glMonitor->getControllerProxy(), &MonitorProxy::removeSnap, this, &Monitor::removeSnapPoint, Qt::DirectConnection);
if (out == -1) {
m_glMonitor->getControllerProxy()->setZone(m_controller->zone(), false);
} else {
m_glMonitor->getControllerProxy()->setZone(in, out + 1, false);
}
m_snaps->addPoint((int)m_controller->frameDuration() - 1);
// Loading new clip / zone, stop if playing
if (m_playAction->isActive()) {
m_playAction->setActive(false);
}
m_audioMeterWidget->audioChannels = controller->audioInfo() ? controller->audioInfo()->channels() : 0;
if (!m_controller->hasVideo() || KdenliveSettings::displayClipMonitorInfo() & 0x10) {
m_glMonitor->getControllerProxy()->setAudioThumb(m_audioMeterWidget->audioChannels == 0 ? QUrl() : ThumbnailCache::get()->getAudioThumbPath(m_controller->clipId()));
}
m_controller->getMarkerModel()->registerSnapModel(m_snaps);
m_glMonitor->getControllerProxy()->setClipProperties(controller->clipId().toInt(), controller->clipType(), controller->hasAudioAndVideo(), controller->clipName());
m_glMonitor->setProducer(m_controller->originalProducer(), isActive(), in);
} else {
m_glMonitor->getControllerProxy()->setZone(in, out + 1, false);
}
m_snaps->addPoint((int)m_controller->frameDuration() - 1);
// Loading new clip / zone, stop if playing
if (m_playAction->isActive()) {
m_playAction->setActive(false);
}
m_audioMeterWidget->audioChannels = controller->audioInfo() ? controller->audioInfo()->channels() : 0;
if (!m_controller->hasVideo() || KdenliveSettings::displayClipMonitorInfo() & 0x10) {
m_glMonitor->getControllerProxy()->setAudioThumb(m_audioMeterWidget->audioChannels == 0 ? QUrl() : ThumbnailCache::get()->getAudioThumbPath(m_controller->clipId()));
qDebug()<<"*************** CONTROLLER NOT READY";
}
m_controller->getMarkerModel()->registerSnapModel(m_snaps);
m_glMonitor->getControllerProxy()->setClipProperties(controller->clipId().toInt(), controller->clipType(), controller->hasAudioAndVideo(), controller->clipName());
m_glMonitor->setProducer(m_controller->originalProducer(), isActive(), in);
// hasEffects = controller->hasEffects();
} else {
loadQmlScene(MonitorSceneDefault);
......
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