Improve handling of missing clips, draw "photo" frame on image clips to...

Improve handling of missing clips, draw "photo" frame on image clips to differentiate from video clips
parent f9638000
......@@ -226,11 +226,24 @@ public:
}
m_thumbRect = r;
}
// Add audio/video icons for selective drag
int cType = index.data(AbstractProjectItem::ClipType).toInt();
if (clipStatus == AbstractProjectItem::StatusMissing) {
painter->save();
painter->setPen(QPen(Qt::red, 3));
painter->drawRect(m_thumbRect);
painter->restore();
} else if (cType == ClipType::Image || cType == ClipType::SlideShow) {
// Draw 'photo' frame to identify image clips
painter->save();
int penWidth = m_thumbRect.height() / 14;
penWidth += penWidth % 2;
painter->setPen(QPen(QColor(255, 255, 255, 160), penWidth));
penWidth /= 2;
painter->drawRoundedRect(m_thumbRect.adjusted(penWidth, penWidth, -penWidth - 1, -penWidth - 1), 4, 4);
painter->setPen(QPen(Qt::black, 1));
painter->drawRoundedRect(m_thumbRect.adjusted(0, 0, -1, -1), 4, 4);
painter->restore();
}
int mid = (int)((r1.height() / 2));
r1.adjust(decoWidth, 0, 0, -mid);
......@@ -265,8 +278,6 @@ public:
}
painter->drawText(r2, Qt::AlignLeft | Qt::AlignTop, subText, &bounding);
// Add audio/video icons for selective drag
int cType = index.data(AbstractProjectItem::ClipType).toInt();
bool hasAudioAndVideo = index.data(AbstractProjectItem::ClipHasAudioAndVideo).toBool();
if (hasAudioAndVideo && (cType == ClipType::AV || cType == ClipType::Playlist) && (opt.state & QStyle::State_MouseOver)) {
bounding.moveLeft(bounding.right() + (2 * textMargin));
......
......@@ -40,11 +40,6 @@ void FileWatcher::addFile(const QString &binId, const QString &url)
if (url.isEmpty()) {
return;
}
QFileInfo check_file(url);
// check if file exists and if yes: Is it really a file and no directory?
if (!check_file.exists() || !check_file.isFile()) {
return;
}
if (m_occurences.count(url) == 0) {
m_fileWatcher->addFile(url);
}
......
......@@ -82,7 +82,11 @@ ProjectClip::ProjectClip(const QString &id, const QIcon &thumb, const std::share
, ClipController(id, std::move(producer))
{
m_markerModel = std::make_shared<MarkerListModel>(id, pCore->projectManager()->undoStack());
m_clipStatus = StatusReady;
if (producer->get_int("_placeholder") == 1 || producer->get_int("_missingsource") == 1) {
m_clipStatus = StatusMissing;
} else {
m_clipStatus = StatusReady;
}
m_name = clipName();
m_duration = getStringDuration();
m_inPoint = 0;
......
......@@ -1079,7 +1079,11 @@ void ProjectItemModel::updateWatcher(const std::shared_ptr<ProjectClip> &clipIte
if (clipItem->clipType() == ClipType::AV || clipItem->clipType() == ClipType::Audio || clipItem->clipType() == ClipType::Image ||
clipItem->clipType() == ClipType::Video || clipItem->clipType() == ClipType::Playlist || clipItem->clipType() == ClipType::TextTemplate) {
m_fileWatcher->removeFile(clipItem->clipId());
m_fileWatcher->addFile(clipItem->clipId(), clipItem->clipUrl());
QFileInfo check_file(clipItem->clipUrl());
// check if file exists and if yes: Is it really a file and no directory?
if ((check_file.exists() && check_file.isFile()) || clipItem->clipStatus() == AbstractProjectItem::StatusMissing) {
m_fileWatcher->addFile(clipItem->clipId(), clipItem->clipUrl());
}
}
}
......
......@@ -606,6 +606,7 @@ bool DocumentChecker::hasErrorInClips()
if (missingPaths.contains(realPath)) {
// Proxy AND source missing
setProperty(mltProd, QStringLiteral("_placeholder"), QStringLiteral("1"));
setProperty(mltProd, QStringLiteral("kdenlive:orig_service"), Xml::getXmlProperty(mltProd, "mlt_service"));
}
}
}
......
......@@ -63,6 +63,13 @@ ClipController::ClipController(const QString &clipId, const std::shared_ptr<Mlt:
if (m_properties) {
setProducerProperty(QStringLiteral("kdenlive:id"), m_controllerBinId);
m_service = m_properties->get("mlt_service");
if (m_service == QLatin1String("qtext")) {
// Placeholder clip, find real service
QString originalService = m_properties->get("kdenlive:orig_service");
if (!originalService.isEmpty()) {
m_service = originalService;
}
}
QString proxy = m_properties->get("kdenlive:proxy");
QString path = m_properties->get("resource");
if (proxy.length() > 2) {
......@@ -653,7 +660,7 @@ void ClipController::checkAudioVideo()
{
QReadLocker lock(&m_producerLock);
m_masterProducer->seek(0);
if (m_masterProducer->get_int("_placeholder") == 1 || m_masterProducer->get_int("_missingsource") == 1 || m_masterProducer->get("text") == QLatin1String("INVALID")) {
if (m_masterProducer->get_int("_placeholder") == 1 || m_masterProducer->get_int("_missingsource") == 1) {
// This is a placeholder file, try to guess from its properties
QString orig_service = m_masterProducer->get("kdenlive:orig_service");
if (orig_service.startsWith(QStringLiteral("avformat")) || (m_masterProducer->get_int("audio_index") + m_masterProducer->get_int("video_index") > 0)) {
......
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