Improve notification of missing(deleted files) and don't allow reloading a mising clip.

Related to #663
parent efe3ee4d
......@@ -148,7 +148,7 @@ public:
enum CLIPSTATUS { StatusReady = 0, StatusMissing, StatusWaiting, StatusDeleting };
void setClipStatus(AbstractProjectItem::CLIPSTATUS status);
virtual void setClipStatus(AbstractProjectItem::CLIPSTATUS status);
AbstractProjectItem::CLIPSTATUS clipStatus() const;
bool statusReady() const;
......
......@@ -214,6 +214,7 @@ public:
painter->setFont(font);
if (type == AbstractProjectItem::ClipItem || type == AbstractProjectItem::SubClipItem) {
int decoWidth = 0;
AbstractProjectItem::CLIPSTATUS clipStatus = (AbstractProjectItem::CLIPSTATUS)index.data(AbstractProjectItem::ClipStatus).toInt();
if (opt.decorationSize.height() > 0) {
r.setWidth(r.height() * pCore->getCurrentDar());
QPixmap pix = opt.icon.pixmap(opt.icon.actualSize(r.size()));
......@@ -225,6 +226,12 @@ public:
}
m_thumbRect = r;
}
if (clipStatus == AbstractProjectItem::StatusMissing) {
painter->save();
painter->setPen(QPen(Qt::red, 3));
painter->drawRect(m_thumbRect);
painter->restore();
}
int mid = (int)((r1.height() / 2));
r1.adjust(decoWidth, 0, 0, -mid);
QRect r2 = option.rect;
......@@ -286,7 +293,6 @@ public:
r.setWidth(bounding.height());
reload.paint(painter, r);
}
int jobProgress = index.data(AbstractProjectItem::JobProgress).toInt();
auto status = index.data(AbstractProjectItem::JobStatus).value<JobManagerStatus>();
if (status == JobManagerStatus::Pending || status == JobManagerStatus::Running) {
......@@ -1394,6 +1400,11 @@ void Bin::slotReloadClip()
}
if (currentItem) {
emit openClip(std::shared_ptr<ProjectClip>());
if (currentItem->clipStatus() == AbstractProjectItem::StatusMissing) {
// Don't attempt to reload missing clip
emit displayBinMessage(i18n("Missing source clip"), KMessageWidget::Warning);
return;
}
if (currentItem->clipType() == ClipType::Playlist) {
// Check if a clip inside playlist is missing
QString path = currentItem->url();
......
......@@ -1197,10 +1197,16 @@ bool ProjectClip::rename(const QString &name, int column)
QVariant ProjectClip::getData(DataType type) const
{
switch (type) {
case AbstractProjectItem::IconOverlay:
return m_effectStack && m_effectStack->rowCount() > 0 ? QVariant("kdenlive-track_has_effect") : QVariant();
default:
return AbstractProjectItem::getData(type);
case AbstractProjectItem::IconOverlay:
if (m_clipStatus == AbstractProjectItem::StatusMissing) {
return QVariant("window-close");
}
if (m_clipStatus == AbstractProjectItem::StatusWaiting) {
return QVariant("view-refresh");
}
return m_effectStack && m_effectStack->rowCount() > 0 ? QVariant("kdenlive-track_has_effect") : QVariant();
default:
return AbstractProjectItem::getData(type);
}
}
......@@ -1480,3 +1486,12 @@ void ProjectClip::setRating(uint rating)
setProducerProperty(QStringLiteral("kdenlive:rating"), (int) rating);
pCore->currentDoc()->setModified(true);
}
void ProjectClip::setClipStatus(AbstractProjectItem::CLIPSTATUS status)
{
AbstractProjectItem::setClipStatus(status);
if (auto ptr = m_model.lock()) {
std::static_pointer_cast<ProjectItemModel>(ptr)->onItemUpdated(std::static_pointer_cast<ProjectClip>(shared_from_this()),
AbstractProjectItem::IconOverlay);
}
}
......@@ -224,6 +224,7 @@ public:
/** @brief Display Bin thumbnail given a percent
*/
void getThumbFromPercent(int percent);
void setClipStatus(AbstractProjectItem::CLIPSTATUS status) override;
protected:
friend class ClipModel;
......
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