Commit 0ccb60ca authored by Julius Künzel's avatar Julius Künzel
Browse files

Add option to ignore subfolder structure on import

Fixes #1179
parent 59e09e3f
Pipeline #79173 canceled with stage
......@@ -312,11 +312,16 @@ const QString ClipCreator::createClipsFromList(const QList<QUrl> &list, bool che
}
}
if (!sublist.isEmpty()) {
// Create main folder
bool folderCreated = pCore->projectItemModel()->requestAddFolder(folderId, dir.dirName(), parentFolder, local_undo, local_redo);
if (!folderCreated) {
continue;
if (!KdenliveSettings::ignoresubdirstructure() || topLevel) {
// Create main folder
bool folderCreated = pCore->projectItemModel()->requestAddFolder(folderId, dir.dirName(), parentFolder, local_undo, local_redo);
if (!folderCreated) {
continue;
}
} else {
folderId = parentFolder;
}
createdItem = folderId;
// load subfolders
const QString clipId = createClipsFromList(sublist, checkRemovable, folderId, model, undo, redo, false);
......@@ -325,10 +330,14 @@ const QString ClipCreator::createClipsFromList(const QList<QUrl> &list, bool che
}
}
} else {
// Create main folder
bool folderCreated = pCore->projectItemModel()->requestAddFolder(folderId, dir.dirName(), parentFolder, local_undo, local_redo);
if (!folderCreated) {
continue;
if (!KdenliveSettings::ignoresubdirstructure() || topLevel) {
// Create main folder
bool folderCreated = pCore->projectItemModel()->requestAddFolder(folderId, dir.dirName(), parentFolder, local_undo, local_redo);
if (!folderCreated) {
continue;
}
} else {
folderId = parentFolder;
}
createdItem = folderId;
const QString clipId = createClipsFromList(folderFiles, checkRemovable, folderId, model, local_undo, local_redo, false);
......
......@@ -90,6 +90,9 @@ bool createClipFromFile(const QString &path, const QString &parentFolder, std::s
@param checkRemovable: if true, it will check if files are on removable devices, and warn the user if so
@param parentFolder: the binId of the containing folder
@param model: a shared pointer to the bin item model
@param undo
@param redo
@param topLevel
*/
const QString createClipsFromList(const QList<QUrl> &list, bool checkRemovable, const QString &parentFolder, const std::shared_ptr<ProjectItemModel> &model, Fun &undo,
Fun &redo, bool topLevel = true);
......
......@@ -368,10 +368,13 @@ void ClipCreationDialog::createClipsCommand(KdenliveDoc *doc, const QString &par
QString dialogFilter = allExtensions + QLatin1Char('|') + i18n("All Supported Files") + QStringLiteral("\n*|") + i18n("All Files");
QCheckBox *b = new QCheckBox(i18n("Import image sequence"));
b->setChecked(KdenliveSettings::autoimagesequence());
QCheckBox *bf = new QCheckBox(i18n("Ignore subfolder structur"));
bf->setChecked(KdenliveSettings::ignoresubdirstructure());
QFrame *f = new QFrame();
f->setFrameShape(QFrame::NoFrame);
auto *l = new QHBoxLayout;
l->addWidget(b);
l->addWidget(bf);
l->addStretch(5);
f->setLayout(l);
QString clipFolder = KRecentDirs::dir(QStringLiteral(":KdenliveClipFolder"));
......@@ -398,6 +401,7 @@ void ClipCreationDialog::createClipsCommand(KdenliveDoc *doc, const QString &par
int result = dlg->exec();
if (result == QDialog::Accepted) {
KdenliveSettings::setAutoimagesequence(b->isChecked());
KdenliveSettings::setIgnoresubdirstructure(bf->isChecked());
list = fileWidget->selectedUrls();
if (!list.isEmpty()) {
KRecentDirs::add(QStringLiteral(":KdenliveClipFolder"), list.constFirst().adjusted(QUrl::RemoveFilename).toLocalFile());
......@@ -463,19 +467,31 @@ void ClipCreationDialog::clipWidget(QDockWidget* m_DockClipWidget)
QPushButton* importseq = new QPushButton(i18n("Import image sequence"));
// Make importseq checkable so that we can differentiate between a double click in filewidget and a click on the pushbutton
importseq->setCheckable(true);
fileWidget->setCustomWidget(importseq);
QCheckBox *b = new QCheckBox(i18n("Ignore subfolder structur"));
b->setChecked(KdenliveSettings::ignoresubdirstructure());
QFrame *f = new QFrame();
f->setFrameShape(QFrame::NoFrame);
auto *l = new QHBoxLayout;
l->addWidget(b);
l->addStretch(5);
l->addWidget(importseq);
f->setLayout(l);
fileWidget->setCustomWidget(f);
// Required to only add file on double click and not on single click
fileWidget->setOperationMode(KFileWidget::Saving);
QObject::connect(fileWidget, &KFileWidget::accepted , [fileWidget, importseq]() {
QObject::connect(fileWidget, &KFileWidget::accepted , [fileWidget, importseq, b]() {
if (importseq->isChecked()) {
// We are importing an image sequence, abort
return;
}
fileWidget->accept();
QList <QUrl> urls = fileWidget->selectedUrls();
pCore->bin()->droppedUrls(urls);
pCore->bin()->droppedUrls(urls, QString());
});
fileWidget->setFilter(dialogFilter);
QObject::connect(b, &QCheckBox::toggled , [](bool checked) {
KdenliveSettings::setIgnoresubdirstructure(checked);
});
QObject::connect(importseq, &QPushButton::clicked, fileWidget, [=]{
fileWidget->slotOk();
emit fileWidget->accepted();
......
......@@ -108,6 +108,10 @@
<label>Automatically import image sequences.</label>
<default>false</default>
</entry>
<entry name="ignoresubdirstructure" type="Bool">
<label>Ignore the subfolder structure (all clips in subfolders are added to the toplevel folder)</label>
<default>false</default>
</entry>
<entry name="disableimagescaling" type="Bool">
<label>Add a filter to disable default image scaling.</label>
<default>false</default>
......
......@@ -11,43 +11,6 @@
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="12" column="0">
<spacer>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="9" column="1">
<widget class="QComboBox" name="kcfg_tabposition">
<item>
<property name="text">
<string>Top</string>
</property>
</item>
<item>
<property name="text">
<string>Bottom</string>
</property>
</item>
<item>
<property name="text">
<string>Left</string>
</property>
</item>
<item>
<property name="text">
<string>Right</string>
</property>
</item>
</widget>
</item>
<item row="10" column="0" colspan="3">
<widget class="QGroupBox" name="groupBox">
<property name="title">
......@@ -137,17 +100,23 @@
</layout>
</widget>
</item>
<item row="5" column="0" colspan="3">
<widget class="QCheckBox" name="kcfg_automultistreams">
<property name="text">
<string>Automatically import all streams in multi stream clips</string>
<item row="13" column="0">
<spacer>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="0" colspan="3">
<widget class="QCheckBox" name="kcfg_usekuiserver">
<item row="9" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Use KDE job tracking for render jobs</string>
<string>Tab position</string>
</property>
</widget>
</item>
......@@ -158,17 +127,61 @@
</property>
</widget>
</item>
<item row="6" column="0" colspan="3">
<widget class="QCheckBox" name="kcfg_bypasscodeccheck">
<item row="9" column="2">
<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="9" column="1">
<widget class="QComboBox" name="kcfg_tabposition">
<item>
<property name="text">
<string>Top</string>
</property>
</item>
<item>
<property name="text">
<string>Bottom</string>
</property>
</item>
<item>
<property name="text">
<string>Left</string>
</property>
</item>
<item>
<property name="text">
<string>Right</string>
</property>
</item>
</widget>
</item>
<item row="8" column="0" colspan="3">
<widget class="QCheckBox" name="kcfg_use_magicLantern">
<property name="text">
<string>Bypass codec verification</string>
<string>Get clip metadata created by Magic Lantern</string>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="label_4">
<item row="5" column="0" colspan="3">
<widget class="QCheckBox" name="kcfg_automultistreams">
<property name="text">
<string>Tab position</string>
<string>Automatically import all streams in multi stream clips</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="3">
<widget class="QCheckBox" name="kcfg_openlastproject">
<property name="text">
<string>Open last project on startup</string>
</property>
</widget>
</item>
......@@ -186,13 +199,6 @@
</property>
</widget>
</item>
<item row="8" column="0" colspan="3">
<widget class="QCheckBox" name="kcfg_use_magicLantern">
<property name="text">
<string>Get clip metadata created by Magic Lantern</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="3">
<widget class="QCheckBox" name="kcfg_checkfirstprojectclip">
<property name="text">
......@@ -200,23 +206,10 @@
</property>
</widget>
</item>
<item row="9" column="2">
<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="0" column="0" colspan="3">
<widget class="QCheckBox" name="kcfg_openlastproject">
<item row="3" column="0" colspan="3">
<widget class="QCheckBox" name="kcfg_usekuiserver">
<property name="text">
<string>Open last project on startup</string>
<string>Use KDE job tracking for render jobs</string>
</property>
</widget>
</item>
......@@ -227,6 +220,20 @@
</property>
</widget>
</item>
<item row="6" column="0" colspan="3">
<widget class="QCheckBox" name="kcfg_bypasscodeccheck">
<property name="text">
<string>Bypass codec verification</string>
</property>
</widget>
</item>
<item row="12" column="0" colspan="3">
<widget class="QCheckBox" name="kcfg_ignoresubdirstructure">
<property name="text">
<string>Ignore subfolder structure on import (import all files into toplevel folder)</string>
</property>
</widget>
</item>
</layout>
</widget>
<tabstops>
......
  • clipcreator.cpp: Why need/is line 315-323 and 333-340 the same code? Could that be not a separate function?

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