#include <KFileDialog>
#include <KApplication>
#include <KMessageBox>
+#include <KSelectAction>
#include <QMouseEvent>
#include <QStylePainter>
Monitor::Monitor(Kdenlive::MONITORID id, MonitorManager *manager, QString profile, QWidget *parent) :
- AbstractMonitor(id, manager, parent),
- render(NULL),
- m_currentClip(NULL),
- m_overlay(NULL),
- m_scale(1),
- m_length(2),
- m_dragStarted(false),
- m_contextMenu(NULL),
- m_effectWidget(NULL),
- m_selectedClip(NULL),
- m_loopClipTransition(true),
+ AbstractMonitor(id, manager, parent)
+ , render(NULL)
+ , m_currentClip(NULL)
+ , m_overlay(NULL)
+ , m_scale(1)
+ , m_length(2)
+ , m_dragStarted(false)
+ , m_loopClipAction(NULL)
+ , m_contextMenu(NULL)
+ , m_effectWidget(NULL)
+ , m_selectedClip(NULL)
+ , m_loopClipTransition(true)
#ifdef USE_OPENGL
- m_glWidget(NULL),
+ , m_glWidget(NULL)
#endif
- m_editMarker(NULL)
+ , m_editMarker(NULL)
{
QVBoxLayout *layout = new QVBoxLayout;
layout->setContentsMargins(0, 0, 0, 0);
#endif
// Monitor ruler
- m_ruler = new SmallRuler(m_monitorManager, render);
+ m_ruler = new SmallRuler(this, render);
if (id == Kdenlive::dvdMonitor) m_ruler->setZone(-3, -2);
layout->addWidget(m_ruler);
m_timePos = new TimecodeDisplay(m_monitorManager->timecode(), this);
m_toolbar->addWidget(m_timePos);
connect(m_timePos, SIGNAL(timeCodeEditingFinished()), this, SLOT(slotSeek()));
- m_toolbar->setMaximumHeight(s * 1.5);
+ m_toolbar->setMaximumHeight(m_timePos->height());
layout->addWidget(m_toolbar);
}
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)
videoBox->setMinimumSize(0, 0);
}
+QString Monitor::getTimecodeFromFrames(int pos)
+{
+ return m_monitorManager->timecode().getTimecodeFromFrames(pos);
+}
+
+double Monitor::fps() const
+{
+ return m_monitorManager->timecode().fps();
+}
+
DocClipBase *Monitor::activeClip()
{
return m_currentClip;
}
}
+void Monitor::setMarkers(QList <CommentedTime> markers)
+{
+ m_ruler->setMarkers(markers);
+}
+
void Monitor::slotSeekToPreviousSnap()
{
if (m_currentClip) slotSeek(getSnapForPos(true).frames(m_monitorManager->timecode().fps()));
// virtual
void Monitor::mousePressEvent(QMouseEvent * event)
{
+ if (render) render->setActiveMonitor();
if (event->button() != Qt::RightButton) {
if (videoBox->geometry().contains(event->pos()) && (!m_overlay || !m_overlay->underMouse())) {
m_dragStarted = true;
void Monitor::updateClipProducer(Mlt::Producer *prod)
{
if (render == NULL) return;
- render->setProducer(prod, render->seekFramePosition());
+ render->setProducer(prod, render->seekFramePosition());
}
void Monitor::slotSetClipProducer(DocClipBase *clip, QPoint zone, bool forceUpdate, int position)
if (render == NULL) return;
if (clip == NULL && m_currentClip != NULL) {
m_currentClip->lastSeekPosition = render->seekFramePosition();
- kDebug()<<"// SETTING NULL CLIP MONITOR";
m_currentClip = NULL;
m_length = -1;
render->setProducer(NULL, -1);
if (render->setProducer(prod, position) == -1) {
// MLT CONSUMER is broken
kDebug(QtWarningMsg) << "ERROR, Cannot start monitor";
- }
+ } else start();
} else {
if (m_currentClip) {
slotActivateMonitor();
if (position == -1) position = render->seekFramePosition();
render->seek(position);
+ if (zone.isNull()) {
+ zone = m_currentClip->zone();
+ m_ruler->setZone(zone.x(), zone.y());
+ return;
+ }
}
}
if (!zone.isNull()) {
if (!render->hasProfile(profile)) {
slotActivateMonitor();
render->resetProfile(profile);
-#ifdef USE_OPENGL
+#ifdef USE_OPENGL
if (m_glWidget) m_glWidget->setImageAspectRatio(render->dar());
#endif
}
void Monitor::slotSetSelectedClip(AbstractClipItem* item)
{
if (item) {
- m_loopClipAction->setEnabled(true);
+ if (m_loopClipAction) m_loopClipAction->setEnabled(true);
m_selectedClip = item;
} else {
- m_loopClipAction->setEnabled(false);
+ if (m_loopClipAction) m_loopClipAction->setEnabled(false);
}
}
slotSetClipProducer(m_currentClip, m_currentClip->zone(), true);
}
+QString Monitor::getMarkerThumb(GenTime pos)
+{
+ if (!m_currentClip) return QString();
+ if (!m_currentClip->getClipHash().isEmpty()) {
+ QString url = m_monitorManager->getProjectFolder() + "thumbs/" + m_currentClip->getClipHash() + '#' + QString::number((int) pos.frames(m_monitorManager->timecode().fps())) + ".png";
+ if (QFile::exists(url)) return url;
+ }
+ return QString();
+}
+
void Monitor::setPalette ( const QPalette & p)
{
QWidget::setPalette(p);