Fix timeline thumbnail for image/title clips sometimes missing, small optimisations

parent caf51309
......@@ -272,6 +272,7 @@ void ProjectClip::setThumbnail(QImage img)
p.drawText(r, Qt::AlignCenter, i18nc("The first letter of Proxy, used as abbreviation", "P"));
}
m_thumbnail = QIcon(thumb);
emit thumbUpdated(img);
bin()->emitItemUpdated(this);
}
......
......@@ -239,6 +239,7 @@ signals:
void refreshAnalysisPanel();
void refreshClipDisplay();
void thumbReady(int, QImage);
void thumbUpdated(QImage);
void updateJobStatus(int jobType, int status, int progress = 0, const QString &statusMessage = QString());
};
......
......@@ -102,7 +102,8 @@ ClipItem::ClipItem(ProjectClip *clip, const ItemInfo& info, double fps, double s
m_baseColor = m_binClip->getProducerColorProperty("resource");
} else if (m_clipType == Image || m_clipType == Text) {
m_baseColor = QColor(141, 166, 215);
m_startPix = m_binClip->thumbnail(rect().height(), frame_width);
m_startPix = m_binClip->thumbnail(frame_width, rect().height());
connect(m_binClip, SIGNAL(thumbUpdated(QImage)), this, SLOT(slotUpdateThumb(QImage)));
//connect(m_clip->thumbProducer(), SIGNAL(thumbReady(int,QImage)), this, SLOT(slotThumbReady(int,QImage)));
} else if (m_clipType == Audio) {
m_baseColor = QColor(141, 215, 166);
......@@ -428,6 +429,10 @@ QDomElement ClipItem::selectedEffect()
void ClipItem::resetThumbs(bool clearExistingThumbs)
{
if (m_clipType == Image || m_clipType || Text || m_clipType == Color || m_clipType == Audio) {
// These clip thumbnails are linked to bin thumbnail, not dynamic, nothing to do
return;
}
if (clearExistingThumbs) {
m_startPix = QPixmap();
m_endPix = QPixmap();
......@@ -458,7 +463,9 @@ void ClipItem::refreshClip(bool checkDuration, bool forceResetThumbs)
m_baseColor = m_binClip->getProducerColorProperty("resource");
m_paintColor = m_baseColor;
update();
} else if (KdenliveSettings::videothumbnails()) resetThumbs(forceResetThumbs);
} else if (KdenliveSettings::videothumbnails()) {
resetThumbs(forceResetThumbs);
}
}
void ClipItem::slotFetchThumbs()
......@@ -2064,3 +2071,9 @@ void ClipItem::updateState(const QString &id)
}
}
void ClipItem::slotUpdateThumb(QImage img)
{
m_startPix = QPixmap::fromImage(img);
update();
}
......@@ -248,6 +248,8 @@ private slots:
void slotSetStartThumb(const QImage &img);
void slotSetEndThumb(const QImage &img);
void slotThumbReady(int frame, const QImage &img);
/** @brief For fixed thumbnail clip (image / titles), update thumb to reflect bin thumbnail. */
void slotUpdateThumb(QImage);
/** @brief Something changed a detail in clip (thumbs, markers,...), repaint. */
void slotRefreshClip();
......
......@@ -273,7 +273,6 @@ void CustomTrackView::updateSceneFrameWidth()
if (itemList.at(i)->type() == AVWidget) {
item = static_cast<ClipItem*>(itemList.at(i));
item->resetFrameWidth(frameWidth);
item->resetThumbs(true);
}
}
}
......@@ -303,7 +302,6 @@ bool CustomTrackView::checkTrackHeight(bool force)
item->setPos((qreal) item->startPos().frames(m_document->fps()), getPositionFromTrack(item->track()) + 1);
m_scene->addItem(item);
item->resetFrameWidth(frameWidth);
item->resetThumbs(true);
} else if (itemList.at(i)->type() == TransitionWidget) {
transitionitem = static_cast<Transition*>(itemList.at(i));
transitionitem->setRect(0, 0, transitionitem->rect().width(), m_tracksHeight / 3 * 2 - 1);
......
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