]> git.sesse.net Git - kdenlive/commitdiff
Proxy settings is now configurable per project
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Sat, 12 Feb 2011 00:31:44 +0000 (00:31 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Sat, 12 Feb 2011 00:31:44 +0000 (00:31 +0000)
svn path=/trunk/kdenlive/; revision=5391

14 files changed:
src/docclipbase.cpp
src/docclipbase.h
src/kdenlivedoc.cpp
src/kdenlivesettings.kcfg
src/kdenlivesettingsdialog.cpp
src/kdenlivesettingsdialog.h
src/mainwindow.cpp
src/projectlist.cpp
src/projectlist.h
src/projectsettings.cpp
src/projectsettings.h
src/renderwidget.cpp
src/renderwidget.h
src/widgets/projectsettings_ui.ui

index 06342e6c9dbcbbd6f83d2cfa4c6a85b501e5b3e6..740628ef4e9bedd865e12e11b112446dca4ae3ff 100644 (file)
@@ -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
index eea1e33df660492600b580fd2567d69ea7bf6cc4..a130e16ad4e592c6c708e79cd1c392cfa11a02a6 100644 (file)
@@ -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
index 1ce567cb1a1dcacc8d7e2e94bb3f2f21cfea463e..91d6a4a3db860eac56a762fbe248b66b7b00c037 100644 (file)
@@ -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);
index 1ff03befa366e6dbc2f8327a06d673c814d1e2a6..e9ed358e534be52e019e8204b9eae3034dd5c767 100644 (file)
   </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>
index b6eb1efde3059ceeed96688a52225c4796604d21..9bed2b3cc41c79f5a5604f2e1b1eb807fa9c8427 100644 (file)
@@ -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) {
index 6ffa99b9937979ba3f436cf6b020f27b14c54db1..1f06efc7648ee845c9adcfed6aab66b6890aa1f5 100644 (file)
@@ -104,7 +104,6 @@ signals:
     void customChanged();
     void doResetProfile();
     void updateCaptureFolder();
-    void updateProxySettings();
 };
 
 
index 66d52156223ca2f11b400d4336021ca566a8ac3b..7b99e596ef27e9a15d6b6d9fa20f8b833a11cad6 100644 (file)
@@ -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();
index e44fbc1a1839b8fe088f4b74d8181e52d52c68f9..03b8cd2c49fe438e59bd1b256136386fed395edd 100644 (file)
@@ -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
index fdb6d4945237ec91864cef24aba1539f3e975c9e..198baee42d5a4e1b70e98114d3894086b60b8767 100644 (file)
@@ -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);
 
index abefb7616006d85eef010231b728e4fd05e7a108..0fec99c79d6233f85637a54ce3c1f7feb7a41614 100644 (file)
@@ -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)
index cc64a3880f29d1bd06f747138ca4e291f9801907..6442307befdbd5b122ecd417bf4d911d0c1c5761 100644 (file)
@@ -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);
 
index 2535ced859d8c2524a60319996cf918902979bb0..7b0d5117c2370ff6a658183f1784057d972b4b80 100644 (file)
@@ -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()
index 7b1c20d82d3095d5379cb79a1200d92c076bd0a0..708d39a605c1b728b2fe8f30c0bd6cd672490164 100644 (file)
@@ -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();
 
index d96e83bb8594e9851205d03b7dde1619f7eb232d..30b9cdcb476a39a0c717f8cc49420f3679fc8070 100644 (file)
@@ -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">
    <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">
          </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>
          </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>
          </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">
      </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>