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

In project settings > delete unused files, don't show color clips as url,...

In project settings > delete unused files, don't show color clips as url, don't propose deleting missing files
parent ea5f5465
......@@ -879,7 +879,7 @@ bool ProjectItemModel::requestCleanupUnused()
return true;
}
bool ProjectItemModel::requestTrashClips(QStringList &urls)
bool ProjectItemModel::requestTrashClips(QStringList &ids, QStringList &urls)
{
QWriteLocker locker(&m_lock);
Fun undo = []() { return true; };
......@@ -888,7 +888,7 @@ bool ProjectItemModel::requestTrashClips(QStringList &urls)
// Iterate to find clips that are not in timeline
for (const auto &clip : m_allItems) {
auto c = std::static_pointer_cast<AbstractProjectItem>(clip.second.lock());
if (c->itemType() == AbstractProjectItem::ClipItem && urls.contains(std::static_pointer_cast<ProjectClip>(c)->getOriginalUrl())) {
if (ids.contains(c->clipId())) {
to_delete.push_back(c);
}
}
......
......@@ -179,7 +179,7 @@ public:
bool requestCleanupUnused();
/** @brief Request that all clips using one of the given urls are removed from the project and deleted from the hard disk*/
bool requestTrashClips(QStringList &urls);
bool requestTrashClips(QStringList &ids, QStringList &urls);
/** @brief Retrieves the next id available for attribution to a folder */
int getFreeFolderId();
......
......@@ -346,6 +346,8 @@ public slots:
void slotUpdateCompositeAction(bool enable);
/** @brief Update duration of projet in timeline toolbar. */
void slotUpdateProjectDuration(int pos);
/** @brief Remove all unused clips from the project. */
void slotCleanProject();
private slots:
/** @brief Shows the shortcut dialog. */
......@@ -483,7 +485,6 @@ private slots:
/** @brief Removes the focus of anything. */
void slotRemoveFocus();
void slotCleanProject();
void slotShutdown();
void slotSwitchMonitors();
......
......@@ -15,6 +15,7 @@ SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
#include "dialogs/profilesdialog.h"
#include "doc/kdenlivedoc.h"
#include "kdenlivesettings.h"
#include "mainwindow.h"
#include "mltcontroller/clipcontroller.h"
#include "profiles/profilemodel.hpp"
#include "project/dialogs/profilewidget.h"
......@@ -65,6 +66,7 @@ ProjectSettings::ProjectSettings(KdenliveDoc *doc, QMap<QString, QString> metada
vbox->addWidget(m_pw);
profile_box->setLayout(vbox);
profile_box->setTitle(i18n("Select the profile (preset) of the project"));
file_message->hide();
list_search->setTreeWidget(files_list);
project_folder->setMode(KFile::Directory);
......@@ -338,11 +340,18 @@ void ProjectSettings::slotEditMetadata(QTreeWidgetItem *item, int)
void ProjectSettings::slotDeleteUnused()
{
QStringList toDelete;
QStringList idsToDelete;
QList<std::shared_ptr<ProjectClip>> clipList = pCore->projectItemModel()->getRootFolder()->childClips();
for (const std::shared_ptr<ProjectClip> &clip : qAsConst(clipList)) {
if (!clip->isIncludedInTimeline()) {
QUrl url(clip->getOriginalUrl());
if (url.isValid() && !toDelete.contains(url.path())) toDelete << url.path();
idsToDelete << clip->clipId();
ClipType::ProducerType type = clip->clipType();
if (type != ClipType::Color && type != ClipType::Text && type != ClipType::TextTemplate) {
QUrl url = QUrl::fromLocalFile(clip->getOriginalUrl());
if (url.isValid() && !toDelete.contains(url.path()) && QFile::exists(url.path())) {
toDelete << url.path();
}
}
}
}
// make sure our urls are not used in another clip
......@@ -353,6 +362,10 @@ void ProjectSettings::slotDeleteUnused()
}
}
if (toDelete.count() == 0) {
file_message->setText(i18n("No files to delete on your drive."));
file_message->animatedShow();
pCore->window()->slotCleanProject();
slotUpdateFiles();
return;
}
if (KMessageBox::warningYesNoList(this,
......@@ -360,7 +373,7 @@ void ProjectSettings::slotDeleteUnused()
"what you are doing.\nAre you sure you want to continue?"),
toDelete, i18n("Delete unused clips")) != KMessageBox::Yes)
return;
pCore->projectItemModel()->requestTrashClips(toDelete);
pCore->projectItemModel()->requestTrashClips(idsToDelete, toDelete);
slotUpdateFiles();
}
......
......@@ -616,6 +616,13 @@
<string>Project Files</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_4">
<item row="4" column="0">
<widget class="QLabel" name="label_fonts">
<property name="text">
<string>Fonts</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="5">
<widget class="QListWidget" name="fonts_list">
<property name="alternatingRowColors">
......@@ -647,15 +654,11 @@
</column>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="label_12">
<property name="text">
<string>Clips used in project:</string>
</property>
</widget>
<item row="2" column="3" colspan="2">
<widget class="KTreeWidgetSearchLine" name="list_search"/>
</item>
<item row="0" column="2">
<widget class="QLabel" name="used_count">
<item row="1" column="3">
<widget class="QLabel" name="unused_size">
<property name="text">
<string/>
</property>
......@@ -668,65 +671,65 @@
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_6">
<item row="2" column="0">
<widget class="QLabel" name="label_13">
<property name="text">
<string>Unused clips:</string>
<string>Project files:</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="unused_count">
<item row="6" column="0" colspan="2">
<widget class="QPushButton" name="button_export">
<property name="text">
<string/>
<string>Plain Text Export...</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QLabel" name="unused_size">
<item row="2" column="2">
<widget class="QLabel" name="files_count">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QPushButton" name="delete_unused">
<item row="0" column="2">
<widget class="QLabel" name="used_count">
<property name="text">
<string>Delete files</string>
<string/>
</property>
</widget>
</item>
<item row="2" column="3" colspan="2">
<widget class="KTreeWidgetSearchLine" name="list_search"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_13">
<item row="1" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Project files:</string>
<string>Unused clips:</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_fonts">
<item row="1" column="4">
<widget class="QPushButton" name="delete_unused">
<property name="text">
<string>Fonts</string>
<string>Delete files</string>
</property>
</widget>
</item>
<item row="6" column="0" colspan="2">
<widget class="QPushButton" name="button_export">
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="label_12">
<property name="text">
<string>Plain Text Export...</string>
<string>Clips used in project:</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLabel" name="files_count">
<item row="1" column="2">
<widget class="QLabel" name="unused_count">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="7" column="0" colspan="5">
<widget class="KMessageWidget" name="file_message"/>
</item>
</layout>
</widget>
</widget>
......@@ -750,6 +753,11 @@
<extends>QLineEdit</extends>
<header>ktreewidgetsearchline.h</header>
</customwidget>
<customwidget>
<class>KMessageWidget</class>
<extends>QFrame</extends>
<header>kmessagewidget.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections>
......
Supports Markdown
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