1 /***************************************************************************
2 * Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
23 #include "monitormanager.h"
24 #include "smallruler.h"
25 #include "docclipbase.h"
26 #include "monitorscene.h"
27 #include "kdenlivesettings.h"
31 #include <KFileDialog>
32 #include <KApplication>
33 #include <KMessageBox>
35 #include <QMouseEvent>
36 #include <QStylePainter>
38 #include <QToolButton>
40 #include <QDesktopWidget>
42 #include <QIntValidator>
43 #include <QVBoxLayout>
44 #include <QGraphicsView>
47 Monitor::Monitor(QString name, MonitorManager *manager, QString profile, QWidget *parent) :
51 m_monitorManager(manager),
53 m_ruler(new SmallRuler(m_monitorManager)),
63 QVBoxLayout *layout = new QVBoxLayout;
64 layout->setContentsMargins(0, 0, 0, 0);
65 layout->addWidget(m_ruler);
66 m_ui.ruler_frame->setLayout(layout);
67 setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
68 setMinimumHeight(200);
69 QToolBar *toolbar = new QToolBar(name, this);
70 QVBoxLayout *layout2 = new QVBoxLayout;
71 layout2->setContentsMargins(0, 0, 0, 0);
73 m_playIcon = KIcon("media-playback-start");
74 m_pauseIcon = KIcon("media-playback-pause");
76 if (name != "chapter") {
77 toolbar->addAction(KIcon("kdenlive-zone-start"), i18n("Set zone start"), this, SLOT(slotSetZoneStart()));
78 toolbar->addAction(KIcon("kdenlive-zone-end"), i18n("Set zone end"), this, SLOT(slotSetZoneEnd()));
80 m_ruler->setZone(-3, -2);
83 toolbar->addAction(KIcon("media-seek-backward"), i18n("Rewind"), this, SLOT(slotRewind()));
84 //toolbar->addAction(KIcon("media-skip-backward"), i18n("Rewind 1 frame"), this, SLOT(slotRewindOneFrame()));
86 QToolButton *playButton = new QToolButton(toolbar);
87 m_playMenu = new QMenu(i18n("Play..."), this);
88 m_playAction = m_playMenu->addAction(m_playIcon, i18n("Play"));
89 m_playAction->setCheckable(true);
90 connect(m_playAction, SIGNAL(triggered()), this, SLOT(slotPlay()));
92 playButton->setMenu(m_playMenu);
93 playButton->setPopupMode(QToolButton::MenuButtonPopup);
94 toolbar->addWidget(playButton);
96 //toolbar->addAction(KIcon("media-skip-forward"), i18n("Forward 1 frame"), this, SLOT(slotForwardOneFrame()));
97 toolbar->addAction(KIcon("media-seek-forward"), i18n("Forward"), this, SLOT(slotForward()));
99 playButton->setDefaultAction(m_playAction);
101 if (name != "chapter") {
102 QToolButton *configButton = new QToolButton(toolbar);
103 m_configMenu = new QMenu(i18n("Misc..."), this);
104 configButton->setIcon(KIcon("system-run"));
105 configButton->setMenu(m_configMenu);
106 configButton->setPopupMode(QToolButton::QToolButton::InstantPopup);
107 toolbar->addWidget(configButton);
109 if (name == "clip") {
110 m_markerMenu = new QMenu(i18n("Go to marker..."), this);
111 m_markerMenu->setEnabled(false);
112 m_configMenu->addMenu(m_markerMenu);
113 connect(m_markerMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotGoToMarker(QAction *)));
115 m_configMenu->addAction(KIcon("transform-scale"), i18n("Resize (100%)"), this, SLOT(slotSetSizeOneToOne()));
116 m_configMenu->addAction(KIcon("transform-scale"), i18n("Resize (50%)"), this, SLOT(slotSetSizeOneToTwo()));
119 QWidget *spacer = new QWidget(this);
120 spacer->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
121 toolbar->addWidget(spacer);
122 m_timePos = new TimecodeDisplay(m_monitorManager->timecode(), this);
123 toolbar->addWidget(m_timePos);
124 connect(m_timePos, SIGNAL(editingFinished()), this, SLOT(slotSeek()));
126 layout2->addWidget(toolbar);
127 m_ui.button_frame->setLayout(layout2);
128 const int toolHeight = toolbar->height();
129 m_ui.button_frame->setMinimumHeight(toolHeight);
131 //m_ruler->setPixelPerMark(3);
133 if (profile.isEmpty()) profile = KdenliveSettings::current_profile();
135 QVBoxLayout *rendererBox = new QVBoxLayout(m_ui.video_frame);
136 rendererBox->setContentsMargins(0, 0, 0, 0);
138 m_glWidget = new VideoGLWidget(m_ui.video_frame);
139 rendererBox->addWidget(m_glWidget);
140 render = new Render(m_name, (int) m_ui.video_frame->winId(), -1, profile, this);
141 m_glWidget->setImageAspectRatio(render->dar());
142 m_glWidget->setBackgroundColor(KdenliveSettings::window_background());
143 m_glWidget->resize(m_ui.video_frame->size());
144 connect(render, SIGNAL(showImageSignal(QImage)), m_glWidget, SLOT(showImage(QImage)));
145 m_monitorRefresh = 0;
147 m_monitorRefresh = new MonitorRefresh(m_ui.video_frame);
148 rendererBox->addWidget(m_monitorRefresh);
149 render = new Render(m_name, (int) m_monitorRefresh->winId(), -1, profile, this);
150 m_monitorRefresh->setRenderer(render);
153 connect(m_ruler, SIGNAL(seekRenderer(int)), this, SLOT(slotSeek(int)));
154 connect(render, SIGNAL(durationChanged(int)), this, SLOT(adjustRulerSize(int)));
155 connect(render, SIGNAL(rendererStopped(int)), this, SLOT(rendererStopped(int)));
157 //render->createVideoXWindow(m_ui.video_frame->winId(), -1);
159 if (name != "clip") {
160 connect(render, SIGNAL(rendererPosition(int)), this, SIGNAL(renderPosition(int)));
161 connect(render, SIGNAL(durationChanged(int)), this, SIGNAL(durationChanged(int)));
162 connect(m_ruler, SIGNAL(zoneChanged(QPoint)), this, SIGNAL(zoneUpdated(QPoint)));
164 connect(m_ruler, SIGNAL(zoneChanged(QPoint)), this, SLOT(setClipZone(QPoint)));
167 m_monitorRefresh->show();
170 if (name == "project") {
171 m_effectScene = new MonitorScene(render);
172 m_effectView = new QGraphicsView(m_effectScene, m_ui.video_frame);
173 m_effectView->setRenderHints(QFlags<QPainter::RenderHint>());
174 m_effectView->scale(((double) render->renderWidth()) / render->frameRenderWidth(), 1.0);
175 rendererBox->addWidget(m_effectView);
176 m_effectView->setMouseTracking(true);
177 m_effectScene->setUp();
178 m_effectView->hide();
181 kDebug() << "/////// BUILDING MONITOR, ID: " << m_ui.video_frame->winId();
189 if (m_name == "project") {
191 delete m_effectScene;
193 delete m_monitorRefresh;
197 QString Monitor::name() const
202 void Monitor::setupMenu(QMenu *goMenu, QAction *playZone, QAction *loopZone, QMenu *markerMenu)
204 m_contextMenu = new QMenu(this);
205 m_contextMenu->addMenu(m_playMenu);
206 if (goMenu) m_contextMenu->addMenu(goMenu);
207 if (markerMenu) m_contextMenu->addMenu(markerMenu);
209 m_playMenu->addAction(playZone);
210 m_playMenu->addAction(loopZone);
212 //TODO: add save zone to timeline monitor when fixed
213 if (m_name == "clip") {
214 m_contextMenu->addMenu(m_markerMenu);
215 m_contextMenu->addAction(KIcon("document-save"), i18n("Save zone"), this, SLOT(slotSaveZone()));
217 QAction *extractFrame = m_configMenu->addAction(KIcon("document-new"), i18n("Extract frame"), this, SLOT(slotExtractCurrentFrame()));
218 m_contextMenu->addAction(extractFrame);
220 if (m_name != "clip") {
222 QAction *splitView = m_contextMenu->addAction(KIcon("view-split-left-right"), i18n("Split view"), render, SLOT(slotSplitView(bool)));
223 splitView->setCheckable(true);
224 m_configMenu->addAction(splitView);
227 QAction *setThumbFrame = m_contextMenu->addAction(KIcon("document-new"), i18n("Set current image as thumbnail"), this, SLOT(slotSetThumbFrame()));
228 m_configMenu->addAction(setThumbFrame);
231 QAction *showTips = m_contextMenu->addAction(KIcon("help-hint"), i18n("Monitor overlay infos"));
232 showTips->setCheckable(true);
233 connect(showTips, SIGNAL(toggled(bool)), this, SLOT(slotSwitchMonitorInfo(bool)));
234 showTips->setChecked(KdenliveSettings::displayMonitorInfo());
236 QAction *dropFrames = m_contextMenu->addAction(KIcon(), i18n("Real time (drop frames)"));
237 dropFrames->setCheckable(true);
238 dropFrames->setChecked(true);
239 connect(dropFrames, SIGNAL(toggled(bool)), this, SLOT(slotSwitchDropFrames(bool)));
241 m_configMenu->addAction(showTips);
242 m_configMenu->addAction(dropFrames);
246 void Monitor::slotGoToMarker(QAction *action)
248 int pos = action->data().toInt();
252 void Monitor::slotSetSizeOneToOne()
254 QRect r = QApplication::desktop()->screenGeometry();
255 const int maxWidth = r.width() - 20;
256 const int maxHeight = r.height() - 20;
257 int width = render->renderWidth();
258 int height = render->renderHeight();
259 kDebug() << "// render info: " << width << "x" << height;
260 while (width >= maxWidth || height >= maxHeight) {
262 height = height * 0.8;
264 kDebug() << "// MONITOR; set SIZE: " << width << ", " << height;
265 m_ui.video_frame->setFixedSize(width, height);
268 //m_ui.video_frame->setMinimumSize(0, 0);
269 emit adjustMonitorSize();
272 void Monitor::slotSetSizeOneToTwo()
274 QRect r = QApplication::desktop()->screenGeometry();
275 const int maxWidth = r.width() - 20;
276 const int maxHeight = r.height() - 20;
277 int width = render->renderWidth() / 2;
278 int height = render->renderHeight() / 2;
279 kDebug() << "// render info: " << width << "x" << height;
280 while (width >= maxWidth || height >= maxHeight) {
282 height = height * 0.8;
284 kDebug() << "// MONITOR; set SIZE: " << width << ", " << height;
285 m_ui.video_frame->setFixedSize(width, height);
288 //m_ui.video_frame->setMinimumSize(0, 0);
289 emit adjustMonitorSize();
292 void Monitor::resetSize()
294 m_ui.video_frame->setMinimumSize(0, 0);
297 DocClipBase *Monitor::activeClip()
299 return m_currentClip;
302 void Monitor::updateMarkers(DocClipBase *source)
304 if (source == m_currentClip && source != NULL) {
305 m_markerMenu->clear();
306 QList <CommentedTime> markers = m_currentClip->commentedSnapMarkers();
307 if (!markers.isEmpty()) {
309 for (int i = 0; i < markers.count(); i++) {
310 int pos = (int) markers.at(i).time().frames(m_monitorManager->timecode().fps());
312 QString position = m_monitorManager->timecode().getTimecode(markers.at(i).time()) + ' ' + markers.at(i).comment();
313 QAction *go = m_markerMenu->addAction(position);
316 m_ruler->setMarkers(marks);
317 } else m_ruler->setMarkers(QList <int>());
318 m_markerMenu->setEnabled(!m_markerMenu->isEmpty());
322 void Monitor::slotSeekToPreviousSnap()
324 if (m_currentClip) slotSeek(getSnapForPos(true).frames(m_monitorManager->timecode().fps()));
327 void Monitor::slotSeekToNextSnap()
329 if (m_currentClip) slotSeek(getSnapForPos(false).frames(m_monitorManager->timecode().fps()));
332 GenTime Monitor::position()
334 return render->seekPosition();
337 GenTime Monitor::getSnapForPos(bool previous)
339 QList <GenTime> snaps;
340 QList < GenTime > markers = m_currentClip->snapMarkers();
341 for (int i = 0; i < markers.size(); ++i) {
342 GenTime t = markers.at(i);
345 QPoint zone = m_ruler->zone();
346 snaps.append(GenTime(zone.x(), m_monitorManager->timecode().fps()));
347 snaps.append(GenTime(zone.y(), m_monitorManager->timecode().fps()));
348 snaps.append(GenTime());
349 snaps.append(m_currentClip->duration());
352 const GenTime pos = render->seekPosition();
353 for (int i = 0; i < snaps.size(); ++i) {
354 if (previous && snaps.at(i) >= pos) {
356 return snaps.at(i - 1);
357 } else if (!previous && snaps.at(i) > pos) {
364 void Monitor::slotZoneMoved(int start, int end)
366 m_ruler->setZone(start, end);
368 setClipZone(m_ruler->zone());
371 void Monitor::slotSetZoneStart()
373 m_ruler->setZone(render->seekFramePosition(), -1);
374 emit zoneUpdated(m_ruler->zone());
376 setClipZone(m_ruler->zone());
379 void Monitor::slotSetZoneEnd()
381 m_ruler->setZone(-1, render->seekFramePosition());
382 emit zoneUpdated(m_ruler->zone());
384 setClipZone(m_ruler->zone());
388 void Monitor::mousePressEvent(QMouseEvent * event)
390 if (event->button() != Qt::RightButton) {
391 if (m_ui.video_frame->underMouse()) {
392 m_dragStarted = true;
393 m_DragStartPosition = event->pos();
395 } else m_contextMenu->popup(event->globalPos());
399 void Monitor::mouseReleaseEvent(QMouseEvent * event)
402 if (m_ui.video_frame->underMouse() && (!m_effectView || !m_effectView->isVisible())) {
403 if (isActive()) slotPlay();
404 else activateMonitor();
405 } else QWidget::mouseReleaseEvent(event);
406 m_dragStarted = false;
411 void Monitor::mouseMoveEvent(QMouseEvent *event)
413 // kDebug() << "// DRAG STARTED, MOUSE MOVED: ";
414 if (!m_dragStarted || m_currentClip == NULL) return;
416 if ((event->pos() - m_DragStartPosition).manhattanLength()
417 < QApplication::startDragDistance())
421 QDrag *drag = new QDrag(this);
422 QMimeData *mimeData = new QMimeData;
425 list.append(m_currentClip->getId());
426 QPoint p = m_ruler->zone();
427 list.append(QString::number(p.x()));
428 list.append(QString::number(p.y()));
430 data.append(list.join(";").toUtf8());
431 mimeData->setData("kdenlive/clip", data);
432 drag->setMimeData(mimeData);
433 QPixmap pix = m_currentClip->thumbnail();
434 drag->setPixmap(pix);
435 drag->setHotSpot(QPoint(0, 50));
436 drag->start(Qt::MoveAction);
438 //Qt::DropAction dropAction;
439 //dropAction = drag->start(Qt::CopyAction | Qt::MoveAction);
441 //Qt::DropAction dropAction = drag->exec();
447 /*void Monitor::dragMoveEvent(QDragMoveEvent * event) {
448 event->setDropAction(Qt::IgnoreAction);
449 event->setDropAction(Qt::MoveAction);
450 if (event->mimeData()->hasText()) {
451 event->acceptProposedAction();
455 Qt::DropActions Monitor::supportedDropActions() const {
456 // returns what actions are supported when dropping
457 return Qt::MoveAction;
460 QStringList Monitor::mimeTypes() const
462 QStringList qstrList;
463 // list of accepted mime types for drop
464 qstrList.append("kdenlive/clip");
469 void Monitor::wheelEvent(QWheelEvent * event)
471 if (event->modifiers() == Qt::ControlModifier) {
472 int delta = m_monitorManager->timecode().fps();
473 if (event->delta() > 0) delta = 0 - delta;
474 slotSeek(render->seekFramePosition() - delta);
476 if (event->delta() >= 0) slotForwardOneFrame();
477 else slotRewindOneFrame();
481 void Monitor::slotSetThumbFrame()
483 if (m_currentClip == NULL) {
486 m_currentClip->setClipThumbFrame((uint) render->seekFramePosition());
487 emit refreshClipThumbnail(m_currentClip->getId());
490 void Monitor::slotExtractCurrentFrame()
492 QImage frame = render->extractFrame(render->seekFramePosition());
493 KFileDialog *fs = new KFileDialog(KUrl(), "image/png", this);
494 fs->setOperationMode(KFileDialog::Saving);
495 fs->setMode(KFile::File);
496 #if KDE_IS_VERSION(4,2,0)
497 fs->setConfirmOverwrite(true);
499 fs->setKeepLocation(true);
501 QString path = fs->selectedFile();
503 if (!path.isEmpty()) {
508 bool Monitor::isActive() const
513 void Monitor::activateMonitor()
516 m_monitorManager->slotSwitchMonitors(m_name == "clip");
520 void Monitor::setTimePos(const QString &pos)
522 m_timePos->setValue(pos);
526 void Monitor::slotSeek()
528 slotSeek(m_timePos->getValue());
531 void Monitor::slotSeek(int pos)
534 if (render == NULL) return;
535 render->seekToFrame(pos);
538 void Monitor::checkOverlay()
540 if (m_overlay == NULL) return;
541 int pos = render->seekFramePosition();
542 QPoint zone = m_ruler->zone();
544 m_overlay->setOverlayText(i18n("In Point"));
545 else if (pos == zone.y())
546 m_overlay->setOverlayText(i18n("Out Point"));
549 QString markerComment = m_currentClip->markerComment(GenTime(pos, m_monitorManager->timecode().fps()));
550 if (markerComment.isEmpty())
551 m_overlay->setHidden(true);
553 m_overlay->setOverlayText(markerComment, false);
554 } else m_overlay->setHidden(true);
558 void Monitor::slotStart()
562 render->seekToFrame(0);
565 void Monitor::slotEnd()
569 render->seekToFrame(render->getLength());
572 void Monitor::slotZoneStart()
576 render->seekToFrame(m_ruler->zone().x());
579 void Monitor::slotZoneEnd()
583 render->seekToFrame(m_ruler->zone().y());
586 void Monitor::slotRewind(double speed)
590 double currentspeed = render->playSpeed();
591 if (currentspeed >= 0) render->play(-2);
592 else render->play(currentspeed * 2);
593 } else render->play(speed);
594 m_playAction->setChecked(true);
595 m_playAction->setIcon(m_pauseIcon);
598 void Monitor::slotForward(double speed)
602 double currentspeed = render->playSpeed();
603 if (currentspeed <= 1) render->play(2);
604 else render->play(currentspeed * 2);
605 } else render->play(speed);
606 m_playAction->setChecked(true);
607 m_playAction->setIcon(m_pauseIcon);
610 void Monitor::slotRewindOneFrame(int diff)
614 render->seekToFrameDiff(-diff);
617 void Monitor::slotForwardOneFrame(int diff)
621 render->seekToFrameDiff(diff);
624 void Monitor::seekCursor(int pos)
627 if (m_ruler->slotNewValue(pos)) {
629 m_timePos->setValue(pos);
633 void Monitor::rendererStopped(int pos)
635 if (m_ruler->slotNewValue(pos)) {
637 m_timePos->setValue(pos);
639 disconnect(m_playAction, SIGNAL(triggered()), this, SLOT(slotPlay()));
640 m_playAction->setChecked(false);
641 connect(m_playAction, SIGNAL(triggered()), this, SLOT(slotPlay()));
642 m_playAction->setIcon(m_playIcon);
645 void Monitor::initMonitor()
647 kDebug() << "/////// INITING MONITOR, ID: " << m_ui.video_frame->winId();
651 /*void Monitor::resizeEvent(QResizeEvent * event) {
652 QWidget::resizeEvent(event);
654 if (render && m_isActive) render->doRefresh();
658 void Monitor::adjustRulerSize(int length)
660 if (length > 0) m_length = length;
661 m_ruler->adjustScale(m_length);
662 if (m_currentClip != NULL) {
663 QPoint zone = m_currentClip->zone();
664 m_ruler->setZone(zone.x(), zone.y());
671 disconnect(render, SIGNAL(rendererPosition(int)), this, SLOT(seekCursor(int)));
672 if (render) render->stop();
675 void Monitor::start()
678 if (render) render->start();
679 connect(render, SIGNAL(rendererPosition(int)), this, SLOT(seekCursor(int)));
682 void Monitor::refreshMonitor(bool visible)
684 if (visible && render && !m_isActive) {
686 render->doRefresh(); //askForRefresh();
690 void Monitor::pause()
692 if (render == NULL) return;
695 //m_playAction->setChecked(true);
696 //m_playAction->setIcon(m_pauseIcon);
699 void Monitor::slotPlay()
701 if (render == NULL) return;
703 if (render->playSpeed() == 0) {
704 m_playAction->setChecked(true);
705 m_playAction->setIcon(m_pauseIcon);
707 m_playAction->setChecked(false);
708 m_playAction->setIcon(m_playIcon);
710 render->switchPlay();
713 void Monitor::slotPlayZone()
715 if (render == NULL) return;
717 QPoint p = m_ruler->zone();
718 render->playZone(GenTime(p.x(), m_monitorManager->timecode().fps()), GenTime(p.y(), m_monitorManager->timecode().fps()));
719 m_playAction->setChecked(true);
720 m_playAction->setIcon(m_pauseIcon);
723 void Monitor::slotLoopZone()
725 if (render == NULL) return;
727 QPoint p = m_ruler->zone();
728 render->loopZone(GenTime(p.x(), m_monitorManager->timecode().fps()), GenTime(p.y(), m_monitorManager->timecode().fps()));
729 m_playAction->setChecked(true);
730 m_playAction->setIcon(m_pauseIcon);
733 void Monitor::slotSetXml(DocClipBase *clip, QPoint zone, const int position)
735 if (render == NULL) return;
736 if (clip == NULL && m_currentClip != NULL) {
737 m_currentClip = NULL;
739 render->setProducer(NULL, -1);
742 if (m_currentClip != NULL) activateMonitor();
743 if (clip != m_currentClip) {
744 m_currentClip = clip;
746 if (render->setProducer(clip->producer(), position) == -1) {
747 // MLT CONSUMER is broken
748 kDebug(QtWarningMsg) << "ERROR, Cannot start monitor";
750 } else if (position != -1) render->seek(GenTime(position, m_monitorManager->timecode().fps()));
751 if (!zone.isNull()) {
752 m_ruler->setZone(zone.x(), zone.y());
753 render->seek(GenTime(zone.x(), m_monitorManager->timecode().fps()));
757 void Monitor::slotOpenFile(const QString &file)
759 if (render == NULL) return;
762 QDomElement mlt = doc.createElement("mlt");
763 doc.appendChild(mlt);
764 QDomElement prod = doc.createElement("producer");
765 mlt.appendChild(prod);
766 prod.setAttribute("mlt_service", "avformat");
767 prod.setAttribute("resource", file);
768 render->setSceneList(doc, 0);
771 void Monitor::slotSaveZone()
773 if (render == NULL) return;
774 emit saveZone(render, m_ruler->zone());
776 //render->setSceneList(doc, 0);
779 void Monitor::resetProfile(const QString profile)
781 m_timePos->updateTimeCode(m_monitorManager->timecode());
782 if (render == NULL) return;
783 render->resetProfile(profile);
785 m_effectView->scale(((double) render->renderWidth()) / render->frameRenderWidth(), 1.0);
786 m_effectScene->resetProfile();
790 void Monitor::saveSceneList(QString path, QDomElement info)
792 if (render == NULL) return;
793 render->saveSceneList(path, info);
796 const QString Monitor::sceneList()
798 if (render == NULL) return QString();
799 return render->sceneList();
802 void Monitor::setClipZone(QPoint pos)
804 if (m_currentClip == NULL) return;
805 m_currentClip->setZone(pos);
808 void Monitor::slotSwitchDropFrames(bool show)
810 render->setDropFrames(show);
813 void Monitor::slotSwitchMonitorInfo(bool show)
815 KdenliveSettings::setDisplayMonitorInfo(show);
817 if (m_overlay) return;
819 m_overlay = new Overlay(m_monitorRefresh);
821 m_overlay->setHidden(true);
823 m_overlay = new Overlay(m_glWidget);
831 void Monitor::updateTimecodeFormat()
833 m_timePos->slotUpdateTimeCodeFormat();
836 QStringList Monitor::getZoneInfo() const
839 if (m_currentClip == NULL) return result;
840 result << m_currentClip->getId();
841 QPoint zone = m_ruler->zone();
842 result << QString::number(zone.x()) << QString::number(zone.y());
846 void Monitor::slotEffectScene(bool show)
848 if (m_name == "project") {
850 m_glWidget->setVisible(!show);
852 m_monitorRefresh->setVisible(!show);
854 m_effectView->setVisible(show);
855 emit requestFrameForAnalysis(show);
858 m_effectScene->slotZoomFit();
863 MonitorScene * Monitor::getEffectScene()
865 return m_effectScene;
868 bool Monitor::effectSceneDisplayed()
870 return m_effectView->isVisible();
873 MonitorRefresh::MonitorRefresh(QWidget* parent) :
877 setAttribute(Qt::WA_PaintOnScreen);
878 setAttribute(Qt::WA_OpaquePaintEvent);
879 //setAttribute(Qt::WA_NoSystemBackground);
882 void MonitorRefresh::setRenderer(Render* render)
887 void MonitorRefresh::paintEvent(QPaintEvent *event)
890 if (m_renderer) m_renderer->doRefresh();
893 Overlay::Overlay(QWidget* parent) :
896 setAttribute(Qt::WA_TransparentForMouseEvents);
897 //setAttribute(Qt::WA_OpaquePaintEvent);
898 //setAttribute(Qt::WA_NoSystemBackground);
899 setAutoFillBackground(true);
900 setBackgroundRole(QPalette::Base);
903 void Overlay::setOverlayText(const QString &text, bool isZone)
908 p.setColor(QPalette::Text, Qt::white);
909 if (m_isZone) p.setColor(QPalette::Base, QColor(200, 0, 0));
910 else p.setColor(QPalette::Base, QColor(0, 0, 200));
912 setText(' ' + text + ' ');
917 #include "monitor.moc"