]> git.sesse.net Git - kdenlive/commitdiff
User can now enable / disable proxy for each clip
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 18 Jan 2011 22:16:49 +0000 (22:16 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 18 Jan 2011 22:16:49 +0000 (22:16 +0000)
svn path=/trunk/kdenlive/; revision=5334

src/kdenlivesettings.kcfg
src/projectitem.cpp
src/projectitem.h
src/projectlist.cpp
src/projectlist.h
src/renderer.cpp
src/widgets/configproject_ui.ui

index 904d1162238dc0728fcdba7398089ef75554aaf0..6c3169627b07ef0ae41769753c00c70097b9f8af 100644 (file)
       <label>Enable proxy clips.</label>
       <default>false</default>
     </entry>
-
-    <entry name="autoproxy" type="Bool">
-      <label>Automatically create proxy clips.</label>
-      <default>true</default>
-    </entry>
     
     <entry name="proxyparams" type="String">
       <label>Proxy clips transcoding parameters.</label>
index ac2a52568d113d30846f0f03433aaacc9b95e83a..731c5a69bd359d1c5a9b4b9ad9e926e146676570 100644 (file)
@@ -244,3 +244,7 @@ void ProjectItem::setProxyStatus(int status)
     setData(0, ProxyRole, status);
 }
 
+bool ProjectItem::hasProxy() const
+{
+    return data(0, ProxyRole).toInt() == 2;
+}
index 06ff6979e0f8b452fa89627517277472da101169..536c34037ca7fbdf0203af5d1dff67c69c746251 100644 (file)
@@ -65,6 +65,8 @@ public:
     void slotSetToolTip();
     /** \brief Set the status of proxy clip creation. 0 = no proxy, 1 = creating proxy, 2 = proxy created. */
     void setProxyStatus(int status);
