From 548782dfe8b4ec1edc0c15f0062f5a976f1c6ee3 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Wed, 16 Feb 2011 18:31:06 +0000 Subject: [PATCH] * Allow to edit transparent background for images in group properties * Fix editing duration of title, image and color clips svn path=/trunk/kdenlive/; revision=5414 --- src/clipmanager.cpp | 10 +++--- src/clipproperties.cpp | 56 +++++++++++++++++++++++++------- src/docclipbase.cpp | 1 - src/mainwindow.cpp | 9 ++++- src/projectlist.cpp | 31 ++++++++++++++++-- src/renderer.cpp | 8 +++-- src/titlewidget.cpp | 8 ++--- src/widgets/clipproperties_ui.ui | 29 ++++++++++++++--- 8 files changed, 120 insertions(+), 32 deletions(-) diff --git a/src/clipmanager.cpp b/src/clipmanager.cpp index 3ed3ed37..c8152690 100644 --- a/src/clipmanager.cpp +++ b/src/clipmanager.cpp @@ -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); diff --git a/src/clipproperties.cpp b/src/clipproperties.cpp index fa51041f..8364d1ad 100644 --- a/src/clipproperties.cpp +++ b/src/clipproperties.cpp @@ -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 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 props = cliplist.at(0)->properties(); m_old_props = commonproperties; @@ -507,7 +515,25 @@ ClipProperties::ClipProperties(QList 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 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 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 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 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 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 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 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 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 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" + diff --git a/src/docclipbase.cpp b/src/docclipbase.cpp index 740628ef..a299a57d 100644 --- a/src/docclipbase.cpp +++ b/src/docclipbase.cpp @@ -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; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 64c420cf..9a3382f9 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -3192,10 +3192,17 @@ void MainWindow::slotShowClipProperties(QList cliplist, QMaptimecode(), commonproperties, this); if (dia.exec() == QDialog::Accepted) { QUndoCommand *command = new QUndoCommand(); + QMap newImageProps = dia.properties(); + // Transparency setting applies only for images + QMap 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++) diff --git a/src/projectlist.cpp b/src/projectlist.cpp index 94286501..e6d91498 100644 --- a/src/projectlist.cpp +++ b/src/projectlist.cpp @@ -262,9 +262,11 @@ void ProjectList::editClipSelection(QList 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 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 list) } if (allowDurationChange) commonproperties.insert("out", QString::number(commonDuration)); + if (hasImages) + commonproperties.insert("transparency", transparency); /*QMapIterator 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); } } diff --git a/src/renderer.cpp b/src/renderer.cpp index 90f733b9..9ddfd753 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp @@ -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()); diff --git a/src/titlewidget.cpp b/src/titlewidget.cpp index b6f2ef84..e9ac9175 100644 --- a/src/titlewidget.cpp +++ b/src/titlewidget.cpp @@ -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)); diff --git a/src/widgets/clipproperties_ui.ui b/src/widgets/clipproperties_ui.ui index 602fe8ec..8c1a43d5 100644 --- a/src/widgets/clipproperties_ui.ui +++ b/src/widgets/clipproperties_ui.ui @@ -6,8 +6,8 @@ 0 0 - 308 - 507 + 280 + 520 @@ -556,7 +556,7 @@ Advanced - + Qt::Vertical @@ -701,7 +701,7 @@ - + Full luma range @@ -765,6 +765,27 @@ + + + + Image background + + + + + + + + Normal + + + + + Transparent + + + + -- 2.39.2