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 "kdenlivesettings.h"
30 #include <KFileDialog>
31 #include <KApplication>
32 #include <KMessageBox>
34 #include <QMouseEvent>
35 #include <QStylePainter>
37 #include <QToolButton>
39 #include <QDesktopWidget>
41 #include <QIntValidator>
44 Monitor::Monitor(QString name, MonitorManager *manager, QString profile, QWidget *parent) :
48 m_monitorManager(manager),
50 m_ruler(new SmallRuler(m_monitorManager)),
58 QVBoxLayout *layout = new QVBoxLayout;
59 layout->setContentsMargins(0, 0, 0, 0);
60 layout->addWidget(m_ruler);
61 m_ui.ruler_frame->setLayout(layout);
62 setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
63 setMinimumHeight(200);
64 QToolBar *toolbar = new QToolBar(name, this);
65 QVBoxLayout *layout2 = new QVBoxLayout;
66 layout2->setContentsMargins(0, 0, 0, 0);
68 m_playIcon = KIcon("media-playback-start");
69 m_pauseIcon = KIcon("media-playback-pause");
71 if (name != "chapter") {
72 toolbar->addAction(KIcon("kdenlive-zone-start"), i18n("Set zone start"), this, SLOT(slotSetZoneStart()));
73 toolbar->addAction(KIcon("kdenlive-zone-end"), i18n("Set zone end"), this, SLOT(slotSetZoneEnd()));
74 } else m_ruler->setZone(-3, -2);
76 toolbar->addAction(KIcon("media-seek-backward"), i18n("Rewind"), this, SLOT(slotRewind()));
77 toolbar->addAction(KIcon("media-skip-backward"), i18n("Rewind 1 frame"), this, SLOT(slotRewindOneFrame()));
79 QToolButton *playButton = new QToolButton(toolbar);
80 m_playMenu = new QMenu(i18n("Play..."), this);
81 m_playAction = m_playMenu->addAction(m_playIcon, i18n("Play"));
82 m_playAction->setCheckable(true);
83 connect(m_playAction, SIGNAL(triggered()), this, SLOT(slotPlay()));
85 playButton->setMenu(m_playMenu);
86 playButton->setPopupMode(QToolButton::MenuButtonPopup);
87 toolbar->addWidget(playButton);
89 toolbar->addAction(KIcon("media-skip-forward"), i18n("Forward 1 frame"), this, SLOT(slotForwardOneFrame()));
90 toolbar->addAction(KIcon("media-seek-forward"), i18n("Forward"), this, SLOT(slotForward()));
92 playButton->setDefaultAction(m_playAction);
94 if (name != "chapter") {
95 QToolButton *configButton = new QToolButton(toolbar);
96 m_configMenu = new QMenu(i18n("Misc..."), this);
97 configButton->setIcon(KIcon("system-run"));
98 configButton->setMenu(m_configMenu);
99 configButton->setPopupMode(QToolButton::QToolButton::InstantPopup);
100 toolbar->addWidget(configButton);
102 if (name == "clip") {
103 m_markerMenu = new QMenu(i18n("Go to marker..."), this);
104 m_markerMenu->setEnabled(false);
105 m_configMenu->addMenu(m_markerMenu);
106 connect(m_markerMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotGoToMarker(QAction *)));
108 m_configMenu->addAction(KIcon("transform-scale"), i18n("Resize (100%)"), this, SLOT(slotSetSizeOneToOne()));
109 m_configMenu->addAction(KIcon("transform-scale"), i18n("Resize (50%)"), this, SLOT(slotSetSizeOneToTwo()));
112 QWidget *spacer = new QWidget(this);
113 spacer->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
114 toolbar->addWidget(spacer);
115 m_timePos = new KRestrictedLine(this);
116 m_timePos->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::MinimumExpanding);
117 m_frametimecode = KdenliveSettings::frametimecode();
118 if (m_frametimecode) {
119 m_timePos->setInputMask(QString());
120 m_timePos->setValidator(new QIntValidator(this));
121 } else m_timePos->setInputMask(m_monitorManager->timecode().inputMask());
123 toolbar->addWidget(m_timePos);
125 connect(m_timePos, SIGNAL(editingFinished()), this, SLOT(slotSeek()));
127 layout2->addWidget(toolbar);
128 m_ui.button_frame->setLayout(layout2);
129 const int toolHeight = toolbar->height();
130 m_ui.button_frame->setMinimumHeight(toolHeight);
132 //m_ruler->setPixelPerMark(3);
134 if (profile.isEmpty()) profile = KdenliveSettings::current_profile();
136 QVBoxLayout *rendererBox = new QVBoxLayout(m_ui.video_frame);
137 rendererBox->setContentsMargins(0, 0, 0, 0);
139 m_glWidget = new VideoGLWidget(m_ui.video_frame);
140 rendererBox->addWidget(m_glWidget);
141 render = new Render(m_name, (int) m_ui.video_frame->winId(), -1, profile, this);
142 m_glWidget->setImageAspectRatio(render->dar());
143 m_glWidget->setBackgroundColor(KdenliveSettings::window_background());
144 m_glWidget->resize(m_ui.video_frame->size());
145 connect(render, SIGNAL(showImageSignal(QImage)), m_glWidget, SLOT(showImage(QImage)));
146 m_monitorRefresh = 0;
148 m_monitorRefresh = new MonitorRefresh(m_ui.video_frame);
149 rendererBox->addWidget(m_monitorRefresh);
150 render = new Render(m_name, (int) m_monitorRefresh->winId(), -1, profile, this);
151 m_monitorRefresh->setRenderer(render);
154 connect(m_ruler, SIGNAL(seekRenderer(int)), this, SLOT(slotSeek(int)));
155 connect(render, SIGNAL(durationChanged(int)), this, SLOT(adjustRulerSize(int)));
156 connect(render, SIGNAL(rendererStopped(int)), this, SLOT(rendererStopped(int)));
158 //render->createVideoXWindow(m_ui.video_frame->winId(), -1);
160 if (name != "clip") {
161 connect(render, SIGNAL(rendererPosition(int)), this, SIGNAL(renderPosition(int)));
162 connect(render, SIGNAL(durationChanged(int)), this, SIGNAL(durationChanged(int)));
163 connect(m_ruler, SIGNAL(zoneChanged(QPoint)), this, SIGNAL(zoneUpdated(QPoint)));
165 connect(m_ruler, SIGNAL(zoneChanged(QPoint)), this, SLOT(setClipZone(QPoint)));
168 m_monitorRefresh->show();
170 kDebug() << "/////// BUILDING MONITOR, ID: " << m_ui.video_frame->winId();
178 delete m_monitorRefresh;
182 QString Monitor::name() const
187 void Monitor::setupMenu(QMenu *goMenu, QAction *playZone, QAction *loopZone, QMenu *markerMenu)
189 m_contextMenu = new QMenu(this);
190 m_contextMenu->addMenu(m_playMenu);
191 if (goMenu) m_contextMenu->addMenu(goMenu);
192 if (markerMenu) m_contextMenu->addMenu(markerMenu);
194 m_playMenu->addAction(playZone);
195 m_playMenu->addAction(loopZone);
197 //TODO: add save zone to timeline monitor when fixed
198 if (m_name == "clip") {
199 m_contextMenu->addMenu(m_markerMenu);
200 m_contextMenu->addAction(KIcon("document-save"), i18n("Save zone"), this, SLOT(slotSaveZone()));
202 QAction *extractFrame = m_configMenu->addAction(KIcon("document-new"), i18n("Extract frame"), this, SLOT(slotExtractCurrentFrame()));
203 m_contextMenu->addAction(extractFrame);
205 if (m_name != "clip") {
207 QAction *splitView = m_contextMenu->addAction(KIcon("view-split-left-right"), i18n("Split view"), render, SLOT(slotSplitView(bool)));
208 splitView->setCheckable(true);
209 m_configMenu->addAction(splitView);
212 QAction *setThumbFrame = m_contextMenu->addAction(KIcon("document-new"), i18n("Set current image as thumbnail"), this, SLOT(slotSetThumbFrame()));
213 m_configMenu->addAction(setThumbFrame);
216 QAction *showTips = m_contextMenu->addAction(KIcon("help-hint"), i18n("Monitor overlay infos"));
217 showTips->setCheckable(true);
218 connect(showTips, SIGNAL(toggled(bool)), this, SLOT(slotSwitchMonitorInfo(bool)));
219 showTips->setChecked(KdenliveSettings::displayMonitorInfo());
221 QAction *dropFrames = m_contextMenu->addAction(KIcon(), i18n("Real time (drop frames)"));
222 dropFrames->setCheckable(true);
223 dropFrames->setChecked(true);
224 connect(dropFrames, SIGNAL(toggled(bool)), this, SLOT(slotSwitchDropFrames(bool)));
226 m_configMenu->addAction(showTips);
227 m_configMenu->addAction(dropFrames);
231 void Monitor::slotGoToMarker(QAction *action)
233 int pos = action->data().toInt();
237 void Monitor::slotSetSizeOneToOne()
239 QRect r = QApplication::desktop()->screenGeometry();
240 const int maxWidth = r.width() - 20;
241 const int maxHeight = r.height() - 20;
242 int width = render->renderWidth();
243 int height = render->renderHeight();
244 kDebug() << "// render info: " << width << "x" << height;
245 while (width >= maxWidth || height >= maxHeight) {
247 height = height * 0.8;
249 kDebug() << "// MONITOR; set SIZE: " << width << ", " << height;
250 m_ui.video_frame->setFixedSize(width, height);
253 //m_ui.video_frame->setMinimumSize(0, 0);
254 emit adjustMonitorSize();
257 void Monitor::slotSetSizeOneToTwo()
259 QRect r = QApplication::desktop()->screenGeometry();
260 const int maxWidth = r.width() - 20;
261 const int maxHeight = r.height() - 20;
262 int width = render->renderWidth() / 2;
263 int height = render->renderHeight() / 2;
264 kDebug() << "// render info: " << width << "x" << height;
265 while (width >= maxWidth || height >= maxHeight) {
267 height = height * 0.8;
269 kDebug() << "// MONITOR; set SIZE: " << width << ", " << height;
270 m_ui.video_frame->setFixedSize(width, height);
273 //m_ui.video_frame->setMinimumSize(0, 0);
274 emit adjustMonitorSize();
277 void Monitor::resetSize()
279 m_ui.video_frame->setMinimumSize(0, 0);
282 DocClipBase *Monitor::activeClip()
284 return m_currentClip;
287 void Monitor::updateMarkers(DocClipBase *source)
289 if (source == m_currentClip && source != NULL) {
290 m_markerMenu->clear();
291 QList <CommentedTime> markers = m_currentClip->commentedSnapMarkers();
292 if (!markers.isEmpty()) {
294 for (int i = 0; i < markers.count(); i++) {
295 int pos = (int) markers.at(i).time().frames(m_monitorManager->timecode().fps());
297 QString position = m_monitorManager->timecode().getTimecode(markers.at(i).time()) + ' ' + markers.at(i).comment();
298 QAction *go = m_markerMenu->addAction(position);
301 m_ruler->setMarkers(marks);
302 } else m_ruler->setMarkers(QList <int>());
303 m_markerMenu->setEnabled(!m_markerMenu->isEmpty());
307 void Monitor::slotSeekToPreviousSnap()
309 if (m_currentClip) slotSeek(getSnapForPos(true).frames(m_monitorManager->timecode().fps()));
312 void Monitor::slotSeekToNextSnap()
314 if (m_currentClip) slotSeek(getSnapForPos(false).frames(m_monitorManager->timecode().fps()));
317 GenTime Monitor::position()
319 return render->seekPosition();
322 GenTime Monitor::getSnapForPos(bool previous)
324 QList <GenTime> snaps;
325 QList < GenTime > markers = m_currentClip->snapMarkers();
326 for (int i = 0; i < markers.size(); ++i) {
327 GenTime t = markers.at(i);
330 QPoint zone = m_ruler->zone();
331 snaps.append(GenTime(zone.x(), m_monitorManager->timecode().fps()));
332 snaps.append(GenTime(zone.y(), m_monitorManager->timecode().fps()));
333 snaps.append(GenTime());
334 snaps.append(m_currentClip->duration());
337 const GenTime pos = render->seekPosition();
338 for (int i = 0; i < snaps.size(); ++i) {
339 if (previous && snaps.at(i) >= pos) {
341 return snaps.at(i - 1);
342 } else if (!previous && snaps.at(i) > pos) {
351 void Monitor::slotZoneMoved(int start, int end)
353 m_ruler->setZone(start, end);
355 setClipZone(m_ruler->zone());
358 void Monitor::slotSetZoneStart()
360 m_ruler->setZone(render->seekFramePosition(), -1);
361 emit zoneUpdated(m_ruler->zone());
363 setClipZone(m_ruler->zone());
366 void Monitor::slotSetZoneEnd()
368 m_ruler->setZone(-1, render->seekFramePosition());
369 emit zoneUpdated(m_ruler->zone());
371 setClipZone(m_ruler->zone());
375 void Monitor::mousePressEvent(QMouseEvent * event)
377 if (event->button() != Qt::RightButton) {
378 if (m_ui.video_frame->underMouse()) {
379 m_dragStarted = true;
380 m_DragStartPosition = event->pos();
382 } else m_contextMenu->popup(event->globalPos());
386 void Monitor::mouseReleaseEvent(QMouseEvent * event)
389 if (m_ui.video_frame->underMouse()) {
390 if (isActive()) slotPlay();
391 else activateMonitor();
392 } else QWidget::mouseReleaseEvent(event);
393 m_dragStarted = false;
399 void Monitor::mouseMoveEvent(QMouseEvent *event)
401 // kDebug() << "// DRAG STARTED, MOUSE MOVED: ";
402 if (!m_dragStarted || m_currentClip == NULL) return;
404 if ((event->pos() - m_DragStartPosition).manhattanLength()
405 < QApplication::startDragDistance())
409 QDrag *drag = new QDrag(this);
410 QMimeData *mimeData = new QMimeData;
413 list.append(m_currentClip->getId());
414 QPoint p = m_ruler->zone();
415 list.append(QString::number(p.x()));
416 list.append(QString::number(p.y()));
418 data.append(list.join(";").toUtf8());
419 mimeData->setData("kdenlive/clip", data);
420 drag->setMimeData(mimeData);
421 QPixmap pix = m_currentClip->thumbnail();
422 drag->setPixmap(pix);
423 drag->setHotSpot(QPoint(0, 50));
424 drag->start(Qt::MoveAction);
426 //Qt::DropAction dropAction;
427 //dropAction = drag->start(Qt::CopyAction | Qt::MoveAction);
429 //Qt::DropAction dropAction = drag->exec();
435 /*void Monitor::dragMoveEvent(QDragMoveEvent * event) {
436 event->setDropAction(Qt::IgnoreAction);
437 event->setDropAction(Qt::MoveAction);
438 if (event->mimeData()->hasText()) {
439 event->acceptProposedAction();
443 Qt::DropActions Monitor::supportedDropActions() const {
444 // returns what actions are supported when dropping
445 return Qt::MoveAction;
448 QStringList Monitor::mimeTypes() const
450 QStringList qstrList;
451 // list of accepted mime types for drop
452 qstrList.append("kdenlive/clip");
458 /** Move to other position on mousewheel
460 * Moves towards end of clip/timeline on mousewheel down/back,
461 * opposite for mousewheel up/forward.
463 * Ctrl+wheel moves single frame, without Ctrl moves a second.
465 * See also http://www.kdenlive.org/mantis/view.php?id=265 */
466 void Monitor::wheelEvent(QWheelEvent * event)
468 if (event->modifiers() == Qt::ControlModifier) {
469 int delta = m_monitorManager->timecode().fps();
470 if (event->delta() > 0) delta = 0 - delta;
471 slotSeek(render->seekFramePosition() - delta);
473 if (event->delta() >= 0) slotForwardOneFrame();
474 else slotRewindOneFrame();
478 void Monitor::slotSetThumbFrame()
480 if (m_currentClip == NULL) {
483 m_currentClip->setClipThumbFrame((uint) render->seekFramePosition());
484 emit refreshClipThumbnail(m_currentClip->getId());
487 void Monitor::slotExtractCurrentFrame()
489 QImage frame = render->extractFrame(render->seekFramePosition());
490 KFileDialog *fs = new KFileDialog(KUrl(), "image/png", this);
491 fs->setOperationMode(KFileDialog::Saving);
492 fs->setMode(KFile::File);
493 #if KDE_IS_VERSION(4,2,0)
494 fs->setConfirmOverwrite(true);
496 fs->setKeepLocation(true);
498 QString path = fs->selectedFile();
500 if (!path.isEmpty()) {
505 bool Monitor::isActive() const
510 void Monitor::activateMonitor()
513 m_monitorManager->slotSwitchMonitors(m_name == "clip");
517 void Monitor::setTimePos(const QString &pos)
519 if (m_frametimecode) {
520 int frames = m_monitorManager->timecode().getFrameCount(pos);
521 m_timePos->setText(QString::number(frames));
522 } else m_timePos->setText(pos);
526 void Monitor::slotSeek()
529 if (m_frametimecode) frames = m_timePos->text().toInt();
530 else frames = m_monitorManager->timecode().getFrameCount(m_timePos->text());
531 //kDebug() << "// / / SEEK TO: " << frames;
535 void Monitor::slotSeek(int pos)
538 if (render == NULL) return;
539 render->seekToFrame(pos);
540 emit renderPosition(render->seekFramePosition());
543 void Monitor::checkOverlay()
545 if (m_overlay == NULL) return;
546 int pos = render->seekFramePosition();
547 QPoint zone = m_ruler->zone();
548 if (pos == zone.x()) m_overlay->setOverlayText(i18n("In Point"));
549 else if (pos == zone.y()) m_overlay->setOverlayText(i18n("Out Point"));
552 QString markerComment = m_currentClip->markerComment(GenTime(pos, m_monitorManager->timecode().fps()));
553 if (markerComment.isEmpty()) m_overlay->setHidden(true);
554 else m_overlay->setOverlayText(markerComment, false);
555 } else m_overlay->setHidden(true);
559 void Monitor::slotStart()
563 render->seekToFrame(0);
564 //emit renderPosition(0);
567 void Monitor::slotEnd()
571 render->seekToFrame(render->getLength());
572 //emit renderPosition(render->seekFramePosition());
575 void Monitor::slotZoneStart()
579 render->seekToFrame(m_ruler->zone().x());
580 emit renderPosition(render->seekFramePosition());
583 void Monitor::slotZoneEnd()
587 render->seekToFrame(m_ruler->zone().y());
588 emit renderPosition(render->seekFramePosition());
591 void Monitor::slotRewind(double speed)
595 double currentspeed = render->playSpeed();
596 if (currentspeed >= 0) render->play(-2);
597 else render->play(currentspeed * 2);
598 } else render->play(speed);
599 m_playAction->setChecked(true);
600 m_playAction->setIcon(m_pauseIcon);
603 void Monitor::slotForward(double speed)
607 double currentspeed = render->playSpeed();
608 if (currentspeed <= 1) render->play(2);
609 else render->play(currentspeed * 2);
610 } else render->play(speed);
611 m_playAction->setChecked(true);
612 m_playAction->setIcon(m_pauseIcon);
615 void Monitor::slotRewindOneFrame(int diff)
619 render->seekToFrameDiff(-diff);
620 emit renderPosition(render->seekFramePosition());
623 void Monitor::slotForwardOneFrame(int diff)
627 render->seekToFrameDiff(diff);
628 emit renderPosition(render->seekFramePosition());
631 void Monitor::seekCursor(int pos)
634 if (m_ruler->slotNewValue(pos)) {
636 if (m_frametimecode) m_timePos->setText(QString::number(pos));
637 else m_timePos->setText(m_monitorManager->timecode().getTimecodeFromFrames(pos));
641 void Monitor::rendererStopped(int pos)
643 if (m_ruler->slotNewValue(pos)) {
645 if (m_frametimecode) m_timePos->setText(QString::number(pos));
646 else m_timePos->setText(m_monitorManager->timecode().getTimecodeFromFrames(pos));
648 disconnect(m_playAction, SIGNAL(triggered()), this, SLOT(slotPlay()));
649 m_playAction->setChecked(false);
650 connect(m_playAction, SIGNAL(triggered()), this, SLOT(slotPlay()));
651 m_playAction->setIcon(m_playIcon);
654 void Monitor::initMonitor()
656 kDebug() << "/////// INITING MONITOR, ID: " << m_ui.video_frame->winId();
660 /*void Monitor::resizeEvent(QResizeEvent * event) {
661 QWidget::resizeEvent(event);
663 if (render && m_isActive) render->doRefresh();
667 void Monitor::adjustRulerSize(int length)
669 if (length > 0) m_length = length;
670 m_ruler->adjustScale(m_length);
671 if (m_currentClip != NULL) {
672 QPoint zone = m_currentClip->zone();
673 m_ruler->setZone(zone.x(), zone.y());
680 disconnect(render, SIGNAL(rendererPosition(int)), this, SLOT(seekCursor(int)));
681 if (render) render->stop();
684 void Monitor::start()
687 if (render) render->start();
688 connect(render, SIGNAL(rendererPosition(int)), this, SLOT(seekCursor(int)));
691 void Monitor::refreshMonitor(bool visible)
693 if (visible && render && !m_isActive) {
695 render->doRefresh(); //askForRefresh();
699 void Monitor::pause()
701 if (render == NULL) return;
704 //m_playAction->setChecked(true);
705 //m_playAction->setIcon(m_pauseIcon);
708 void Monitor::slotPlay()
710 if (render == NULL) return;
712 if (render->playSpeed() == 0) {
713 m_playAction->setChecked(true);
714 m_playAction->setIcon(m_pauseIcon);
716 m_playAction->setChecked(false);
717 m_playAction->setIcon(m_playIcon);
719 render->switchPlay();
722 void Monitor::slotPlayZone()
724 if (render == NULL) return;
726 QPoint p = m_ruler->zone();
727 render->playZone(GenTime(p.x(), m_monitorManager->timecode().fps()), GenTime(p.y(), m_monitorManager->timecode().fps()));
728 m_playAction->setChecked(true);
729 m_playAction->setIcon(m_pauseIcon);
732 void Monitor::slotLoopZone()
734 if (render == NULL) return;
736 QPoint p = m_ruler->zone();
737 render->loopZone(GenTime(p.x(), m_monitorManager->timecode().fps()), GenTime(p.y(), m_monitorManager->timecode().fps()));
738 m_playAction->setChecked(true);
739 m_playAction->setIcon(m_pauseIcon);
742 void Monitor::slotSetXml(DocClipBase *clip, QPoint zone, const int position)
744 if (render == NULL) return;
745 if (clip == NULL && m_currentClip != NULL) {
746 m_currentClip = NULL;
748 render->setProducer(NULL, -1);
751 if (m_currentClip != NULL) activateMonitor();
752 if (clip != m_currentClip) {
753 m_currentClip = clip;
755 if (render->setProducer(clip->producer(), position) == -1) {
756 // MLT CONSUMER is broken
757 kDebug(QtWarningMsg) << "ERROR, Cannot start monitor";
759 } else if (position != -1) render->seek(GenTime(position, m_monitorManager->timecode().fps()));
760 if (!zone.isNull()) {
761 m_ruler->setZone(zone.x(), zone.y());
762 render->seek(GenTime(zone.x(), m_monitorManager->timecode().fps()));
766 void Monitor::slotOpenFile(const QString &file)
768 if (render == NULL) return;
771 QDomElement mlt = doc.createElement("mlt");
772 doc.appendChild(mlt);
773 QDomElement prod = doc.createElement("producer");
774 mlt.appendChild(prod);
775 prod.setAttribute("mlt_service", "avformat");
776 prod.setAttribute("resource", file);
777 render->setSceneList(doc, 0);
780 void Monitor::slotSaveZone()
782 if (render == NULL) return;
783 emit saveZone(render, m_ruler->zone());
785 //render->setSceneList(doc, 0);
789 void Monitor::resetProfile(const QString profile)
791 if (render == NULL) return;
792 render->resetProfile(profile);
795 void Monitor::saveSceneList(QString path, QDomElement info)
797 if (render == NULL) return;
798 render->saveSceneList(path, info);
801 const QString Monitor::sceneList()
803 if (render == NULL) return QString();
804 return render->sceneList();
808 void Monitor::setClipZone(QPoint pos)
810 if (m_currentClip == NULL) return;
811 m_currentClip->setZone(pos);
814 void Monitor::slotSwitchDropFrames(bool show)
816 render->setDropFrames(show);
819 void Monitor::slotSwitchMonitorInfo(bool show)
821 KdenliveSettings::setDisplayMonitorInfo(show);
823 if (m_overlay) return;
825 m_overlay = new Overlay(m_monitorRefresh);
827 m_overlay->setHidden(true);
829 m_overlay = new Overlay(m_glWidget);
837 void Monitor::updateTimecodeFormat()
839 m_frametimecode = KdenliveSettings::frametimecode();
840 if (m_frametimecode) {
841 int frames = m_monitorManager->timecode().getFrameCount(m_timePos->text());
842 m_timePos->setValidator(new QIntValidator(this));
843 m_timePos->setInputMask(QString());
844 m_timePos->setText(QString::number(frames));
846 int pos = m_timePos->text().toInt();
847 m_timePos->setValidator(0);
848 m_timePos->setInputMask(m_monitorManager->timecode().inputMask());
849 m_timePos->setText(m_monitorManager->timecode().getTimecodeFromFrames(pos));
853 QStringList Monitor::getZoneInfo() const
856 if (m_currentClip == NULL) return result;
857 result << m_currentClip->getId();
858 QPoint zone = m_ruler->zone();
859 result << QString::number(zone.x()) << QString::number(zone.y());
864 MonitorRefresh::MonitorRefresh(QWidget* parent) : \
868 setAttribute(Qt::WA_PaintOnScreen);
869 setAttribute(Qt::WA_OpaquePaintEvent);
870 //setAttribute(Qt::WA_NoSystemBackground);
873 void MonitorRefresh::setRenderer(Render* render)
878 void MonitorRefresh::paintEvent(QPaintEvent * /*event*/)
880 if (m_renderer) m_renderer->doRefresh();
884 Overlay::Overlay(QWidget* parent) :
887 setAttribute(Qt::WA_TransparentForMouseEvents);
888 setAttribute(Qt::WA_OpaquePaintEvent);
889 //setAttribute(Qt::WA_NoSystemBackground);
890 setAutoFillBackground(false);
893 void Overlay::paintEvent(QPaintEvent * /*event*/)
895 QPainter painter(this);
897 painter.setPen(Qt::white);
898 if (m_isZone) col = QColor(200, 0, 0);
899 else col = QColor(0, 0, 200);
900 painter.fillRect(rect(), col);
901 painter.drawText(rect(), Qt::AlignCenter, text());
906 void Overlay::setOverlayText(const QString &text, bool isZone)
910 setText(' ' + text + ' ');
915 #include "monitor.moc"