m_playAction = m_playMenu->addAction(m_playIcon, i18n("Play"));
m_playAction->setCheckable(true);
connect(m_playAction, SIGNAL(triggered()), this, SLOT(slotPlay()));
- m_playMenu->addAction(m_playIcon, i18n("Play Section"), this, SLOT(slotPlayZone()));
- m_playMenu->addAction(m_playIcon, i18n("Loop Section"), this, SLOT(slotLoopZone()));
playButton->setMenu(m_playMenu);
playButton->setPopupMode(QToolButton::MenuButtonPopup);
connect(m_ruler, SIGNAL(seekRenderer(int)), this, SLOT(slotSeek(int)));
- connect(m_ruler, SIGNAL(zoneChanged(QPoint)), this, SIGNAL(zoneUpdated(QPoint)));
connect(render, SIGNAL(durationChanged(int)), this, SLOT(adjustRulerSize(int)));
connect(render, SIGNAL(rendererPosition(int)), this, SLOT(seekCursor(int)));
connect(render, SIGNAL(rendererStopped(int)), this, SLOT(rendererStopped(int)));
if (name != "clip") {
connect(render, SIGNAL(rendererPosition(int)), this, SIGNAL(renderPosition(int)));
connect(render, SIGNAL(durationChanged(int)), this, SIGNAL(durationChanged(int)));
+ connect(m_ruler, SIGNAL(zoneChanged(QPoint)), this, SIGNAL(zoneUpdated(QPoint)));
+ } else {
+ connect(m_ruler, SIGNAL(zoneChanged(QPoint)), this, SLOT(setClipZone(QPoint)));
}
m_monitorRefresh->show();
kDebug() << "/////// BUILDING MONITOR, ID: " << ui.video_frame->winId();
return m_name;
}
-void Monitor::setupMenu(QMenu *goMenu, QMenu *markerMenu) {
+void Monitor::setupMenu(QMenu *goMenu, QAction *playZone, QAction *loopZone, QMenu *markerMenu) {
m_contextMenu = new QMenu(this);
m_contextMenu->addMenu(m_playMenu);
m_contextMenu->addMenu(goMenu);
if (markerMenu) m_contextMenu->addMenu(markerMenu);
+ m_playMenu->addAction(playZone);
+ m_playMenu->addAction(loopZone);
+
//TODO: add save zone to timeline monitor when fixed
if (m_name == "clip") m_contextMenu->addAction(KIcon("document-save"), i18n("Save zone"), this, SLOT(slotSaveZone()));
void Monitor::slotZoneMoved(int start, int end) {
m_ruler->setZone(start, end);
checkOverlay();
+ setClipZone(m_ruler->zone());
}
void Monitor::slotSetZoneStart() {
m_ruler->setZone(m_position, -1);
emit zoneUpdated(m_ruler->zone());
checkOverlay();
+ setClipZone(m_ruler->zone());
}
void Monitor::slotSetZoneEnd() {
m_ruler->setZone(-1, m_position);
emit zoneUpdated(m_ruler->zone());
checkOverlay();
+ setClipZone(m_ruler->zone());
}
// virtual
m_playAction->setIcon(m_pauseIcon);
}
-void Monitor::slotRewindOneFrame() {
+void Monitor::slotRewindOneFrame(int diff) {
activateMonitor();
render->play(0);
if (m_position < 1) return;
- m_position--;
- checkOverlay();
+ m_position -= diff;
+ m_position = qMax(m_position, 0);
render->seekToFrame(m_position);
emit renderPosition(m_position);
m_timePos->setText(m_monitorManager->timecode().getTimecodeFromFrames(m_position));
+ checkOverlay();
}
-void Monitor::slotForwardOneFrame() {
+void Monitor::slotForwardOneFrame(int diff) {
activateMonitor();
render->play(0);
if (m_position >= m_length) return;
- m_position++;
- checkOverlay();
+ m_position += diff;
+ m_position = qMin(m_position, m_length);
render->seekToFrame(m_position);
emit renderPosition(m_position);
m_timePos->setText(m_monitorManager->timecode().getTimecodeFromFrames(m_position));
+ checkOverlay();
}
void Monitor::seekCursor(int pos) {
activateMonitor();
m_position = pos;
- checkOverlay();
m_timePos->setText(m_monitorManager->timecode().getTimecodeFromFrames(pos));
m_ruler->slotNewValue(pos);
}
//int rulerPos = (int)(pos * m_scale);
m_ruler->slotNewValue(pos);
m_position = pos;
+ checkOverlay();
m_timePos->setText(m_monitorManager->timecode().getTimecodeFromFrames(pos));
m_playAction->setChecked(false);
m_playAction->setIcon(m_playIcon);
void Monitor::adjustRulerSize(int length) {
if (length > 0) m_length = length;
m_ruler->adjustScale(m_length);
+ if (m_currentClip != NULL) {
+ QPoint zone = m_currentClip->zone();
+ m_ruler->setZone(zone.x(), zone.y());
+ }
}
void Monitor::stop() {
void Monitor::slotPlay() {
if (render == NULL) return;
activateMonitor();
+ if (render->playSpeed() == 0) {
+ m_playAction->setChecked(true);
+ m_playAction->setIcon(m_pauseIcon);
+ } else {
+ m_playAction->setChecked(false);
+ m_playAction->setIcon(m_playIcon);
+ }
render->switchPlay();
- m_playAction->setChecked(true);
- m_playAction->setIcon(m_pauseIcon);
}
void Monitor::slotPlayZone() {
void Monitor::slotSetXml(DocClipBase *clip, const int position) {
if (render == NULL) return;
activateMonitor();
- if (!clip) return;
- if (clip != m_currentClip && clip->producer() != NULL) {
+ if (!clip && m_currentClip != NULL) {
+ m_currentClip = NULL;
+ render->setProducer(NULL, -1);
+ return;
+ }
+ if (clip != m_currentClip) {
m_currentClip = clip;
render->setProducer(clip->producer(), position);
- //m_ruler->slotNewValue(0);
- //adjustRulerSize(clip->producer()->get_playtime());
- //m_timePos->setText("00:00:00:00");
m_position = position;
} else if (position != -1) render->seek(GenTime(position, render->fps()));
}
return doc;
}
+
+void Monitor::setClipZone(QPoint pos) {
+ if (m_currentClip == NULL) return;
+ m_currentClip->setZone(pos);
+}
+
MonitorRefresh::MonitorRefresh(QWidget* parent): QWidget(parent), m_renderer(NULL) {
setAttribute(Qt::WA_PaintOnScreen);
setAttribute(Qt::WA_OpaquePaintEvent); //setAttribute(Qt::WA_NoSystemBackground);
Overlay::Overlay(QWidget* parent): QLabel(parent) {
setAttribute(Qt::WA_TransparentForMouseEvents);
- //setAttribute(Qt::WA_OpaquePaintEvent); //
+ setAttribute(Qt::WA_OpaquePaintEvent);
//setAttribute(Qt::WA_NoSystemBackground);
setAutoFillBackground(false);
}