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("99:99:99:99");
122 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();
169 kDebug() << "/////// BUILDING MONITOR, ID: " << m_ui.video_frame->winId();
177 delete m_monitorRefresh;
181 QString Monitor::name() const
186 void Monitor::setupMenu(QMenu *goMenu, QAction *playZone, QAction *loopZone, QMenu *markerMenu)
188 m_contextMenu = new QMenu(this);
189 m_contextMenu->addMenu(m_playMenu);
190 if (goMenu) m_contextMenu->addMenu(goMenu);
191 if (markerMenu) m_contextMenu->addMenu(markerMenu);
193 m_playMenu->addAction(playZone);
194 m_playMenu->addAction(loopZone);
196 //TODO: add save zone to timeline monitor when fixed
197 if (m_name == "clip") {
198 m_contextMenu->addMenu(m_markerMenu);
199 m_contextMenu->addAction(KIcon("document-save"), i18n("Save zone"), this, SLOT(slotSaveZone()));
201 QAction *extractFrame = m_configMenu->addAction(KIcon("document-new"), i18n("Extract frame"), this, SLOT(slotExtractCurrentFrame()));
202 m_contextMenu->addAction(extractFrame);
204 if (m_name != "clip") {
206 QAction *splitView = m_contextMenu->addAction(KIcon("view-split-left-right"), i18n("Split view"), render, SLOT(slotSplitView(bool)));
207 splitView->setCheckable(true);
208 m_configMenu->addAction(splitView);
211 QAction *setThumbFrame = m_contextMenu->addAction(KIcon("document-new"), i18n("Set current image as thumbnail"), this, SLOT(slotSetThumbFrame()));
212 m_configMenu->addAction(setThumbFrame);
215 QAction *showTips = m_contextMenu->addAction(KIcon("help-hint"), i18n("Monitor overlay infos"));
216 showTips->setCheckable(true);
217 connect(showTips, SIGNAL(toggled(bool)), this, SLOT(slotSwitchMonitorInfo(bool)));
218 showTips->setChecked(KdenliveSettings::displayMonitorInfo());
220 QAction *dropFrames = m_contextMenu->addAction(KIcon(), i18n("Real time (drop frames)"));
221 dropFrames->setCheckable(true);
222 dropFrames->setChecked(true);
223 connect(dropFrames, SIGNAL(toggled(bool)), this, SLOT(slotSwitchDropFrames(bool)));
225 m_configMenu->addAction(showTips);
226 m_configMenu->addAction(dropFrames);
230 void Monitor::slotGoToMarker(QAction *action)
232 int pos = action->data().toInt();
236 void Monitor::slotSetSizeOneToOne()
238 QRect r = QApplication::desktop()->screenGeometry();
239 const int maxWidth = r.width() - 20;
240 const int maxHeight = r.height() - 20;
241 int width = render->renderWidth();
242 int height = render->renderHeight();
243 kDebug() << "// render info: " << width << "x" << height;
244 while (width >= maxWidth || height >= maxHeight) {
246 height = height * 0.8;
248 kDebug() << "// MONITOR; set SIZE: " << width << ", " << height;
249 m_ui.video_frame->setFixedSize(width, height);
252 //m_ui.video_frame->setMinimumSize(0, 0);
253 emit adjustMonitorSize();
256 void Monitor::slotSetSizeOneToTwo()
258 QRect r = QApplication::desktop()->screenGeometry();
259 const int maxWidth = r.width() - 20;
260 const int maxHeight = r.height() - 20;
261 int width = render->renderWidth() / 2;
262 int height = render->renderHeight() / 2;
263 kDebug() << "// render info: " << width << "x" << height;
264 while (width >= maxWidth || height >= maxHeight) {
266 height = height * 0.8;
268 kDebug() << "// MONITOR; set SIZE: " << width << ", " << height;
269 m_ui.video_frame->setFixedSize(width, height);
272 //m_ui.video_frame->setMinimumSize(0, 0);
273 emit adjustMonitorSize();
276 void Monitor::resetSize()
278 m_ui.video_frame->setMinimumSize(0, 0);
281 DocClipBase *Monitor::activeClip()
283 return m_currentClip;
286 void Monitor::updateMarkers(DocClipBase *source)
288 if (source == m_currentClip && source != NULL) {
289 m_markerMenu->clear();
290 QList <CommentedTime> markers = m_currentClip->commentedSnapMarkers();
291 if (!markers.isEmpty()) {
293 for (int i = 0; i < markers.count(); i++) {
294 int pos = (int) markers.at(i).time().frames(m_monitorManager->timecode().fps());
296 QString position = m_monitorManager->timecode().getTimecode(markers.at(i).time()) + ' ' + markers.at(i).comment();
297 QAction *go = m_markerMenu->addAction(position);
300 m_ruler->setMarkers(marks);
301 } else m_ruler->setMarkers(QList <int>());
302 m_markerMenu->setEnabled(!m_markerMenu->isEmpty());
306 void Monitor::slotSeekToPreviousSnap()
308 if (m_currentClip) slotSeek(getSnapForPos(true).frames(m_monitorManager->timecode().fps()));
311 void Monitor::slotSeekToNextSnap()
313 if (m_currentClip) slotSeek(getSnapForPos(false).frames(m_monitorManager->timecode().fps()));
316 GenTime Monitor::position()
318 return render->seekPosition();
321 GenTime Monitor::getSnapForPos(bool previous)
323 QList <GenTime> snaps;
324 QList < GenTime > markers = m_currentClip->snapMarkers();
325 for (int i = 0; i < markers.size(); ++i) {
326 GenTime t = markers.at(i);
329 QPoint zone = m_ruler->zone();
330 snaps.append(GenTime(zone.x(), m_monitorManager->timecode().fps()));
331 snaps.append(GenTime(zone.y(), m_monitorManager->timecode().fps()));
332 snaps.append(GenTime());
333 snaps.append(m_currentClip->duration());
336 const GenTime pos = render->seekPosition();
337 for (int i = 0; i < snaps.size(); ++i) {
338 if (previous && snaps.at(i) >= pos) {
340 return snaps.at(i - 1);
341 } else if (!previous && snaps.at(i) > pos) {
350 void Monitor::slotZoneMoved(int start, int end)
352 m_ruler->setZone(start, end);
354 setClipZone(m_ruler->zone());
357 void Monitor::slotSetZoneStart()
359 m_ruler->setZone(render->seekFramePosition(), -1);
360 emit zoneUpdated(m_ruler->zone());
362 setClipZone(m_ruler->zone());
365 void Monitor::slotSetZoneEnd()
367 m_ruler->setZone(-1, render->seekFramePosition());
368 emit zoneUpdated(m_ruler->zone());
370 setClipZone(m_ruler->zone());
374 void Monitor::mousePressEvent(QMouseEvent * event)
376 if (event->button() != Qt::RightButton) {
377 if (m_ui.video_frame->underMouse()) {
378 m_dragStarted = true;
379 m_DragStartPosition = event->pos();
381 } else m_contextMenu->popup(event->globalPos());
385 void Monitor::mouseReleaseEvent(QMouseEvent * event)
388 if (m_ui.video_frame->underMouse()) {
389 if (isActive()) slotPlay();
390 else activateMonitor();
391 } else QWidget::mouseReleaseEvent(event);
392 m_dragStarted = false;
398 void Monitor::mouseMoveEvent(QMouseEvent *event)
400 // kDebug() << "// DRAG STARTED, MOUSE MOVED: ";
401 if (!m_dragStarted || m_currentClip == NULL) return;
403 if ((event->pos() - m_DragStartPosition).manhattanLength()
404 < QApplication::startDragDistance())
408 QDrag *drag = new QDrag(this);
409 QMimeData *mimeData = new QMimeData;
412 list.append(m_currentClip->getId());
413 QPoint p = m_ruler->zone();
414 list.append(QString::number(p.x()));
415 list.append(QString::number(p.y()));
417 data.append(list.join(";").toUtf8());
418 mimeData->setData("kdenlive/clip", data);
419 drag->setMimeData(mimeData);
420 QPixmap pix = m_currentClip->thumbnail();
421 drag->setPixmap(pix);
422 drag->setHotSpot(QPoint(0, 50));
423 drag->start(Qt::MoveAction);
425 //Qt::DropAction dropAction;
426 //dropAction = drag->start(Qt::CopyAction | Qt::MoveAction);
428 //Qt::DropAction dropAction = drag->exec();
434 /*void Monitor::dragMoveEvent(QDragMoveEvent * event) {
435 event->setDropAction(Qt::IgnoreAction);
436 event->setDropAction(Qt::MoveAction);
437 if (event->mimeData()->hasText()) {
438 event->acceptProposedAction();
442 Qt::DropActions Monitor::supportedDropActions() const {
443 // returns what actions are supported when dropping
444 return Qt::MoveAction;
447 QStringList Monitor::mimeTypes() const
449 QStringList qstrList;
450 // list of accepted mime types for drop
451 qstrList.append("kdenlive/clip");
457 /** Move to other position on mousewheel
459 * Moves towards end of clip/timeline on mousewheel down/back,
460 * opposite for mousewheel up/forward.
462 * Ctrl+wheel moves single frame, without Ctrl moves a second.
464 * See also http://www.kdenlive.org/mantis/view.php?id=265 */
465 void Monitor::wheelEvent(QWheelEvent * event)
467 if (event->modifiers() == Qt::ControlModifier) {
468 int delta = m_monitorManager->timecode().fps();
469 if (event->delta() > 0) delta = 0 - delta;
470 slotSeek(render->seekFramePosition() - delta);
472 if (event->delta() >= 0) slotForwardOneFrame();
473 else slotRewindOneFrame();
477 void Monitor::slotSetThumbFrame()
479 if (m_currentClip == NULL) {
482 m_currentClip->setClipThumbFrame((uint) render->seekFramePosition());
483 emit refreshClipThumbnail(m_currentClip->getId());
486 void Monitor::slotExtractCurrentFrame()
488 QImage frame = render->extractFrame(render->seekFramePosition());
489 KFileDialog *fs = new KFileDialog(KUrl(), "image/png", this);
490 fs->setOperationMode(KFileDialog::Saving);
491 fs->setMode(KFile::File);
492 #if KDE_IS_VERSION(4,2,0)
493 fs->setConfirmOverwrite(true);
495 fs->setKeepLocation(true);
497 QString path = fs->selectedFile();
499 if (!path.isEmpty()) {
504 bool Monitor::isActive() const
509 void Monitor::activateMonitor()
512 m_monitorManager->slotSwitchMonitors();
516 void Monitor::setTimePos(const QString &pos)
518 if (m_frametimecode) {
519 int frames = m_monitorManager->timecode().getFrameCount(pos);
520 m_timePos->setText(QString::number(frames));
521 } else m_timePos->setText(pos);
525 void Monitor::slotSeek()
528 if (m_frametimecode) frames = m_timePos->text().toInt();
529 else frames = m_monitorManager->timecode().getFrameCount(m_timePos->text());
530 //kDebug() << "// / / SEEK TO: " << frames;
534 void Monitor::slotSeek(int pos)
537 if (render == NULL) return;
538 render->seekToFrame(pos);
539 emit renderPosition(render->seekFramePosition());
542 void Monitor::checkOverlay()
544 if (m_overlay == NULL) return;
545 int pos = render->seekFramePosition();
546 QPoint zone = m_ruler->zone();
547 if (pos == zone.x()) m_overlay->setOverlayText(i18n("In Point"));
548 else if (pos == zone.y()) m_overlay->setOverlayText(i18n("Out Point"));
551 QString markerComment = m_currentClip->markerComment(GenTime(pos, m_monitorManager->timecode().fps()));
552 if (markerComment.isEmpty()) m_overlay->setHidden(true);
553 else m_overlay->setOverlayText(markerComment, false);
554 } else m_overlay->setHidden(true);
558 void Monitor::slotStart()
562 render->seekToFrame(0);
563 //emit renderPosition(0);
566 void Monitor::slotEnd()
570 render->seekToFrame(render->getLength());
571 //emit renderPosition(render->seekFramePosition());
574 void Monitor::slotZoneStart()
578 render->seekToFrame(m_ruler->zone().x());
579 emit renderPosition(render->seekFramePosition());
582 void Monitor::slotZoneEnd()
586 render->seekToFrame(m_ruler->zone().y());
587 emit renderPosition(render->seekFramePosition());
590 void Monitor::slotRewind(double speed)
594 double currentspeed = render->playSpeed();
595 if (currentspeed >= 0) render->play(-2);
596 else render->play(currentspeed * 2);
597 } else render->play(speed);
598 m_playAction->setChecked(true);
599 m_playAction->setIcon(m_pauseIcon);
602 void Monitor::slotForward(double speed)
606 double currentspeed = render->playSpeed();
607 if (currentspeed <= 1) render->play(2);
608 else render->play(currentspeed * 2);
609 } else render->play(speed);
610 m_playAction->setChecked(true);
611 m_playAction->setIcon(m_pauseIcon);
614 void Monitor::slotRewindOneFrame(int diff)
618 render->seekToFrameDiff(-diff);
619 emit renderPosition(render->seekFramePosition());
622 void Monitor::slotForwardOneFrame(int diff)
626 render->seekToFrameDiff(diff);
627 emit renderPosition(render->seekFramePosition());
630 void Monitor::seekCursor(int pos)
633 if (m_ruler->slotNewValue(pos)) {
635 if (m_frametimecode) m_timePos->setText(QString::number(pos));
636 else m_timePos->setText(m_monitorManager->timecode().getTimecodeFromFrames(pos));
640 void Monitor::rendererStopped(int pos)
642 if (m_currentClip != NULL && m_playAction->isChecked()) {
644 if (pos >= m_length - 1) {
649 if (m_ruler->slotNewValue(pos)) {
651 if (m_frametimecode) m_timePos->setText(QString::number(pos));
652 else m_timePos->setText(m_monitorManager->timecode().getTimecodeFromFrames(pos));
654 disconnect(m_playAction, SIGNAL(triggered()), this, SLOT(slotPlay()));
655 m_playAction->setChecked(false);
656 connect(m_playAction, SIGNAL(triggered()), this, SLOT(slotPlay()));
657 m_playAction->setIcon(m_playIcon);
660 void Monitor::initMonitor()
662 kDebug() << "/////// INITING MONITOR, ID: " << m_ui.video_frame->winId();
666 /*void Monitor::resizeEvent(QResizeEvent * event) {
667 QWidget::resizeEvent(event);
669 if (render && m_isActive) render->doRefresh();
673 void Monitor::adjustRulerSize(int length)
675 if (length > 0) m_length = length;
676 m_ruler->adjustScale(m_length);
677 if (m_currentClip != NULL) {
678 QPoint zone = m_currentClip->zone();
679 m_ruler->setZone(zone.x(), zone.y());
686 disconnect(render, SIGNAL(rendererPosition(int)), this, SLOT(seekCursor(int)));
687 if (render) render->stop();
690 void Monitor::start()
693 if (render) render->start();
694 connect(render, SIGNAL(rendererPosition(int)), this, SLOT(seekCursor(int)));
697 void Monitor::refreshMonitor(bool visible)
699 if (visible && render) {
701 render->doRefresh(); //askForRefresh();
705 void Monitor::pause()
707 if (render == NULL) return;
710 //m_playAction->setChecked(true);
711 //m_playAction->setIcon(m_pauseIcon);
714 void Monitor::slotPlay()
716 if (render == NULL) return;
718 if (render->playSpeed() == 0) {
719 m_playAction->setChecked(true);
720 m_playAction->setIcon(m_pauseIcon);
722 m_playAction->setChecked(false);
723 m_playAction->setIcon(m_playIcon);
725 render->switchPlay();
728 void Monitor::slotPlayZone()
730 if (render == NULL) return;
732 QPoint p = m_ruler->zone();
733 render->playZone(GenTime(p.x(), m_monitorManager->timecode().fps()), GenTime(p.y(), m_monitorManager->timecode().fps()));
734 m_playAction->setChecked(true);
735 m_playAction->setIcon(m_pauseIcon);
738 void Monitor::slotLoopZone()
740 if (render == NULL) return;
742 QPoint p = m_ruler->zone();
743 render->loopZone(GenTime(p.x(), m_monitorManager->timecode().fps()), GenTime(p.y(), m_monitorManager->timecode().fps()));
744 m_playAction->setChecked(true);
745 m_playAction->setIcon(m_pauseIcon);
748 void Monitor::slotSetXml(DocClipBase *clip, QPoint zone, const int position)
750 if (render == NULL) return;
752 if (clip == NULL && m_currentClip != NULL) {
753 m_currentClip = NULL;
754 render->setProducer(NULL, -1);
757 if (clip != m_currentClip) {
758 m_currentClip = clip;
760 if (render->setProducer(clip->producer(), position) == -1) {
761 // MLT CONSUMER is broken
762 kDebug(QtWarningMsg) << "ERROR, Cannot start monitor";
764 } else if (position != -1) render->seek(GenTime(position, m_monitorManager->timecode().fps()));
765 if (!zone.isNull()) {
766 m_ruler->setZone(zone.x(), zone.y());
767 render->seek(GenTime(zone.x(), m_monitorManager->timecode().fps()));
771 void Monitor::slotOpenFile(const QString &file)
773 if (render == NULL) return;
776 QDomElement mlt = doc.createElement("mlt");
777 doc.appendChild(mlt);
778 QDomElement prod = doc.createElement("producer");
779 mlt.appendChild(prod);
780 prod.setAttribute("mlt_service", "avformat");
781 prod.setAttribute("resource", file);
782 render->setSceneList(doc, 0);
785 void Monitor::slotSaveZone()
787 if (render == NULL) return;
788 emit saveZone(render, m_ruler->zone());
790 //render->setSceneList(doc, 0);
794 void Monitor::resetProfile(const QString profile)
796 if (render == NULL) return;
797 render->resetProfile(profile);
800 void Monitor::saveSceneList(QString path, QDomElement info)
802 if (render == NULL) return;
803 render->saveSceneList(path, info);
806 const QString Monitor::sceneList()
808 if (render == NULL) return QString();
809 return render->sceneList();
813 void Monitor::setClipZone(QPoint pos)
815 if (m_currentClip == NULL) return;
816 m_currentClip->setZone(pos);
819 void Monitor::slotSwitchDropFrames(bool show)
821 render->setDropFrames(show);
824 void Monitor::slotSwitchMonitorInfo(bool show)
826 KdenliveSettings::setDisplayMonitorInfo(show);
828 if (m_overlay) return;
830 m_overlay = new Overlay(m_monitorRefresh);
832 m_overlay->setHidden(true);
834 m_overlay = new Overlay(m_glWidget);
842 void Monitor::updateTimecodeFormat()
844 m_frametimecode = KdenliveSettings::frametimecode();
845 if (m_frametimecode) {
846 int frames = m_monitorManager->timecode().getFrameCount(m_timePos->text());
847 m_timePos->setValidator(new QIntValidator(this));
848 m_timePos->setInputMask(QString());
849 m_timePos->setText(QString::number(frames));
851 int pos = m_timePos->text().toInt();
852 m_timePos->setValidator(0);
853 m_timePos->setInputMask("99:99:99:99");
854 m_timePos->setText(m_monitorManager->timecode().getTimecodeFromFrames(pos));
858 QStringList Monitor::getZoneInfo() const
861 if (m_currentClip == NULL) return result;
862 result << m_currentClip->getId();
863 QPoint zone = m_ruler->zone();
864 result << QString::number(zone.x()) << QString::number(zone.y());
869 MonitorRefresh::MonitorRefresh(QWidget* parent) : \
873 setAttribute(Qt::WA_PaintOnScreen);
874 setAttribute(Qt::WA_OpaquePaintEvent);
875 //setAttribute(Qt::WA_NoSystemBackground);
878 void MonitorRefresh::setRenderer(Render* render)
883 void MonitorRefresh::paintEvent(QPaintEvent * /*event*/)
885 if (m_renderer) m_renderer->doRefresh();
889 Overlay::Overlay(QWidget* parent) :
892 setAttribute(Qt::WA_TransparentForMouseEvents);
893 setAttribute(Qt::WA_OpaquePaintEvent);
894 //setAttribute(Qt::WA_NoSystemBackground);
895 setAutoFillBackground(false);
898 void Overlay::paintEvent(QPaintEvent * /*event*/)
900 QPainter painter(this);
902 painter.setPen(Qt::white);
903 if (m_isZone) col = QColor(200, 0, 0);
904 else col = QColor(0, 0, 200);
905 painter.fillRect(rect(), col);
906 painter.drawText(rect(), Qt::AlignCenter, text());
911 void Overlay::setOverlayText(const QString &text, bool isZone)
915 setText(' ' + text + ' ');
920 #include "monitor.moc"