]> git.sesse.net Git - kdenlive/blobdiff - src/clipitem.cpp
* Do not allow dvd buttons to overlap
[kdenlive] / src / clipitem.cpp
index 51712d9a81fd0aba08c4d9ccde1b1025a4fbf52c..4f93bef4df350ab6d516d3c57aee295632676641 100644 (file)
@@ -139,6 +139,8 @@ ClipItem *ClipItem::clone(ItemInfo info) const
     if (info.cropStart + (info.endPos - info.startPos) == m_cropStart + m_cropDuration) duplicate->slotSetEndThumb(m_endPix);
     kDebug() << "// CLoning clip: " << (info.cropStart + (info.endPos - info.startPos)).frames(m_fps) << ", CURRENT end: " << (cropStart() + duration()).frames(m_fps);
     duplicate->setEffectList(m_effectList.clone());
+    duplicate->setVideoOnly(m_videoOnly);
+    duplicate->setAudioOnly(m_audioOnly);
     //duplicate->setSpeed(m_speed);
     return duplicate;
 }
@@ -400,9 +402,24 @@ void ClipItem::resetThumbs()
 }
 
 
-void ClipItem::refreshClip()
+void ClipItem::refreshClip(bool checkDuration)
 {
-    m_maxDuration = m_clip->maxDuration();
+    if (checkDuration && (m_maxDuration != m_clip->maxDuration())) {
+        m_maxDuration = m_clip->maxDuration();
+        if (m_clipType != IMAGE && m_clipType != TEXT && m_clipType != COLOR) {
+            if (m_cropStart + m_cropDuration > m_maxDuration) {
+                // Clip duration changed, make sure to stay in correct range
+                if (m_cropStart > m_maxDuration) {
+                    m_cropStart = GenTime();
+                    m_cropDuration = qMin(m_cropDuration, m_maxDuration);
+                    updateRectGeometry();
+                } else {
+                    m_cropDuration = m_maxDuration;
+                    updateRectGeometry();
+                }
+            }
+        }
+    }
     if (m_clipType == COLOR) {
         QString colour = m_clip->getProperty("colour");
         colour = colour.replace(0, 2, "#");
@@ -540,6 +557,8 @@ QDomElement ClipItem::xml() const
 {
     QDomElement xml = m_clip->toXML();
     if (m_speed != 1.0) xml.setAttribute("speed", m_speed);
+    if (m_audioOnly) xml.setAttribute("audio_only", 1);
+    else if (m_videoOnly) xml.setAttribute("video_only", 1);
     return xml;
 }
 
@@ -607,9 +626,9 @@ void ClipItem::paint(QPainter *painter,
     painter->setClipRect(exposed);
 
     //Fill clip rectangle
-    QRectF bgRect = br;
-    bgRect.setLeft(br.left() + xoffset);
-    painter->fillRect(bgRect, paintColor);
+    /*QRectF bgRect = br;
+    bgRect.setLeft(br.left() + xoffset);*/
+    painter->fillRect(exposed, paintColor);
 
     //painter->setClipPath(resultClipPath, Qt::IntersectClip);
 
@@ -773,7 +792,6 @@ void ClipItem::paint(QPainter *painter,
     }
 
     // Draw clip name
-    // draw frame around clip
     QColor frameColor(Qt::black);
     int alphaBase = 60;
     if (isSelected() || (parentItem() && parentItem()->isSelected())) {
@@ -1087,7 +1105,7 @@ void ClipItem::resizeStart(int posx, double /*speed*/)
 
 void ClipItem::resizeEnd(int posx, double /*speed*/, bool updateKeyFrames)
 {
-    const int max = (startPos() - cropStart() + maxDuration()).frames(m_fps) + 1;
+    const int max = (startPos() - cropStart() + maxDuration()).frames(m_fps);
     if (posx > max) posx = max;
     if (posx == endPos().frames(m_fps)) return;
     //kDebug() << "// NEW POS: " << posx << ", OLD END: " << endPos().frames(m_fps);
@@ -1527,30 +1545,4 @@ bool ClipItem::isVideoOnly() const
 }
 
 
-// virtual
-/*
-void CustomTrackView::mousePressEvent ( QMouseEvent * event )
-{
-  int pos = event->x();
-  if (event->modifiers() == Qt::ControlModifier)
-    setDragMode(QGraphicsView::ScrollHandDrag);
-  else if (event->modifiers() == Qt::ShiftModifier)
-    setDragMode(QGraphicsView::RubberBandDrag);
-  else {
-    QGraphicsItem * item = itemAt(event->pos());
-    if (item) {
-    }
-    else emit cursorMoved((int) mapToScene(event->x(), 0).x());
-  }
-  kDebug()<<pos;
-  QGraphicsView::mousePressEvent(event);
-}
-
-void CustomTrackView::mouseReleaseEvent ( QMouseEvent * event )
-{
-  QGraphicsView::mouseReleaseEvent(event);
-  setDragMode(QGraphicsView::NoDrag);
-}
-*/
-
 #include "clipitem.moc"