]> git.sesse.net Git - kdenlive/blobdiff - src/effectstackview.cpp
Fix rendering of documents that have a locale different than the system's locale
[kdenlive] / src / effectstackview.cpp
index cd9a6b4de1012f2964967907c4e2b11d2460854f..d188762525d2bacf0343b390606e1a6d5f73cc8c 100644 (file)
@@ -23,6 +23,7 @@
 #include "docclipbase.h"
 #include "projectlist.h"
 #include "kthumb.h"
+#include "monitoreditwidget.h"
 #include "monitorscene.h"
 #include "kdenlivesettings.h"
 
@@ -48,9 +49,12 @@ EffectStackView::EffectStackView(Monitor *monitor, QWidget *parent) :
     m_ui.setupUi(this);
     QVBoxLayout *vbox1 = new QVBoxLayout(m_ui.frame);
     m_effectedit = new EffectStackEdit(monitor, m_ui.frame);
-    vbox1->setContentsMargins(0, 0, 0, 0);
+    m_ui.frame->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
+    vbox1->setContentsMargins(2, 0, 2, 0);
     vbox1->setSpacing(0);
     vbox1->addWidget(m_effectedit);
+    m_ui.splitter->setStretchFactor(0, 1);
+    m_ui.splitter->setStretchFactor(1, 20);
 
     //m_ui.region_url->fileDialog()->setFilter(ProjectList::getExtensions());
     //m_ui.effectlist->horizontalHeader()->setVisible(false);
@@ -92,13 +96,10 @@ EffectStackView::EffectStackView(Monitor *monitor, QWidget *parent) :
     connect(m_effectedit, SIGNAL(displayMessage(const QString&, int)), this, SIGNAL(displayMessage(const QString&, int)));
     connect(m_effectedit, SIGNAL(checkMonitorPosition(int)), this, SLOT(slotCheckMonitorPosition(int)));
     connect(monitor, SIGNAL(renderPosition(int)), this, SLOT(slotRenderPos(int)));
-    connect(this, SIGNAL(showComments()), m_effectedit, SIGNAL(showComments()));
+    connect(this, SIGNAL(showComments(bool)), m_effectedit, SIGNAL(showComments(bool)));
     m_effectLists["audio"] = &MainWindow::audioEffects;
     m_effectLists["video"] = &MainWindow::videoEffects;
     m_effectLists["custom"] = &MainWindow::customEffects;
-    m_ui.splitter->setStretchFactor(1, 10);
-    m_ui.splitter->setStretchFactor(0, 1);
-
     setEnabled(false);
 }
 
