]> git.sesse.net Git - kdenlive/blobdiff - src/markerdialog.cpp
Fix crash on rendering with some project profiles:http://kdenlive.org/mantis/view...
[kdenlive] / src / markerdialog.cpp
index 0ee5657f72685a0fb9d3e8f338798e75cda5832b..3402fb2b5fe3140a2a536295431297bf75036345 100644 (file)
@@ -36,6 +36,13 @@ MarkerDialog::MarkerDialog(DocClipBase *clip, CommentedTime t, Timecode tc, cons
     setupUi(this);
     setWindowTitle(caption);
 
+    // Set  up categories
+    for (int i = 0; i < 5; ++i) {
+         marker_type->insertItem(i, i18n("Category %1", i));
+         marker_type->setItemData(i, CommentedTime::markerColor(i), Qt::DecorationRole);
+     }
+    marker_type->setCurrentIndex(t.markerType());
+
     m_in = new TimecodeDisplay(tc, this);
     inputLayout->addWidget(m_in);
     m_in->setValue(t.time());
@@ -61,6 +68,7 @@ MarkerDialog::MarkerDialog(DocClipBase *clip, CommentedTime t, Timecode tc, cons
         if (width % 2 == 1) width++;
         QPixmap p(width, 100);
         QString colour = clip->getProperty("colour");
+        int swidth = (int) (100.0 * m_profile->width() / m_profile->height() + 0.5);
 
         switch (m_clip->clipType()) {
         case VIDEO:
@@ -70,7 +78,7 @@ MarkerDialog::MarkerDialog(DocClipBase *clip, CommentedTime t, Timecode tc, cons
             connect(this, SIGNAL(updateThumb()), m_previewTimer, SLOT(start()));
         case IMAGE:
         case TEXT:
-            p = QPixmap::fromImage(KThumb::getFrame(m_producer, m_in->value(), width, 100));
+            p = QPixmap::fromImage(KThumb::getFrame(m_producer, m_in->getValue(), swidth, width, 100));
             break;
         case COLOR:
             colour = colour.replace(0, 2, "#");
@@ -85,7 +93,7 @@ MarkerDialog::MarkerDialog(DocClipBase *clip, CommentedTime t, Timecode tc, cons
             clip_thumb->setFixedHeight(p.height());
             clip_thumb->setPixmap(p);
         }
-        connect(m_in, SIGNAL(editingFinished()), this, SIGNAL(updateThumb()));
+        connect(m_in, SIGNAL(timeCodeEditingFinished()), this, SIGNAL(updateThumb()));
     } else {
         clip_thumb->setHidden(true);
     }
@@ -107,10 +115,11 @@ MarkerDialog::~MarkerDialog()
 void MarkerDialog::slotUpdateThumb()
 {
     m_previewTimer->stop();
-    int pos = m_in->value();
+    int pos = m_in->getValue();
     int width = 100.0 * m_dar;
+    int swidth = (int) (100.0 * m_profile->width() / m_profile->height() + 0.5);
     if (width % 2 == 1) width++;
-    QPixmap p = QPixmap::fromImage(KThumb::getFrame(m_producer, pos, width, 100));
+    QPixmap p = QPixmap::fromImage(KThumb::getFrame(m_producer, pos, swidth, width, 100));
     if (!p.isNull())
         clip_thumb->setPixmap(p);
     else
@@ -119,7 +128,8 @@ void MarkerDialog::slotUpdateThumb()
 
 CommentedTime MarkerDialog::newMarker()
 {
-    return CommentedTime(m_in->gentime(), marker_comment->text());
+    KdenliveSettings::setDefault_marker_type(marker_type->currentIndex());
+    return CommentedTime(m_in->gentime(), marker_comment->text(), marker_type->currentIndex());
 }
 
 #include "markerdialog.moc"