]> git.sesse.net Git - kdenlive/commitdiff
Show project duration in status bar
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 2 Apr 2013 15:52:10 +0000 (17:52 +0200)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 2 Apr 2013 15:52:10 +0000 (17:52 +0200)
src/customruler.cpp
src/customruler.h
src/customtrackview.cpp
src/customtrackview.h
src/mainwindow.cpp
src/mainwindow.h
src/trackview.cpp

index ae5555ccc6afa4eb9d8864ede8a78a74cf9a252a..645ecb0f525923f04b68d72ea226ca9ea555b0f9 100644 (file)
@@ -181,11 +181,13 @@ void CustomRuler::mousePressEvent(QMouseEvent * event)
 // virtual
 void CustomRuler::mouseMoveEvent(QMouseEvent * event)
 {
+    int mappedXPos = (int)((event->x() + offset()) / m_factor);
+    emit mousePosition(mappedXPos);
     if (event->buttons() == Qt::LeftButton) {
         int pos;
         if (m_moveCursor == RULER_START || m_moveCursor == RULER_END) {
-            pos = m_view->getSnapPointForPos((int)((event->x() + offset()) / m_factor));
-        } else pos = (int)((event->x() + offset()) / m_factor);
+            pos = m_view->getSnapPointForPos(mappedXPos);
+        } else pos = mappedXPos;
         int zoneStart = m_zoneStart;
         int zoneEnd = m_zoneEnd;
         if (pos < 0) pos = 0;
index abdc5944eef98479ba7c088e5f30a50dd0172da7..f7ba21bd61f521cb859f31e827dfaa5e3c9d1581 100644 (file)
@@ -98,6 +98,7 @@ private slots:
 signals:
     void zoneMoved(int, int);
     void adjustZoom(int);
+    void mousePosition(int);
 };
 
 #endif
index bd5d4d720dd44f2adb539c467dfe9c89b78b33b5..f069ed9d037ce885236d7f110230cea28f6ee5da 100644 (file)
@@ -422,6 +422,11 @@ void CustomTrackView::slotAlignPlayheadToMousePos()
        seekCursorPos(mappedXPos);
 }
 
+int CustomTrackView::getMousePos() const
+{
+    return qMax((int)(mapToScene(mapFromGlobal(QCursor::pos())).x() + 0.5), 0);
+}
+
 // virtual
 void CustomTrackView::mouseMoveEvent(QMouseEvent * event)
 {
index 4e0d8036f8a2598a69dd202721db2caf6c700d16..ecdf17b6398726b5cffb6b7e0be432a0c0587477 100644 (file)
@@ -211,6 +211,9 @@ public:
     /** @brief Trigger a monitor refresh. */
     void monitorRefresh();
     
+    /** @brief Returns frame number of current mouse position. */
+    int getMousePos() const;
+    
 public slots:
     /** @brief Send seek request to MLT. */
     void seekCursorPos(int pos);
index bae50b8fb8b190c70b6e6acfeb74be9aa7189aa4..553731c9a6caceeb2bde50a45d0499acaef77f7b 100644 (file)
 
 static const char version[] = VERSION;
 
-static const int ID_TIMELINE_POS = 0;
 namespace Mlt
 {
 class Producer;
@@ -1005,14 +1004,7 @@ private:
 
 void MainWindow::setupActions()
 {
-
     NameGrabbingKActionCollection collection(actionCollection(), m_action_names);
-    m_timecodeFormat = new KComboBox(this);
-    m_timecodeFormat->addItem(i18n("hh:mm:ss:ff"));
-    m_timecodeFormat->addItem(i18n("Frames"));
-    if (KdenliveSettings::frametimecode()) m_timecodeFormat->setCurrentIndex(1);
-    connect(m_timecodeFormat, SIGNAL(activated(int)), this, SLOT(slotUpdateTimecodeFormat(int)));
-
     m_statusProgressBar = new QProgressBar(this);
     m_statusProgressBar->setMinimum(0);
     m_statusProgressBar->setMaximum(100);
@@ -1024,7 +1016,7 @@ void MainWindow::setupActions()
     
     setStatusBarStyleSheet(palette());
     QString styleBorderless = "QToolButton { border-width: 0px;margin: 1px 3px 0px;padding: 0px;}";
-
+    
     //create edit mode buttons
     m_normalEditTool = new KAction(KIcon("kdenlive-normal-edit"), i18n("Normal mode"), this);
     m_normalEditTool->setShortcut(i18nc("Normal editing", "n"));
@@ -1212,9 +1204,20 @@ void MainWindow::setupActions()
     statusBar()->addWidget(m_messageLabel, 10);
     statusBar()->addWidget(m_statusProgressBar, 0);
     statusBar()->addPermanentWidget(toolbar);
-    statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
-    statusBar()->addPermanentWidget(m_timecodeFormat);
-    //statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 3);
+    
+    m_timeFormatButton = new KSelectAction("00:00:00:00 / 00:00:00:00", this);
+    m_timeFormatButton->addAction(i18n("hh:mm:ss:ff"));
+    m_timeFormatButton->addAction(i18n("Frames"));
+    if (KdenliveSettings::frametimecode()) m_timeFormatButton->setCurrentItem(1);
+    else m_timeFormatButton->setCurrentItem(0);
+    connect(m_timeFormatButton, SIGNAL(triggered(int)), this, SLOT(slotUpdateTimecodeFormat(int)));
+    m_timeFormatButton->setToolBarMode(KSelectAction::MenuMode);
+    toolbar->addAction(m_timeFormatButton);
+    actionWidget = toolbar->widgetForAction(m_timeFormatButton);
+    const QFontMetrics metric = toolbar->fontMetrics();
+    actionWidget->setFixedWidth(metric.width("000:00:00:00 / 00:00:00:000") + 10);
+    actionWidget->setObjectName("timecode");
+
 
     collection.addAction("normal_mode", m_normalEditTool);
     collection.addAction("overwrite_mode", m_overwriteEditTool);
@@ -1796,7 +1799,7 @@ void MainWindow::setStatusBarStyleSheet(const QPalette &p)
     QColor buttonBord = scheme.foreground(KColorScheme::LinkText).color();
     QColor buttonBord2 = scheme.shade(KColorScheme::LightShade);
     statusBar()->setStyleSheet(QString("QStatusBar QLabel {font-size:%1pt;} QStatusBar::item { border: 0px; font-size:%1pt;padding:0px; }").arg(statusBar()->font().pointSize()));
-    QString style1 = QString("QToolBar { border: 0px } QToolButton { border-style: inset; border:1px solid transparent;border-radius: 3px;margin: 0px 3px;padding: 0px;} QToolButton:hover { background: %3;border-style: inset; border:1px solid %3;border-radius: 3px;} QToolButton:checked { background-color: %1; border-style: inset; border:1px solid %2;border-radius: 3px;}").arg(buttonBg.name()).arg(buttonBord.name()).arg(buttonBord2.name());
+    QString style1 = QString("QToolBar { border: 0px } QToolButton { border-style: inset; border:1px solid transparent;border-radius: 3px;margin: 0px 3px;padding: 0px;} QToolButton#timecode {padding-right:8px} QToolButton:hover { background: %3;border-style: inset; border:1px solid %3;border-radius: 3px;} QToolButton:checked { background-color: %1; border-style: inset; border:1px solid %2;border-radius: 3px;}").arg(buttonBg.name()).arg(buttonBord.name()).arg(buttonBord2.name());
     statusBar()->setStyleSheet(style1);
 }
 
@@ -2537,15 +2540,23 @@ void MainWindow::slotCleanProject()
 void MainWindow::slotUpdateMousePosition(int pos)
 {
     if (m_activeDocument)
-        switch (m_timecodeFormat->currentIndex()) {
+        switch (m_timeFormatButton->currentItem()) {
         case 0:
-            statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
+           m_timeFormatButton->setText(m_activeDocument->timecode().getTimecodeFromFrames(pos) + " / " + m_activeDocument->timecode().getTimecodeFromFrames(m_activeTimeline->duration()));
             break;
         default:
-            statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
+           m_timeFormatButton->setText(QString::number(pos) + " / " + QString::number(m_activeTimeline->duration()));
         }
 }
 
+void MainWindow::slotUpdateProjectDuration(int pos)
+{
+    if (m_activeDocument) {
+       m_activeTimeline->setDuration(pos);
+       slotUpdateMousePosition(m_activeTimeline->projectView()->getMousePos());
+    }
+}
+
 void MainWindow::slotUpdateDocumentState(bool modified)
 {
     if (!m_activeDocument) return;
@@ -2649,7 +2660,6 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc)   //cha
     connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
     connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
     connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
-    connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
     connect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers(bool, bool)), doc, SLOT(checkProjectClips(bool, bool)));
 
     connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
@@ -2729,6 +2739,7 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc)   //cha
     m_saveAction->setEnabled(doc->isModified());
     m_normalEditTool->setChecked(true);
     m_activeDocument = doc;
