]> git.sesse.net Git - kdenlive/commitdiff
Make sure mouse wheel does not change transition parameter when scrolling
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Sun, 1 Apr 2012 17:55:58 +0000 (19:55 +0200)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Sun, 1 Apr 2012 17:55:58 +0000 (19:55 +0200)
src/effectstack/collapsibleeffect.h
src/effectstackedit.cpp
src/effectstackedit.h

index 8d391f52ec0c6d24d8857ea3bf23a1bde8c22e44..2804cbe10bc56d0d713d86258f6612d73dcd7bb5 100644 (file)
@@ -127,6 +127,7 @@ public:
     void setupWidget(ItemInfo info, EffectMetaInfo *metaInfo);
     void updateTimecodeFormat();
     void setActive(bool activate);
+    /** @brief Install event filter so that scrolling with mouse wheel does not change parameter value. */
     virtual bool eventFilter( QObject * o, QEvent * e );
     /** @brief Update effect GUI to reflect parameted changes. */
     void updateWidget(ItemInfo info, QDomElement effect, EffectMetaInfo *metaInfo);
index b56a1a869deaecd76771d6b17472dc601bca5b0e..3aba930560aef1bc76f2e7ee6923c0c7c1506c36 100644 (file)
@@ -50,6 +50,8 @@
 #include <QPushButton>
 #include <QCheckBox>
 #include <QScrollArea>
+#include <QScrollBar>
+#include <QProgressBar>
 
 // For QDomNode debugging (output into files); leaving here as sample code.
 //#define DEBUG_ESE
@@ -182,6 +184,55 @@ void EffectStackEdit::updateParameter(const QString &name, const QString &value)
     }
 }
 
+bool EffectStackEdit::eventFilter( QObject * o, QEvent * e ) 
+{
+    if (e->type() == QEvent::Wheel) {
+       QWheelEvent *we = static_cast<QWheelEvent *>(e);
+       bool filterWheel = verticalScrollBar() && verticalScrollBar()->isVisible();
+       if (!filterWheel || we->modifiers() != Qt::NoModifier) {
+           e->accept();
+           return false;
+       }
+       if (qobject_cast<QAbstractSpinBox*>(o)) {
+           if(qobject_cast<QAbstractSpinBox*>(o)->focusPolicy() == Qt::WheelFocus)
+           {
+               e->accept();
+               return false;
+           }
+           else
+           {
+               e->ignore();
+               return true;
+           }
+       }
+       if (qobject_cast<KComboBox*>(o)) {
+           if(qobject_cast<KComboBox*>(o)->focusPolicy() == Qt::WheelFocus)
+           {
+               e->accept();
+               return false;
+           }
+           else
+           {
+               e->ignore();
+               return true;
+           }
+       }
+       if (qobject_cast<QProgressBar*>(o)) {
+           if(qobject_cast<QProgressBar*>(o)->focusPolicy() == Qt::WheelFocus)
+           {
+               e->accept();
+               return false;
+           }
+           else
+           {
+               e->ignore();
+               return true;
+           }
+       }
+    }
+    return QWidget::eventFilter(o, e);
+}
+
 void EffectStackEdit::transferParamDesc(const QDomElement &d, ItemInfo info, bool /*isEffect*/)
 {
     if (m_paramWidget) delete m_paramWidget;
@@ -193,6 +244,21 @@ void EffectStackEdit::transferParamDesc(const QDomElement &d, ItemInfo info, boo
     connect (this, SIGNAL(syncEffectsPos(int)), m_paramWidget, SIGNAL(syncEffectsPos(int)));
     connect (m_paramWidget, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int)));
     connect (m_paramWidget, SIGNAL(seekTimeline(int)), this, SIGNAL(seekTimeline(int)));
+    
+    
+    Q_FOREACH( QSpinBox * sp, m_baseWidget->findChildren<QSpinBox*>() ) {
+        sp->installEventFilter( this );
+        sp->setFocusPolicy( Qt::StrongFocus );
+    }
+    Q_FOREACH( KComboBox * cb, m_baseWidget->findChildren<KComboBox*>() ) {
+       cb->installEventFilter( this );
+        cb->setFocusPolicy( Qt::StrongFocus );
+    }
+    Q_FOREACH( QProgressBar * cb, m_baseWidget->findChildren<QProgressBar*>() ) {
+       cb->installEventFilter( this );
+        cb->setFocusPolicy( Qt::StrongFocus );
+    }
+    
     return;
     /*
     //clearAllItems();
index 18d4d3167f6fb32b9a981a34d1d6437cb9ae623d..11a6658d4c1bc2cbc15fa1ffb56fdefbc7335472 100644 (file)
@@ -52,6 +52,8 @@ public:
     /** @brief Returns true if this effect wants to keep track of current position in clip. */
     bool effectNeedsSyncPosition() const;
     Monitor *monitor();
+    /** @brief Install event filter so that scrolling with mouse wheel does not change parameter value. */
+    virtual bool eventFilter( QObject * o, QEvent * e );
 
 private:
     /** @brief Deletes all parameter widgets. */