From: Jean-Baptiste Mardelle Date: Tue, 2 Apr 2013 15:52:10 +0000 (+0200) Subject: Show project duration in status bar X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=691411ad08e02a64c3bb4c6603da0ba204afe9fb;p=kdenlive Show project duration in status bar --- diff --git a/src/customruler.cpp b/src/customruler.cpp index ae5555cc..645ecb0f 100644 --- a/src/customruler.cpp +++ b/src/customruler.cpp @@ -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; diff --git a/src/customruler.h b/src/customruler.h index abdc5944..f7ba21bd 100644 --- a/src/customruler.h +++ b/src/customruler.h @@ -98,6 +98,7 @@ private slots: signals: void zoneMoved(int, int); void adjustZoom(int); + void mousePosition(int); }; #endif diff --git a/src/customtrackview.cpp b/src/customtrackview.cpp index bd5d4d72..f069ed9d 100644 --- a/src/customtrackview.cpp +++ b/src/customtrackview.cpp @@ -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) { diff --git a/src/customtrackview.h b/src/customtrackview.h index 4e0d8036..ecdf17b6 100644 --- a/src/customtrackview.h +++ b/src/customtrackview.h @@ -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); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index bae50b8f..553731c9 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -126,7 +126,6 @@ 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() diff --git a/src/mainwindow.h b/src/mainwindow.h index d4d76084..b7414b22 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -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 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(); diff --git a/src/trackview.cpp b/src/trackview.cpp index 5ffa2af6..436aa467 100644 --- a/src/trackview.cpp +++ b/src/trackview.cpp @@ -58,6 +58,7 @@ TrackView::TrackView(KdenliveDoc *doc, QList 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);