1 /***************************************************************************
2 * Copyright (C) 2010 by Till Theato (root@ttill.de) *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
21 #include "monitorscene.h"
23 #include "kdenlivesettings.h"
25 #include <QGraphicsView>
26 #include <QGraphicsPixmapItem>
29 MonitorScene::MonitorScene(Render *renderer, QObject* parent) :
30 QGraphicsScene(parent),
35 void MonitorScene::setUp()
37 setBackgroundBrush(QBrush(QColor(KdenliveSettings::window_background().name())));
39 QPen framepen(Qt::DotLine);
40 framepen.setColor(Qt::red);
42 m_frameBorder = new QGraphicsRectItem(QRectF(0, 0, m_renderer->renderWidth(), m_renderer->renderHeight()));
43 m_frameBorder->setPen(framepen);
44 m_frameBorder->setZValue(-9);
45 m_frameBorder->setBrush(Qt::transparent);
46 m_frameBorder->setFlags(0);
47 addItem(m_frameBorder);
50 m_background = new QGraphicsPixmapItem();
51 m_background->setZValue(-10);
52 m_background->setFlags(0);
53 QPixmap bg(m_renderer->renderWidth(), m_renderer->renderHeight());
55 m_background->setPixmap(bg);
56 addItem(m_background);
58 connect(m_renderer, SIGNAL(rendererPosition(int)), this, SLOT(slotUpdateBackground()));
59 connect(m_renderer, SIGNAL(frameUpdated(int)), this, SLOT(slotUpdateBackground()));
60 slotUpdateBackground();
63 void MonitorScene::slotUpdateBackground()
65 if (views().count() > 0 && views().at(0)->isVisible()) {
66 if (m_lastUpdate.elapsed() > 200) {
67 m_background->setPixmap(QPixmap::fromImage(m_renderer->extractFrame(m_renderer->seekFramePosition())));
68 views().at(0)->fitInView(m_frameBorder, Qt::KeepAspectRatio);
69 views().at(0)->centerOn(m_frameBorder);
75 void MonitorScene::mousePressEvent(QGraphicsSceneMouseEvent* event)
77 QGraphicsScene::mousePressEvent(event);
81 void MonitorScene::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
83 QGraphicsScene::mouseReleaseEvent(event);
84 emit actionFinished();
87 #include "monitorscene.moc"