+    connect(m_projectMonitor, SIGNAL(durationChanged(int)), this, SLOT(slotUpdateProjectDuration(int)));
     m_monitorManager->setDocument(m_activeDocument);
     m_activeTimeline->updateProjectFps();
     m_activeDocument->checkProjectClips();
@@ -4304,6 +4315,7 @@ void MainWindow::slotUpdateTimecodeFormat(int ix)
     m_effectStack->updateTimecodeFormat();
     //m_activeTimeline->projectView()->clearSelection();
     m_activeTimeline->updateRuler();
+    slotUpdateMousePosition(m_activeTimeline->projectView()->getMousePos());
 }
 
 void MainWindow::slotRemoveFocus()
index d4d760842604d6c4f303847cedf4943c25837e72..b7414b22e73605ce19207cf0359008f0803612fd 100644 (file)
@@ -204,7 +204,7 @@ private:
     QUndoView *m_undoView;
     QUndoGroup *m_commandStack;
 
-    KComboBox *m_timecodeFormat;
+    KSelectAction *m_timeFormatButton;
 
     /** This list holds all the scopes used in Kdenlive, allowing to manage some global settings */
     QList <QDockWidget *> m_gfxScopesList;
@@ -365,6 +365,7 @@ private slots:
     void slotConnectMonitors();
     void slotUpdateClip(const QString &id);
     void slotUpdateMousePosition(int pos);
+    void slotUpdateProjectDuration(int pos);
     void slotAddEffect(const QDomElement effect);
     void slotEditProfiles();
     void slotDetectAudioDriver();
index 5ffa2af605fd7faf0fe1cc19a19d91a73f68027f..436aa46744f9a99c464e4fc82892a7161bb44304 100644 (file)
@@ -58,6 +58,7 @@ TrackView::TrackView(KdenliveDoc *doc, QList <QAction*> actions, bool *ok, QWidg
     m_ruler = new CustomRuler(doc->timecode(), m_trackview);
     connect(m_ruler, SIGNAL(zoneMoved(int, int)), this, SIGNAL(zoneMoved(int, int)));
     connect(m_ruler, SIGNAL(adjustZoom(int)), this, SIGNAL(setZoom(int)));
+    connect(m_ruler, SIGNAL(mousePosition(int)), this, SIGNAL(mousePosition(int)));
     QHBoxLayout *layout = new QHBoxLayout;
     layout->setContentsMargins(m_trackview->frameWidth(), 0, 0, 0);
     layout->setSpacing(0);