]> git.sesse.net Git - kdenlive/blob - src/rgbparade.cpp
0ae2ab0e16dcb3eb3c7a6e02d81e59e3e79650d2
[kdenlive] / src / rgbparade.cpp
1 /***************************************************************************
2  *   Copyright (C) 2010 by Simon Andreas Eugster (simon.eu@gmail.com)      *
3  *   This file is part of kdenlive. See www.kdenlive.org.                  *
4  *                                                                         *
5  *   This program 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.                                   *
9  ***************************************************************************/
10
11 #include <QRect>
12 #include <QTime>
13 #include "renderer.h"
14 #include "rgbparade.h"
15 #include "rgbparadegenerator.h"
16
17 RGBParade::RGBParade(Monitor *projMonitor, Monitor *clipMonitor, QWidget *parent) :
18         AbstractScopeWidget(projMonitor, clipMonitor, parent)
19 {
20     ui = new Ui::RGBParade_UI();
21     ui->setupUi(this);
22
23     ui->paintMode->addItem(i18n("RGB"), QVariant(RGBParadeGenerator::PaintMode_RGB));
24     ui->paintMode->addItem(i18n("RGB 2"), QVariant(RGBParadeGenerator::PaintMode_RGB2));
25
26     bool b = true;
27     b &= connect(ui->paintMode, SIGNAL(currentIndexChanged(int)), this, SLOT(forceUpdateScope()));
28     Q_ASSERT(b);
29
30     m_rgbParadeGenerator = new RGBParadeGenerator();
31     init();
32 }
33
34 RGBParade::~RGBParade()
35 {
36     writeConfig();
37
38     delete ui;
39     delete m_rgbParadeGenerator;
40 }
41
42 void RGBParade::readConfig()
43 {
44     AbstractScopeWidget::readConfig();
45
46     KSharedConfigPtr config = KGlobal::config();
47     KConfigGroup scopeConfig(config, configName());
48     ui->paintMode->setCurrentIndex(scopeConfig.readEntry("paintmode", 0));
49 }
50
51 void RGBParade::writeConfig()
52 {
53     KSharedConfigPtr config = KGlobal::config();
54     KConfigGroup scopeConfig(config, configName());
55     scopeConfig.writeEntry("paintmode", ui->paintMode->currentIndex());
56     scopeConfig.sync();
57 }
58
59
60 QString RGBParade::widgetName() const { return "RGB Parade"; }
61
62 QRect RGBParade::scopeRect()
63 {
64     QPoint topleft(offset, ui->verticalSpacer->geometry().y() + 2*offset);
65     return QRect(topleft, QPoint(this->size().width() - offset, this->size().height() - offset));
66 }
67
68 QImage RGBParade::renderHUD(uint) { return QImage(); }
69 QImage RGBParade::renderScope(uint accelerationFactor, QImage qimage)
70 {
71     QTime start = QTime::currentTime();
72     start.start();
73
74     int paintmode = ui->paintMode->itemData(ui->paintMode->currentIndex()).toInt();
75     QImage parade = m_rgbParadeGenerator->calculateRGBParade(m_scopeRect.size(), qimage, (RGBParadeGenerator::PaintMode) paintmode,
76                                                     true, accelerationFactor);
77     emit signalScopeRenderingFinished(start.elapsed(), accelerationFactor);
78     return parade;
79 }
80 QImage RGBParade::renderBackground(uint) { return QImage(); }
81
82 bool RGBParade::isHUDDependingOnInput() const { return false; }
83 bool RGBParade::isScopeDependingOnInput() const { return true; }
84 bool RGBParade::isBackgroundDependingOnInput() const { return false; }