- : QWidget(parent), render(NULL), m_monitorManager(manager), m_name(name), m_isActive(false)
-{
- ui.setupUi(this);
- m_scale = 1;
- m_ruler = new SmallRuler();
- QVBoxLayout *layout = new QVBoxLayout;
- layout->addWidget( m_ruler);
- ui.ruler_frame->setLayout( layout );
- //m_ruler->setPixelPerMark(3);
- m_playIcon = KIcon("media-playback-start");
- m_pauseIcon = KIcon("media-playback-pause");
- ui.button_play->setIcon(m_playIcon);
- ui.button_rew1->setIcon(KIcon("media-skip-backward"));
- ui.button_rew->setIcon(KIcon("media-seek-backward"));
- ui.button_fwd1->setIcon(KIcon("media-skip-forward"));
- ui.button_fwd->setIcon(KIcon("media-seek-forward"));
- connect(m_ruler, SIGNAL(seekRenderer(int)), this, SLOT(slotSeek(int)));
- connect(ui.button_rew, SIGNAL(clicked()), this, SLOT(slotRewind()));
- connect(ui.button_rew1, SIGNAL(clicked()), this, SLOT(slotRewindOneFrame()));
- connect(ui.button_fwd, SIGNAL(clicked()), this, SLOT(slotForward()));
- connect(ui.button_fwd1, SIGNAL(clicked()), this, SLOT(slotForwardOneFrame()));
- connect(ui.button_play, SIGNAL(clicked()), this, SLOT(slotPlay()));
- //if ( render ) return;
- render = new Render(m_name, (int) ui.video_frame->winId(), -1, this);
- connect(render, SIGNAL(playListDuration(int)), this, SLOT(adjustRulerSize(int)));
- connect(render, SIGNAL(rendererPosition(int)), this, SLOT(seekCursor(int)));
- connect(render, SIGNAL(rendererStopped(int)), this, SLOT(rendererStopped(int)));
- if (name != "clip") connect(render, SIGNAL(rendererPosition(int)), this, SIGNAL(renderPosition(int)));
- //render->createVideoXWindow(ui.video_frame->winId(), -1);
- int width = m_ruler->width();
- m_ruler->setLength(width);
- m_ruler->setMaximum(width);
- m_length = 0;
-
- kDebug()<<"/////// BUILDING MONITOR, ID: "<<ui.video_frame->winId();
+ : QWidget(parent), render(NULL), m_monitorManager(manager), m_name(name), m_isActive(false), m_currentClip(NULL), m_dragStarted(false) {
+ ui.setupUi(this);
+ 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 *zoneStart = toolbar->addAction(KIcon("kdenlive-zone-start"), i18n("Set zone start"), this, SLOT(slotSetZoneStart()));
+ QAction *zoneEnd = 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);
+ 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()));
+ 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);
+ m_configMenu = new QMenu(i18n("Misc..."), this);
+ configButton->setIcon(KIcon("system-run"));
+ configButton->setMenu(m_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);
+
+ connect(m_timePos, SIGNAL(editingFinished()), this, SLOT(slotSeek()));
+
+ 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);
+ m_monitorRefresh->setRenderer(render);
+
+
+
+ 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)));
+
+ 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)));
+ }
+ m_monitorRefresh->show();
+ kDebug() << "/////// BUILDING MONITOR, ID: " << ui.video_frame->winId();
+}
+
+QString Monitor::name() const {
+ 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;
+ 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) {
+ if (ui.video_frame->underMouse()) {
+ m_dragStarted = true;
+ m_DragStartPosition = event->pos();
+ }
+ } else m_contextMenu->popup(event->globalPos());