From: Simon A. Eugster Date: Fri, 13 Aug 2010 15:02:51 +0000 (+0000) Subject: * Scopes: Configuration is saved now. X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=20381b3a7cebadd7be7ec6898ef0f847f5651326;p=kdenlive * 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 --- diff --git a/src/abstractscopewidget.cpp b/src/abstractscopewidget.cpp index f0317534..8e377479 100644 --- a/src/abstractscopewidget.cpp +++ b/src/abstractscopewidget.cpp @@ -80,15 +80,43 @@ AbstractScopeWidget::AbstractScopeWidget(Monitor *projMonitor, Monitor *clipMoni AbstractScopeWidget::~AbstractScopeWidget() { + writeConfig(); + delete m_menu; delete m_aAutoRefresh; 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() { if (this->visibleRegion().isEmpty()) { - qDebug() << "Scope " << widgetName() << " is not visible. Not calculating HUD."; + qDebug() << "Scope " << m_widgetName << " is not visible. Not calculating HUD."; } else { if (m_semaphoreHUD.tryAcquire(1)) { Q_ASSERT(!m_threadHUD.isRunning()); @@ -96,10 +124,10 @@ void AbstractScopeWidget::prodHUDThread() m_newHUDFrames.fetchAndStoreRelaxed(0); m_newHUDUpdates.fetchAndStoreRelaxed(0); m_threadHUD = QtConcurrent::run(this, &AbstractScopeWidget::renderHUD, m_accelFactorHUD); - qDebug() << "HUD thread started in " << widgetName(); + qDebug() << "HUD thread started in " << m_widgetName; } 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() // Only start a new thread if the scope is actually visible // and not hidden by another widget on the stack. if (this->visibleRegion().isEmpty()) { - qDebug() << "Scope " << widgetName() << " is not visible. Not calculating scope."; + qDebug() << "Scope " << m_widgetName << " is not visible. Not calculating scope."; } else { // 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. @@ -120,21 +148,23 @@ void AbstractScopeWidget::prodScopeThread() m_newScopeFrames.fetchAndStoreRelaxed(0); m_newScopeUpdates.fetchAndStoreRelaxed(0); + Q_ASSERT(m_accelFactorScope > 0); + // See http://doc.qt.nokia.com/latest/qtconcurrentrun.html#run about // running member functions in a thread 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 { - 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() { if (this->visibleRegion().isEmpty()) { - qDebug() << "Scope " << widgetName() << " is not visible. Not calculating background."; + qDebug() << "Scope " << m_widgetName << " is not visible. Not calculating background."; } else { if (m_semaphoreBackground.tryAcquire(1)) { Q_ASSERT(!m_threadBackground.isRunning()); @@ -142,10 +172,10 @@ void AbstractScopeWidget::prodBackgroundThread() m_newBackgroundFrames.fetchAndStoreRelaxed(0); m_newBackgroundUpdates.fetchAndStoreRelaxed(0); m_threadBackground = QtConcurrent::run(this, &AbstractScopeWidget::renderBackground, m_accelFactorBackground); - qDebug() << "Background thread started in " << widgetName(); + qDebug() << "Background thread started in " << m_widgetName; } 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) 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_imgHUD = m_threadHUD.result(); @@ -253,7 +283,7 @@ void AbstractScopeWidget::slotHUDRenderingFinished(uint mseconds, uint oldFactor } 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; prodHUDThread();; } @@ -263,7 +293,7 @@ void AbstractScopeWidget::slotScopeRenderingFinished(uint mseconds, uint oldFact { // 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. - 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_imgScope = m_threadScope.result(); @@ -276,7 +306,7 @@ void AbstractScopeWidget::slotScopeRenderingFinished(uint mseconds, uint oldFact int accel; if (m_aRealtime->isChecked()) { accel = calculateAccelFactorScope(mseconds, oldFactor); - if (m_accelFactorScope < 1) { + if (accel < 1) { // If mseconds happens to be 0. accel = 1; } @@ -287,7 +317,7 @@ void AbstractScopeWidget::slotScopeRenderingFinished(uint mseconds, uint oldFact } 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; prodScopeThread(); } @@ -295,7 +325,7 @@ void AbstractScopeWidget::slotScopeRenderingFinished(uint mseconds, uint oldFact 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_imgBackground = m_threadBackground.result(); @@ -312,7 +342,7 @@ void AbstractScopeWidget::slotBackgroundRenderingFinished(uint mseconds, uint ol } 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; prodBackgroundThread();; } @@ -320,7 +350,7 @@ void AbstractScopeWidget::slotBackgroundRenderingFinished(uint mseconds, uint ol 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); Q_ASSERT(b); @@ -347,7 +377,7 @@ void AbstractScopeWidget::slotRenderZoneUpdated() << "/" << m_newScopeFrames << "/" << m_newBackgroundFrames; 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 { if (m_aAutoRefresh->isChecked()) { prodHUDThread(); diff --git a/src/abstractscopewidget.h b/src/abstractscopewidget.h index 029274e6..dff821ae 100644 --- a/src/abstractscopewidget.h +++ b/src/abstractscopewidget.h @@ -68,6 +68,10 @@ public: virtual ~AbstractScopeWidget(); // Must be virtual because of inheritance, to avoid memory leaks QPalette m_scopePalette; + /** Initializes widget settings (reads configuration). + Has to be called in the implementing object. */ + void init(); + ///// Unimplemented ///// virtual QString widgetName() const = 0; @@ -113,6 +117,15 @@ protected: int m_accelFactorScope; 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 ///// @@ -195,6 +208,8 @@ private: QImage m_scopeImage; + QString m_widgetName; + bool initialDimensionUpdateDone; void prodHUDThread(); void prodScopeThread(); diff --git a/src/histogram.cpp b/src/histogram.cpp index 64c307a8..b4903f8b 100644 --- a/src/histogram.cpp +++ b/src/histogram.cpp @@ -19,6 +19,7 @@ Histogram::Histogram(Monitor *projMonitor, Monitor *clipMonitor, QWidget *parent { ui = new Ui::Histogram_UI(); ui->setupUi(this); + init(); ui->cbY->setChecked(true); ui->cbR->setChecked(true); diff --git a/src/rgbparade.cpp b/src/rgbparade.cpp index 3fe44412..200a2abb 100644 --- a/src/rgbparade.cpp +++ b/src/rgbparade.cpp @@ -19,6 +19,8 @@ RGBParade::RGBParade(Monitor *projMonitor, Monitor *clipMonitor, QWidget *parent { ui = new Ui::RGBParade_UI(); ui->setupUi(this); + init(); + m_rgbParadeGenerator = new RGBParadeGenerator(); } diff --git a/src/vectorscope.cpp b/src/vectorscope.cpp index 01a41d4d..1c38d7ab 100644 --- a/src/vectorscope.cpp +++ b/src/vectorscope.cpp @@ -48,8 +48,6 @@ Vectorscope::Vectorscope(Monitor *projMonitor, Monitor *clipMonitor, QWidget *pa ui = new Ui::Vectorscope_UI(); ui->setupUi(this); - //TODO don't draw circle when mouseLeaved - m_colorTools = new ColorTools(); m_colorPlaneExport = new ColorPlaneExport(this); m_vectorscopeGenerator = new VectorscopeGenerator(); @@ -100,10 +98,14 @@ Vectorscope::Vectorscope(Monitor *projMonitor, Monitor *clipMonitor, QWidget *pa this->setMouseTracking(true); slotGainChanged(ui->sliderGain->value()); + + init(); } Vectorscope::~Vectorscope() { + writeConfig(); + delete m_colorTools; delete m_colorPlaneExport; delete m_vectorscopeGenerator; @@ -115,6 +117,25 @@ Vectorscope::~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() { // Distance from top/left/right @@ -209,10 +230,7 @@ QImage Vectorscope::renderScope(uint accelerationFactor, QImage qimage) } unsigned int mseconds = start.msecsTo(QTime::currentTime()); -// qDebug() << "Scope rendered in " << mseconds << " ms. Sending finished signal."; -// emit signalScopeCalculationFinished(mseconds, skipPixels); emit signalScopeRenderingFinished(mseconds, accelerationFactor); -// qDebug() << "xxScope: Signal finished sent."; return scope; } diff --git a/src/vectorscope.h b/src/vectorscope.h index bf6e5c08..dda0e402 100644 --- a/src/vectorscope.h +++ b/src/vectorscope.h @@ -46,6 +46,10 @@ protected: bool isHUDDependingOnInput() const; bool isScopeDependingOnInput() const; bool isBackgroundDependingOnInput() const; + virtual void readConfig(); + + ///// Other ///// + void writeConfig(); private: Ui::Vectorscope_UI *ui; diff --git a/src/waveform.cpp b/src/waveform.cpp index c4191fa9..aaf8d082 100644 --- a/src/waveform.cpp +++ b/src/waveform.cpp @@ -23,6 +23,7 @@ Waveform::Waveform(Monitor *projMonitor, Monitor *clipMonitor, QWidget *parent) { ui = new Ui::Waveform_UI(); ui->setupUi(this); + init(); m_waveformGenerator = new WaveformGenerator(); }