When opening project with missing proxies, allow not rebuilding proxies

parent 78f53637
Pipeline #23501 passed with stage
in 26 minutes and 48 seconds
......@@ -1755,7 +1755,7 @@ void Bin::slotAddFolder()
// Edit folder name
auto folder = m_itemModel->getFolderByBinId(newId);
auto ix = m_itemModel->getIndexFromItem(folder);
// Scroll to ensure folder is visible
m_itemView->scrollTo(m_proxyModel->mapFromSource(ix), QAbstractItemView::PositionAtCenter);
qDebug() << "selecting" << ix;
......@@ -4171,3 +4171,21 @@ void Bin::addClipMarker(const QString binId, QList<int> positions)
}
clip->getMarkerModel()->addMarkers(markers, KdenliveSettings::default_marker_type());
}
void Bin::checkMissingProxies()
{
if (m_itemModel->getRootFolder() == nullptr || m_itemModel->getRootFolder()->childCount() == 0) {
return;
}
QList<std::shared_ptr<ProjectClip>> clipList = m_itemModel->getRootFolder()->childClips();
QList<std::shared_ptr<ProjectClip>> toProxy;
for (auto clip : clipList) {
if (clip->getProducerIntProperty(QStringLiteral("_replaceproxy")) > 0) {
clip->resetProducerProperty(QStringLiteral("_replaceproxy"));
toProxy << clip;
}
}
if (!toProxy.isEmpty()) {
pCore->currentDoc()->slotProxyCurrentItem(true, toProxy);
}
}
......@@ -283,6 +283,8 @@ public:
void saveZone(const QStringList &info, const QDir &dir);
/** @brief A bin clip changed (its effects), invalidate preview */
void invalidateClip(const QString &binId);
/** @brief Recreate missing proxies on document opening */
void checkMissingProxies();
// TODO refac: remove this and call directly the function in ProjectItemModel
void cleanup();
......
......@@ -37,6 +37,7 @@
#include <QStandardPaths>
#include <QTreeWidgetItem>
#include <utility>
const int hashRole = Qt::UserRole;
const int sizeRole = Qt::UserRole + 1;
const int idRole = Qt::UserRole + 2;
......@@ -541,7 +542,19 @@ bool DocumentChecker::hasErrorInClips()
if (!infoLabel.isEmpty()) {
infoLabel.append(QStringLiteral("\n"));
}
infoLabel.append(i18n("Missing proxies will be recreated after opening."));
infoLabel.append(i18n("Missing proxies can be recreated on opening."));
m_ui.rebuildProxies->setChecked(true);
connect(m_ui.rebuildProxies, &QCheckBox::stateChanged, [missingProxies] (int state) {
for (QDomElement e : missingProxies) {
if (state == Qt::Checked) {
e.setAttribute(QStringLiteral("_replaceproxy"), QStringLiteral("1"));
} else {
e.removeAttribute(QStringLiteral("_replaceproxy"));
}
}
});
} else {
m_ui.rebuildProxies->setVisible(false);
}
if (!missingSources.isEmpty()) {
if (!infoLabel.isEmpty()) {
......@@ -579,6 +592,8 @@ bool DocumentChecker::hasErrorInClips()
m_missingProxyIds << id;
// Tell Kdenlive to recreate proxy
e.setAttribute(QStringLiteral("_replaceproxy"), QStringLiteral("1"));
// Remove reference to missing proxy
Xml::setXmlProperty(e, QStringLiteral("kdenlive:proxy"), QStringLiteral("-"));
// Replace proxy url with real clip in MLT producers
QDomElement mltProd;
int prodsCount = documentProducers.count();
......
......@@ -58,6 +58,7 @@ bool constructTimelineFromMelt(const std::shared_ptr<TimelineItemModel> &timelin
m_errorMessage.clear();
std::unordered_map<QString, QString> binIdCorresp;
pCore->projectItemModel()->loadBinPlaylist(&tractor, timeline->tractor(), binIdCorresp, progressDialog);
pCore->bin()->checkMissingProxies();
QSet<QString> reserved_names{QLatin1String("playlistmain"), QLatin1String("timeline_preview"), QLatin1String("timeline_overlay"),
QLatin1String("black_track")};
......
......@@ -914,3 +914,9 @@ const QString ClipModel::clipName()
{
return pCore->projectItemModel()->getClipByBinID(m_binClipId)->clipName();
}
bool ClipModel::isProxied() const
{
std::shared_ptr<ProjectClip> binClip = pCore->projectItemModel()->getClipByBinID(m_binClipId);
return binClip->hasProxy();
}
......@@ -211,6 +211,9 @@ protected:
/** @brief Returns the producer's duration, or -1 if it can be resized without limit */
int getMaxDuration() const;
/** @brief Returns true if the parent Bin Clip uses a proxy */
bool isProxied() const;
/*@brief This is a debug function to ensure the clip is in a valid state */
bool checkConsistency();
......
......@@ -273,8 +273,7 @@ QVariant TimelineItemModel::data(const QModelIndex &index, int role) const
return result;
}
case IsProxyRole: {
const QString proxy = clip->getProperty("kdenlive:proxy");
return proxy.size() > 2;
return clip->isProxied();
}
case FakeTrackIdRole:
return clip->getFakeTrackId();
......
......@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>1201</width>
<width>981</width>
<height>269</height>
</rect>
</property>
......@@ -14,21 +14,47 @@
<string> Clip Problems</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="0">
<widget class="QPushButton" name="recursiveSearch">
<property name="text">
<string>Search recursively</string>
<item row="3" column="5">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0" colspan="7">
<widget class="KMessageWidget" name="infoLabel">
<property name="wordWrap" stdset="0">
<bool>true</bool>
</property>
<property name="closeButtonVisible" stdset="0">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="1">
<item row="3" column="6">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Abort|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QPushButton" name="usePlaceholders">
<property name="text">
<string>Use placeholders for missing clips</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="5">
<item row="0" column="0" colspan="7">
<widget class="QTreeWidget" name="treeWidget">
<property name="alternatingRowColors">
<bool>true</bool>
......@@ -57,46 +83,24 @@
</column>
</widget>
</item>
<item row="2" column="4">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Abort|QDialogButtonBox::Ok</set>
<item row="3" column="2">
<widget class="QPushButton" name="removeSelected">
<property name="text">
<string>Remove selected clips</string>
</property>
</widget>
</item>
<item row="2" column="3">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0" colspan="5">
<widget class="KMessageWidget" name="infoLabel">
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="closeButtonVisible">
<bool>false</bool>
</property>
<property name="messageType">
<enum>KMessageWidget::Warning</enum>
<item row="3" column="3">
<widget class="QCheckBox" name="rebuildProxies">
<property name="text">
<string>Rebuild Proxies</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QPushButton" name="removeSelected">
<item row="2" column="1">
<widget class="QPushButton" name="recursiveSearch">
<property name="text">
<string>Remove selected clips</string>
<string>Search recursively</string>
</property>
</widget>
</item>
......@@ -107,12 +111,11 @@
<class>KMessageWidget</class>
<extends>QFrame</extends>
<header>kmessagewidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>recursiveSearch</tabstop>
<tabstop>usePlaceholders</tabstop>
<tabstop>removeSelected</tabstop>
<tabstop>treeWidget</tabstop>
</tabstops>
<resources/>
......
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