From 0da74b31221622b53639fae1b31ffc5ddd61c009 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Sat, 12 Feb 2011 00:31:44 +0000 Subject: [PATCH] Proxy settings is now configurable per project svn path=/trunk/kdenlive/; revision=5391 --- src/docclipbase.cpp | 3 +- src/docclipbase.h | 4 +- src/kdenlivedoc.cpp | 4 +- src/kdenlivesettings.kcfg | 4 -- src/kdenlivesettingsdialog.cpp | 1 - src/kdenlivesettingsdialog.h | 1 - src/mainwindow.cpp | 18 +++++++-- src/projectlist.cpp | 45 +++++++++++++++------- src/projectlist.h | 6 ++- src/projectsettings.cpp | 22 ++++++++++- src/projectsettings.h | 2 + src/renderwidget.cpp | 8 ++-- src/renderwidget.h | 4 +- src/widgets/projectsettings_ui.ui | 64 +++++++++++++++++-------------- 14 files changed, 121 insertions(+), 65 deletions(-) diff --git a/src/docclipbase.cpp b/src/docclipbase.cpp index 06342e6c..740628ef 100644 --- a/src/docclipbase.cpp +++ b/src/docclipbase.cpp @@ -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 diff --git a/src/docclipbase.h b/src/docclipbase.h index eea1e33d..a130e16a 100644 --- a/src/docclipbase.h +++ b/src/docclipbase.h @@ -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 diff --git a/src/kdenlivedoc.cpp b/src/kdenlivedoc.cpp index 1ce567cb..91d6a4a3 100644 --- a/src/kdenlivedoc.cpp +++ b/src/kdenlivedoc.cpp @@ -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); diff --git a/src/kdenlivesettings.kcfg b/src/kdenlivesettings.kcfg index 1ff03bef..e9ed358e 100644 --- a/src/kdenlivesettings.kcfg +++ b/src/kdenlivesettings.kcfg @@ -518,10 +518,6 @@ - - - false - 0 diff --git a/src/kdenlivesettingsdialog.cpp b/src/kdenlivesettingsdialog.cpp index b6eb1efd..9bed2b3c 100644 --- a/src/kdenlivesettingsdialog.cpp +++ b/src/kdenlivesettingsdialog.cpp @@ -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) { diff --git a/src/kdenlivesettingsdialog.h b/src/kdenlivesettingsdialog.h index 6ffa99b9..1f06efc7 100644 --- a/src/kdenlivesettingsdialog.h +++ b/src/kdenlivesettingsdialog.h @@ -104,7 +104,6 @@ signals: void customChanged(); void doResetProfile(); void updateCaptureFolder(); - void updateProxySettings(); }; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 66d52156..7b99e596 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -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 )), this, SLOT(slotSetDocumentRenderProfile(QMap ))); 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 proxies = m_projectList->getProxies(); QMapIterator 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(); diff --git a/src/projectlist.cpp b/src/projectlist.cpp index e44fbc1a..03b8cd2c 100644 --- a/src/projectlist.cpp +++ b/src/projectlist.cpp @@ -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(*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 (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 diff --git a/src/projectlist.h b/src/projectlist.h index fdb6d494..198baee4 100644 --- a/src/projectlist.h +++ b/src/projectlist.h @@ -192,6 +192,10 @@ public: QMap 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); diff --git a/src/projectsettings.cpp b/src/projectsettings.cpp index abefb761..0fec99c7 100644 --- a/src/projectsettings.cpp +++ b/src/projectsettings.cpp @@ -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) diff --git a/src/projectsettings.h b/src/projectsettings.h index cc64a388..6442307b 100644 --- a/src/projectsettings.h +++ b/src/projectsettings.h @@ -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); diff --git a/src/renderwidget.cpp b/src/renderwidget.cpp index 2535ced8..7b0d5117 100644 --- a/src/renderwidget.cpp +++ b/src/renderwidget.cpp @@ -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() diff --git a/src/renderwidget.h b/src/renderwidget.h index 7b1c20d8..708d39a6 100644 --- a/src/renderwidget.h +++ b/src/renderwidget.h @@ -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(); diff --git a/src/widgets/projectsettings_ui.ui b/src/widgets/projectsettings_ui.ui index d96e83bb..30b9cdcb 100644 --- a/src/widgets/projectsettings_ui.ui +++ b/src/widgets/projectsettings_ui.ui @@ -6,8 +6,8 @@ 0 0 - 289 - 367 + 285 + 433 @@ -23,6 +23,28 @@ 0 + + + + QFrame::NoFrame + + + QFrame::Raised + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + @@ -196,7 +218,7 @@ - + Qt::Horizontal @@ -209,7 +231,7 @@ - + Qt::Vertical @@ -222,6 +244,16 @@ + + + + Enable proxy clips + + + + + + @@ -372,30 +404,6 @@ - - - - QFrame::NoFrame - - - QFrame::Raised - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - buttonBox - buttonBox - - -- 2.39.2