+void Monitor::setupMenu(QMenu *goMenu, QAction *playZone, QAction *loopZone, QMenu *markerMenu)
+{
+ m_contextMenu = new QMenu(this);
+ m_contextMenu->addMenu(m_playMenu);
+ if (goMenu) 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->addMenu(m_markerMenu);
+ m_contextMenu->addAction(KIcon("document-save"), i18n("Save zone"), this, SLOT(slotSaveZone()));
+ }
+ QAction *extractFrame = m_configMenu->addAction(KIcon("document-new"), i18n("Extract frame"), this, SLOT(slotExtractCurrentFrame()));
+ m_contextMenu->addAction(extractFrame);
+
+ if (m_name != "clip") {
+#ifndef Q_WS_MAC
+ QAction *splitView = m_contextMenu->addAction(KIcon("view-split-left-right"), i18n("Split view"), render, SLOT(slotSplitView(bool)));
+ splitView->setCheckable(true);
+ m_configMenu->addAction(splitView);
+#endif
+ } else {
+ QAction *setThumbFrame = m_contextMenu->addAction(KIcon("document-new"), i18n("Set current image as thumbnail"), this, SLOT(slotSetThumbFrame()));
+ m_configMenu->addAction(setThumbFrame);
+ }
+
+ QAction *showTips = m_contextMenu->addAction(KIcon("help-hint"), i18n("Monitor overlay infos"));
+ showTips->setCheckable(true);
+ connect(showTips, SIGNAL(toggled(bool)), this, SLOT(slotSwitchMonitorInfo(bool)));
+ showTips->setChecked(KdenliveSettings::displayMonitorInfo());
+
+ QAction *dropFrames = m_contextMenu->addAction(KIcon(), i18n("Real time (drop frames)"));
+ dropFrames->setCheckable(true);
+ dropFrames->setChecked(true);
+ connect(dropFrames, SIGNAL(toggled(bool)), this, SLOT(slotSwitchDropFrames(bool)));
+
+ m_configMenu->addAction(showTips);
+ m_configMenu->addAction(dropFrames);
+
+}
+
+void Monitor::slotGoToMarker(QAction *action)
+{
+ int pos = action->data().toInt();
+ slotSeek(pos);
+}
+
+void Monitor::slotSetSizeOneToOne()
+{
+ QRect r = QApplication::desktop()->screenGeometry();
+ const int maxWidth = r.width() - 20;
+ const int maxHeight = r.height() - 20;
+ int width = render->renderWidth();
+ int height = render->renderHeight();
+ kDebug() << "// render info: " << width << "x" << height;
+ while (width >= maxWidth || height >= maxHeight) {
+ width = width * 0.8;
+ height = height * 0.8;
+ }
+ kDebug() << "// MONITOR; set SIZE: " << width << ", " << height;
+ m_ui.video_frame->setFixedSize(width, height);
+ updateGeometry();
+ adjustSize();
+ //m_ui.video_frame->setMinimumSize(0, 0);
+ emit adjustMonitorSize();
+}
+
+void Monitor::slotSetSizeOneToTwo()
+{
+ QRect r = QApplication::desktop()->screenGeometry();
+ const int maxWidth = r.width() - 20;
+ const int maxHeight = r.height() - 20;
+ int width = render->renderWidth() / 2;
+ int height = render->renderHeight() / 2;
+ kDebug() << "// render info: " << width << "x" << height;
+ while (width >= maxWidth || height >= maxHeight) {
+ width = width * 0.8;
+ height = height * 0.8;
+ }
+ kDebug() << "// MONITOR; set SIZE: " << width << ", " << height;
+ m_ui.video_frame->setFixedSize(width, height);
+ updateGeometry();
+ adjustSize();
+ //m_ui.video_frame->setMinimumSize(0, 0);
+ emit adjustMonitorSize();
+}
+
+void Monitor::resetSize()
+{
+ m_ui.video_frame->setMinimumSize(0, 0);
+}
+
+DocClipBase *Monitor::activeClip()
+{
+ return m_currentClip;
+}
+
+void Monitor::updateMarkers(DocClipBase *source)
+{
+ if (source == m_currentClip && source != NULL) {
+ m_markerMenu->clear();
+ QList <CommentedTime> markers = m_currentClip->commentedSnapMarkers();
+ if (!markers.isEmpty()) {
+ QList <int> marks;
+ for (int i = 0; i < markers.count(); i++) {
+ int pos = (int) markers.at(i).time().frames(m_monitorManager->timecode().fps());
+ marks.append(pos);
+ QString position = m_monitorManager->timecode().getTimecode(markers.at(i).time()) + ' ' + markers.at(i).comment();
+ QAction *go = m_markerMenu->addAction(position);
+ go->setData(pos);
+ }
+ m_ruler->setMarkers(marks);
+ } else m_ruler->setMarkers(QList <int>());
+ m_markerMenu->setEnabled(!m_markerMenu->isEmpty());
+ }
+}
+
+void Monitor::slotSeekToPreviousSnap()
+{
+ if (m_currentClip) slotSeek(getSnapForPos(true).frames(m_monitorManager->timecode().fps()));
+}
+
+void Monitor::slotSeekToNextSnap()
+{
+ if (m_currentClip) slotSeek(getSnapForPos(false).frames(m_monitorManager->timecode().fps()));
+}
+
+GenTime Monitor::position()
+{
+ return render->seekPosition();
+}
+
+GenTime Monitor::getSnapForPos(bool previous)
+{
+ QList <GenTime> snaps;
+ QList < GenTime > markers = m_currentClip->snapMarkers();
+ for (int i = 0; i < markers.size(); ++i) {
+ GenTime t = markers.at(i);
+ snaps.append(t);
+ }
+ QPoint zone = m_ruler->zone();
+ snaps.append(GenTime(zone.x(), m_monitorManager->timecode().fps()));
+ snaps.append(GenTime(zone.y(), m_monitorManager->timecode().fps()));
+ snaps.append(GenTime());
+ snaps.append(m_currentClip->duration());
+ qSort(snaps);
+
+ const GenTime pos = render->seekPosition();
+ for (int i = 0; i < snaps.size(); ++i) {
+ if (previous && snaps.at(i) >= pos) {
+ if (i == 0) i = 1;
+ return snaps.at(i - 1);
+ } else if (!previous && snaps.at(i) > pos) {
+ return snaps.at(i);
+ }
+ }
+ return GenTime();
+}
+
+void Monitor::slotZoneMoved(int start, int end)
+{
+ m_ruler->setZone(start, end);
+ checkOverlay();
+ setClipZone(m_ruler->zone());
+}
+
+void Monitor::slotSetZoneStart()
+{
+ m_ruler->setZone(render->seekFramePosition(), -1);
+ emit zoneUpdated(m_ruler->zone());
+ checkOverlay();
+ setClipZone(m_ruler->zone());
+}
+
+void Monitor::slotSetZoneEnd()
+{
+ m_ruler->setZone(-1, render->seekFramePosition());
+ emit zoneUpdated(m_ruler->zone());
+ checkOverlay();
+ setClipZone(m_ruler->zone());
+}
+
+// virtual
+void Monitor::mousePressEvent(QMouseEvent * event)
+{
+ if (event->button() != Qt::RightButton) {
+ if (m_ui.video_frame->underMouse()) {
+ m_dragStarted = true;
+ m_DragStartPosition = event->pos();
+ }
+ } else m_contextMenu->popup(event->globalPos());
+}
+