]> git.sesse.net Git - kdenlive/commitdiff
* Scopes: Configuration is saved now.
authorSimon A. Eugster <simon.eu@gmail.com>
Fri, 13 Aug 2010 15:02:51 +0000 (15:02 +0000)
committerSimon A. Eugster <simon.eu@gmail.com>
Fri, 13 Aug 2010 15:02:51 +0000 (15:02 +0000)
* Fixed: Tested wrong variable to < 1 allowed an acceleration factor of 0, causing an nearly infinite loop.

svn path=/trunk/kdenlive/; revision=4714

src/abstractscopewidget.cpp
src/abstractscopewidget.h
src/histogram.cpp
src/rgbparade.cpp
src/vectorscope.cpp
src/vectorscope.h
src/waveform.cpp

index f0317534fe859eb280f9611d4f8ff1209c86b6fc..8e377479e67f599125cb9d97481d23473f826c39 100644 (file)
@@ -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();
index 029274e6425d46b18bd970e61fe422a198f4cae8..dff821ae23d4d32f93b072bfe61f025e5e0a1ae9 100644 (file)
@@ -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();
index 64c307a871918edc019a793984c27f7906dc8976..b4903f8b857c0f8b5b71b26b19471d1791464547 100644 (file)
@@ -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);
index 3fe44412e78cf7d059e0eb0dfee33ecb5bc396b2..200a2abb8940c6a56d95b0ee5a3c8898755b281e 100644 (file)
@@ -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();
 }
 
index 01a41d4dd6ff187a50372b510a780c47e4c4b827..1c38d7ab8610a704e3f7fa0267e872336ac699d1 100644 (file)
@@ -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;
 }
 
index bf6e5c08406503042d88acf2940f6de7786ea411..dda0e40238a3dcd2d2204f2f959bab2268c79a6b 100644 (file)
@@ -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;
index c4191fa97b9e4bd45f2beb4ba8f5459aef032026..aaf8d0824a6a2405f2dc116ff9e708307cb4ad9c 100644 (file)
@@ -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();
 }