Commit 20311cb5 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Add new option to apply bin tag color to timeline clips, enabled by default

parent 2f9edda6
Pipeline #38519 canceled with stage
......@@ -1159,13 +1159,14 @@ void ProjectClip::setProperties(const QMap<QString, QString> &properties, bool r
refreshOnly = false;
reload = true;
}
QVector <int> refreshRoles;
if (properties.contains(QStringLiteral("kdenlive:tags"))) {
setTags(properties.value(QStringLiteral("kdenlive:tags")));
if (auto ptr = m_model.lock()) {
std::static_pointer_cast<ProjectItemModel>(ptr)->onItemUpdated(std::static_pointer_cast<ProjectClip>(shared_from_this()),
AbstractProjectItem::DataTag);
}
refreshRoles << TimelineModel::TagRole;
}
if (properties.contains(QStringLiteral("kdenlive:clipname"))) {
m_name = properties.value(QStringLiteral("kdenlive:clipname"));
......@@ -1174,10 +1175,11 @@ void ProjectClip::setProperties(const QMap<QString, QString> &properties, bool r
std::static_pointer_cast<ProjectItemModel>(ptr)->onItemUpdated(std::static_pointer_cast<ProjectClip>(shared_from_this()),
AbstractProjectItem::DataName);
}
// update timeline clips
if (!reload) {
updateTimelineClips({TimelineModel::NameRole});
}
refreshRoles << TimelineModel::NameRole;
}
// update timeline clips
if (!reload) {
updateTimelineClips(refreshRoles);
}
bool audioStreamChanged = properties.contains(QStringLiteral("audio_index"));
if (reload) {
......
......@@ -784,8 +784,8 @@
<default>true</default>
</entry>
<entry name="automatictransitions" type="Bool">
<label>New transitions are automatic transitions.</label>
<entry name="tagsintimeline" type="Bool">
<label>Show color tags in timeline.</label>
<default>true</default>
</entry>
......
......@@ -1195,11 +1195,11 @@ void MainWindow::setupActions()
m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
connect(m_buttonSnap, &QAction::triggered, this, &MainWindow::slotSwitchSnap);
m_buttonAutomaticTransition = new QAction(QIcon::fromTheme(QStringLiteral("auto-transition")), i18n("Automatic transitions"), this);
m_buttonTimelineTags = new QAction(QIcon::fromTheme(QStringLiteral("tag")), i18n("Show color tags in timeline"), this);
m_buttonAutomaticTransition->setCheckable(true);
m_buttonAutomaticTransition->setChecked(KdenliveSettings::automatictransitions());
connect(m_buttonAutomaticTransition, &QAction::triggered, this, &MainWindow::slotSwitchAutomaticTransition);
m_buttonTimelineTags->setCheckable(true);
m_buttonTimelineTags->setChecked(KdenliveSettings::tagsintimeline());
connect(m_buttonTimelineTags, &QAction::triggered, this, &MainWindow::slotShowTimelineTags);
m_buttonFitZoom = new QAction(QIcon::fromTheme(QStringLiteral("zoom-fit-best")), i18n("Fit zoom to project"), this);
......@@ -1240,7 +1240,7 @@ void MainWindow::setupActions()
toolbar->addWidget(m_trimLabel);
toolbar->addAction(m_buttonAutomaticTransition);
toolbar->addAction(m_buttonTimelineTags);
toolbar->addAction(m_buttonVideoThumbs);
toolbar->addAction(m_buttonAudioThumbs);
toolbar->addAction(m_buttonShowMarkers);
......@@ -1273,7 +1273,7 @@ void MainWindow::setupActions()
addAction(QStringLiteral("razor_tool"), m_buttonRazorTool, Qt::Key_X);
addAction(QStringLiteral("spacer_tool"), m_buttonSpacerTool, Qt::Key_M);
addAction(QStringLiteral("automatic_transition"), m_buttonAutomaticTransition);
addAction(QStringLiteral("automatic_transition"), m_buttonTimelineTags);
addAction(QStringLiteral("show_video_thumbs"), m_buttonVideoThumbs);
addAction(QStringLiteral("show_audio_thumbs"), m_buttonAudioThumbs);
addAction(QStringLiteral("show_markers"), m_buttonShowMarkers);
......@@ -2418,7 +2418,6 @@ void MainWindow::updateConfiguration()
m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
slotSwitchAutomaticTransition();
// Update list of transcoding profiles
buildDynamicActions();
......@@ -2454,10 +2453,12 @@ void MainWindow::slotSwitchSnap()
emit getMainTimeline()->controller()->snapChanged();
}
void MainWindow::slotSwitchAutomaticTransition()
void MainWindow::slotShowTimelineTags()
{
KdenliveSettings::setAutomatictransitions(!KdenliveSettings::automatictransitions());
m_buttonAutomaticTransition->setChecked(KdenliveSettings::automatictransitions());
KdenliveSettings::setTagsintimeline(!KdenliveSettings::tagsintimeline());
m_buttonTimelineTags->setChecked(KdenliveSettings::tagsintimeline());
// Reset view to update timeline colors
getMainTimeline()->controller()->getModel()->_resetView();
}
void MainWindow::slotDeleteItem()
......
......@@ -219,7 +219,7 @@ private:
QAction *m_buttonVideoThumbs;
QAction *m_buttonShowMarkers;
QAction *m_buttonFitZoom;
QAction *m_buttonAutomaticTransition;
QAction *m_buttonTimelineTags;
QAction *m_normalEditTool;
QAction *m_overwriteEditTool;
QAction *m_insertEditTool;
......@@ -307,7 +307,7 @@ private slots:
void slotEditProjectSettings();
void slotSwitchMarkersComments();
void slotSwitchSnap();
void slotSwitchAutomaticTransition();
void slotShowTimelineTags();
void slotRenderProject();
void slotStopRenderProject();
void slotFullScreen();
......
......@@ -849,64 +849,6 @@ void ClipController::mirrorOriginalProperties(Mlt::Properties &props)
}
}
void ClipController::addEffect(QDomElement &xml)
{
Q_UNUSED(xml)
// TODO refac: this must be rewritten
/*
QMutexLocker lock(&m_effectMutex);
Mlt::Service service = m_masterProducer->parent();
ItemInfo info;
info.cropStart = GenTime();
info.cropDuration = getPlaytime();
EffectsList eff = effectList();
EffectsController::initEffect(info, eff, getProducerProperty(QStringLiteral("kdenlive:proxy")), xml);
// Add effect to list and setup a kdenlive_ix value
int kdenlive_ix = 0;
for (int i = 0; i < service.filter_count(); ++i) {
QScopedPointer<Mlt::Filter> effect(service.filter(i));
int ix = effect->get_int("kdenlive_ix");
if (ix > kdenlive_ix) {
kdenlive_ix = ix;
}
}
kdenlive_ix++;
xml.setAttribute(QStringLiteral("kdenlive_ix"), kdenlive_ix);
EffectsParameterList params = EffectsController::getEffectArgs(xml);
EffectManager effect(service);
effect.addEffect(params, getPlaytime().frames(pCore->getCurrentFps()));
if (auto ptr = m_binController.lock()) ptr->updateTrackProducer(m_controllerBinId);
*/
}
void ClipController::removeEffect(int effectIndex, bool delayRefresh)
{
Q_UNUSED(effectIndex) Q_UNUSED(delayRefresh)
// TODO refac: this must be rewritten
/*
QMutexLocker lock(&m_effectMutex);
Mlt::Service service(m_masterProducer->parent());
EffectManager effect(service);
effect.removeEffect(effectIndex, true);
if (!delayRefresh) {
if (auto ptr = m_binController.lock()) ptr->updateTrackProducer(m_controllerBinId);
}
*/
}
void ClipController::moveEffect(int oldPos, int newPos)
{
Q_UNUSED(oldPos)
Q_UNUSED(newPos)
// TODO refac: this must be rewritten
/*
QMutexLocker lock(&m_effectMutex);
Mlt::Service service(m_masterProducer->parent());
EffectManager effect(service);
effect.moveEffect(oldPos, newPos);
*/
}
int ClipController::effectsCount()
{
int count = 0;
......@@ -922,61 +864,6 @@ int ClipController::effectsCount()
return count;
}
void ClipController::changeEffectState(const QList<int> &indexes, bool disable)
{
Q_UNUSED(indexes)
Q_UNUSED(disable)
// TODO refac : this must be rewritten
/*
Mlt::Service service = m_masterProducer->parent();
for (int i = 0; i < service.filter_count(); ++i) {
QScopedPointer<Mlt::Filter> effect(service.filter(i));
if ((effect != nullptr) && effect->is_valid() && indexes.contains(effect->get_int("kdenlive_ix"))) {
effect->set("disable", (int)disable);
}
}
if (auto ptr = m_binController.lock()) ptr->updateTrackProducer(m_controllerBinId);
*/
}
void ClipController::updateEffect(const QDomElement &e, int ix)
{
Q_UNUSED(e)
Q_UNUSED(ix)
// TODO refac : this must be rewritten
/*
QString tag = e.attribute(QStringLiteral("id"));
if (tag == QLatin1String("autotrack_rectangle") || tag.startsWith(QLatin1String("ladspa")) || tag == QLatin1String("sox")) {
// this filters cannot be edited, remove and re-add it
removeEffect(ix, true);
QDomElement clone = e.cloneNode().toElement();
addEffect(clone);
return;
}
EffectsParameterList params = EffectsController::getEffectArgs(e);
Mlt::Service service = m_masterProducer->parent();
for (int i = 0; i < service.filter_count(); ++i) {
QScopedPointer<Mlt::Filter> effect(service.filter(i));
if (!effect || !effect->is_valid() || effect->get_int("kdenlive_ix") != ix) {
continue;
}
service.lock();
QString prefix;
QString ser = effect->get("mlt_service");
if (ser == QLatin1String("region")) {
prefix = QStringLiteral("filter0.");
}
for (int j = 0; j < params.count(); ++j) {
effect->set((prefix + params.at(j).name()).toUtf8().constData(), params.at(j).value().toUtf8().constData());
// qCDebug(KDENLIVE_LOG)<<params.at(j).name()<<" = "<<params.at(j).value();
}
service.unlock();
}
if (auto ptr = m_binController.lock()) ptr->updateTrackProducer(m_controllerBinId);
// slotRefreshTracks();
*/
}
bool ClipController::hasEffects() const
{
return m_effectStack->rowCount() > 0;
......
......@@ -177,12 +177,7 @@ public:
void forceLimitedDuration();
Mlt::Properties &properties();
void mirrorOriginalProperties(Mlt::Properties &props);
void addEffect(QDomElement &xml);
bool copyEffect(const std::shared_ptr<EffectStackModel> &stackModel, int rowId);
void removeEffect(int effectIndex, bool delayRefresh = false);
/** @brief Enable/disable an effect. */
void changeEffectState(const QList<int> &indexes, bool disable);
void updateEffect(const QDomElement &e, int ix);
/** @brief Returns true if the bin clip has effects */
bool hasEffects() const;
/** @brief Returns true if the clip contains at least one audio stream */
......@@ -202,8 +197,6 @@ public:
void setBinEffectsEnabled(bool enabled);
/** @brief Returns the number of Kdenlive added effects for this bin clip */
int effectsCount();
/** @brief Move an effect in stack for this bin clip */
void moveEffect(int oldPos, int newPos);
/** @brief Save an xml playlist of current clip with in/out points as zone.x()/y() */
void saveZone(QPoint zone, const QDir &dir);
......
......@@ -915,6 +915,14 @@ const QString ClipModel::clipName() const
return pCore->projectItemModel()->getClipByBinID(m_binClipId)->clipName();
}
const QString ClipModel::clipTag() const
{
if (KdenliveSettings::tagsintimeline()) {
return pCore->projectItemModel()->getClipByBinID(m_binClipId)->tags();
}
return QString();
}
FileStatus::ClipStatus ClipModel::clipStatus() const
{
std::shared_ptr<ProjectClip> binClip = pCore->projectItemModel()->getClipByBinID(m_binClipId);
......
......@@ -75,6 +75,7 @@ public:
/** @brief returns the bin clip name
*/
const QString clipName() const;
const QString clipTag() const;
QSize getFrameSize() const;
Q_INVOKABLE bool showKeyframes() const;
Q_INVOKABLE void setShowKeyframes(bool show);
......
......@@ -193,6 +193,7 @@ QHash<int, QByteArray> TimelineItemModel::roleNames() const
roles[ServiceRole] = "mlt_service";
roles[BinIdRole] = "binId";
roles[TrackIdRole] = "trackId";
roles[TagRole] = "tag";
roles[FakeTrackIdRole] = "fakeTrackId";
roles[FakePositionRole] = "fakePosition";
roles[StartRole] = "start";
......@@ -343,6 +344,8 @@ QVariant TimelineItemModel::data(const QModelIndex &index, int role) const
return clip->isGrabbed();
case SelectedRole:
return clip->selected;
case TagRole:
return clip->clipTag();
default:
break;
}
......
......@@ -138,6 +138,7 @@ public:
IsDisabledRole, /// track only
IsAudioRole,
SortRole,
TagRole, /// clip only
ShowKeyframesRole,
AudioLevelsRole, /// clip only
AudioChannelsRole, /// clip only
......
......@@ -28,6 +28,7 @@ Rectangle {
id: clipRoot
property real timeScale: 1
property string clipName: ''
property string tagColor: ''
property string clipResource: ''
property string mltService: ''
property string effectNames
......@@ -198,6 +199,9 @@ Rectangle {
if (clipState == ClipState.Disabled) {
return 'grey'
}
if (clipRoot.tagColor) {
return clipRoot.tagColor
}
if (itemType == ProducerType.Text) {
return titleColor
}
......
......@@ -62,6 +62,12 @@ Item{
value: model.fakeTrackId
when: loader.status == Loader.Ready && loader.item && isClip(model.clipType)
}
Binding {
target: loader.item
property: "tagColor"
value: model.tag
when: loader.status == Loader.Ready && loader.item && isClip(model.clipType)
}
Binding {
target: loader.item
property: "fakePosition"
......
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