#include <KDebug>
#include <KLocale>
#include <KFileDialog>
+#include <KApplication>
#include "gentime.h"
#include "monitor.h"
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);
- playButton->setMenu(playMenu);
- playButton->setPopupMode(QToolButton::MenuButtonPopup);
- toolbar->addWidget(playButton);
-
- m_playAction = playMenu->addAction(m_playIcon, i18n("Play"));
+ m_playMenu = new QMenu(i18n("Play..."), this);
+ m_playAction = m_playMenu->addAction(m_playIcon, i18n("Play"));
m_playAction->setCheckable(true);
connect(m_playAction, SIGNAL(triggered()), this, SLOT(slotPlay()));
- playMenu->addAction(m_playIcon, i18n("Play Section"), this, SLOT(slotPlayZone()));
- playMenu->addAction(m_playIcon, i18n("Loop Section"), this, SLOT(slotLoopZone()));
+ m_playMenu->addAction(m_playIcon, i18n("Play Section"), this, SLOT(slotPlayZone()));
+ m_playMenu->addAction(m_playIcon, i18n("Loop Section"), this, SLOT(slotLoopZone()));
+
+ playButton->setMenu(m_playMenu);
+ playButton->setPopupMode(QToolButton::MenuButtonPopup);
+ toolbar->addWidget(playButton);
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);
+ m_configMenu = new QMenu(i18n("Misc..."), this);
configButton->setIcon(KIcon("system-run"));
- configButton->setMenu(configMenu);
+ configButton->setMenu(m_configMenu);
configButton->setPopupMode(QToolButton::QToolButton::InstantPopup);
toolbar->addWidget(configButton);
m_timePos->setInputMask("99:99:99:99");
toolbar->addWidget(m_timePos);
+ connect(m_timePos, SIGNAL(editingFinished()), this, SLOT(slotSeek()));
+
layout2->addWidget(toolbar);
ui.button_frame->setLayout(layout2);
const int toolHeight = toolbar->height();
//m_ruler->setPixelPerMark(3);
-
QVBoxLayout *rendererBox = new QVBoxLayout(ui.video_frame);
rendererBox->setContentsMargins(0, 0, 0, 0);
m_monitorRefresh = new MonitorRefresh(ui.video_frame);
render = new Render(m_name, (int) m_monitorRefresh->winId(), -1, this);
m_monitorRefresh->setRenderer(render);
- m_contextMenu = new QMenu(this);
- m_contextMenu->addMenu(playMenu);
-
- QMenu *goMenu = new QMenu(i18n("Go to..."), this);
- goMenu->addAction(i18n("Start"), this, SLOT(slotStart()));
- goMenu->addAction(i18n("End"), this, SLOT(slotEnd()));
- goMenu->addAction(i18n("Zone start"), this, SLOT(slotZoneStart()));
- goMenu->addAction(i18n("Zone end"), this, SLOT(slotZoneEnd()));
- m_contextMenu->addMenu(goMenu);
- m_contextMenu->addAction(zoneStart);
- m_contextMenu->addAction(zoneEnd);
- 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(m_ruler, SIGNAL(zoneChanged(QPoint)), this, SIGNAL(zoneUpdated(QPoint)));
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);
+ m_configMenu->addSeparator();
+ m_configMenu->addAction(KIcon("transform-scale"), i18n("Resize (100%)"), this, SLOT(slotSetSizeOneToOne()));
+ m_configMenu->addAction(KIcon("transform-scale"), i18n("Resize (50%)"), this, SLOT(slotSetSizeOneToTwo()));
+ //render->createVideoXWindow(ui.video_frame->winId(), -1);
+ m_length = 0;
+
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"), 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);
- m_length = 0;
m_monitorRefresh->show();
kDebug() << "/////// BUILDING MONITOR, ID: " << ui.video_frame->winId();
}
return m_name;
}
+void Monitor::setupMenu(QMenu *goMenu) {
+ m_contextMenu = new QMenu(this);
+ m_contextMenu->addMenu(m_playMenu);
+ m_contextMenu->addMenu(goMenu);
+
+ //TODO: add save zone to timeline monitor when fixed
+ if (m_name == "clip") m_contextMenu->addAction(KIcon("document-save"), i18n("Save zone"), this, SLOT(slotSaveZone()));
+
+ QAction *extractFrame = m_configMenu->addAction(KIcon("document-new"), i18n("Extract frame"), this, SLOT(slotExtractCurrentFrame()));
+ m_contextMenu->addAction(extractFrame);
+
+ if (m_name != "clip") {
+ QAction *splitView = m_contextMenu->addAction(KIcon("document-new"), i18n("Split view"), render, SLOT(slotSplitView(bool)));
+ splitView->setCheckable(true);
+ m_configMenu->addAction(splitView);
+ } else {
+ QAction *setThumbFrame = m_contextMenu->addAction(KIcon("document-new"), i18n("Set current image as thumbnail"), this, SLOT(slotSetThumbFrame()));
+ m_configMenu->addAction(setThumbFrame);
+ }
+
+}
+
void Monitor::slotSetSizeOneToOne() {
QRect r = QApplication::desktop()->screenGeometry();
const int maxWidth = r.width() - 20;
// virtual
+/** Move to other position on mousewheel
+ *
+ * Moves towards end of clip/timeline on mousewheel down/back,
+ * opposite for mousewheel up/forward.
+ *
+ * Ctrl+wheel moves single frame, without Ctrl moves a second.
+ *
+ * See also http://www.kdenlive.org/mantis/view.php?id=265 */
void Monitor::wheelEvent(QWheelEvent * event) {
if (event->modifiers() == Qt::ControlModifier) {
int delta = m_monitorManager->timecode().fps();
if (event->delta() < 0) delta = 0 - delta;
- slotSeek(m_position + delta);
+ slotSeek(m_position - delta);
} else {
- if (event->delta() > 0) slotForwardOneFrame();
+ if (event->delta() <= 0) slotForwardOneFrame();
else slotRewindOneFrame();
}
}
if (!outputFile.isEmpty()) frame.save(outputFile);
}
+bool Monitor::isActive() const {
+ return m_isActive;
+}
+
void Monitor::activateMonitor() {
if (!m_isActive) m_monitorManager->activateMonitor(m_name);
}
+void Monitor::slotSeek() {
+ const int frames = m_monitorManager->timecode().getFrameCount(m_timePos->text(), m_monitorManager->timecode().fps());
+ slotSeek(frames);
+}
+
void Monitor::slotSeek(int pos) {
if (!m_isActive) m_monitorManager->activateMonitor(m_name);
if (render == NULL) return;
}
}
+void Monitor::pause() {
+ if (render == NULL) return;
+ if (!m_isActive) m_monitorManager->activateMonitor(m_name);
+ render->pause();
+ //m_playAction->setChecked(true);
+ //m_playAction->setIcon(m_pauseIcon);
+}
+
void Monitor::slotPlay() {
if (render == NULL) return;
if (!m_isActive) m_monitorManager->activateMonitor(m_name);
render->setSceneList(doc, 0);
}
+void Monitor::slotSaveZone() {
+ if (render == NULL) return;
+ emit saveZone(render, m_ruler->zone());
+
+ //render->setSceneList(doc, 0);
+}
+
+
void Monitor::resetProfile() {
if (render == NULL) return;
render->resetProfile();
render->saveSceneList(path, info);
}
+QDomDocument Monitor::sceneList() {
+ if (render == NULL) return QDomDocument();
+ QDomDocument doc;
+ doc.setContent(render->sceneList());
+ return doc;
+}
+
MonitorRefresh::MonitorRefresh(QWidget* parent): QWidget(parent), m_renderer(NULL) {
setAttribute(Qt::WA_PaintOnScreen);
setAttribute(Qt::WA_OpaquePaintEvent); //setAttribute(Qt::WA_NoSystemBackground);