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

Initial support for externally created proxy clips through a pattern

Should work with Sony PXW camcorder proxy clips
parent e997a3be
......@@ -14,6 +14,7 @@ endif()
install(FILES
banner.png
encodingprofiles.rc
externalproxies.rc
metadata.properties
meta_ffmpeg.png
meta_libav.png
......
# This lists patterns for camcorder proxy clips. a ';' separated list with
# * relative path
# * prefix
# * suffix
[proxy]
Sony PXW=../Sub;;S03.MP4
......@@ -158,6 +158,7 @@ ki18n_wrap_ui(kdenlive_UIS
ui/configjogshuttle_ui.ui
ui/configmisc_ui.ui
ui/configproject_ui.ui
ui/configproxy_ui.ui
ui/configsdl_ui.ui
ui/configtimeline_ui.ui
ui/configtranscode_ui.ui
......
......@@ -86,12 +86,18 @@ KdenliveSettingsDialog::KdenliveSettingsDialog(const QMap<QString, QString> &map
m_pw->loadProfile(KdenliveSettings::default_profile().isEmpty() ? pCore->getCurrentProfile()->path() : KdenliveSettings::default_profile());
connect(m_pw, &ProfileWidget::profileChanged, this, &KdenliveSettingsDialog::slotDialogModified);
m_page8->setIcon(QIcon::fromTheme(QStringLiteral("project-defaults")));
connect(m_configProject.kcfg_generateproxy, &QAbstractButton::toggled, m_configProject.kcfg_proxyminsize, &QWidget::setEnabled);
m_configProject.kcfg_proxyminsize->setEnabled(KdenliveSettings::generateproxy());
m_configProject.projecturl->setMode(KFile::Directory);
m_configProject.projecturl->setUrl(QUrl::fromLocalFile(KdenliveSettings::defaultprojectfolder()));
connect(m_configProject.kcfg_generateimageproxy, &QAbstractButton::toggled, m_configProject.kcfg_proxyimageminsize, &QWidget::setEnabled);
m_configProject.kcfg_proxyimageminsize->setEnabled(KdenliveSettings::generateimageproxy());
QWidget *p9 = new QWidget;
m_configProxy.setupUi(p9);
KPageWidgetItem* page9 = addPage(p9, i18n("Proxy Clips"));
page9->setIcon(QIcon::fromTheme(QStringLiteral("zoom-out")));
connect(m_configProxy.kcfg_generateproxy, &QAbstractButton::toggled, m_configProxy.kcfg_proxyminsize, &QWidget::setEnabled);
m_configProxy.kcfg_proxyminsize->setEnabled(KdenliveSettings::generateproxy());
connect(m_configProxy.kcfg_generateimageproxy, &QAbstractButton::toggled, m_configProxy.kcfg_proxyimageminsize, &QWidget::setEnabled);
m_configProxy.kcfg_proxyimageminsize->setEnabled(KdenliveSettings::generateimageproxy());
loadExternalProxyProfiles();
QWidget *p3 = new QWidget;
m_configTimeline.setupUi(p3);
......@@ -308,22 +314,22 @@ KdenliveSettingsDialog::KdenliveSettingsDialog(const QMap<QString, QString> &map
m_configProject.kcfg_preview_profile->setToolTip(i18n("Select default timeline preview profile"));
// proxy profile stuff
m_configProject.proxy_showprofileinfo->setIcon(QIcon::fromTheme(QStringLiteral("help-about")));
m_configProject.proxy_showprofileinfo->setToolTip(i18n("Show default profile parameters"));
m_configProject.proxy_manageprofile->setIcon(QIcon::fromTheme(QStringLiteral("configure")));
m_configProject.proxy_manageprofile->setToolTip(i18n("Manage proxy profiles"));
m_configProject.kcfg_proxy_profile->setToolTip(i18n("Select default proxy profile"));
m_configProject.proxyparams->setVisible(false);
m_configProject.proxyparams->setMaximumHeight(QFontMetrics(font()).lineSpacing() * 3);
m_configProject.proxyparams->setPlainText(KdenliveSettings::proxyparams());
m_configProxy.proxy_showprofileinfo->setIcon(QIcon::fromTheme(QStringLiteral("help-about")));
m_configProxy.proxy_showprofileinfo->setToolTip(i18n("Show default profile parameters"));
m_configProxy.proxy_manageprofile->setIcon(QIcon::fromTheme(QStringLiteral("configure")));
m_configProxy.proxy_manageprofile->setToolTip(i18n("Manage proxy profiles"));
m_configProxy.kcfg_proxy_profile->setToolTip(i18n("Select default proxy profile"));
m_configProxy.proxyparams->setVisible(false);
m_configProxy.proxyparams->setMaximumHeight(QFontMetrics(font()).lineSpacing() * 3);
m_configProxy.proxyparams->setPlainText(KdenliveSettings::proxyparams());
act = new QAction(QIcon::fromTheme(QStringLiteral("configure")), i18n("Configure profiles"), this);
act->setData(0);
connect(act, &QAction::triggered, this, &KdenliveSettingsDialog::slotManageEncodingProfile);
m_configProject.proxy_manageprofile->setDefaultAction(act);
m_configProxy.proxy_manageprofile->setDefaultAction(act);
connect(m_configProject.proxy_showprofileinfo, &QAbstractButton::clicked, m_configProject.proxyparams, &QWidget::setVisible);
connect(m_configProject.kcfg_proxy_profile, static_cast<void (KComboBox::*)(int)>(&KComboBox::currentIndexChanged), this,
connect(m_configProxy.proxy_showprofileinfo, &QAbstractButton::clicked, m_configProxy.proxyparams, &QWidget::setVisible);
connect(m_configProxy.kcfg_proxy_profile, static_cast<void (KComboBox::*)(int)>(&KComboBox::currentIndexChanged), this,
&KdenliveSettingsDialog::slotUpdateProxyProfile);
slotUpdateProxyProfile(-1);
......@@ -828,14 +834,14 @@ void KdenliveSettingsDialog::updateSettings()
// Check encoding profiles
// FFmpeg
QString profilestr = m_configCapture.kcfg_v4l_profile->itemData(m_configCapture.kcfg_v4l_profile->currentIndex()).toString();
QString profilestr = m_configCapture.kcfg_v4l_profile->currentData().toString();
if (!profilestr.isEmpty() && (profilestr.section(QLatin1Char(';'), 0, 0) != KdenliveSettings::v4l_parameters() ||
profilestr.section(QLatin1Char(';'), 1, 1) != KdenliveSettings::v4l_extension())) {
KdenliveSettings::setV4l_parameters(profilestr.section(QLatin1Char(';'), 0, 0));
KdenliveSettings::setV4l_extension(profilestr.section(QLatin1Char(';'), 1, 1));
}
// screengrab
profilestr = m_configCapture.kcfg_grab_profile->itemData(m_configCapture.kcfg_grab_profile->currentIndex()).toString();
profilestr = m_configCapture.kcfg_grab_profile->currentData().toString();
if (!profilestr.isEmpty() && (profilestr.section(QLatin1Char(';'), 0, 0) != KdenliveSettings::grab_parameters() ||
profilestr.section(QLatin1Char(';'), 1, 1) != KdenliveSettings::grab_extension())) {
KdenliveSettings::setGrab_parameters(profilestr.section(QLatin1Char(';'), 0, 0));
......@@ -843,22 +849,28 @@ void KdenliveSettingsDialog::updateSettings()
}
// decklink
profilestr = m_configCapture.kcfg_decklink_profile->itemData(m_configCapture.kcfg_decklink_profile->currentIndex()).toString();
profilestr = m_configCapture.kcfg_decklink_profile->currentData().toString();
if (!profilestr.isEmpty() && (profilestr.section(QLatin1Char(';'), 0, 0) != KdenliveSettings::decklink_parameters() ||
profilestr.section(QLatin1Char(';'), 1, 1) != KdenliveSettings::decklink_extension())) {
KdenliveSettings::setDecklink_parameters(profilestr.section(QLatin1Char(';'), 0, 0));
KdenliveSettings::setDecklink_extension(profilestr.section(QLatin1Char(';'), 1, 1));
}
// proxies
profilestr = m_configProject.kcfg_proxy_profile->itemData(m_configProject.kcfg_proxy_profile->currentIndex()).toString();
profilestr = m_configProxy.kcfg_proxy_profile->currentData().toString();
if (!profilestr.isEmpty() && (profilestr.section(QLatin1Char(';'), 0, 0) != KdenliveSettings::proxyparams() ||
profilestr.section(QLatin1Char(';'), 1, 1) != KdenliveSettings::proxyextension())) {
KdenliveSettings::setProxyparams(profilestr.section(QLatin1Char(';'), 0, 0));
KdenliveSettings::setProxyextension(profilestr.section(QLatin1Char(';'), 1, 1));
}
// external proxies
profilestr = m_configProxy.kcfg_external_proxy_profile->currentData().toString();
if (!profilestr.isEmpty() && (profilestr != KdenliveSettings::externalProxyProfile())) {
KdenliveSettings::setExternalProxyProfile(profilestr);
}
// timeline preview
profilestr = m_configProject.kcfg_preview_profile->itemData(m_configProject.kcfg_preview_profile->currentIndex()).toString();
profilestr = m_configProject.kcfg_preview_profile->currentData().toString();
if (!profilestr.isEmpty() && (profilestr.section(QLatin1Char(';'), 0, 0) != KdenliveSettings::previewparams() ||
profilestr.section(QLatin1Char(';'), 1, 1) != KdenliveSettings::previewextension())) {
KdenliveSettings::setPreviewparams(profilestr.section(QLatin1Char(';'), 0, 0));
......@@ -872,7 +884,7 @@ void KdenliveSettingsDialog::updateSettings()
emit updateLibraryFolder();
}
QString value = m_configCapture.kcfg_v4l_alsadevice->itemData(m_configCapture.kcfg_v4l_alsadevice->currentIndex()).toString();
QString value = m_configCapture.kcfg_v4l_alsadevice->currentData().toString();
if (value != KdenliveSettings::v4l_alsadevicename()) {
KdenliveSettings::setV4l_alsadevicename(value);
}
......@@ -886,7 +898,7 @@ void KdenliveSettingsDialog::updateSettings()
fullReset = true;
}
value = m_configSdl.kcfg_audio_driver->itemData(m_configSdl.kcfg_audio_driver->currentIndex()).toString();
value = m_configSdl.kcfg_audio_driver->currentData().toString();
if (value != KdenliveSettings::audiodrivername()) {
KdenliveSettings::setAudiodrivername(value);
resetConsumer = true;
......@@ -894,7 +906,7 @@ void KdenliveSettingsDialog::updateSettings()
if (value == QLatin1String("alsa")) {
// Audio device setting is only valid for alsa driver
value = m_configSdl.kcfg_audio_device->itemData(m_configSdl.kcfg_audio_device->currentIndex()).toString();
value = m_configSdl.kcfg_audio_device->currentData().toString();
if (value != KdenliveSettings::audiodevicename()) {
KdenliveSettings::setAudiodevicename(value);
resetConsumer = true;
......@@ -904,7 +916,7 @@ void KdenliveSettingsDialog::updateSettings()
resetConsumer = true;
}
value = m_configSdl.kcfg_audio_backend->itemData(m_configSdl.kcfg_audio_backend->currentIndex()).toString();
value = m_configSdl.kcfg_audio_backend->currentData().toString();
if (value != KdenliveSettings::audiobackend()) {
KdenliveSettings::setAudiobackend(value);
resetConsumer = true;
......@@ -1293,6 +1305,31 @@ void KdenliveSettingsDialog::slotManageEncodingProfile()
loadEncodingProfiles();
}
void KdenliveSettingsDialog::loadExternalProxyProfiles()
{
// load proxy profiles
KConfig conf(QStringLiteral("externalproxies.rc"), KConfig::CascadeConfig, QStandardPaths::AppDataLocation);
KConfigGroup group(&conf, "proxy");
QMap<QString, QString> values = group.entryMap();
QMapIterator<QString, QString> k(values);
int ix = -1;
QString currentItem = KdenliveSettings::externalProxyProfile();
m_configProxy.kcfg_external_proxy_profile->blockSignals(true);
m_configProxy.kcfg_external_proxy_profile->clear();
while (k.hasNext()) {
k.next();
if (!k.key().isEmpty()) {
if (k.value().contains(QLatin1Char(';'))) {
m_configProxy.kcfg_external_proxy_profile->addItem(k.key(), k.value());
}
}
}
if (!currentItem.isEmpty()) {
m_configProxy.kcfg_external_proxy_profile->setCurrentIndex(m_configProxy.kcfg_external_proxy_profile->findText(currentItem));
}
m_configProxy.kcfg_external_proxy_profile->blockSignals(false);
}
void KdenliveSettingsDialog::loadEncodingProfiles()
{
KConfig conf(QStringLiteral("encodingprofiles.rc"), KConfig::CascadeConfig, QStandardPaths::AppDataLocation);
......@@ -1377,28 +1414,28 @@ void KdenliveSettingsDialog::loadEncodingProfiles()
}
// Load Proxy profiles
m_configProject.kcfg_proxy_profile->blockSignals(true);
currentItem = m_configProject.kcfg_proxy_profile->currentText();
m_configProject.kcfg_proxy_profile->clear();
m_configProxy.kcfg_proxy_profile->blockSignals(true);
currentItem = m_configProxy.kcfg_proxy_profile->currentText();
m_configProxy.kcfg_proxy_profile->clear();
KConfigGroup group4(&conf, "proxy");
values = group4.entryMap();
m_configProject.kcfg_proxy_profile->addItem(i18n("Automatic"));
m_configProxy.kcfg_proxy_profile->addItem(i18n("Automatic"));
QMapIterator<QString, QString> m(values);
while (m.hasNext()) {
m.next();
if (!m.key().isEmpty()) {
m_configProject.kcfg_proxy_profile->addItem(m.key(), m.value());
m_configProxy.kcfg_proxy_profile->addItem(m.key(), m.value());
}
}
if (!currentItem.isEmpty()) {
m_configProject.kcfg_proxy_profile->setCurrentIndex(m_configProject.kcfg_proxy_profile->findText(currentItem));
m_configProxy.kcfg_proxy_profile->setCurrentIndex(m_configProxy.kcfg_proxy_profile->findText(currentItem));
}
m_configProject.kcfg_proxy_profile->blockSignals(false);
profilestr = m_configProject.kcfg_proxy_profile->itemData(m_configProject.kcfg_proxy_profile->currentIndex()).toString();
m_configProxy.kcfg_proxy_profile->blockSignals(false);
profilestr = m_configProxy.kcfg_proxy_profile->itemData(m_configProxy.kcfg_proxy_profile->currentIndex()).toString();
if (profilestr.isEmpty()) {
m_configProject.proxyparams->clear();
m_configProxy.proxyparams->clear();
} else {
m_configProject.proxyparams->setPlainText(profilestr.section(QLatin1Char(';'), 0, 0));
m_configProxy.proxyparams->setPlainText(profilestr.section(QLatin1Char(';'), 0, 0));
}
}
......@@ -1452,13 +1489,13 @@ void KdenliveSettingsDialog::slotUpdateProxyProfile(int ix)
if (ix == -1) {
ix = KdenliveSettings::proxy_profile();
} else {
ix = m_configProject.kcfg_proxy_profile->currentIndex();
ix = m_configProxy.kcfg_proxy_profile->currentIndex();
}
QString profilestr = m_configProject.kcfg_proxy_profile->itemData(ix).toString();
QString profilestr = m_configProxy.kcfg_proxy_profile->itemData(ix).toString();
if (profilestr.isEmpty()) {
return;
}
m_configProject.proxyparams->setPlainText(profilestr.section(QLatin1Char(';'), 0, 0));
m_configProxy.proxyparams->setPlainText(profilestr.section(QLatin1Char(';'), 0, 0));
}
void KdenliveSettingsDialog::slotUpdatePreviewProfile(int ix)
......
......@@ -29,6 +29,7 @@
#include "ui_configjogshuttle_ui.h"
#include "ui_configmisc_ui.h"
#include "ui_configproject_ui.h"
#include "ui_configproxy_ui.h"
#include "ui_configsdl_ui.h"
#include "ui_configtimeline_ui.h"
#include "ui_configtranscode_ui.h"
......@@ -83,6 +84,7 @@ private slots:
void slotEditVideo4LinuxProfile();
void slotReloadBlackMagic();
void slotReloadShuttleDevices();
void loadExternalProxyProfiles();
private:
KPageWidgetItem *m_page1;
......@@ -101,6 +103,7 @@ private:
Ui::ConfigSdl_UI m_configSdl;
Ui::ConfigTranscode_UI m_configTranscode;
Ui::ConfigProject_UI m_configProject;
Ui::ConfigProxy_UI m_configProxy;
ProfileWidget *m_pw;
KProcess m_readProcess;
bool m_modified;
......
......@@ -1362,7 +1362,6 @@ bool DocumentValidator::upgrade(double version, const double currentVersion)
originalProd.removeAttribute(QStringLiteral("file_hash"));
originalProd.removeAttribute(QStringLiteral("file_size"));
originalProd.removeAttribute(QStringLiteral("frame_size"));
originalProd.removeAttribute(QStringLiteral("proxy_out"));
originalProd.removeAttribute(QStringLiteral("zone_out"));
originalProd.removeAttribute(QStringLiteral("zone_in"));
originalProd.removeAttribute(QStringLiteral("name"));
......
......@@ -100,6 +100,8 @@ KdenliveDoc::KdenliveDoc(const QUrl &url, const QString &projectFolder, QUndoGro
m_documentProperties[QStringLiteral("proxyextension")] = KdenliveSettings::proxyextension();
m_documentProperties[QStringLiteral("previewparameters")] = KdenliveSettings::previewparams();
m_documentProperties[QStringLiteral("previewextension")] = KdenliveSettings::previewextension();
m_documentProperties[QStringLiteral("externalproxyparams")] = KdenliveSettings::externalProxyProfile();
m_documentProperties[QStringLiteral("enableexternalproxy")] = QString::number((int)KdenliveSettings::externalproxy());
m_documentProperties[QStringLiteral("generateproxy")] = QString::number((int)KdenliveSettings::generateproxy());
m_documentProperties[QStringLiteral("proxyminsize")] = QString::number(KdenliveSettings::proxyminsize());
m_documentProperties[QStringLiteral("generateimageproxy")] = QString::number((int)KdenliveSettings::generateimageproxy());
......@@ -407,6 +409,11 @@ bool KdenliveDoc::useProxy() const
return m_documentProperties.value(QStringLiteral("enableproxy")).toInt() != 0;
}
bool KdenliveDoc::useExternalProxy() const
{
return m_documentProperties.value(QStringLiteral("enableexternalproxy")).toInt() != 0;
}
bool KdenliveDoc::autoGenerateProxy(int width) const
{
return (m_documentProperties.value(QStringLiteral("generateproxy")).toInt() != 0) &&
......@@ -1174,6 +1181,7 @@ void KdenliveDoc::slotProxyCurrentItem(bool doProxy, QList<std::shared_ptr<Proje
}
// Parse clips
QStringList externalProxyParams = m_documentProperties.value(QStringLiteral("externalproxyparams")).split(QLatin1Char(';'));
for (int i = 0; i < clipList.count(); ++i) {
std::shared_ptr<ProjectClip> item = clipList.at(i);
ClipType::ProducerType t = item->clipType();
......@@ -1188,9 +1196,30 @@ void KdenliveDoc::slotProxyCurrentItem(bool doProxy, QList<std::shared_ptr<Proje
if (doProxy) {
newProps.clear();
QString path = dir.absoluteFilePath(item->hash() + (t == ClipType::Image ? QStringLiteral(".png") : extension));
// insert required duration for proxy
newProps.insert(QStringLiteral("proxy_out"), item->getProducerProperty(QStringLiteral("out")));
QString path;
if (useExternalProxy() && item->hasLimitedDuration()) {
if (externalProxyParams.count() == 3) {
QFileInfo info(item->url());
QDir clipDir = info.absoluteDir();
if (clipDir.cd(externalProxyParams.at(0))) {
// Find correct file
QString fileName = info.fileName();
if (!externalProxyParams.at(1).isEmpty()) {
fileName.prepend(externalProxyParams.at(1));
}
if (!externalProxyParams.at(2).isEmpty()) {
fileName = fileName.section(QLatin1Char('.'), 0, -2);
fileName.append(externalProxyParams.at(2));
}
if (clipDir.exists(fileName)) {
path = clipDir.absoluteFilePath(fileName);
}
}
}
}
if (path.isEmpty()) {
path = dir.absoluteFilePath(item->hash() + (t == ClipType::Image ? QStringLiteral(".png") : extension));
}
newProps.insert(QStringLiteral("kdenlive:proxy"), path);
// We need to insert empty proxy so that undo will work
// TODO: how to handle clip properties
......
......@@ -122,6 +122,7 @@ public:
/** @brief Get all document properties that need to be saved */
QMap<QString, QString> documentProperties();
bool useProxy() const;
bool useExternalProxy() const;
bool autoGenerateProxy(int width) const;
bool autoGenerateImageProxy(int width) const;
/** @brief Saves effects embedded in project file. */
......
......@@ -131,11 +131,26 @@
<default>false</default>
</entry>
<entry name="externalproxy" type="Bool">
<label>Enable proxy clips.</label>
<default>false</default>
</entry>
<entry name="generateproxy" type="Bool">
<label>Auto generate proxy for new clips.</label>
<default>false</default>
</entry>
<entry name="external_proxy_profile" type="Int">
<label>index for the external proxy clips combo.</label>
<default></default>
</entry>
<entry name="externalProxyProfile" type="String">
<label>Pattern to find external proxy clips.</label>
<default></default>
</entry>
<entry name="generateimageproxy" type="Bool">
<label>Auto generate proxy for new image clips.</label>
<default>false</default>
......
......@@ -1621,6 +1621,17 @@ void MainWindow::slotEditProjectSettings()
pCore->bin()->rebuildProxies();
}
}
if (project->getDocumentProperty(QStringLiteral("externalproxyparams")) != w->externalProxyParams()) {
modified = true;
project->setDocumentProperty(QStringLiteral("externalproxyparams"), w->externalProxyParams());
if (pCore->projectItemModel()->clipsCount() > 0 &&
KMessageBox::questionYesNo(this, i18n("You have changed the proxy parameters. Do you want to recreate all proxy clips for this project?")) ==
KMessageBox::Yes) {
pCore->bin()->rebuildProxies();
}
}
if (project->getDocumentProperty(QStringLiteral("generateproxy")) != QString::number((int)w->generateProxy())) {
modified = true;
project->setDocumentProperty(QStringLiteral("generateproxy"), QString::number((int)w->generateProxy()));
......@@ -1646,6 +1657,10 @@ void MainWindow::slotEditProjectSettings()
modified = true;
slotUpdateProxySettings();
}
if (QString::number((int)w->useExternalProxy()) != project->getDocumentProperty(QStringLiteral("enableexternalproxy"))) {
project->setDocumentProperty(QStringLiteral("enableexternalproxy"), QString::number((int)w->useExternalProxy()));
modified = true;
}
if (w->metadata() != project->metadata()) {
project->setMetadata(w->metadata());
}
......
......@@ -100,10 +100,12 @@ ProjectSettings::ProjectSettings(KdenliveDoc *doc, QMap<QString, QString> metada
generate_proxy->setChecked(doc->getDocumentProperty(QStringLiteral("generateproxy")).toInt() != 0);
proxy_minsize->setValue(doc->getDocumentProperty(QStringLiteral("proxyminsize")).toInt());
m_proxyparameters = doc->getDocumentProperty(QStringLiteral("proxyparams"));
m_initialExternalProxyProfile = doc->getDocumentProperty(QStringLiteral("externalproxyparams"));
generate_imageproxy->setChecked(doc->getDocumentProperty(QStringLiteral("generateimageproxy")).toInt() != 0);
proxy_imageminsize->setValue(doc->getDocumentProperty(QStringLiteral("proxyimageminsize")).toInt());
proxy_imagesize->setValue(doc->getDocumentProperty(QStringLiteral("proxyimagesize")).toInt());
m_proxyextension = doc->getDocumentProperty(QStringLiteral("proxyextension"));
external_proxy->setChecked(doc->getDocumentProperty(QStringLiteral("enableexternalproxy")).toInt() != 0);
m_previewparams = doc->getDocumentProperty(QStringLiteral("previewparameters"));
m_previewextension = doc->getDocumentProperty(QStringLiteral("previewextension"));
QString storageFolder = doc->getDocumentProperty(QStringLiteral("storagefolder"));
......@@ -118,6 +120,9 @@ ProjectSettings::ProjectSettings(KdenliveDoc *doc, QMap<QString, QString> metada
} else {
currentProf = KdenliveSettings::default_profile();
enable_proxy->setChecked(KdenliveSettings::enableproxy());
external_proxy->setChecked(KdenliveSettings::externalproxy());
qDebug()<<"//// INITIAL REPORT; ENABLE EXT PROCY: "<<KdenliveSettings::externalproxy()<<"\n++++++++";
m_initialExternalProxyProfile = KdenliveSettings::externalProxyProfile();
generate_proxy->setChecked(KdenliveSettings::generateproxy());
proxy_minsize->setValue(KdenliveSettings::proxyminsize());
m_proxyparameters = KdenliveSettings::proxyparams();
......@@ -137,6 +142,7 @@ ProjectSettings::ProjectSettings(KdenliveDoc *doc, QMap<QString, QString> metada
loadProxyProfiles();
loadPreviewProfiles();
loadExternalProxyProfiles();
// Proxy GUI stuff
proxy_showprofileinfo->setIcon(QIcon::fromTheme(QStringLiteral("help-about")));
......@@ -147,11 +153,13 @@ ProjectSettings::ProjectSettings(KdenliveDoc *doc, QMap<QString, QString> metada
connect(proxy_manageprofile, &QAbstractButton::clicked, this, &ProjectSettings::slotManageEncodingProfile);
proxy_profile->setToolTip(i18n("Select default proxy profile"));
connect(proxy_profile, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUpdateProxyParams()));
connect(proxy_profile, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &ProjectSettings::slotUpdateProxyParams);
proxyparams->setVisible(false);
proxyparams->setMaximumHeight(QFontMetrics(font()).lineSpacing() * 5);
connect(proxy_showprofileinfo, &QAbstractButton::clicked, proxyparams, &QWidget::setVisible);
external_proxy_profile->setToolTip(i18n("Select camcorder profile"));
// Preview GUI stuff
preview_showprofileinfo->setIcon(QIcon::fromTheme(QStringLiteral("help-about")));
preview_showprofileinfo->setToolTip(i18n("Show default profile parameters"));
......@@ -161,7 +169,7 @@ ProjectSettings::ProjectSettings(KdenliveDoc *doc, QMap<QString, QString> metada
connect(preview_manageprofile, &QAbstractButton::clicked, this, &ProjectSettings::slotManagePreviewProfile);
preview_profile->setToolTip(i18n("Select default preview profile"));
connect(preview_profile, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUpdatePreviewParams()));
connect(preview_profile, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &ProjectSettings::slotUpdatePreviewParams);
previewparams->setVisible(false);
previewparams->setMaximumHeight(QFontMetrics(font()).lineSpacing() * 5);
connect(preview_showprofileinfo, &QAbstractButton::clicked, previewparams, &QWidget::setVisible);
......@@ -477,6 +485,11 @@ bool ProjectSettings::useProxy() const
return enable_proxy->isChecked();
}
bool ProjectSettings::useExternalProxy() const
{
return external_proxy->isChecked();
}
bool ProjectSettings::generateProxy() const
{
return generate_proxy->isChecked();
......@@ -502,15 +515,21 @@ int ProjectSettings::proxyImageSize() const
return proxy_imagesize->value();
}
QString ProjectSettings::externalProxyParams() const
{
return external_proxy_profile->currentData().toString();
}
QString ProjectSettings::proxyParams() const
{
QString params = proxy_profile->itemData(proxy_profile->currentIndex()).toString();
QString params = proxy_profile->currentData().toString();
return params.section(QLatin1Char(';'), 0, 0);
}
QString ProjectSettings::proxyExtension() const
{
QString params = proxy_profile->itemData(proxy_profile->currentIndex()).toString();
QString params = proxy_profile->currentData().toString();
return params.section(QLatin1Char(';'), 1, 1);
}
......@@ -649,13 +668,13 @@ void ProjectSettings::slotExportToText()
void ProjectSettings::slotUpdateProxyParams()
{
QString params = proxy_profile->itemData(proxy_profile->currentIndex()).toString();
QString params = proxy_profile->currentData().toString();
proxyparams->setPlainText(params.section(QLatin1Char(';'), 0, 0));
}
void ProjectSettings::slotUpdatePreviewParams()
{
QString params = preview_profile->itemData(preview_profile->currentIndex()).toString();
QString params = preview_profile->currentData().toString();
previewparams->setPlainText(params.section(QLatin1Char(';'), 0, 0));
}
......@@ -756,6 +775,36 @@ void ProjectSettings::loadProxyProfiles()
slotUpdateProxyParams();
}
void ProjectSettings::loadExternalProxyProfiles()
{
// load proxy profiles
KConfig conf(QStringLiteral("externalproxies.rc"), KConfig::CascadeConfig, QStandardPaths::AppDataLocation);
KConfigGroup group(&conf, "proxy");
QMap<QString, QString> values = group.entryMap();
QMapIterator<QString, QString> k(values);
int ix = -1;
external_proxy_profile->clear();
while (k.hasNext()) {
k.next();
if (!k.key().isEmpty()) {
if (ix == -1 && k.value() == m_initialExternalProxyProfile) {
// this is the current profile
ix = external_proxy_profile->count();
}
if (k.value().contains(QLatin1Char(';'))) {
external_proxy_profile->addItem(k.key(), k.value());
}
}
}
if (ix == -1 && !m_initialExternalProxyProfile.isEmpty()) {
// Current project proxy settings not found
ix = external_proxy_profile->count();
external_proxy_profile->addItem(i18n("Current Settings"), m_initialExternalProxyProfile);
}
external_proxy_profile->setCurrentIndex(ix);
}
void ProjectSettings::loadPreviewProfiles()
{
// load proxy profiles
......
......@@ -41,11 +41,13 @@ public:
bool enableVideoThumbs() const;
bool enableAudioThumbs() const;
bool useProxy() const;
bool useExternalProxy() const;
bool generateProxy() const;
int proxyMinSize() const;
bool generateImageProxy() const;
int proxyImageMinSize() const;
int proxyImageSize() const;
QString externalProxyParams() const;
QString proxyParams() const;
QString proxyExtension() const;
const QMap<QString, QString> metadata() const;
......@@ -90,8 +92,11 @@ private:
QDir m_previewDir;
/** @brief Fill the proxy profiles combobox. */
void loadProxyProfiles();
/** @brief Fill the external proxy profiles combobox. */
void loadExternalProxyProfiles();
QString m_previewparams;
QString m_previewextension;
QString m_initialExternalProxyProfile;
/** @brief Fill the proxy profiles combobox. */
void loadPreviewProfiles();
......