]> git.sesse.net Git - kdenlive/commitdiff
small bugfixes
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 9 Jun 2008 22:05:03 +0000 (22:05 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 9 Jun 2008 22:05:03 +0000 (22:05 +0000)
svn path=/branches/KDE4/; revision=2241

src/customruler.cpp
src/customruler.h
src/customtrackview.cpp
src/kdenlivedoc.cpp

index 2ac7ac2b9a604f0ecd1d9b6501f0858c6174fd58..a5448a651b8129885ab1c42262386e6588b4741e 100644 (file)
@@ -21,6 +21,7 @@
 #include <QStylePainter>
 
 #include <KDebug>
+#include <KIcon>
 #include <KGlobalSettings>
 
 #include "customruler.h"
@@ -85,20 +86,27 @@ CustomRuler::CustomRuler(Timecode tc, CustomTrackView *parent)
     setBigMarkDistance(FRAME_SIZE * m_timecode.fps() * 60);
     m_zoneStart = 2 * m_timecode.fps();
     m_zoneEnd = 10 * m_timecode.fps();
+       m_contextMenu = new QMenu(this);
+    QAction *addGuide = m_contextMenu->addAction(KIcon("document-new"), i18n("Add Guide"));
+    connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
 }
 
 // virtual
 void CustomRuler::mousePressEvent(QMouseEvent * event) {
+       if (event->button() == Qt::RightButton) {
+               
+               return;
+       }
     m_view->activateMonitor();
-    int pos = (int)((event->x() + offset()) / pixelPerMark() / FRAME_SIZE);
+    int pos = (int)((event->x() + offset()));
     m_moveCursor = RULER_CURSOR;
     if (event->y() > 10) {
-        if (qAbs(pos - m_zoneStart) < 4) m_moveCursor = RULER_START;
-        else if (qAbs(pos - (m_zoneStart + (m_zoneEnd - m_zoneStart) / 2)) < 4) m_moveCursor = RULER_MIDDLE;
-        else if (qAbs(pos - m_zoneEnd) < 4) m_moveCursor = RULER_END;
+        if (qAbs(pos - m_zoneStart * pixelPerMark() * FRAME_SIZE) < 4) m_moveCursor = RULER_START;
+        else if (qAbs(pos - (m_zoneStart + (m_zoneEnd - m_zoneStart) / 2) * pixelPerMark() * FRAME_SIZE) < 4) m_moveCursor = RULER_MIDDLE;
+        else if (qAbs(pos - m_zoneEnd * pixelPerMark() * FRAME_SIZE) < 4) m_moveCursor = RULER_END;
     }
     if (m_moveCursor == RULER_CURSOR)
-        m_view->setCursorPos(pos);
+        m_view->setCursorPos((int) pos / pixelPerMark() / FRAME_SIZE);
 }
 
 // virtual
@@ -139,8 +147,12 @@ void CustomRuler::slotMoveRuler(int newPos) {
 }
 
 void CustomRuler::slotCursorMoved(int oldpos, int newpos) {
-    //TODO: optimize (redraw only around cursor positions
-    update();
+    update(oldpos - offset() -6, 2, 17, 16);
+    update(newpos - offset() - 6, 2, 17, 16);
+}
+
+void CustomRuler::slotAddGuide() {
+
 }
 
 void CustomRuler::setPixelPerMark(double rate) {
index ae3a9a3017f0eb8d1f8227064ce303d12608a543..6d01e4ba7254767705962f384108c869c0768a01 100644 (file)
@@ -34,11 +34,15 @@ private:
     int m_duration;
     double m_textSpacing;
     RULER_MOVE m_moveCursor;
+       QMenu *m_contextMenu;
 
 public slots:
     void slotMoveRuler(int newPos);
     void slotCursorMoved(int oldpos, int newpos);
 
+private slots:
+       void slotAddGuide();
+
 };
 
 #endif
index 0e154baea6c69e6be7c057f009340b9be199ef53..a3d18d6c9b2dda398ee14279a739910b33180bb6 100644 (file)
@@ -81,7 +81,7 @@ CustomTrackView::CustomTrackView(KdenliveDoc *doc, QGraphicsScene * projectscene
     setContentsMargins(0, 0, 0, 0);
     if (projectscene) {
         m_cursorLine = projectscene->addLine(0, 0, 0, m_tracksHeight);
-        m_cursorLine->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIgnoresTransformations);
+        m_cursorLine->setFlags(QGraphicsItem::ItemIsMovable);
         m_cursorLine->setZValue(1000);
     }
 
@@ -1209,6 +1209,9 @@ void CustomTrackView::updateSnapPoints(AbstractClipItem *selected) {
             }
         }
     }
+    GenTime pos = GenTime(m_cursorPos, m_document->fps());
+       m_snapPoints.append(pos);
+       if (offset != GenTime()) m_snapPoints.append(pos - offset);
     qSort(m_snapPoints);
     //for (int i = 0; i < m_snapPoints.size(); ++i)
     //    kDebug() << "SNAP POINT: " << m_snapPoints.at(i).frames(25);
index 9c350ca51e44de66a621bf260ba07acaa953ee66..6e0d2e5fe9f06a04ffaf13db0320b674ea32a34b 100644 (file)
@@ -36,7 +36,7 @@
 #include "titlewidget.h"
 #include "mainwindow.h"
 
-KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, MltVideoProfile profile, QUndoGroup *undoGroup, MainWindow *parent): QObject(parent), m_render(NULL), m_url(url), m_projectFolder(projectFolder), m_profile(profile), m_fps((double)profile.frame_rate_num / profile.frame_rate_den), m_width(profile.width), m_height(profile.height), m_commandStack(new KUndoStack(undoGroup)), m_modified(false), m_documentLoadingProgress(0), m_documentLoadingStep(0.0) {
+KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, MltVideoProfile profile, QUndoGroup *undoGroup, MainWindow *parent): QObject(parent), m_render(NULL), m_url(url), m_projectFolder(projectFolder), m_profile(profile), m_fps((double)profile.frame_rate_num / profile.frame_rate_den), m_width(profile.width), m_height(profile.height), m_commandStack(new KUndoStack(undoGroup)), m_modified(false), m_documentLoadingProgress(0), m_documentLoadingStep(0.0), m_startPos(0) {
     m_clipManager = new ClipManager(this);
     if (!url.isEmpty()) {
         QString tmpFile;