1 /***************************************************************************
2 * Copyright (C) 2011 by Till Theato (root@ttill.de) *
3 * This file is part of Kdenlive (www.kdenlive.org). *
5 * Kdenlive is free software: you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation, either version 2 of the License, or *
8 * (at your option) any later version. *
10 * Kdenlive is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with Kdenlive. If not, see <http://www.gnu.org/licenses/>. *
17 ***************************************************************************/
20 #include "monitoreditwidget.h"
22 #include "monitorscene.h"
23 #include "kdenlivesettings.h"
25 #include <QGraphicsView>
26 #include <QVBoxLayout>
31 MonitorEditWidget::MonitorEditWidget(Render* renderer, QWidget* parent) :
36 m_scene = new MonitorScene(renderer);
37 m_view = new QGraphicsView(m_scene, m_ui.frameVideo);
38 m_view->setRenderHints(QFlags<QPainter::RenderHint>());
39 m_view->scale(((double) renderer->renderWidth()) / renderer->frameRenderWidth(), 1.0);
40 m_view->setMouseTracking(true);
43 ((QVBoxLayout*)m_ui.frameVideo->layout())->addWidget(m_view);
45 m_customControlsLayout = static_cast<QVBoxLayout *>(m_ui.frameCustomControls->layout());
47 m_visibilityAction = new QAction(KIcon("video-display"), i18n("Show/Hide edit mode"), this);
48 m_visibilityAction->setCheckable(true);
49 m_visibilityAction->setVisible(false);
51 m_ui.buttonDirectUpdate->setIcon(KIcon("transform-scale"));
52 m_ui.buttonDirectUpdate->setToolTip(i18n("Update parameters while monitor scene changes"));
53 m_ui.buttonDirectUpdate->setChecked(KdenliveSettings::monitorscene_directupdate());
55 m_ui.buttonZoomFit->setIcon(KIcon("zoom-fit-best"));
56 m_ui.buttonZoomFit->setToolTip(i18n("Fit zoom to monitor size"));
57 m_ui.buttonZoomOriginal->setIcon(KIcon("zoom-original"));
58 m_ui.buttonZoomOriginal->setToolTip(i18n("Original size"));
60 connect(m_ui.sliderZoom, SIGNAL(valueChanged(int)), m_scene, SLOT(slotZoom(int)));
61 connect(m_scene, SIGNAL(zoomChanged(int)), m_ui.sliderZoom, SLOT(setValue(int)));
62 connect(m_ui.buttonZoomFit, SIGNAL(clicked()), m_scene, SLOT(slotZoomFit()));
63 connect(m_ui.buttonZoomOriginal, SIGNAL(clicked()), m_scene, SLOT(slotZoomOriginal()));
64 m_scene->slotZoomFit();
66 connect(m_visibilityAction, SIGNAL(triggered(bool)), this, SIGNAL(showEdit(bool)));
67 connect(m_ui.buttonDirectUpdate, SIGNAL(toggled(bool)), this, SLOT(slotSetDirectUpdate(bool)));
70 MonitorEditWidget::~MonitorEditWidget()
74 delete m_visibilityAction;
77 void MonitorEditWidget::resetProfile(Render* renderer)
79 m_view->scale(((double) renderer->renderWidth()) / renderer->frameRenderWidth(), 1.0);
80 m_scene->resetProfile();
83 MonitorScene* MonitorEditWidget::getScene()
88 QAction* MonitorEditWidget::getVisibilityAction()
90 return m_visibilityAction;
93 void MonitorEditWidget::showVisibilityButton(bool show)
95 m_visibilityAction->setVisible(show);
98 void MonitorEditWidget::addCustomControl(QWidget* widget)
100 m_customControlsLayout->addWidget(widget);
103 void MonitorEditWidget::removeCustomControls()
106 while ((child = m_customControlsLayout->takeAt(0)) != 0)
110 void MonitorEditWidget::slotSetDirectUpdate(bool directUpdate)
112 KdenliveSettings::setMonitorscene_directupdate(directUpdate);
115 #include "monitoreditwidget.moc"