@@ -176,9 +177,9 @@ void EffectStackView::slotClipItemSelected(ClipItem* c, int ix)
         m_clipref = c;
         if (c) {
             QString cname = m_clipref->clipName();
-            if (cname.length() > 20) {
+            if (cname.length() > 30) {
                 m_ui.checkAll->setToolTip(i18n("Effects for %1").arg(cname));
-                cname.truncate(17);
+                cname.truncate(27);
                 m_ui.checkAll->setText(i18n("Effects for %1").arg(cname) + "...");
             } else {
                 m_ui.checkAll->setToolTip(QString());
@@ -196,7 +197,8 @@ void EffectStackView::slotClipItemSelected(ClipItem* c, int ix)
     if (m_clipref == NULL) {
         m_ui.effectlist->blockSignals(true);
         m_ui.effectlist->clear();
-        m_effectedit->transferParamDesc(QDomElement(), 0, 0, 0);
+        ItemInfo info;
+        m_effectedit->transferParamDesc(QDomElement(), info);
         //m_ui.region_url->clear();
         m_ui.effectlist->blockSignals(false);
         m_ui.checkAll->setToolTip(QString());
@@ -229,8 +231,7 @@ void EffectStackView::slotItemChanged(QListWidgetItem *item)
 {
     bool disable = true;
     if (item->checkState() == Qt::Checked) disable = false;
-    m_ui.frame->setEnabled(!disable);
-    m_ui.buttonReset->setEnabled(!disable);
+    m_ui.buttonReset->setEnabled(!disable || !KdenliveSettings::disable_effect_parameters());
     int activeRow = m_ui.effectlist->currentRow();
     if (activeRow >= 0) {
         m_effectedit->updateParameter("disable", QString::number((int) disable));
@@ -265,17 +266,17 @@ void EffectStackView::setupListView(int ix)
         doc.appendChild(doc.importNode(d, true));
         kDebug() << "IMPORTED STK: " << doc.toString();*/
 
-        QDomNode namenode = d.elementsByTagName("name").item(0);
+        QDomElement namenode = d.firstChildElement("name");
         if (!namenode.isNull()) {
             // Issue 238: Add icons for effect type in effectstack.
             // Logic more or less copied from initeffects.cpp
             QString type = d.attribute("type", QString());
             if ("audio" == type) {
-                item = new QListWidgetItem(audioIcon, i18n(namenode.toElement().text().toUtf8().data()), m_ui.effectlist);
+                item = new QListWidgetItem(audioIcon, i18n(namenode.text().toUtf8().data()), m_ui.effectlist);
             } else if ("custom" == type) {
-                item = new QListWidgetItem(customIcon, i18n(namenode.toElement().text().toUtf8().data()), m_ui.effectlist);
+                item = new QListWidgetItem(customIcon, i18n(namenode.text().toUtf8().data()), m_ui.effectlist);
             } else {
-                item = new QListWidgetItem(videoIcon, i18n(namenode.toElement().text().toUtf8().data()), m_ui.effectlist);
+                item = new QListWidgetItem(videoIcon, i18n(namenode.text().toUtf8().data()), m_ui.effectlist);
             }
             item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
             if (d.attribute("disable") == "1")
@@ -294,14 +295,14 @@ void EffectStackView::setupListView(int ix)
         m_ui.buttonShowComments->setEnabled(false);
         m_ui.labelComment->setHidden(true);
     } else {
-        qMin(ix, 0);
-        qMax(ix, m_ui.effectlist->count() - 1);
+        ix = qBound(0, ix, m_ui.effectlist->count() - 1);
         m_ui.effectlist->setCurrentRow(ix);
         m_ui.checkAll->setEnabled(true);
     }
     m_ui.effectlist->blockSignals(false);
     if (m_ui.effectlist->count() == 0) {
-        m_effectedit->transferParamDesc(QDomElement(), 0, 0, 0);
+        ItemInfo info;
+        m_effectedit->transferParamDesc(QDomElement(), info);
         //m_ui.region_url->clear();
     } else slotItemSelectionChanged(false);
     slotUpdateCheckAllButton();
@@ -313,30 +314,34 @@ void EffectStackView::slotItemSelectionChanged(bool update)
     int activeRow = m_ui.effectlist->currentRow();
     bool isChecked = false;
     if (hasItem && m_ui.effectlist->currentItem()->checkState() == Qt::Checked) isChecked = true;
+    QDomElement eff;
     if (hasItem && m_ui.effectlist->currentItem()->isSelected()) {
-        QDomElement eff = m_currentEffectList.at(activeRow);
+        eff = m_currentEffectList.at(activeRow);
         if (m_trackMode) {
             // showing track effects
-            m_effectedit->transferParamDesc(eff, 0, 0, m_trackInfo.duration);
-        } else m_effectedit->transferParamDesc(eff,
-                                                   0,
-                                                   m_clipref->cropStart().frames(KdenliveSettings::project_fps()),
-                                                   (m_clipref->cropStart() + m_clipref->cropDuration()).frames(KdenliveSettings::project_fps()) - 1); //minx max frame
+            ItemInfo info;
+            info.track = m_trackInfo.type;
+            info.cropDuration = GenTime(m_trackInfo.duration, KdenliveSettings::project_fps());
+            info.cropStart = GenTime(0);
+            info.startPos = GenTime(-1);
+            info.track = 0;
+            m_effectedit->transferParamDesc(eff, info);
+        } else {
+            m_effectedit->transferParamDesc(eff, m_clipref->info());
+        }
         //m_ui.region_url->setUrl(KUrl(eff.attribute("region")));
         m_ui.labelComment->setText(i18n(eff.firstChildElement("description").firstChildElement("full").text().toUtf8().data()));
     }
     if (!m_trackMode && m_clipref && update) m_clipref->setSelectedEffect(activeRow);
     m_ui.buttonDel->setEnabled(hasItem);
     m_ui.buttonSave->setEnabled(hasItem);
-    m_ui.buttonReset->setEnabled(hasItem && isChecked);
+    m_ui.buttonReset->setEnabled(hasItem && (isChecked || !KdenliveSettings::disable_effect_parameters()));
     m_ui.buttonUp->setEnabled(activeRow > 0);
     m_ui.buttonDown->setEnabled((activeRow < m_ui.effectlist->count() - 1) && hasItem);
-    m_ui.frame->setEnabled(isChecked);
     m_ui.buttonShowComments->setEnabled(hasItem);
 
-    if (m_ui.buttonShowComments->isChecked())
-        emit showComments();
-    m_ui.labelComment->setHidden(!m_ui.buttonShowComments->isChecked() || !m_ui.labelComment->text().count() || !hasItem);
+    emit showComments(m_ui.buttonShowComments->isChecked());
+    m_ui.labelComment->setVisible(hasItem && m_ui.labelComment->text().count() && (m_ui.buttonShowComments->isChecked() || !eff.elementsByTagName("parameter").count()));
 }
 
 void EffectStackView::slotItemUp()
@@ -386,18 +391,23 @@ void EffectStackView::slotResetEffect()
         if (m_trackMode) {
             EffectsList::setParameter(dom, "in", QString::number(0));
             EffectsList::setParameter(dom, "out", QString::number(m_trackInfo.duration));
-            m_effectedit->transferParamDesc(dom, 0, 0, m_trackInfo.duration);//minx max frame
+            ItemInfo info;
+            info.track = m_trackInfo.type;
+            info.cropDuration = GenTime(m_trackInfo.duration, KdenliveSettings::project_fps());
+            info.cropStart = GenTime(0);
+            info.startPos = GenTime(-1);
+            info.track = 0;
+            m_effectedit->transferParamDesc(dom, info);
             emit updateEffect(NULL, m_trackindex, old, dom, activeRow);
         } else {
             m_clipref->initEffect(dom);
-            m_effectedit->transferParamDesc(dom, 0, m_clipref->cropStart().frames(KdenliveSettings::project_fps()), (m_clipref->cropStart() + m_clipref->cropDuration()).frames(KdenliveSettings::project_fps()));//minx max frame
+            m_effectedit->transferParamDesc(dom, m_clipref->info());
             //m_ui.region_url->setUrl(KUrl(dom.attribute("region")));
             emit updateEffect(m_clipref, -1, old, dom, activeRow);
         }
     }
 
-    if (m_ui.buttonShowComments->isChecked())
-        emit showComments();
+    emit showComments(m_ui.buttonShowComments->isChecked());
     m_ui.labelComment->setHidden(!m_ui.buttonShowComments->isChecked() || !m_ui.labelComment->text().count());
 }
 
@@ -418,7 +428,8 @@ void EffectStackView::clear()
     m_ui.buttonUp->setEnabled(false);
     m_ui.buttonDown->setEnabled(false);
     m_ui.checkAll->setEnabled(false);
-    m_effectedit->transferParamDesc(QDomElement(), 0, 0, 0);
+    ItemInfo info;
+    m_effectedit->transferParamDesc(QDomElement(), info);
     //m_ui.region_url->clear();
     m_ui.buttonShowComments->setEnabled(false);
     m_ui.labelComment->setText(QString());
@@ -485,8 +496,8 @@ void EffectStackView::slotCheckAll(int state)
 
 void EffectStackView::slotCheckMonitorPosition(int renderPos)
 {
-    if (m_trackMode || (renderPos >= m_clipref->startPos().frames(KdenliveSettings::project_fps()) && renderPos <= m_clipref->endPos().frames(KdenliveSettings::project_fps()))) {
-        if (!m_monitor->getEffectScene()->views().at(0)->isVisible())
+    if (m_trackMode || (m_clipref && renderPos >= m_clipref->startPos().frames(KdenliveSettings::project_fps()) && renderPos <= m_clipref->endPos().frames(KdenliveSettings::project_fps()))) {
+        if (!m_monitor->getEffectEdit()->getScene()->views().at(0)->isVisible())
             m_monitor->slotEffectScene(true);
     } else {
         m_monitor->slotEffectScene(false);
@@ -513,7 +524,7 @@ int EffectStackView::isTrackMode(bool *ok) const
 void EffectStackView::slotShowComments()
 {
     m_ui.labelComment->setHidden(!m_ui.buttonShowComments->isChecked() || !m_ui.labelComment->text().count());
-    emit showComments();
+    emit showComments(m_ui.buttonShowComments->isChecked());
 }
 
 #include "effectstackview.moc"