]> git.sesse.net Git - kdenlive/blobdiff - src/mainwindow.cpp
fix seeking issue
[kdenlive] / src / mainwindow.cpp
index 72d6994b9d6c9961f1e4d22049852f559206d45e..be6354d9227ecd78612cf11bc98ebc9eb14fb6b9 100644 (file)
 #include <KRuler>
 #include <KConfigDialog>
 #include <KXMLGUIFactory>
+#include <KStatusBar>
 
 #include <mlt++/Mlt.h>
 
 #include "mainwindow.h"
 #include "kdenlivesettings.h"
 #include "ui_configmisc_ui.h"
+
+#define ID_STATUS_MSG 1
+#define ID_EDITMODE_MSG 2
+#define ID_TIMELINE_MSG 3
+#define ID_TIMELINE_POS 4
+#define ID_TIMELINE_FORMAT 5
  
 MainWindow::MainWindow(QWidget *parent)
     : KXmlGuiWindow(parent),
@@ -52,6 +59,7 @@ MainWindow::MainWindow(QWidget *parent)
   m_timelineArea->setTabReorderingEnabled(true);
   connect(m_timelineArea, SIGNAL(currentChanged (int)), this, SLOT(activateDocument()));
 
+  Mlt::Factory::init(NULL);
   m_monitorManager = new MonitorManager();
 
   projectListDock = new QDockWidget(i18n("Project Tree"), this);
@@ -78,14 +86,14 @@ MainWindow::MainWindow(QWidget *parent)
   transitionConfigDock->setWidget(transitionConfig);
   addDockWidget(Qt::TopDockWidgetArea, transitionConfigDock);
 
-  Mlt::Factory::init(NULL);
 
   clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
   clipMonitorDock->setObjectName("clip_monitor");
   m_clipMonitor = new Monitor("clip", m_monitorManager, this);
   clipMonitorDock->setWidget(m_clipMonitor);
   addDockWidget(Qt::TopDockWidgetArea, clipMonitorDock);
-  
+  //m_clipMonitor->stop();
+
   projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
   projectMonitorDock->setObjectName("project_monitor");
   m_projectMonitor = new Monitor("project", m_monitorManager, this);
@@ -101,7 +109,7 @@ MainWindow::MainWindow(QWidget *parent)
 
   overviewDock = new QDockWidget(i18n("Project Overview"), this);
   overviewDock->setObjectName("project_overview");
-  m_overView = new CustomTrackView(NULL, this);
+  m_overView = new CustomTrackView(NULL, NULL, this);
   overviewDock->setWidget(m_overView);
   addDockWidget(Qt::TopDockWidgetArea, overviewDock);
 
@@ -114,6 +122,13 @@ MainWindow::MainWindow(QWidget *parent)
 
   tabifyDockWidget (clipMonitorDock, projectMonitorDock);
   setCentralWidget(m_timelineArea);
+
+  m_timecodeFormat = new KComboBox(this);
+  m_timecodeFormat->addItem(i18n("hh:mm:ss::ff"));
+  m_timecodeFormat->addItem(i18n("Frames"));
+  statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
+  statusBar()->insertPermanentWidget(ID_TIMELINE_FORMAT, m_timecodeFormat); 
+
   setupGUI(Default, "kdenliveui.rc");
 
   connect(projectMonitorDock, SIGNAL(visibilityChanged (bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
@@ -147,6 +162,12 @@ void MainWindow::slotRaiseMonitor(bool clipMonitor)
   else projectMonitorDock->raise();
 }
 
+void MainWindow::slotSetClipDuration(int id, int duration)
+{
+  if (!m_activeDocument) return;
+  m_activeDocument->setProducerDuration(id, duration);
+}
+
 void MainWindow::slotConnectMonitors()
 {
 
@@ -154,6 +175,8 @@ void MainWindow::slotConnectMonitors()
 
   connect(m_projectList, SIGNAL(clipSelected(const QDomElement &)), m_clipMonitor, SLOT(slotSetXml(const QDomElement &)));
 
+  connect(m_projectList, SIGNAL(receivedClipDuration(int, int)), this, SLOT(slotSetClipDuration(int, int)));
+
   connect(m_projectList, SIGNAL(getFileProperties(const QDomElement &, int)), m_clipMonitor->render, SLOT(getFileProperties(const QDomElement &, int)));
 
   connect(m_clipMonitor->render, SIGNAL(replyGetImage(int, int, const QPixmap &, int, int)), m_projectList, SLOT(slotReplyGetImage(int, int, const QPixmap &, int, int)));
@@ -190,6 +213,9 @@ void MainWindow::setupActions()
   KStandardAction::openNew(this, SLOT(newFile()),
                         actionCollection());
 
+  KStandardAction::preferences(this, SLOT(slotPreferences()),
+                        actionCollection());
+
   /*KStandardAction::undo(this, SLOT(undo()),
                         actionCollection());
 
@@ -279,6 +305,18 @@ void MainWindow::openFile(const KUrl &url) //new
   //connectDocument(trackView, doc);
 }
 
+void MainWindow::slotUpdateMousePosition(int pos)
+{
+  if (m_activeDocument)
+    switch(m_timecodeFormat->currentIndex()) {
+      case 0:
+       statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
+       break;
+    default:
+      statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
+    }
+}
+
 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
 {
   //m_projectMonitor->stop();
@@ -287,6 +325,9 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //chang
     m_activeDocument->setProducers(m_projectList->producersList());
     m_activeDocument->setRenderer(NULL);
   }
+  connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
+  connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
+  connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
   m_projectList->setDocument(doc);
   m_monitorManager->setTimecode(doc->timecode());
   doc->setRenderer(m_projectMonitor->render);