Commit 20381b3a authored by Simon Eugster's avatar Simon Eugster
Browse files

* Scopes: Configuration is saved now.

* Fixed: Tested wrong variable to < 1 allowed an acceleration factor of 0, causing an nearly infinite loop.

svn path=/trunk/kdenlive/; revision=4714
parent 35728e41
...@@ -80,15 +80,43 @@ AbstractScopeWidget::AbstractScopeWidget(Monitor *projMonitor, Monitor *clipMoni ...@@ -80,15 +80,43 @@ AbstractScopeWidget::AbstractScopeWidget(Monitor *projMonitor, Monitor *clipMoni
AbstractScopeWidget::~AbstractScopeWidget() AbstractScopeWidget::~AbstractScopeWidget()
{ {
writeConfig();
delete m_menu; delete m_menu;
delete m_aAutoRefresh; delete m_aAutoRefresh;
delete m_aRealtime; delete m_aRealtime;
} }
void AbstractScopeWidget::init()
{
m_widgetName = widgetName();
readConfig();
}
void AbstractScopeWidget::readConfig()
{
KSharedConfigPtr config = KGlobal::config();
KConfigGroup scopeConfig(config, configName());
m_aAutoRefresh->setChecked(scopeConfig.readEntry("autoRefresh", true));
m_aRealtime->setChecked(scopeConfig.readEntry("realtime", false));
scopeConfig.sync();
}
void AbstractScopeWidget::writeConfig()
{
KSharedConfigPtr config = KGlobal::config();
KConfigGroup scopeConfig(config, configName());
scopeConfig.writeEntry("autoRefresh", m_aAutoRefresh->isChecked());
scopeConfig.writeEntry("realtime", m_aRealtime->isChecked());
scopeConfig.sync();
}
QString AbstractScopeWidget::configName() { return "Scope_" + m_widgetName; }
void AbstractScopeWidget::prodHUDThread() void AbstractScopeWidget::prodHUDThread()
{ {
if (this->visibleRegion().isEmpty()) { if (this->visibleRegion().isEmpty()) {
qDebug() << "Scope " << widgetName() << " is not visible. Not calculating HUD."; qDebug() << "Scope " << m_widgetName << " is not visible. Not calculating HUD.";
} else { } else {
if (m_semaphoreHUD.tryAcquire(1)) { if (m_semaphoreHUD.tryAcquire(1)) {
Q_ASSERT(!m_threadHUD.isRunning()); Q_ASSERT(!m_threadHUD.isRunning());
...@@ -96,10 +124,10 @@ void AbstractScopeWidget::prodHUDThread() ...@@ -96,10 +124,10 @@ void AbstractScopeWidget::prodHUDThread()
m_newHUDFrames.fetchAndStoreRelaxed(0); m_newHUDFrames.fetchAndStoreRelaxed(0);
m_newHUDUpdates.fetchAndStoreRelaxed(0); m_newHUDUpdates.fetchAndStoreRelaxed(0);
m_threadHUD = QtConcurrent::run(this, &AbstractScopeWidget::renderHUD, m_accelFactorHUD); m_threadHUD = QtConcurrent::run(this, &AbstractScopeWidget::renderHUD, m_accelFactorHUD);
qDebug() << "HUD thread started in " << widgetName(); qDebug() << "HUD thread started in " << m_widgetName;
} else { } else {
qDebug() << "HUD semaphore locked, not prodding in " << widgetName() << ". Thread running: " << m_threadHUD.isRunning(); qDebug() << "HUD semaphore locked, not prodding in " << m_widgetName << ". Thread running: " << m_threadHUD.isRunning();
} }
} }
} }
...@@ -109,7 +137,7 @@ void AbstractScopeWidget::prodScopeThread() ...@@ -109,7 +137,7 @@ void AbstractScopeWidget::prodScopeThread()
// Only start a new thread if the scope is actually visible // Only start a new thread if the scope is actually visible
// and not hidden by another widget on the stack. // and not hidden by another widget on the stack.
if (this->visibleRegion().isEmpty()) { if (this->visibleRegion().isEmpty()) {
qDebug() << "Scope " << widgetName() << " is not visible. Not calculating scope."; qDebug() << "Scope " << m_widgetName << " is not visible. Not calculating scope.";
} else { } else {
// Try to acquire the semaphore. This must only succeed if m_threadScope is not running // Try to acquire the semaphore. This must only succeed if m_threadScope is not running
// anymore. Therefore the semaphore must NOT be released before m_threadScope ends. // anymore. Therefore the semaphore must NOT be released before m_threadScope ends.
...@@ -120,21 +148,23 @@ void AbstractScopeWidget::prodScopeThread() ...@@ -120,21 +148,23 @@ void AbstractScopeWidget::prodScopeThread()
m_newScopeFrames.fetchAndStoreRelaxed(0); m_newScopeFrames.fetchAndStoreRelaxed(0);
m_newScopeUpdates.fetchAndStoreRelaxed(0); m_newScopeUpdates.fetchAndStoreRelaxed(0);
Q_ASSERT(m_accelFactorScope > 0);
// See http://doc.qt.nokia.com/latest/qtconcurrentrun.html#run about // See http://doc.qt.nokia.com/latest/qtconcurrentrun.html#run about
// running member functions in a thread // running member functions in a thread
m_threadScope = QtConcurrent::run(this, &AbstractScopeWidget::renderScope, m_accelFactorScope, m_scopeImage); m_threadScope = QtConcurrent::run(this, &AbstractScopeWidget::renderScope, m_accelFactorScope, m_scopeImage);
qDebug() << "Scope thread started in " << widgetName(); qDebug() << "Scope thread started in " << m_widgetName;
} else { } else {
qDebug() << "Scope semaphore locked, not prodding in " << widgetName() << ". Thread running: " << m_threadScope.isRunning(); qDebug() << "Scope semaphore locked, not prodding in " << m_widgetName << ". Thread running: " << m_threadScope.isRunning();
} }
} }
} }
void AbstractScopeWidget::prodBackgroundThread() void AbstractScopeWidget::prodBackgroundThread()
{ {
if (this->visibleRegion().isEmpty()) { if (this->visibleRegion().isEmpty()) {
qDebug() << "Scope " << widgetName() << " is not visible. Not calculating background."; qDebug() << "Scope " << m_widgetName << " is not visible. Not calculating background.";
} else { } else {
if (m_semaphoreBackground.tryAcquire(1)) { if (m_semaphoreBackground.tryAcquire(1)) {
Q_ASSERT(!m_threadBackground.isRunning()); Q_ASSERT(!m_threadBackground.isRunning());
...@@ -142,10 +172,10 @@ void AbstractScopeWidget::prodBackgroundThread() ...@@ -142,10 +172,10 @@ void AbstractScopeWidget::prodBackgroundThread()
m_newBackgroundFrames.fetchAndStoreRelaxed(0); m_newBackgroundFrames.fetchAndStoreRelaxed(0);
m_newBackgroundUpdates.fetchAndStoreRelaxed(0); m_newBackgroundUpdates.fetchAndStoreRelaxed(0);
m_threadBackground = QtConcurrent::run(this, &AbstractScopeWidget::renderBackground, m_accelFactorBackground); m_threadBackground = QtConcurrent::run(this, &AbstractScopeWidget::renderBackground, m_accelFactorBackground);
qDebug() << "Background thread started in " << widgetName(); qDebug() << "Background thread started in " << m_widgetName;
} else { } else {
qDebug() << "Background semaphore locked, not prodding in " << widgetName() << ". Thread running: " << m_threadBackground.isRunning(); qDebug() << "Background semaphore locked, not prodding in " << m_widgetName << ". Thread running: " << m_threadBackground.isRunning();
} }
} }
} }
...@@ -236,7 +266,7 @@ uint AbstractScopeWidget::calculateAccelFactorBackground(uint oldMseconds, uint) ...@@ -236,7 +266,7 @@ uint AbstractScopeWidget::calculateAccelFactorBackground(uint oldMseconds, uint)
void AbstractScopeWidget::slotHUDRenderingFinished(uint mseconds, uint oldFactor) void AbstractScopeWidget::slotHUDRenderingFinished(uint mseconds, uint oldFactor)
{ {
qDebug() << "HUD rendering has finished, waiting for termination in " << widgetName(); qDebug() << "HUD rendering has finished, waiting for termination in " << m_widgetName;
m_threadHUD.waitForFinished(); m_threadHUD.waitForFinished();
m_imgHUD = m_threadHUD.result(); m_imgHUD = m_threadHUD.result();
...@@ -253,7 +283,7 @@ void AbstractScopeWidget::slotHUDRenderingFinished(uint mseconds, uint oldFactor ...@@ -253,7 +283,7 @@ void AbstractScopeWidget::slotHUDRenderingFinished(uint mseconds, uint oldFactor
} }
if ( (m_newHUDFrames > 0 && m_aAutoRefresh->isChecked()) || m_newHUDUpdates > 0) { if ( (m_newHUDFrames > 0 && m_aAutoRefresh->isChecked()) || m_newHUDUpdates > 0) {
qDebug() << "Trying to start a new HUD thread for " << widgetName() qDebug() << "Trying to start a new HUD thread for " << m_widgetName
<< ". New frames/updates: " << m_newHUDFrames << "/" << m_newHUDUpdates; << ". New frames/updates: " << m_newHUDFrames << "/" << m_newHUDUpdates;
prodHUDThread();; prodHUDThread();;
} }
...@@ -263,7 +293,7 @@ void AbstractScopeWidget::slotScopeRenderingFinished(uint mseconds, uint oldFact ...@@ -263,7 +293,7 @@ void AbstractScopeWidget::slotScopeRenderingFinished(uint mseconds, uint oldFact
{ {
// The signal can be received before the thread has really finished. So we // The signal can be received before the thread has really finished. So we
// need to wait until it has really finished before starting a new thread. // need to wait until it has really finished before starting a new thread.
qDebug() << "Scope rendering has finished, waiting for termination in " << widgetName(); qDebug() << "Scope rendering has finished, waiting for termination in " << m_widgetName;
m_threadScope.waitForFinished(); m_threadScope.waitForFinished();
m_imgScope = m_threadScope.result(); m_imgScope = m_threadScope.result();
...@@ -276,7 +306,7 @@ void AbstractScopeWidget::slotScopeRenderingFinished(uint mseconds, uint oldFact ...@@ -276,7 +306,7 @@ void AbstractScopeWidget::slotScopeRenderingFinished(uint mseconds, uint oldFact
int accel; int accel;
if (m_aRealtime->isChecked()) { if (m_aRealtime->isChecked()) {
accel = calculateAccelFactorScope(mseconds, oldFactor); accel = calculateAccelFactorScope(mseconds, oldFactor);
if (m_accelFactorScope < 1) { if (accel < 1) {
// If mseconds happens to be 0. // If mseconds happens to be 0.
accel = 1; accel = 1;
} }
...@@ -287,7 +317,7 @@ void AbstractScopeWidget::slotScopeRenderingFinished(uint mseconds, uint oldFact ...@@ -287,7 +317,7 @@ void AbstractScopeWidget::slotScopeRenderingFinished(uint mseconds, uint oldFact
} }
if ( (m_newScopeFrames > 0 && m_aAutoRefresh->isChecked()) || m_newScopeUpdates > 0) { if ( (m_newScopeFrames > 0 && m_aAutoRefresh->isChecked()) || m_newScopeUpdates > 0) {
qDebug() << "Trying to start a new scope thread for " << widgetName() qDebug() << "Trying to start a new scope thread for " << m_widgetName
<< ". New frames/updates: " << m_newScopeFrames << "/" << m_newScopeUpdates; << ". New frames/updates: " << m_newScopeFrames << "/" << m_newScopeUpdates;
prodScopeThread(); prodScopeThread();
} }
...@@ -295,7 +325,7 @@ void AbstractScopeWidget::slotScopeRenderingFinished(uint mseconds, uint oldFact ...@@ -295,7 +325,7 @@ void AbstractScopeWidget::slotScopeRenderingFinished(uint mseconds, uint oldFact
void AbstractScopeWidget::slotBackgroundRenderingFinished(uint mseconds, uint oldFactor) void AbstractScopeWidget::slotBackgroundRenderingFinished(uint mseconds, uint oldFactor)
{ {
qDebug() << "Background rendering has finished, waiting for termination in " << widgetName(); qDebug() << "Background rendering has finished, waiting for termination in " << m_widgetName;
m_threadBackground.waitForFinished(); m_threadBackground.waitForFinished();
m_imgBackground = m_threadBackground.result(); m_imgBackground = m_threadBackground.result();
...@@ -312,7 +342,7 @@ void AbstractScopeWidget::slotBackgroundRenderingFinished(uint mseconds, uint ol ...@@ -312,7 +342,7 @@ void AbstractScopeWidget::slotBackgroundRenderingFinished(uint mseconds, uint ol
} }
if ( (m_newBackgroundFrames > 0 && m_aAutoRefresh->isChecked()) || m_newBackgroundUpdates > 0) { if ( (m_newBackgroundFrames > 0 && m_aAutoRefresh->isChecked()) || m_newBackgroundUpdates > 0) {
qDebug() << "Trying to start a new background thread for " << widgetName() qDebug() << "Trying to start a new background thread for " << m_widgetName
<< ". New frames/updates: " << m_newBackgroundFrames << "/" << m_newBackgroundUpdates; << ". New frames/updates: " << m_newBackgroundFrames << "/" << m_newBackgroundUpdates;
prodBackgroundThread();; prodBackgroundThread();;
} }
...@@ -320,7 +350,7 @@ void AbstractScopeWidget::slotBackgroundRenderingFinished(uint mseconds, uint ol ...@@ -320,7 +350,7 @@ void AbstractScopeWidget::slotBackgroundRenderingFinished(uint mseconds, uint ol
void AbstractScopeWidget::slotActiveMonitorChanged(bool isClipMonitor) void AbstractScopeWidget::slotActiveMonitorChanged(bool isClipMonitor)
{ {
qDebug() << "Active monitor has changed in " << widgetName() << ". Is the clip monitor active now? " << isClipMonitor; qDebug() << "Active monitor has changed in " << m_widgetName << ". Is the clip monitor active now? " << isClipMonitor;
bool b = m_activeRender->disconnect(this); bool b = m_activeRender->disconnect(this);
Q_ASSERT(b); Q_ASSERT(b);
...@@ -347,7 +377,7 @@ void AbstractScopeWidget::slotRenderZoneUpdated() ...@@ -347,7 +377,7 @@ void AbstractScopeWidget::slotRenderZoneUpdated()
<< "/" << m_newScopeFrames << "/" << m_newBackgroundFrames; << "/" << m_newScopeFrames << "/" << m_newBackgroundFrames;
if (this->visibleRegion().isEmpty()) { if (this->visibleRegion().isEmpty()) {
qDebug() << "Scope of widget " << widgetName() << " is not at the top, not rendering."; qDebug() << "Scope of widget " << m_widgetName << " is not at the top, not rendering.";
} else { } else {
if (m_aAutoRefresh->isChecked()) { if (m_aAutoRefresh->isChecked()) {
prodHUDThread(); prodHUDThread();
......
...@@ -68,6 +68,10 @@ public: ...@@ -68,6 +68,10 @@ public:
virtual ~AbstractScopeWidget(); // Must be virtual because of inheritance, to avoid memory leaks virtual ~AbstractScopeWidget(); // Must be virtual because of inheritance, to avoid memory leaks
QPalette m_scopePalette; QPalette m_scopePalette;
/** Initializes widget settings (reads configuration).
Has to be called in the implementing object. */
void init();
///// Unimplemented ///// ///// Unimplemented /////
virtual QString widgetName() const = 0; virtual QString widgetName() const = 0;
...@@ -113,6 +117,15 @@ protected: ...@@ -113,6 +117,15 @@ protected:
int m_accelFactorScope; int m_accelFactorScope;
int m_accelFactorBackground; int m_accelFactorBackground;
/** Reads the widget's configuration.
Can be extended in the implementing subclass (make sure to run readConfig as well). */
virtual void readConfig();
/** Writes the widget configuration.
Implementing widgets have to implement an own method and run it in their destructor. */
void writeConfig();
/** Identifier for the widget's configuration. */
QString configName();
///// Unimplemented Methods ///// ///// Unimplemented Methods /////
...@@ -195,6 +208,8 @@ private: ...@@ -195,6 +208,8 @@ private:
QImage m_scopeImage; QImage m_scopeImage;
QString m_widgetName;
bool initialDimensionUpdateDone; bool initialDimensionUpdateDone;
void prodHUDThread(); void prodHUDThread();
void prodScopeThread(); void prodScopeThread();
......
...@@ -19,6 +19,7 @@ Histogram::Histogram(Monitor *projMonitor, Monitor *clipMonitor, QWidget *parent ...@@ -19,6 +19,7 @@ Histogram::Histogram(Monitor *projMonitor, Monitor *clipMonitor, QWidget *parent
{ {
ui = new Ui::Histogram_UI(); ui = new Ui::Histogram_UI();
ui->setupUi(this); ui->setupUi(this);
init();
ui->cbY->setChecked(true); ui->cbY->setChecked(true);
ui->cbR->setChecked(true); ui->cbR->setChecked(true);
......
...@@ -19,6 +19,8 @@ RGBParade::RGBParade(Monitor *projMonitor, Monitor *clipMonitor, QWidget *parent ...@@ -19,6 +19,8 @@ RGBParade::RGBParade(Monitor *projMonitor, Monitor *clipMonitor, QWidget *parent
{ {
ui = new Ui::RGBParade_UI(); ui = new Ui::RGBParade_UI();
ui->setupUi(this); ui->setupUi(this);
init();
m_rgbParadeGenerator = new RGBParadeGenerator(); m_rgbParadeGenerator = new RGBParadeGenerator();
} }
......
...@@ -48,8 +48,6 @@ Vectorscope::Vectorscope(Monitor *projMonitor, Monitor *clipMonitor, QWidget *pa ...@@ -48,8 +48,6 @@ Vectorscope::Vectorscope(Monitor *projMonitor, Monitor *clipMonitor, QWidget *pa
ui = new Ui::Vectorscope_UI(); ui = new Ui::Vectorscope_UI();
ui->setupUi(this); ui->setupUi(this);
//TODO don't draw circle when mouseLeaved
m_colorTools = new ColorTools(); m_colorTools = new ColorTools();
m_colorPlaneExport = new ColorPlaneExport(this); m_colorPlaneExport = new ColorPlaneExport(this);
m_vectorscopeGenerator = new VectorscopeGenerator(); m_vectorscopeGenerator = new VectorscopeGenerator();
...@@ -100,10 +98,14 @@ Vectorscope::Vectorscope(Monitor *projMonitor, Monitor *clipMonitor, QWidget *pa ...@@ -100,10 +98,14 @@ Vectorscope::Vectorscope(Monitor *projMonitor, Monitor *clipMonitor, QWidget *pa
this->setMouseTracking(true); this->setMouseTracking(true);
slotGainChanged(ui->sliderGain->value()); slotGainChanged(ui->sliderGain->value());
init();
} }
Vectorscope::~Vectorscope() Vectorscope::~Vectorscope()
{ {
writeConfig();
delete m_colorTools; delete m_colorTools;
delete m_colorPlaneExport; delete m_colorPlaneExport;
delete m_vectorscopeGenerator; delete m_vectorscopeGenerator;
...@@ -115,6 +117,25 @@ Vectorscope::~Vectorscope() ...@@ -115,6 +117,25 @@ Vectorscope::~Vectorscope()
QString Vectorscope::widgetName() const { return QString("Vectorscope"); } QString Vectorscope::widgetName() const { return QString("Vectorscope"); }
void Vectorscope::readConfig()
{
AbstractScopeWidget::readConfig();
KSharedConfigPtr config = KGlobal::config();
KConfigGroup scopeConfig(config, configName());
m_a75PBox->setChecked(scopeConfig.readEntry("75PBox", false));
m_aAxisEnabled->setChecked(scopeConfig.readEntry("axis", false));
}
void Vectorscope::writeConfig()
{
KSharedConfigPtr config = KGlobal::config();
KConfigGroup scopeConfig(config, configName());
scopeConfig.writeEntry("75PBox", m_a75PBox->isChecked());
scopeConfig.writeEntry("axis", m_aAxisEnabled->isChecked());
scopeConfig.sync();
}
QRect Vectorscope::scopeRect() QRect Vectorscope::scopeRect()
{ {
// Distance from top/left/right // Distance from top/left/right
...@@ -209,10 +230,7 @@ QImage Vectorscope::renderScope(uint accelerationFactor, QImage qimage) ...@@ -209,10 +230,7 @@ QImage Vectorscope::renderScope(uint accelerationFactor, QImage qimage)
} }
unsigned int mseconds = start.msecsTo(QTime::currentTime()); unsigned int mseconds = start.msecsTo(QTime::currentTime());
// qDebug() << "Scope rendered in " << mseconds << " ms. Sending finished signal.";
// emit signalScopeCalculationFinished(mseconds, skipPixels);
emit signalScopeRenderingFinished(mseconds, accelerationFactor); emit signalScopeRenderingFinished(mseconds, accelerationFactor);
// qDebug() << "xxScope: Signal finished sent.";
return scope; return scope;
} }
......
...@@ -46,6 +46,10 @@ protected: ...@@ -46,6 +46,10 @@ protected:
bool isHUDDependingOnInput() const; bool isHUDDependingOnInput() const;
bool isScopeDependingOnInput() const; bool isScopeDependingOnInput() const;
bool isBackgroundDependingOnInput() const; bool isBackgroundDependingOnInput() const;
virtual void readConfig();
///// Other /////
void writeConfig();
private: private:
Ui::Vectorscope_UI *ui; Ui::Vectorscope_UI *ui;
......
...@@ -23,6 +23,7 @@ Waveform::Waveform(Monitor *projMonitor, Monitor *clipMonitor, QWidget *parent) ...@@ -23,6 +23,7 @@ Waveform::Waveform(Monitor *projMonitor, Monitor *clipMonitor, QWidget *parent)
{ {
ui = new Ui::Waveform_UI(); ui = new Ui::Waveform_UI();
ui->setupUi(this); ui->setupUi(this);
init();
m_waveformGenerator = new WaveformGenerator(); m_waveformGenerator = new WaveformGenerator();
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment