Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Fix usage count in bin, clip rename and start work on timeline update when bin...

Fix usage count in bin, clip rename and start work on timeline update when bin clip changes (color, thumbnails)
parent 56af7dc8
......@@ -23,6 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "projectclip.h"
#include "core.h"
#include "doc/docundostack.hpp"
#include "bin.h"
#include "doc/kdenlivedoc.h"
#include "doc/kthumb.h"
#include "kdenlivesettings.h"
......@@ -312,7 +313,7 @@ void ProjectClip::setThumbnail(const QImage &img)
p.drawText(r, Qt::AlignCenter, i18nc("The first letter of Proxy, used as abbreviation", "P"));
}
m_thumbnail = QIcon(thumb);
emit thumbUpdated(img);
updateTimelineClips(QVector<int>() << TimelineModel::ReloadThumb);
if (auto ptr = m_model.lock()) std::static_pointer_cast<ProjectItemModel>(ptr)->onItemUpdated(std::static_pointer_cast<ProjectClip>(shared_from_this()));
}
......@@ -550,8 +551,11 @@ void ProjectClip::setProperties(const QMap<QString, QString> &properties, bool r
if (properties.contains(QStringLiteral("kdenlive:clipname"))) {
m_name = properties.value(QStringLiteral("kdenlive:clipname"));
refreshPanel = true;
if (auto ptr = m_model.lock())
if (auto ptr = m_model.lock()) {
std::static_pointer_cast<ProjectItemModel>(ptr)->onItemUpdated(std::static_pointer_cast<ProjectClip>(shared_from_this()));
}
// update timeline clips
updateTimelineClips(QVector<int>() << TimelineModel::NameRole);
}
if (refreshPanel) {
// Some of the clip properties have changed through a command, update properties panel
......@@ -645,8 +649,7 @@ bool ProjectClip::rename(const QString &name, int column)
break;
}
if (edited) {
// TODO refac
//if (auto ptr = m_model.lock()) std::static_pointer_cast<ProjectItemModel>(ptr)->bin()->slotEditClipCommand(m_binId, oldProperites, newProperites);
pCore->bin()->slotEditClipCommand(m_binId, oldProperites, newProperites);
}
return edited;
}
......@@ -1221,12 +1224,14 @@ void ProjectClip::registerTimelineClip(std::weak_ptr<TimelineModel> timeline, in
Q_ASSERT(m_registeredClips.count(clipId) == 0);
Q_ASSERT(!timeline.expired());
m_registeredClips[clipId] = std::move(timeline);
setRefCount(m_registeredClips.size());
}
void ProjectClip::deregisterTimelineClip(int clipId)
{
Q_ASSERT(m_registeredClips.count(clipId) > 0);
m_registeredClips.erase(clipId);
setRefCount(m_registeredClips.size());
}
QList <int> ProjectClip::timelineInstances() const
......@@ -1268,3 +1273,16 @@ void ProjectClip::replaceInTimeline()
}
}
}
void ProjectClip::updateTimelineClips(QVector<int> roles)
{
for (const auto &clip : m_registeredClips) {
if (auto timeline = clip.second.lock()) {
timeline->requestClipUpdate(clip.first, roles);
} else {
qDebug() << "Error while reloading clip thumb: timeline unavailable";
Q_ASSERT(false);
return;
}
}
}
......@@ -241,6 +241,7 @@ private:
const QString geometryWithOffset(const QString &data, int offset);
void doExtractImage();
void doExtractIntra();
void updateTimelineClips(QVector<int> roles);
std::map<int, std::weak_ptr<TimelineModel>> m_registeredClips;
......@@ -254,7 +255,6 @@ signals:
void refreshAnalysisPanel();
void refreshClipDisplay();
void thumbReady(int, const QImage &);
void thumbUpdated(const QImage &);
void updateJobStatus(int jobType, int status, int progress = 0, const QString &statusMessage = QString());
/** @brief Clip is ready, load properties. */
void loadPropertiesPanel();
......
......@@ -313,7 +313,7 @@ std::shared_ptr<Mlt::Producer> BinController::getBinProducer(const QString &id)
{
// TODO: framebuffer speed clips
if (!m_clipList.contains(id)) {
qDebug() << "ERROR: requesting invalid bin producer";
qDebug() << "ERROR: requesting invalid bin producer: "<<id;
return nullptr;
}
return m_clipList[id]->originalProducer();
......
......@@ -102,7 +102,7 @@ ClipItem::ClipItem(ProjectClip *clip, const ItemInfo &info, double fps, double s
} else if (m_clipType == Image || m_clipType == Text || m_clipType == QText || m_clipType == TextTemplate) {
m_baseColor = QColor(141, 166, 215);
m_startPix = m_binClip->thumbnail(frame_width, rect().height());
connect(m_binClip, SIGNAL(thumbUpdated(QImage)), this, SLOT(slotUpdateThumb(QImage)));
//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);
......
......@@ -193,6 +193,7 @@ QHash<int, QByteArray> TimelineItemModel::roleNames() const
roles[ItemIdRole] = "item";
roles[ItemATrack] = "a_track";
roles[HasAudio] = "hasAudio";
roles[ReloadThumb] = "reloadThumb";
return roles;
}
......@@ -263,6 +264,8 @@ QVariant TimelineItemModel::data(const QModelIndex &index, int role) const
return clip->fadeIn();
case FadeOutRole:
return clip->fadeOut();
case ReloadThumb:
return false;
default:
break;
}
......
......@@ -1747,3 +1747,9 @@ void TimelineModel::requestClipReload(int clipId)
getTrackById(old_trackId)->requestClipInsertion(clipId, oldPos, false, local_undo, local_redo);
}
}
void TimelineModel::requestClipUpdate(int clipId, QVector<int> roles)
{
QModelIndex modelIndex = makeClipIndexFromID(clipId);
notifyChange(modelIndex, modelIndex, roles);
}
......@@ -128,6 +128,7 @@ public:
IsCompositionRole, /// clip only
FileHashRole, /// clip only
SpeedRole, /// clip only
ReloadThumb, /// clip only
ItemATrack, /// composition only
ItemIdRole
};
......@@ -473,6 +474,7 @@ public:
virtual void adjustAssetRange(int clipId, int in, int out);
void requestClipReload(int clipId);
void requestClipUpdate(int clipId, QVector<int> roles);
/** @brief Returns the effectstack of a given clip. */
std::shared_ptr<EffectStackModel> getClipEffectStack(int itemId);
......
......@@ -55,6 +55,7 @@ Rectangle {
property string hash: 'ccc' //TODO
property double speed: 1.0
property color borderColor: 'black'
property bool reloadThumb: false
width : clipDuration * timeScale;
signal clicked(var clip, int shiftClick)
......@@ -74,6 +75,11 @@ Rectangle {
x = modelStart * timeScale;
}
onReloadThumbChanged: {
console.log('qml thb rld')
color = Qt.darker(getColor())
}
onTimeScaleChanged: {
x = modelStart * timeScale;
width = clipDuration * timeScale;
......
......@@ -96,6 +96,12 @@ Column{
value: model.fadeIn
when: loader.status == Loader.Ready && !loader.item.isComposition
}
Binding {
target: loader.item
property: "reloadThumb"
value: model.reloadThumb
when: loader.status == Loader.Ready && !loader.item.isComposition
}
Binding {
target: loader.item
property: "fadeOut"
......@@ -115,7 +121,6 @@ Column{
value: root.trackHeight
when: loader.status == Loader.Ready && loader.item.isComposition
}
Binding {
target: loader.item
property: "clipDuration"
......@@ -140,6 +145,12 @@ Column{
value: model.grouped
when: loader.status == Loader.Ready
}
Binding {
target: loader.item
property: "clipName"
value: model.name
when: loader.status == Loader.Ready
}
sourceComponent: {
if (model.isComposition) {
return compositionDelegate
......@@ -149,7 +160,6 @@ Column{
}
onLoaded: {
console.log('loaded clip: ', model.start)
item.clipName= model.name
item.clipResource= model.resource
item.clipId= model.item
item.binId= model.binId
......
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