X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fmonitor.cpp;h=78c0f5ad35aa7c6464747da16440258fbea67c86;hb=f357ad1475ea0374bd781a89910af798c18d468f;hp=03cc00dbe148c6e3d1ada2866835149dbc4cc4e5;hpb=953b93d0b005bb31840cabd824bc75d87c2752dd;p=kdenlive diff --git a/src/monitor.cpp b/src/monitor.cpp index 03cc00db..78c0f5ad 100644 --- a/src/monitor.cpp +++ b/src/monitor.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -41,19 +42,23 @@ Monitor::Monitor(QString name, MonitorManager *manager, QWidget *parent) m_scale = 1; m_ruler = new SmallRuler(); QVBoxLayout *layout = new QVBoxLayout; + layout->setContentsMargins(0, 0, 0, 0); layout->addWidget(m_ruler); ui.ruler_frame->setLayout(layout); + setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); setMinimumHeight(200); QToolBar *toolbar = new QToolBar(name, this); QVBoxLayout *layout2 = new QVBoxLayout; + layout2->setContentsMargins(0, 0, 0, 0); m_playIcon = KIcon("media-playback-start"); m_pauseIcon = KIcon("media-playback-pause"); - QAction *m_rewAction = toolbar->addAction(KIcon("media-seek-backward"), i18n("Rewind")); - connect(m_rewAction, SIGNAL(triggered()), this, SLOT(slotRewind())); - QAction *m_rew1Action = toolbar->addAction(KIcon("media-skip-backward"), i18n("Rewind 1 frame")); - connect(m_rew1Action, SIGNAL(triggered()), this, SLOT(slotRewindOneFrame())); + toolbar->addAction(KIcon("kdenlive-zone-start"), i18n("Set zone start"), this, SLOT(slotSetZoneStart())); + toolbar->addAction(KIcon("kdenlive-zone-end"), i18n("Set zone end"), this, SLOT(slotSetZoneEnd())); + + toolbar->addAction(KIcon("media-seek-backward"), i18n("Rewind"), this, SLOT(slotRewind())); + toolbar->addAction(KIcon("media-skip-backward"), i18n("Rewind 1 frame"), this, SLOT(slotRewindOneFrame())); QToolButton *playButton = new QToolButton(toolbar); QMenu *playMenu = new QMenu(i18n("Play..."), this); @@ -64,29 +69,39 @@ Monitor::Monitor(QString name, MonitorManager *manager, QWidget *parent) m_playAction = playMenu->addAction(m_playIcon, i18n("Play")); m_playAction->setCheckable(true); connect(m_playAction, SIGNAL(triggered()), this, SLOT(slotPlay())); - QAction *m_playSectionAction = playMenu->addAction(m_playIcon, i18n("Play Section")); - connect(m_playSectionAction, SIGNAL(triggered()), this, SLOT(slotPlay())); - QAction *m_loopSectionAction = playMenu->addAction(m_playIcon, i18n("Loop Section")); - connect(m_loopSectionAction, SIGNAL(triggered()), this, SLOT(slotPlay())); + playMenu->addAction(m_playIcon, i18n("Play Section"), this, SLOT(slotPlay())); + playMenu->addAction(m_playIcon, i18n("Loop Section"), this, SLOT(slotPlay())); - QAction *m_fwd1Action = toolbar->addAction(KIcon("media-skip-forward"), i18n("Forward 1 frame")); - connect(m_fwd1Action, SIGNAL(triggered()), this, SLOT(slotForwardOneFrame())); - QAction *m_fwdAction = toolbar->addAction(KIcon("media-seek-forward"), i18n("Forward")); - connect(m_fwdAction, SIGNAL(triggered()), this, SLOT(slotForward())); + toolbar->addAction(KIcon("media-skip-forward"), i18n("Forward 1 frame"), this, SLOT(slotForwardOneFrame())); + toolbar->addAction(KIcon("media-seek-forward"), i18n("Forward"), this, SLOT(slotForward())); playButton->setDefaultAction(m_playAction); + QToolButton *configButton = new QToolButton(toolbar); + QMenu *configMenu = new QMenu(i18n("Misc..."), this); + configButton->setIcon(KIcon("system-run")); + configButton->setMenu(configMenu); + configButton->setPopupMode(QToolButton::QToolButton::InstantPopup); + toolbar->addWidget(configButton); + + QWidget *spacer = new QWidget(this); + spacer->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); + toolbar->addWidget(spacer); m_timePos = new KRestrictedLine(this); + m_timePos->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::MinimumExpanding); m_timePos->setInputMask("99:99:99:99"); toolbar->addWidget(m_timePos); layout2->addWidget(toolbar); ui.button_frame->setLayout(layout2); + const int toolHeight = toolbar->height(); + ui.button_frame->setMinimumHeight(toolHeight); //m_ruler->setPixelPerMark(3); QVBoxLayout *rendererBox = new QVBoxLayout(ui.video_frame); + rendererBox->setContentsMargins(0, 0, 0, 0); m_monitorRefresh = new MonitorRefresh(ui.video_frame); rendererBox->addWidget(m_monitorRefresh); render = new Render(m_name, (int) m_monitorRefresh->winId(), -1, this); @@ -94,24 +109,27 @@ Monitor::Monitor(QString name, MonitorManager *manager, QWidget *parent) m_contextMenu = new QMenu(this); m_contextMenu->addMenu(playMenu); - QAction *extractFrame = m_contextMenu->addAction(KIcon("document-new"), i18n("Extract frame")); - connect(extractFrame, SIGNAL(triggered()), this, SLOT(slotExtractCurrentFrame())); + QAction *extractFrame = m_contextMenu->addAction(KIcon("document-new"), i18n("Extract frame"), this, SLOT(slotExtractCurrentFrame())); connect(m_ruler, SIGNAL(seekRenderer(int)), this, SLOT(slotSeek(int))); - connect(render, SIGNAL(durationChanged(int)), this, SLOT(adjustRulerSize(int))); connect(render, SIGNAL(rendererPosition(int)), this, SLOT(seekCursor(int))); connect(render, SIGNAL(rendererStopped(int)), this, SLOT(rendererStopped(int))); + + configMenu->addAction(extractFrame); if (name != "clip") { connect(render, SIGNAL(rendererPosition(int)), this, SIGNAL(renderPosition(int))); connect(render, SIGNAL(durationChanged(int)), this, SIGNAL(durationChanged(int))); + QAction *splitView = m_contextMenu->addAction(KIcon("document-new"), i18n("Split view"), render, SLOT(slotSplitView(bool))); + splitView->setCheckable(true); + configMenu->addAction(splitView); } else { - QAction *setThumbFrame = m_contextMenu->addAction(KIcon("document-new"), i18n("Set current image as thumbnail")); - connect(setThumbFrame, SIGNAL(triggered()), this, SLOT(slotSetThumbFrame())); + QAction *setThumbFrame = m_contextMenu->addAction(KIcon("document-new"), i18n("Set current image as thumbnail"), this, SLOT(slotSetThumbFrame())); + configMenu->addAction(setThumbFrame); } + configMenu->addSeparator(); + configMenu->addAction(KIcon("transform-scale"), i18n("Resize (100%)"), this, SLOT(slotSetSizeOneToOne())); + configMenu->addAction(KIcon("transform-scale"), i18n("Resize (50%)"), this, SLOT(slotSetSizeOneToTwo())); //render->createVideoXWindow(ui.video_frame->winId(), -1); - int width = m_ruler->width(); - m_ruler->setLength(width); - m_ruler->setMaximum(width); m_length = 0; m_monitorRefresh->show(); kDebug() << "/////// BUILDING MONITOR, ID: " << ui.video_frame->winId(); @@ -121,10 +139,67 @@ QString Monitor::name() const { return m_name; } +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; + ui.video_frame->setFixedSize(width, height); + updateGeometry(); + adjustSize(); + //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; + ui.video_frame->setFixedSize(width, height); + updateGeometry(); + adjustSize(); + //ui.video_frame->setMinimumSize(0, 0); + emit adjustMonitorSize(); +} + +void Monitor::resetSize() { + ui.video_frame->setMinimumSize(0, 0); +} + +void Monitor::slotZoneMoved(int start, int end) { + m_ruler->setZone(start, end); +} + +void Monitor::slotSetZoneStart() { + m_ruler->setZone(m_position, -1); + emit zoneUpdated(m_ruler->zone()); +} + +void Monitor::slotSetZoneEnd() { + m_ruler->setZone(-1, m_position); + emit zoneUpdated(m_ruler->zone()); +} + // virtual void Monitor::mousePressEvent(QMouseEvent * event) { - if (event->button() != Qt::RightButton) slotPlay(); - else m_contextMenu->popup(event->globalPos()); + if (event->button() != Qt::RightButton) { + if (ui.video_frame->underMouse()) slotPlay(); + } else m_contextMenu->popup(event->globalPos()); } // virtual @@ -228,11 +303,9 @@ void Monitor::slotForwardOneFrame() { void Monitor::seekCursor(int pos) { if (!m_isActive) m_monitorManager->activateMonitor(m_name); - //int rulerPos = (int)(pos * m_scale); m_position = pos; m_timePos->setText(m_monitorManager->timecode().getTimecodeFromFrames(pos)); - //kDebug() << "seek: " << pos << ", scale: " << m_scale; - m_ruler->slotNewValue(pos); //rulerPos); + m_ruler->slotNewValue(pos); } void Monitor::rendererStopped(int pos) { @@ -257,15 +330,8 @@ void Monitor::initMonitor() { }*/ void Monitor::adjustRulerSize(int length) { - int width = m_ruler->width(); - m_ruler->setLength(width); if (length > 0) m_length = length; - m_scale = (double) width / m_length; - if (m_scale == 0) m_scale = 1; - kDebug() << "RULER WIDT: " << width << ", RENDER LENGT: " << m_length << ", SCALE: " << m_scale; - m_ruler->setPixelPerMark(m_scale); - m_ruler->setMaximum(width); - //m_ruler->setLength(length); + m_ruler->adjustScale(m_length); } void Monitor::stop() { @@ -299,15 +365,14 @@ void Monitor::slotSetXml(DocClipBase *clip, const int position) { if (render == NULL) return; if (!m_isActive) m_monitorManager->activateMonitor(m_name); if (!clip) return; - if (clip != m_currentClip) { + if (clip != m_currentClip && clip->producer() != NULL) { m_currentClip = clip; - render->setProducer(clip->producer(), 0); - m_ruler->slotNewValue(0); + render->setProducer(clip->producer(), position); + //m_ruler->slotNewValue(0); //adjustRulerSize(clip->producer()->get_playtime()); - m_timePos->setText("00:00:00:00"); - m_position = 0; - } - if (position != -1) render->seek(GenTime(position, render->fps())); + //m_timePos->setText("00:00:00:00"); + m_position = position; + } else if (position != -1) render->seek(GenTime(position, render->fps())); } void Monitor::slotOpenFile(const QString &file) { @@ -323,9 +388,9 @@ void Monitor::slotOpenFile(const QString &file) { render->setSceneList(doc, 0); } -void Monitor::resetProfile(QString prof) { +void Monitor::resetProfile() { if (render == NULL) return; - render->resetProfile(prof); + render->resetProfile(); } void Monitor::saveSceneList(QString path, QDomElement info) { @@ -335,7 +400,7 @@ void Monitor::saveSceneList(QString path, QDomElement info) { MonitorRefresh::MonitorRefresh(QWidget* parent): QWidget(parent), m_renderer(NULL) { setAttribute(Qt::WA_PaintOnScreen); - setAttribute(Qt::WA_OpaquePaintEvent); //Qt::WA_NoSystemBackground); + setAttribute(Qt::WA_OpaquePaintEvent); //setAttribute(Qt::WA_NoSystemBackground); } void MonitorRefresh::setRenderer(Render* render) {