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

Fix audio capture saved in wrong folder.

Fixes #1533
parent d42d98e2
Pipeline #238409 passed with stage
in 7 minutes and 42 seconds
......@@ -442,8 +442,9 @@ int MediaCapture::startCapture()
void MediaCapture::setCaptureOutputLocation()
{
QDir captureFolder;
if (KdenliveSettings::capturetoprojectfolder()) {
captureFolder = QDir(pCore->getProjectFolderName());
bool audioCapture = m_videoRecorder.get() == nullptr;
if (KdenliveSettings::capturetoprojectfolder() < 2) {
captureFolder = QDir(pCore->getProjectFolderName(audioCapture));
} else {
captureFolder = QDir(KdenliveSettings::capturefolder());
}
......
......@@ -1073,10 +1073,10 @@ void Core::resetAudioMonitoring()
}
}
QString Core::getProjectFolderName()
QString Core::getProjectFolderName(bool folderForAudio)
{
if (currentDoc()) {
return currentDoc()->projectDataFolder() + QDir::separator();
return currentDoc()->projectDataFolder(QStringLiteral(), folderForAudio) + QDir::separator();
}
return QString();
}
......
......@@ -222,7 +222,7 @@ public:
bool isMediaCapturing() const;
MediaCapture *getAudioDevice();
/** @brief Returns Project Folder name for capture output location */
QString getProjectFolderName();
QString getProjectFolderName(bool folderForAudio = false);
/** @brief Returns a timeline clip's bin id */
QString getTimelineClipBinId(int cid);
/** @brief Returns all track ids in timeline */
......
......@@ -322,8 +322,16 @@ void KdenliveSettingsDialog::initEnviromentPage()
m_configEnv.tmppathurl->lineEdit()->setObjectName(QStringLiteral("kcfg_currenttmpfolder"));
m_configEnv.capturefolderurl->setMode(KFile::Directory);
m_configEnv.capturefolderurl->lineEdit()->setObjectName(QStringLiteral("kcfg_capturefolder"));
m_configEnv.capturefolderurl->setEnabled(!KdenliveSettings::capturetoprojectfolder());
connect(m_configEnv.kcfg_capturetoprojectfolder, &QAbstractButton::clicked, this, &KdenliveSettingsDialog::slotEnableCaptureFolder);
m_configEnv.capturefolderurl->setEnabled(KdenliveSettings::capturetoprojectfolder() == 2);
m_configEnv.kcfg_capturetoprojectfolder->setItemText(0, i18n("Use default folder: %1", QStandardPaths::writableLocation(QStandardPaths::MoviesLocation)));
if (KdenliveSettings::customprojectfolder()) {
m_configEnv.kcfg_capturetoprojectfolder->setItemText(1, i18n("Always use project folder: %1", KdenliveSettings::defaultprojectfolder()));
} else {
m_configEnv.kcfg_capturetoprojectfolder->setItemText(1, i18n("Always use active project folder"));
}
connect(m_configEnv.kcfg_capturetoprojectfolder, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
&KdenliveSettingsDialog::slotEnableCaptureFolder);
// Library folder
m_configEnv.libraryfolderurl->setMode(KFile::Directory);
m_configEnv.libraryfolderurl->lineEdit()->setObjectName(QStringLiteral("kcfg_libraryfolder"));
......@@ -339,7 +347,12 @@ void KdenliveSettingsDialog::initEnviromentPage()
m_configEnv.videofolderurl->lineEdit()->setObjectName(QStringLiteral("kcfg_videofolder"));
m_configEnv.videofolderurl->setEnabled(KdenliveSettings::videotodefaultfolder() == 2);
m_configEnv.videofolderurl->setPlaceholderText(QStandardPaths::writableLocation(QStandardPaths::MoviesLocation));
m_configEnv.kcfg_videotodefaultfolder->setToolTip(QStandardPaths::writableLocation(QStandardPaths::MoviesLocation));
m_configEnv.kcfg_videotodefaultfolder->setItemText(0, i18n("Use default folder: %1", QStandardPaths::writableLocation(QStandardPaths::MoviesLocation)));
if (KdenliveSettings::customprojectfolder()) {
m_configEnv.kcfg_videotodefaultfolder->setItemText(1, i18n("Always use project folder: %1", KdenliveSettings::defaultprojectfolder()));
} else {
m_configEnv.kcfg_videotodefaultfolder->setItemText(1, i18n("Always use active project folder"));
}
connect(m_configEnv.kcfg_videotodefaultfolder, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &KdenliveSettingsDialog::slotEnableVideoFolder);
// Mime types
......@@ -636,9 +649,9 @@ void KdenliveSettingsDialog::slotUpdateGrabRegionStatus()
m_configCapture.region_group->setHidden(m_configCapture.kcfg_grab_capture_type->currentIndex() != 1);
}
void KdenliveSettingsDialog::slotEnableCaptureFolder()
void KdenliveSettingsDialog::slotEnableCaptureFolder(int ix)
{
m_configEnv.capturefolderurl->setEnabled(!m_configEnv.kcfg_capturetoprojectfolder->isChecked());
m_configEnv.capturefolderurl->setEnabled(ix == 2);
}
void KdenliveSettingsDialog::slotEnableLibraryFolder()
......@@ -993,7 +1006,6 @@ void KdenliveSettingsDialog::updateSettings()
bool resetConsumer = false;
bool fullReset = false;
bool updateCapturePath = false;
bool updateLibrary = false;
/*if (m_configShuttle.shuttledevicelist->count() > 0) {
......@@ -1001,14 +1013,22 @@ void KdenliveSettingsDialog::updateSettings()
if (device != KdenliveSettings::shuttledevice()) KdenliveSettings::setShuttledevice(device);
}*/
// Capture default folder
if (m_configEnv.kcfg_capturetoprojectfolder->isChecked() != KdenliveSettings::capturetoprojectfolder()) {
KdenliveSettings::setCapturetoprojectfolder(m_configEnv.kcfg_capturetoprojectfolder->isChecked());
updateCapturePath = true;
}
if (m_configProject.projecturl->url().toLocalFile() != KdenliveSettings::defaultprojectfolder()) {
KdenliveSettings::setDefaultprojectfolder(m_configProject.projecturl->url().toLocalFile());
if (!KdenliveSettings::sameprojectfolder()) {
m_configEnv.kcfg_videotodefaultfolder->setItemText(1, i18n("Always use project folder: %1", KdenliveSettings::defaultprojectfolder()));
m_configEnv.kcfg_capturetoprojectfolder->setItemText(1, i18n("Always use project folder: %1", KdenliveSettings::defaultprojectfolder()));
}
}
if (m_configProject.kcfg_customprojectfolder->isChecked() != KdenliveSettings::customprojectfolder()) {
if (KdenliveSettings::customprojectfolder()) {
m_configEnv.kcfg_videotodefaultfolder->setItemText(1, i18n("Always use active project folder"));
m_configEnv.kcfg_capturetoprojectfolder->setItemText(1, i18n("Always use active project folder"));
} else {
m_configEnv.kcfg_videotodefaultfolder->setItemText(1, i18n("Always use project folder: %1", KdenliveSettings::defaultprojectfolder()));
m_configEnv.kcfg_capturetoprojectfolder->setItemText(1, i18n("Always use project folder: %1", KdenliveSettings::defaultprojectfolder()));
}
}
if (m_configSdl.fullscreen_monitor->currentData().toString() != KdenliveSettings::fullscreen_monitor()) {
......@@ -1017,7 +1037,6 @@ void KdenliveSettingsDialog::updateSettings()
if (m_configEnv.capturefolderurl->url().toLocalFile() != KdenliveSettings::capturefolder()) {
KdenliveSettings::setCapturefolder(m_configEnv.capturefolderurl->url().toLocalFile());
updateCapturePath = true;
}
// Library default folder
......@@ -1111,9 +1130,6 @@ void KdenliveSettingsDialog::updateSettings()
KdenliveSettings::setPreviewextension(string);
}
if (updateCapturePath) {
emit updateCaptureFolder();
}
if (updateLibrary) {
emit updateLibraryFolder();
}
......
......@@ -82,7 +82,7 @@ private slots:
void slotSetTranscodeProfile();
void slotShuttleModified();
void slotDialogModified();
void slotEnableCaptureFolder();
void slotEnableCaptureFolder(int ix);
void slotEnableLibraryFolder();
void slotEnableVideoFolder(int ix);
void slotUpdatev4lDevice();
......
......@@ -700,8 +700,28 @@ QString KdenliveDoc::projectTempFolder() const
return m_projectFolder;
}
QString KdenliveDoc::projectDataFolder(const QString &newPath) const
QString KdenliveDoc::projectDataFolder(const QString &newPath, bool folderForAudio) const
{
if (folderForAudio) {
if (KdenliveSettings::capturetoprojectfolder() == 2 && !KdenliveSettings::capturefolder().isEmpty()) {
return KdenliveSettings::capturefolder();
}
if (m_projectFolder.isEmpty()) {
// Project has not been saved yet
if (KdenliveSettings::customprojectfolder()) {
return KdenliveSettings::defaultprojectfolder();
}
return QStandardPaths::writableLocation(QStandardPaths::MoviesLocation);
}
if (KdenliveSettings::capturetoprojectfolder() == 1 || m_sameProjectFolder) {
// Always render to project folder
if (KdenliveSettings::customprojectfolder() && !m_sameProjectFolder) {
return KdenliveSettings::defaultprojectfolder();
}
return QFileInfo(m_url.toLocalFile()).absolutePath();
}
return QStandardPaths::writableLocation(QStandardPaths::MoviesLocation);
}
if (KdenliveSettings::videotodefaultfolder() == 2 && !KdenliveSettings::videofolder().isEmpty()) {
return KdenliveSettings::videofolder();
}
......@@ -718,6 +738,9 @@ QString KdenliveDoc::projectDataFolder(const QString &newPath) const
}
if (KdenliveSettings::videotodefaultfolder() == 1 || m_sameProjectFolder) {
// Always render to project folder
if (KdenliveSettings::customprojectfolder() && !m_sameProjectFolder) {
return KdenliveSettings::defaultprojectfolder();
}
return QFileInfo(m_url.toLocalFile()).absolutePath();
}
return QStandardPaths::writableLocation(QStandardPaths::MoviesLocation);
......
......@@ -129,7 +129,7 @@ public:
/** @brief Returns the project folder, used to store project temporary files. */
QString projectTempFolder() const;
/** @brief Returns the folder used to store project data files (titles, etc). */
QString projectDataFolder(const QString &newPath = QString()) const;
QString projectDataFolder(const QString &newPath = QString(), bool folderForAudio = false) const;
void setZoom(int horizontal, int vertical = -1);
QPoint zoom() const;
double dar() const;
......
......@@ -594,9 +594,9 @@
<default>false</default>
</entry>
<entry name="capturetoprojectfolder" type="Bool">
<entry name="capturetoprojectfolder" type="Int">
<label>Save captured files to project folder by default.</label>
<default>true</default>
<default>1</default>
</entry>
<entry name="capturefolder" type="Path">
......
......@@ -181,7 +181,7 @@ void RecManager::slotRecord(bool record)
QString extension = KdenliveSettings::grab_extension();
QDir captureFolder;
if (KdenliveSettings::capturetoprojectfolder()) {
if (KdenliveSettings::capturetoprojectfolder() < 2) {
captureFolder = QDir(pCore->getProjectFolderName());
} else {
captureFolder = QDir(KdenliveSettings::capturefolder());
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>395</width>
<height>514</height>
<width>675</width>
<height>660</height>
</rect>
</property>
<property name="sizePolicy">
......@@ -104,7 +104,7 @@
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
......@@ -191,6 +191,32 @@
<string>Default Folders</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Temporary files:</string>
</property>
</widget>
</item>
<item row="7" column="1">
<spacer name="verticalSpacer_3">
<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="0" column="1" colspan="2">
<widget class="KUrlRequester" name="tmppathurl"/>
</item>
<item row="2" column="1" colspan="2">
<widget class="KUrlRequester" name="capturefolderurl"/>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_16">
<property name="text">
......@@ -201,6 +227,26 @@
</property>
</widget>
</item>
<item row="4" column="1" colspan="2">
<widget class="KUrlRequester" name="libraryfolderurl"/>
</item>
<item row="6" column="1" colspan="2">
<widget class="KUrlRequester" name="videofolderurl">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Capture folder:</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_15">
<property name="text">
......@@ -208,20 +254,27 @@
</property>
</widget>
</item>
<item row="7" column="1">
<spacer name="verticalSpacer_3">
<item row="3" column="1">
<widget class="QCheckBox" name="kcfg_librarytodefaultfolder">
<property name="text">
<string>Use default folder</string>
</property>
</widget>
</item>
<item row="3" column="2">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="5" column="1">
<item row="5" column="1" colspan="2">
<widget class="QComboBox" name="kcfg_videotodefaultfolder">
<item>
<property name="text">
......@@ -240,66 +293,25 @@
</item>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Temporary files:</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Capture folder:</string>
</property>
</widget>
</item>
<item row="5" 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="6" column="1" colspan="2">
<widget class="KUrlRequester" name="videofolderurl">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="4" column="1" colspan="2">
<widget class="KUrlRequester" name="libraryfolderurl"/>
</item>
<item row="3" column="1" colspan="2">
<widget class="QCheckBox" name="kcfg_librarytodefaultfolder">
<property name="text">
<string>Use default folder</string>
</property>
</widget>
</item>
<item row="2" column="1" colspan="2">
<widget class="KUrlRequester" name="capturefolderurl"/>
</item>
<item row="1" column="1" colspan="2">
<widget class="QCheckBox" name="kcfg_capturetoprojectfolder">
<property name="text">
<string>Use project folder</string>
</property>
<widget class="QComboBox" name="kcfg_capturetoprojectfolder">
<item>
<property name="text">
<string>Use default folder</string>
</property>
</item>
<item>
<property name="text">
<string>Always use project folder</string>
</property>
</item>
<item>
<property name="text">
<string>Always use custom folder</string>
</property>
</item>
</widget>
</item>
<item row="0" column="1" colspan="2">
<widget class="KUrlRequester" name="tmppathurl"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_3">
......
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