Proxy settings is now configurable per project

svn path=/trunk/kdenlive/; revision=5391
parent 4881a457
......@@ -1082,12 +1082,11 @@ bool DocClipBase::hasAudioCodec(const QString &codec) const
return prod->get(property) == codec;
}
void DocClipBase::generateProxy(KUrl proxyFolder)
void DocClipBase::generateProxy(KUrl proxyFolder, QString params)
{
if (m_proxyThread.isRunning()) return;
QStringList parameters;
parameters << "-i" << m_properties.value("resource");
QString params = KdenliveSettings::proxyparams().simplified();
foreach(QString s, params.split(' '))
parameters << s;
// Make sure we don't block when proxy file already exists
......
......@@ -205,7 +205,7 @@ Q_OBJECT public:
bool checkHash() const;
void setPlaceHolder(bool place);
/** @brief Generate a proxy clip (lower resolution copy) named like the clip's hash. */
void generateProxy(KUrl proxyFolder);
void generateProxy(KUrl proxyFolder, QString params);
/** @brief Abort creation of the proxy clip (lower resolution copy). */
void abortProxy();
......@@ -278,7 +278,7 @@ private slots:
signals:
void gotAudioData();
void proxyReady(const QString, bool success);
void proxyReady(const QString &, bool success);
};
#endif
......@@ -74,7 +74,9 @@ KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup
m_documentProperties["verticalzoom"] = "1";
m_documentProperties["zonein"] = "0";
m_documentProperties["zoneout"] = "100";
m_documentProperties["enableproxy"] = QString::number((int) KdenliveSettings::enableproxy());
m_documentProperties["proxyparams"] = KdenliveSettings::proxyparams();
if (!url.isEmpty()) {
QString tmpFile;
success = KIO::NetAccess::download(url.path(), tmpFile, parent);
......
......@@ -518,10 +518,6 @@
</group>
<group name="drag_value">
<entry name="dragvalue_nonlinear" type="Bool">
<label>...</label>
<default>false</default>
</entry>
<entry name="dragvalue_mode" type="Int">
<label>...</label>
<default>0</default>
......
......@@ -617,7 +617,6 @@ void KdenliveSettingsDialog::updateSettings()
if (m_configProject.kcfg_enableproxy->isChecked() != KdenliveSettings::enableproxy()) {
KdenliveSettings::setEnableproxy(m_configProject.kcfg_enableproxy->isChecked());
emit updateProxySettings();
}
if (m_modified) {
......
......@@ -104,7 +104,6 @@ signals:
void customChanged();
void doResetProfile();
void updateCaptureFolder();
void updateProxySettings();
};
......
......@@ -1803,6 +1803,8 @@ void MainWindow::newFile(bool showProjectSettings, bool force)
QString profileName = KdenliveSettings::default_profile();
KUrl projectFolder = KdenliveSettings::defaultprojectfolder();
QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
bool useProxy = KdenliveSettings::enableproxy();
QString proxyParams = KdenliveSettings::proxyparams();
if (!showProjectSettings) {
if (!KdenliveSettings::activatetabs())
if (!closeCurrentDocument())
......@@ -1821,11 +1823,15 @@ void MainWindow::newFile(bool showProjectSettings, bool force)
profileName = w->selectedProfile();
projectFolder = w->selectedFolder();
projectTracks = w->tracks();
useProxy = w->useProxy();
proxyParams = w->proxyParams();
delete w;
}
m_timelineArea->setEnabled(true);
m_projectList->setEnabled(true);
KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, m_projectMonitor->render, m_notesWidget, this);
doc->setDocumentProperty("useproxy", QString::number((int) useProxy));
doc->setDocumentProperty("proxyparams", proxyParams);
doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
bool ok;
TrackView *trackView = new TrackView(doc, &ok, this);
......@@ -2219,6 +2225,11 @@ void MainWindow::slotEditProjectSettings()
if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) slotSwitchVideoThumbs();
if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) slotSwitchAudioThumbs();
if (m_activeDocument->profilePath() != profile) slotUpdateProjectProfile(profile);
m_activeDocument->setDocumentProperty("proxyparams", w->proxyParams());
if (QString::number((int) w->useProxy()) != m_activeDocument->getDocumentProperty("enableproxy")) {
m_activeDocument->setDocumentProperty("enableproxy", QString::number((int) w->useProxy()));
slotUpdateProxySettings();
}
}
delete w;
}
......@@ -2265,7 +2276,7 @@ void MainWindow::slotRenderProject()
{
if (!m_renderWidget) {
QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) : KdenliveSettings::defaultprojectfolder();
m_renderWidget = new RenderWidget(projectfolder, this);
m_renderWidget = new RenderWidget(projectfolder, m_projectList->useProxy(), this);
connect(m_renderWidget, SIGNAL(shutdown()), this, SLOT(slotShutdown()));
connect(m_renderWidget, SIGNAL(selectedRenderProfile(QMap <QString, QString>)), this, SLOT(slotSetDocumentRenderProfile(QMap <QString, QString>)));
connect(m_renderWidget, SIGNAL(prepareRenderingData(bool, bool, const QString&)), this, SLOT(slotPrepareRendering(bool, bool, const QString&)));
......@@ -2573,7 +2584,6 @@ void MainWindow::slotPreferences(int page, int option)
KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(actions, this);
connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
connect(dialog, SIGNAL(updateProxySettings()), this, SLOT(slotUpdateProxySettings()));
connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
#ifndef Q_WS_MAC
connect(dialog, SIGNAL(updateCaptureFolder()), this, SLOT(slotUpdateCaptureFolder()));
......@@ -3805,7 +3815,7 @@ void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QS
} else exportAudio = m_renderWidget->selectedAudioExport();
// Do we want proxy rendering
if (KdenliveSettings::enableproxy() && !m_renderWidget->proxyRendering()) {
if (m_projectList->useProxy() && !m_renderWidget->proxyRendering()) {
// replace proxy clips with originals
QMap <QString, QString> proxies = m_projectList->getProxies();
QMapIterator<QString, QString> i(proxies);
......@@ -4139,7 +4149,7 @@ void MainWindow::slotDeleteClip(const QString &id)
void MainWindow::slotUpdateProxySettings()
{
if (m_renderWidget) m_renderWidget->updateProxyConfig();
if (m_renderWidget) m_renderWidget->updateProxyConfig(m_projectList->useProxy());
if (KdenliveSettings::enableproxy())
KStandardDirs::makeDir(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "proxy/");
m_projectList->updateProxyConfig();
......
......@@ -964,14 +964,15 @@ void ProjectList::slotAddClip(DocClipBase *clip, bool getProperties)
item = new ProjectItem(m_listView, clip);
if (item->data(0, DurationRole).isNull()) item->setData(0, DurationRole, i18n("Loading"));
if (getProperties) {
qApp->processEvents();
m_refreshed = false;
// Proxy clips
CLIPTYPE t = clip->clipType();
if ((t == VIDEO || t == AV || t == UNKNOWN) && KdenliveSettings::enableproxy()) {
if ((t == VIDEO || t == AV || t == UNKNOWN) && useProxy()) {
if (clip->getProperty("proxy").isEmpty()) {
connect(clip, SIGNAL(proxyReady(const QString, bool)), this, SLOT(slotGotProxy(const QString, bool)));
connect(clip, SIGNAL(proxyReady(const QString&, bool)), this, SLOT(slotGotProxy(const QString&, bool)));
setProxyStatus(item, 1);
clip->generateProxy(m_doc->projectFolder());
clip->generateProxy(m_doc->projectFolder(), proxyParams());
}
else {
// Proxy clip already created
......@@ -991,9 +992,9 @@ void ProjectList::slotAddClip(DocClipBase *clip, bool getProperties)
//m_render->getFileProperties(clip->toXML(), clip->getId(), true);
}
else if (!clip->getProperty("proxy").isEmpty()) {
connect(clip, SIGNAL(proxyReady(const QString, bool)), this, SLOT(slotGotProxy(const QString, bool)));
connect(clip, SIGNAL(proxyReady(const QString&, bool)), this, SLOT(slotGotProxy(const QString&, bool)));
setProxyStatus(item, 1);
clip->generateProxy(m_doc->projectFolder());
clip->generateProxy(m_doc->projectFolder(), proxyParams());
}
clip->askForAudioThumbs();
......@@ -1041,7 +1042,7 @@ void ProjectList::slotAddClip(DocClipBase *clip, bool getProperties)
m_queueRunner = QtConcurrent::run(this, &ProjectList::slotProcessNextClipInQueue);
}
void ProjectList::slotGotProxy(const QString id, bool success)
void ProjectList::slotGotProxy(const QString &id, bool success)
{
ProjectItem *item = getItemById(id);
if (item) {
......@@ -1668,6 +1669,16 @@ bool ProjectList::adjustProjectProfileToItem(ProjectItem *item)
return profileUpdated;
}
bool ProjectList::useProxy() const
{
return m_doc->getDocumentProperty("enableproxy").toInt();
}
QString ProjectList::proxyParams() const
{
return m_doc->getDocumentProperty("proxyparams").simplified();
}
void ProjectList::slotReplyGetImage(const QString &clipId, const QPixmap &pix)
{
ProjectItem *item = getItemById(clipId);
......@@ -1722,7 +1733,7 @@ ProjectItem *ProjectList::getItemById(const QString &id)
QTreeWidgetItemIterator it(m_listView);
while (*it) {
if ((*it)->type() != PROJECTCLIPTYPE) {
// subitem
// subitem or folder
++it;
continue;
}
......@@ -2010,12 +2021,17 @@ void ProjectList::updateProxyConfig()
continue;
}
item = static_cast<ProjectItem *>(*it);
if (item && item->referencedClip() != NULL) {
if (KdenliveSettings::enableproxy()) {
if (item == NULL) {
++it;
continue;
}
CLIPTYPE t = item->clipType();
if ((t == VIDEO || t == AV || t == UNKNOWN) && item->referencedClip() != NULL) {
if (useProxy()) {
DocClipBase *clip = item->referencedClip();
connect(clip, SIGNAL(proxyReady(const QString, bool)), this, SLOT(slotGotProxy(const QString, bool)));
connect(clip, SIGNAL(proxyReady(const QString &, bool)), this, SLOT(slotGotProxy(const QString &, bool)));
setProxyStatus(item, 1);
clip->generateProxy(m_doc->projectFolder());
clip->generateProxy(m_doc->projectFolder(), proxyParams());
}
else if (!item->referencedClip()->getProperty("proxy").isEmpty()) {
// remove proxy
......@@ -2045,12 +2061,13 @@ void ProjectList::slotProxyCurrentItem(bool doProxy)
}
if (listItem->type() == PROJECTCLIPTYPE) {
ProjectItem *item = static_cast <ProjectItem*>(listItem);
if (item->referencedClip()) {
CLIPTYPE t = item->clipType();
if ((t == VIDEO || t == AV || t == UNKNOWN) && item->referencedClip()) {
if (doProxy) {
DocClipBase *clip = item->referencedClip();
connect(clip, SIGNAL(proxyReady(const QString, bool)), this, SLOT(slotGotProxy(const QString, bool)));
connect(clip, SIGNAL(proxyReady(const QString&, bool)), this, SLOT(slotGotProxy(const QString&, bool)));
setProxyStatus(item, 1);
clip->generateProxy(m_doc->projectFolder());
clip->generateProxy(m_doc->projectFolder(), proxyParams());
}
else if (!item->referencedClip()->getProperty("proxy").isEmpty()) {
// remove proxy
......
......@@ -192,6 +192,10 @@ public:
QMap <QString, QString> getProxies();
/** @brief Enable / disable proxies. */
void updateProxyConfig();
/** @brief Does this project automatically use proxies. */
bool useProxy() const;
/** @brief proxy parameters for this project. */
QString proxyParams() const;
public slots:
void setDocument(KdenliveDoc *doc);
......@@ -306,7 +310,7 @@ private slots:
/** @brief Add a sequence from the stopmotion widget. */
void slotAddOrUpdateSequence(const QString frameName);
/** @brief A proxy clip was created, update display. */
void slotGotProxy(const QString id, bool success);
void slotGotProxy(const QString &id, bool success);
/** @brief Enable / disable proxy for current clip. */
void slotProxyCurrentItem(bool doProxy);
......
......@@ -65,7 +65,18 @@ ProjectSettings::ProjectSettings(ProjectList *projectlist, QStringList lumas, in
video_thumbs->setChecked(KdenliveSettings::videothumbnails());
audio_tracks->setValue(audiotracks);
video_tracks->setValue(videotracks);
connect(enable_proxy, SIGNAL(toggled(bool)), proxy_params, SLOT(setVisible(bool)));
if (projectlist) {
enable_proxy->setChecked(projectlist->useProxy());
proxy_params->setText(projectlist->proxyParams());
proxy_params->setVisible(projectlist->useProxy());
}
else {
enable_proxy->setChecked(KdenliveSettings::enableproxy());
proxy_params->setText(KdenliveSettings::proxyparams());
proxy_params->setVisible(KdenliveSettings::enableproxy());
}
if (readOnlyTracks) {
video_tracks->setEnabled(false);
audio_tracks->setEnabled(false);
......@@ -304,6 +315,15 @@ bool ProjectSettings::enableAudioThumbs() const
return audio_thumbs->isChecked();
}
bool ProjectSettings::useProxy() const
{
return enable_proxy->isChecked();
}
QString ProjectSettings::proxyParams() const
{
return proxy_params->toPlainText();
}
//static
QStringList ProjectSettings::extractPlaylistUrls(QString path)
......
......@@ -38,6 +38,8 @@ public:
QPoint tracks();
bool enableVideoThumbs() const;
bool enableAudioThumbs() const;
bool useProxy() const;
QString proxyParams() const;
static QStringList extractPlaylistUrls(QString path);
static QStringList extractSlideshowUrls(KUrl url);
......
......@@ -59,7 +59,7 @@ const int RUNNINGJOB = 1;
const int FINISHEDJOB = 2;
RenderWidget::RenderWidget(const QString &projectfolder, QWidget * parent) :
RenderWidget::RenderWidget(const QString &projectfolder, bool enableProxy, QWidget * parent) :
QDialog(parent),
m_projectFolder(projectfolder),
m_blockProcessing(false)
......@@ -87,7 +87,7 @@ RenderWidget::RenderWidget(const QString &projectfolder, QWidget * parent) :
m_view.buttonInfo->setDown(true);
} else m_view.advanced_params->hide();
m_view.proxy_render->setHidden(!KdenliveSettings::enableproxy());
m_view.proxy_render->setHidden(!enableProxy);
m_view.rescale_keep->setChecked(KdenliveSettings::rescalekeepratio());
connect(m_view.rescale_width, SIGNAL(valueChanged(int)), this, SLOT(slotUpdateRescaleWidth(int)));
......@@ -1903,9 +1903,9 @@ bool RenderWidget::selectedAudioExport() const
return (m_view.export_audio->checkState() != Qt::Unchecked);
}
void RenderWidget::updateProxyConfig()
void RenderWidget::updateProxyConfig(bool enable)
{
m_view.proxy_render->setHidden(!KdenliveSettings::enableproxy());
m_view.proxy_render->setHidden(!enable);
}
bool RenderWidget::proxyRendering()
......
......@@ -109,7 +109,7 @@ class RenderWidget : public QDialog
Q_OBJECT
public:
explicit RenderWidget(const QString &projectfolder, QWidget * parent = 0);
explicit RenderWidget(const QString &projectfolder, bool enableProxy, QWidget * parent = 0);
virtual ~RenderWidget();
void setGuides(QDomElement guidesxml, double duration);
void focusFirstVisibleItem();
......@@ -128,7 +128,7 @@ public:
/** @brief Returns true if user wants audio export. */
bool selectedAudioExport() const;
/** @brief Show / hide proxy settings. */
void updateProxyConfig();
void updateProxyConfig(bool enable);
/** @brief Should we render using proxy clips. */
bool proxyRendering();
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>289</width>
<height>367</height>
<width>285</width>
<height>433</height>
</rect>
</property>
<property name="windowTitle">
......@@ -23,6 +23,28 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item row="1" column="0" colspan="2">
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
......@@ -196,7 +218,7 @@
</property>
</widget>
</item>
<item row="3" column="3" colspan="2">
<item row="3" column="3" colspan="3">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
......@@ -209,7 +231,7 @@
</property>
</spacer>
</item>
<item row="4" column="0" colspan="2">
<item row="6" column="0" colspan="2">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
......@@ -222,6 +244,16 @@
</property>
</spacer>
</item>
<item row="4" column="0" colspan="5">
<widget class="QCheckBox" name="enable_proxy">
<property name="text">
<string>Enable proxy clips</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="6">
<widget class="QTextEdit" name="proxy_params"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">
......@@ -372,30 +404,6 @@
</widget>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
<zorder>buttonBox</zorder>
<zorder>buttonBox</zorder>
</widget>
</item>
</layout>
</widget>
<customwidgets>
......
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