+    /** \brief Returns the proxy status for this clip (true means there is a proxy clip. */
+    bool hasProxy() const;
 
     virtual bool operator<(const QTreeWidgetItem &other)const {
         int column = treeWidget()->sortColumn();
index bf88350129ab0454074f05af8473ecbe95b7358e..fcb4a6e0bf0fb2c4878c54ef5227556b463f2214 100644 (file)
@@ -111,6 +111,12 @@ ProjectList::ProjectList(QWidget *parent) :
     setLayout(layout);
     searchView->setTreeWidget(m_listView);
 
+    m_proxyAction = new QAction(i18n("Proxy clip"), this);
+    m_proxyAction->setCheckable(true);
+    m_proxyAction->setChecked(false);
+    connect(m_proxyAction, SIGNAL(toggled(bool)), this, SLOT(slotProxyCurrentItem(bool)));
+    
+    
     m_queueTimer.setInterval(100);
     connect(&m_queueTimer, SIGNAL(timeout()), this, SLOT(slotProcessNextClipInQueue()));
     m_queueTimer.setSingleShot(true);
@@ -200,6 +206,7 @@ void ProjectList::setupGeneratorMenu(QMenu *addMenu, QMenu *transcodeMenu, QMenu
         transcodeMenu->setEnabled(false);
     m_transcodeAction = transcodeMenu;
     m_menu->addAction(m_reloadAction);
+    m_menu->addAction(m_proxyAction);
     m_menu->addMenu(inTimelineMenu);
     inTimelineMenu->setEnabled(false);
     m_menu->addAction(m_editButton->defaultAction());
@@ -524,6 +531,7 @@ void ProjectList::slotClipSelected()
             m_openAction->setEnabled(false);
             m_reloadAction->setEnabled(false);
             m_transcodeAction->setEnabled(false);
+            m_proxyAction->setEnabled(false);
         } else {
             ProjectItem *clip;
             if (m_listView->currentItem()->type() == PROJECTSUBCLIPTYPE) {
@@ -567,6 +575,16 @@ void ProjectList::slotClipSelected()
     }
 }
 
+void ProjectList::adjustProxyActions(ProjectItem *clip) const
+{
+    if (clip == NULL || clip->type() != PROJECTCLIPTYPE || clip->clipType() == COLOR || clip->clipType() == TEXT || clip->clipType() == PLAYLIST || clip->clipType() == SLIDESHOW || clip->clipType() == AUDIO) {
+        m_proxyAction->setEnabled(false);
+        return;
+    }
+    m_proxyAction->setEnabled(true);
+    m_proxyAction->setChecked(clip->hasProxy());
+}
+
 void ProjectList::adjustTranscodeActions(ProjectItem *clip) const
 {
     if (clip == NULL || clip->type() != PROJECTCLIPTYPE || clip->clipType() == COLOR || clip->clipType() == TEXT || clip->clipType() == PLAYLIST || clip->clipType() == SLIDESHOW) {
@@ -721,6 +739,7 @@ void ProjectList::slotContextMenu(const QPoint &pos, QTreeWidgetItem *item)
             clip = static_cast <ProjectItem*>(item);
             // Display relevant transcoding actions only
             adjustTranscodeActions(clip);
+            adjustProxyActions(clip);
             // Display uses in timeline
             emit findInTimeline(clip->clipId());
         } else {
@@ -1991,4 +2010,28 @@ void ProjectList::updateProxyConfig()
 
 }
 
+void ProjectList::slotProxyCurrentItem(bool doProxy)
+{
+    if (m_listView->currentItem()->type() == PROJECTCLIPTYPE) {
+        ProjectItem *item = static_cast <ProjectItem*>(m_listView->currentItem());
+        if (item->referencedClip()) {
+            if (doProxy) {
+                DocClipBase *clip = item->referencedClip();
+                connect(clip, SIGNAL(proxyReady(const QString, bool)), this, SLOT(slotGotProxy(const QString, bool)));
+                item->setProxyStatus(1);
+                clip->generateProxy(m_doc->projectFolder());
+            }
+            else if (!item->referencedClip()->getProperty("proxy").isEmpty()) {
+                // remove proxy
+                item->referencedClip()->clearProperty("proxy");
+                QDomElement e = item->toXml().cloneNode().toElement();
+                e.removeAttribute("file_hash");
+                e.setAttribute("replace", 1);
+                m_infoQueue.insert(item->clipId(), e);
+            }
+        }
+        if (!m_infoQueue.isEmpty() && !m_queueTimer.isActive()) m_queueTimer.start();
+    }
+}
+
 #include "projectlist.moc"
index 42d56d6c8af36397fa9aa02e3013c3168a25f165..f63191d2f0547260b11ad138e569611eceba9dc3 100644 (file)
@@ -249,6 +249,7 @@ private:
     QMap <QString, QDomElement> m_producerQueue;
     void requestClipInfo(const QDomElement xml, const QString id);
     QList <QString> m_thumbnailQueue;
+    QAction *m_proxyAction;
     void requestClipThumbnail(const QString id);
 
     /** @brief Creates an EditFolderCommand to change the name of an folder item. */
@@ -261,6 +262,8 @@ private:
 
     /** @brief Enables and disables transcode actions based on the selected clip's type. */
     void adjustTranscodeActions(ProjectItem *clip) const;
+    /** @brief Enables and disables proxy action based on the selected clip. */
+    void adjustProxyActions(ProjectItem *clip) const;
 
     /** @brief Sets the buttons enabled/disabled according to selected item. */
     void updateButtons() const;
@@ -296,6 +299,8 @@ private slots:
     void slotAddOrUpdateSequence(const QString frameName);
     /** @brief A proxy clip was created, update display. */
     void slotGotProxy(const QString id, bool success);
+    /** @brief Enable / disable proxy for current clip. */
+    void slotProxyCurrentItem(bool doProxy);
 
 signals:
     void clipSelected(DocClipBase *, QPoint zone = QPoint());
index 22873c4dcb1f7b740c9a9c843e18b233c9a99957..17ab206be0c49ad2e5917e959bc9a53a6e68fff0 100644 (file)
@@ -523,7 +523,7 @@ void Render::slotSplitView(bool doit)
 void Render::getFileProperties(const QDomElement xml, const QString &clipId, int imageHeight, bool replaceProducer)
 {
     QString path;
-    if (KdenliveSettings::enableproxy() && xml.hasAttribute("proxy")) path = xml.attribute("proxy");
+    if (xml.hasAttribute("proxy")) path = xml.attribute("proxy");
     else path = xml.attribute("resource");
     KUrl url = KUrl(path);
     Mlt::Producer *producer = NULL;
index 398dac0db15c7f963d0fc26e4ca6027e229ec669..52544b57cd4d510fa8e8b01f0859d5872f1cddaa 100644 (file)
@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>268</width>
-    <height>333</height>
+    <width>264</width>
+    <height>304</height>
    </rect>
   </property>
   <property name="windowTitle">
       <item row="0" column="0">
        <widget class="QCheckBox" name="kcfg_enableproxy">
         <property name="text">
-         <string>Enable proxy clips for HD</string>
+         <string>Generate proxy clips</string>
         </property>
        </widget>
       </item>
       <item row="1" column="0">
-       <widget class="QCheckBox" name="kcfg_autoproxy">
-        <property name="text">
-         <string>Generate automatically</string>
-        </property>
-       </widget>
-      </item>
-      <item row="2" column="0">
        <widget class="QLabel" name="label">
         <property name="text">
          <string>Transcoding parameters</string>
         </property>
        </widget>
       </item>
-      <item row="3" column="0">
+      <item row="2" column="0">
        <widget class="QPlainTextEdit" name="kcfg_proxyparams">
         <property name="sizePolicy">
          <sizepolicy hsizetype="Expanding" vsizetype="Preferred">