]> git.sesse.net Git - kdenlive/commitdiff
* Allow to edit transparent background for images in group properties
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Wed, 16 Feb 2011 18:31:06 +0000 (18:31 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Wed, 16 Feb 2011 18:31:06 +0000 (18:31 +0000)
* Fix editing duration of title, image and color clips

svn path=/trunk/kdenlive/; revision=5414

src/clipmanager.cpp
src/clipproperties.cpp
src/docclipbase.cpp
src/mainwindow.cpp
src/projectlist.cpp
src/renderer.cpp
src/titlewidget.cpp
src/widgets/clipproperties_ui.ui

index 3ed3ed378d011b37d8797924edc9291009677392..c81526904d23fb2134ada69c7cb8b22d5885f8ec 100644 (file)
@@ -278,7 +278,7 @@ void ClipManager::slotAddClipList(const KUrl::List urls, const QString group, co
             if (type->name().startsWith("image/")) {
                 prod.setAttribute("type", (int) IMAGE);
                 prod.setAttribute("in", 0);
-                prod.setAttribute("out", m_doc->getFramePos(KdenliveSettings::image_duration()) - 1);
+                prod.setAttribute("out", m_doc->getFramePos(KdenliveSettings::image_duration()));
                 if (KdenliveSettings::autoimagetransparency()) prod.setAttribute("transparency", 1);
                 // Read EXIF metadata for JPEG
                 if (type->is("image/jpeg")) {
@@ -316,7 +316,7 @@ void ClipManager::slotAddClipList(const KUrl::List urls, const QString group, co
                     if (out > 0)
                         prod.setAttribute("out", out);
                     else
-                        prod.setAttribute("out", m_doc->getFramePos(KdenliveSettings::title_duration()) - 1);
+                        prod.setAttribute("out", m_doc->getFramePos(KdenliveSettings::title_duration()));
                 } else
                     txtfile.close();
             }
@@ -362,7 +362,7 @@ void ClipManager::slotAddColorClipFile(const QString name, const QString color,
     uint id = m_clipIdCounter++;
     prod.setAttribute("id", QString::number(id));
     prod.setAttribute("in", "0");
-    prod.setAttribute("out", m_doc->getFramePos(duration) - 1);
+    prod.setAttribute("out", m_doc->getFramePos(duration));
     prod.setAttribute("name", name);
     if (!group.isEmpty()) {
         prod.setAttribute("groupname", group);
@@ -385,7 +385,7 @@ void ClipManager::slotAddSlideshowClipFile(const QString name, const QString pat
     uint id = m_clipIdCounter++;
     prod.setAttribute("id", QString::number(id));
     prod.setAttribute("in", "0");
-    prod.setAttribute("out", m_doc->getFramePos(duration) * count - 1);
+    prod.setAttribute("out", m_doc->getFramePos(duration) * count);
     prod.setAttribute("ttl", m_doc->getFramePos(duration));
     prod.setAttribute("luma_duration", m_doc->getFramePos(luma_duration));
     prod.setAttribute("name", name);
@@ -452,7 +452,7 @@ void ClipManager::slotAddTextTemplateClip(QString titleName, const KUrl path, co
         out = titledoc.documentElement().attribute("out").toInt();
     } else txtfile.close();
 
-    if (out == 0) out = m_doc->getFramePos(KdenliveSettings::image_duration()) - 1;
+    if (out == 0) out = m_doc->getFramePos(KdenliveSettings::image_duration());
     prod.setAttribute("out", out);
 
     AddClipCommand *command = new AddClipCommand(m_doc, doc.documentElement(), QString::number(id), true);
index fa51041fd1f97602a4d582f953dd4e4cc3eb0cd4..8364d1adaf9a2a802fb9912c9f5fa4be7b9cfcb9 100644 (file)
@@ -52,6 +52,11 @@ ClipProperties::ClipProperties(DocClipBase *clip, Timecode tc, double fps, QWidg
     setAttribute(Qt::WA_DeleteOnClose, true);
     setFont(KGlobalSettings::toolBarFont());
     m_view.setupUi(this);
+    
+    // force transparency is only for group properties, so hide it
+    m_view.clip_force_transparency->setHidden(true);
+    m_view.clip_transparency->setHidden(true);
+    
     KUrl url = m_clip->fileURL();
     m_view.clip_path->setText(url.path());
     m_view.clip_description->setText(m_clip->description());
@@ -401,7 +406,10 @@ ClipProperties::ClipProperties(DocClipBase *clip, Timecode tc, double fps, QWidg
     m_view.clip_duration->setValidator(tc.validator());
     m_view.clip_duration->setText(tc.getTimecode(m_clip->duration()));
     if (t != IMAGE && t != COLOR && t != TEXT) m_view.clip_duration->setReadOnly(true);
-    else connect(m_view.clip_duration, SIGNAL(editingFinished()), this, SLOT(slotCheckMaxLength()));
+    else {
+        connect(m_view.clip_duration, SIGNAL(editingFinished()), this, SLOT(slotCheckMaxLength()));
+        connect(m_view.clip_duration, SIGNAL(textChanged(QString)), this, SLOT(slotModified()));
+    }
 
     // markers
     m_view.marker_new->setIcon(KIcon("document-new"));
@@ -437,7 +445,7 @@ ClipProperties::ClipProperties(QList <DocClipBase *>cliplist, Timecode tc, QMap
     setFont(KGlobalSettings::toolBarFont());
     m_view.setupUi(this);
     QString title = windowTitle();
-    title.append(" " + i18np("(%1 clip)", "(%1 clips)", cliplist.count()).arg(cliplist.count()));
+    title.append(" " + i18np("(%1 clip)", "(%1 clips)", cliplist.count()));
     setWindowTitle(title);
     QMap <QString, QString> props = cliplist.at(0)->properties();
     m_old_props = commonproperties;
@@ -507,7 +515,25 @@ ClipProperties::ClipProperties(QList <DocClipBase *>cliplist, Timecode tc, QMap
     if (commonproperties.contains("full_luma") && !commonproperties.value("full_luma").isEmpty()) {
         m_view.clip_full_luma->setChecked(true);
     }
+    
+    if (commonproperties.contains("transparency")) {
+        // image transparency checkbox
+        int transparency = commonproperties.value("transparency").toInt();
+        if (transparency == 0) {
+            m_view.clip_force_transparency->setChecked(true);
+        }
+        else if (transparency == 1) {
+            m_view.clip_force_transparency->setChecked(true);
+            m_view.clip_transparency->setCurrentIndex(1);
+        }
+    }
+    else {
+        m_view.clip_force_transparency->setHidden(true);
+        m_view.clip_transparency->setHidden(true);
+    }
+    
 
+    connect(m_view.clip_force_transparency, SIGNAL(toggled(bool)), m_view.clip_transparency, SLOT(setEnabled(bool)));
     connect(m_view.clip_force_ar, SIGNAL(toggled(bool)), m_view.clip_ar_num, SLOT(setEnabled(bool)));
     connect(m_view.clip_force_ar, SIGNAL(toggled(bool)), m_view.clip_ar_den, SLOT(setEnabled(bool)));
     connect(m_view.clip_force_progressive, SIGNAL(toggled(bool)), m_view.clip_progressive, SLOT(setEnabled(bool)));
@@ -672,11 +698,11 @@ QMap <QString, QString> ClipProperties::properties()
             m_clipNeedsRefresh = true;
         }
     } else {
-        if (m_old_props.contains("force_aspect_num")) {
+        if (m_old_props.contains("force_aspect_num") && !m_old_props.value("force_aspect_num").isEmpty()) {
             props["force_aspect_num"].clear();
             m_clipNeedsRefresh = true;
         }
-        if (m_old_props.contains("force_aspect_den")) {
+        if (m_old_props.contains("force_aspect_den") && !m_old_props.value("force_aspect_den").isEmpty()) {
             props["force_aspect_den"].clear();
             m_clipNeedsRefresh = true;
         }
@@ -688,7 +714,7 @@ QMap <QString, QString> ClipProperties::properties()
             props["force_fps"] = QString::number(fps);
             m_clipNeedsRefresh = true;
         }
-    } else if (m_old_props.contains("force_fps")) {
+    } else if (m_old_props.contains("force_fps") && !m_old_props.value("force_fps").isEmpty()) {
         props["force_fps"].clear();
         m_clipNeedsRefresh = true;
     }
@@ -698,7 +724,7 @@ QMap <QString, QString> ClipProperties::properties()
         if (progressive != m_old_props.value("force_progressive").toInt()) {
             props["force_progressive"] = QString::number(progressive);
         }
-    } else if (m_old_props.contains("force_progressive")) {
+    } else if (m_old_props.contains("force_progressive") && !m_old_props.value("force_progressive").isEmpty()) {
         props["force_progressive"].clear();
     }
 
@@ -707,7 +733,7 @@ QMap <QString, QString> ClipProperties::properties()
         if (fieldOrder != m_old_props.value("force_tff").toInt()) {
             props["force_tff"] = QString::number(fieldOrder);
         }
-    } else if (m_old_props.contains("force_tff")) {
+    } else if (m_old_props.contains("force_tff") && !m_old_props.value("force_tff").isEmpty()) {
         props["force_tff"].clear();
     }
 
@@ -716,7 +742,7 @@ QMap <QString, QString> ClipProperties::properties()
         if (threads != m_old_props.value("threads").toInt()) {
             props["threads"] = QString::number(threads);
         }
-    } else if (m_old_props.contains("threads")) {
+    } else if (m_old_props.contains("threads") && !m_old_props.value("threads").isEmpty()) {
         props["threads"].clear();
     }
 
@@ -725,7 +751,7 @@ QMap <QString, QString> ClipProperties::properties()
         if (vindex != m_old_props.value("video_index").toInt()) {
             props["video_index"] = QString::number(vindex);
         }
-    } else if (m_old_props.contains("video_index")) {
+    } else if (m_old_props.contains("video_index") && !m_old_props.value("video_index").isEmpty()) {
         props["video_index"].clear();
     }
 
@@ -734,7 +760,7 @@ QMap <QString, QString> ClipProperties::properties()
         if (aindex != m_old_props.value("audio_index").toInt()) {
             props["audio_index"] = QString::number(aindex);
         }
-    } else if (m_old_props.contains("audio_index")) {
+    } else if (m_old_props.contains("audio_index") && !m_old_props.value("audio_index").isEmpty()) {
         props["audio_index"].clear();
     }
     
@@ -744,7 +770,7 @@ QMap <QString, QString> ClipProperties::properties()
             props["force_colorspace"] = QString::number(colorspace);
             m_clipNeedsRefresh = true;
         }
-    } else if (m_old_props.contains("force_colorspace")) {
+    } else if (m_old_props.contains("force_colorspace") && !m_old_props.value("force_colorspace").isEmpty()) {
         props["force_colorspace"].clear();
         m_clipNeedsRefresh = true;
     }
@@ -752,10 +778,15 @@ QMap <QString, QString> ClipProperties::properties()
     if (m_view.clip_full_luma->isChecked()) {
         props["full_luma"] = QString::number(1);
         m_clipNeedsRefresh = true;
-    } else if (m_old_props.contains("full_luma")) {
+    } else if (m_old_props.contains("full_luma") && !m_old_props.value("full_luma").isEmpty()) {
         props["full_luma"].clear();
         m_clipNeedsRefresh = true;
     }
+    
+    if (m_view.clip_force_transparency->isChecked()) {
+        QString transp = QString::number(m_view.clip_transparency->currentIndex());
+        if (transp != m_old_props.value("transparency")) props["transparency"] = transp;
+    }
 
     // If we adjust several clips, return now
     if (m_clip == NULL) {
@@ -961,3 +992,4 @@ void ClipProperties::slotUpdateDurationFormat(int ix)
 #include "clipproperties.moc"
 
 
+
index 740628ef4e9bedd865e12e11b112446dca4ae3ff..a299a57d2f27af47e2835224aca60329cafc5d84 100644 (file)
@@ -658,7 +658,6 @@ const char *DocClipBase::producerProperty(const char *name) const
 void DocClipBase::slotRefreshProducer()
 {
     if (m_baseTrackProducers.count() == 0) return;
-    kDebug() << "////////////   REFRESH CLIP !!!!!!!!!!!!!!!!";
     if (m_clipType == SLIDESHOW) {
         /*Mlt::Producer producer(*(m_clipProducer->profile()), getProperty("resource").toUtf8().data());
         delete m_clipProducer;
index 64c420cf0e56863ee694c6233f03f30fdbd134fc..9a3382f9f62c9dbbe27f43c4e9a105e3c56b6cca 100644 (file)
@@ -3192,10 +3192,17 @@ void MainWindow::slotShowClipProperties(QList <DocClipBase *> cliplist, QMap<QSt
     ClipProperties dia(cliplist, m_activeDocument->timecode(), commonproperties, this);
     if (dia.exec() == QDialog::Accepted) {
         QUndoCommand *command = new QUndoCommand();
+        QMap <QString, QString> newImageProps = dia.properties();
+        // Transparency setting applies only for images
+        QMap <QString, QString> newProps = newImageProps;
+        newProps.remove("transparency");
         command->setText(i18n("Edit clips"));
         for (int i = 0; i < cliplist.count(); i++) {
             DocClipBase *clip = cliplist.at(i);
-            new EditClipCommand(m_projectList, clip->getId(), clip->properties(), dia.properties(), true, command);
+            if (clip->clipType() == IMAGE)
+                new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newImageProps, true, command);
+            else 
+                new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newProps, true, command);
         }
         m_activeDocument->commandStack()->push(command);
         for (int i = 0; i < cliplist.count(); i++)
index 94286501a2b344fe40f9df0ed62957f95902ad38..e6d9149893388ae8df9d464f57ef32d8cdbcab9c 100644 (file)
@@ -262,9 +262,11 @@ void ProjectList::editClipSelection(QList<QTreeWidgetItem *> list)
     commonproperties.insert("audio_index", "-");
     commonproperties.insert("force_colorspace", "-");
     commonproperties.insert("full_luma", "-");
+    QString transparency = "-";
 
     bool allowDurationChange = true;
     int commonDuration = -1;
+    bool hasImages = false;;
     ProjectItem *item;
     for (int i = 0; i < list.count(); i++) {
         item = NULL;
@@ -286,6 +288,29 @@ void ProjectList::editClipSelection(QList<QTreeWidgetItem *> list)
             // check properties
             DocClipBase *clip = item->referencedClip();
             if (clipList.contains(clip)) continue;
+            if (clip->clipType() == IMAGE) {
+                hasImages = true;
+                if (clip->getProperty("transparency").isEmpty() || clip->getProperty("transparency").toInt() == 0) {
+                    if (transparency == "-") {
+                        // first non transparent image
+                        transparency = "0";
+                    }
+                    else if (transparency == "1") {
+                        // we have transparent and non transparent clips
+                        transparency = "-1";
+                    }
+                }
+                else {
+                    if (transparency == "-") {
+                        // first transparent image
+                        transparency = "1";
+                    }
+                    else if (transparency == "0") {
+                        // we have transparent and non transparent clips
+                        transparency = "-1";
+                    }
+                }
+            }
             if (clip->clipType() != COLOR && clip->clipType() != IMAGE && clip->clipType() != TEXT)
                 allowDurationChange = false;
             if (allowDurationChange && commonDuration != 0) {
@@ -313,6 +338,8 @@ void ProjectList::editClipSelection(QList<QTreeWidgetItem *> list)
     }
     if (allowDurationChange)
         commonproperties.insert("out", QString::number(commonDuration));
+    if (hasImages)
+        commonproperties.insert("transparency", transparency);
     /*QMapIterator<QString, QString> p(commonproperties);
     while (p.hasNext()) {
         p.next();
@@ -442,10 +469,8 @@ void ProjectList::slotReloadClip(const QString &id)
                 int length = QString(item->referencedClip()->producerProperty("length")).toInt();
                 if (length > 0 && !e.hasAttribute("length")) {
                     e.setAttribute("length", length);
-                    e.setAttribute("out", length - 1);
                 }
-            }
-            
+            }            
             emit getFileProperties(e, item->clipId(), m_listView->iconSize().height(), true, false);
         }
     }
index 90f733b9ebfe8008a3187a8dc351cde4295ad589..9ddfd753a69540cc9545ca7c18f83bb52ef1bc37 100644 (file)
@@ -623,8 +623,12 @@ void Render::getFileProperties(const QDomElement xml, const QString &clipId, int
     }
 
     // setup length here as otherwise default length (currently 15000 frames in MLT) will be taken even if outpoint is larger
-    if (type == COLOR || type == TEXT || type == IMAGE || type == SLIDESHOW)
-        producer->set("length", xml.attribute("out").toInt() - xml.attribute("in").toInt() + 1);
+    if (type == COLOR || type == TEXT || type == IMAGE || type == SLIDESHOW) {
+        int length;
+        if (xml.hasAttribute("length")) length = xml.attribute("length").toInt();
+        else length = xml.attribute("out").toInt() - xml.attribute("in").toInt();
+        producer->set("length", length);
+    }
 
     if (xml.hasAttribute("out"))
         producer->set_in_and_out(xml.attribute("in").toInt(), xml.attribute("out").toInt());
index b6f2ef84789a2850d58b13e46d85a14efea31681..e9ac9175dcfe2a5281f0b62e2b3c1d5951a887f6 100644 (file)
@@ -1805,7 +1805,7 @@ void TitleWidget::saveTitle(KUrl url)
         delete fs;
     }
     if (!url.isEmpty()) {
-        if (m_titledocument.saveDocument(url, m_startViewport, m_endViewport, m_tc.getFrameCount(title_duration->text()) - 1, embed_image) == false)
+        if (m_titledocument.saveDocument(url, m_startViewport, m_endViewport, m_tc.getFrameCount(title_duration->text()), embed_image) == false)
             KMessageBox::error(this, i18n("Cannot write to file %1", url.path()));
     }
 }
@@ -1813,13 +1813,13 @@ void TitleWidget::saveTitle(KUrl url)
 QDomDocument TitleWidget::xml()
 {
     QDomDocument doc = m_titledocument.xml(m_startViewport, m_endViewport);
-    doc.documentElement().setAttribute("out", m_tc.getFrameCount(title_duration->text()) - 1);
+    doc.documentElement().setAttribute("out", m_tc.getFrameCount(title_duration->text()));
     return doc;
 }
 
 int TitleWidget::outPoint() const
 {
-    return m_tc.getFrameCount(title_duration->text()) - 1;
+    return m_tc.getFrameCount(title_duration->text());
 }
 
 void TitleWidget::setXml(QDomDocument doc)
@@ -1827,7 +1827,7 @@ void TitleWidget::setXml(QDomDocument doc)
     int out;
     m_count = m_titledocument.loadFromXml(doc, m_startViewport, m_endViewport, &out, m_projectTitlePath);
     adjustFrameSize();
-    title_duration->setText(m_tc.getTimecode(GenTime(out + 1, m_render->fps())));
+    title_duration->setText(m_tc.getTimecode(GenTime(out, m_render->fps())));
     /*if (doc.documentElement().hasAttribute("out")) {
     GenTime duration = GenTime(doc.documentElement().attribute("out").toDouble() / 1000.0);
     title_duration->setText(m_tc.getTimecode(duration));
index 602fe8ece5566b32fee47a78a2b9094fdc282123..8c1a43d5072f76ee79cb79914efd03f097a8a34b 100644 (file)
@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>308</width>
-    <height>507</height>
+    <width>280</width>
+    <height>520</height>
    </rect>
   </property>
   <property name="windowTitle">
        <string>Advanced</string>
       </attribute>
       <layout class="QGridLayout" name="gridLayout_3">
-       <item row="11" column="2">
+       <item row="12" column="2">
         <spacer name="verticalSpacer">
          <property name="orientation">
           <enum>Qt::Vertical</enum>
          </property>
         </widget>
        </item>
-       <item row="9" column="1">
+       <item row="9" column="1" colspan="2">
         <widget class="QCheckBox" name="clip_full_luma">
          <property name="text">
           <string>Full luma range</string>
          </property>
         </widget>
        </item>
+       <item row="10" column="1">
+        <widget class="QCheckBox" name="clip_force_transparency">
+         <property name="text">
+          <string>Image background</string>
+         </property>
+        </widget>
+       </item>
+       <item row="10" column="2">
+        <widget class="KComboBox" name="clip_transparency">
+         <item>
+          <property name="text">
+           <string>Normal</string>
+          </property>
+         </item>
+         <item>
+          <property name="text">
+           <string>Transparent</string>
+          </property>
+         </item>
+        </widget>
+       </item>
       </layout>
      </widget>
     </widget>