]> git.sesse.net Git - kdenlive/commitdiff
Effect stack: do not change parameter value on mousewheel when scrolling.
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 20 Mar 2012 16:10:27 +0000 (17:10 +0100)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 20 Mar 2012 16:10:27 +0000 (17:10 +0100)
User now needs to click once in the parameter to change value with mouse wheel

src/doubleparameterwidget.h
src/dragvalue.cpp
src/dragvalue.h
src/effectstack/collapsibleeffect.cpp
src/effectstack/collapsibleeffect.h

index a3262ae1998b8526e4f79a255974de83e73a6fda..d18ad11e0fc0889243cd92c7cd2681f4bc13293a 100644 (file)
@@ -59,6 +59,7 @@ public:
     /** @brief Returns minimum size for QSpinBox, used to set all spinboxes to the same width. */
     int spinSize();
     void setSpinSize(int width);
+    
 
 public slots:
     /** @brief Sets the value to @param value. */
index a69f6bd0bbde2399ca8f09cc7a366888256ee2d3..e94b43c5e72b0498980b403b6e8505ab38701de7 100644 (file)
@@ -57,6 +57,7 @@ DragValue::DragValue(const QString &label, double defaultValue, int decimals, do
     else setSizePolicy(QSizePolicy::Maximum, QSizePolicy::MinimumExpanding);
     setFocusPolicy(Qt::StrongFocus);
     setContextMenuPolicy(Qt::CustomContextMenu);
+    setFocusPolicy(Qt::StrongFocus);
     
     QHBoxLayout *l = new QHBoxLayout;
     l->setSpacing(0);
@@ -68,6 +69,7 @@ DragValue::DragValue(const QString &label, double defaultValue, int decimals, do
         m_label->setStep(1);
         m_intEdit = new QSpinBox(this);
         m_intEdit->setObjectName("dragBox");
+       m_intEdit->setFocusPolicy(Qt::StrongFocus);
         if (!suffix.isEmpty()) m_intEdit->setSuffix(suffix);
         m_intEdit->setKeyboardTracking(false);
         m_intEdit->setButtonSymbols(QAbstractSpinBox::NoButtons);
@@ -81,6 +83,7 @@ DragValue::DragValue(const QString &label, double defaultValue, int decimals, do
     else {
         m_doubleEdit = new QDoubleSpinBox(this);
         m_doubleEdit->setDecimals(decimals);
+       m_doubleEdit->setFocusPolicy(Qt::StrongFocus);
         m_doubleEdit->setObjectName("dragBox");
         if (!suffix.isEmpty()) m_doubleEdit->setSuffix(suffix);
         m_doubleEdit->setKeyboardTracking(false);
@@ -274,8 +277,16 @@ void DragValue::setValue(double value, bool final)
     m_label->setProgressValue((value - m_minimum) / (m_maximum - m_minimum) * m_label->maximum());
 }
 
+void DragValue::focusOutEvent(QFocusEvent*)
+{
+    if (m_intEdit) m_intEdit->setFocusPolicy(Qt::StrongFocus);
+    else m_doubleEdit->setFocusPolicy(Qt::StrongFocus);
+}
+
 void DragValue::focusInEvent(QFocusEvent* e)
 {
+    if (m_intEdit) m_intEdit->setFocusPolicy(Qt::WheelFocus);
+    else m_doubleEdit->setFocusPolicy(Qt::WheelFocus);
     if (e->reason() == Qt::TabFocusReason || e->reason() == Qt::BacktabFocusReason) {
         if (m_intEdit) m_intEdit->setFocus(e->reason());
         else m_doubleEdit->setFocus(e->reason());
@@ -351,7 +362,7 @@ CustomLabel::CustomLabel(const QString &label, bool showSlider, int range, QWidg
 {
     setFont(KGlobalSettings::toolBarFont());
     setFormat(" " + label);
-    setFocusPolicy(Qt::ClickFocus);
+    setFocusPolicy(Qt::StrongFocus);
     setCursor(Qt::PointingHandCursor);
     setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Maximum);
     if (showSlider) setRange(0, 1000);
@@ -478,4 +489,14 @@ void CustomLabel::setStep(double step)
     m_step = step;
 }
 
+void CustomLabel::focusInEvent(QFocusEvent*)
+{
+     setFocusPolicy(Qt::WheelFocus);
+}
+
+void CustomLabel::focusOutEvent(QFocusEvent*)
+{
+     setFocusPolicy(Qt::StrongFocus);
+}
+
 #include "dragvalue.moc"
index 22e9916cf3b6a080691091ccd6b479ffb6ca11fe..49dc05551569ec86670e966b631455a56db59ffa 100644 (file)
@@ -49,6 +49,8 @@ protected:
     virtual void mouseMoveEvent(QMouseEvent *event);
     //virtual void paintEvent(QPaintEvent *event);
     virtual void wheelEvent(QWheelEvent * event);
+    virtual void focusInEvent(QFocusEvent *e);
+    virtual void focusOutEvent(QFocusEvent *e);
 
 private:
     QPoint m_dragStartPosition;
@@ -139,6 +141,7 @@ protected:
     virtual void mouseReleaseEvent(QMouseEvent *e);*/
     /** @brief Forwards tab focus to lineedit since it is disabled. */
     virtual void focusInEvent(QFocusEvent *e);
+    virtual void focusOutEvent(QFocusEvent *e);
     //virtual void keyPressEvent(QKeyEvent *e);
     //virtual void wheelEvent(QWheelEvent *e);
     //virtual void paintEvent( QPaintEvent * event );
index 987ce4e6131a364dd8ce772af707b828cea9e4a2..d4b36530a11d9a4449c32af1dc627ec02f79b526 100644 (file)
@@ -38,6 +38,7 @@
 #include "colortools.h"
 #include "doubleparameterwidget.h"
 #include "cornerswidget.h"
+#include "dragvalue.h"
 #include "beziercurve/beziersplinewidget.h"
 #ifdef USE_QJSON
 #include "rotoscoping/rotowidget.h"
@@ -85,6 +86,22 @@ void clearLayout(QLayout *layout)
     }
 }
 
+MySpinBox::MySpinBox(QWidget * parent):
+    QSpinBox(parent)
+{
+    setFocusPolicy(Qt::StrongFocus);
+}
+
+void MySpinBox::focusInEvent(QFocusEvent*)
+{
+     setFocusPolicy(Qt::WheelFocus);
+}
+
+void MySpinBox::focusOutEvent(QFocusEvent*)
+{
+     setFocusPolicy(Qt::StrongFocus);
+}
+
 CollapsibleEffect::CollapsibleEffect(QDomElement effect, QDomElement original_effect, ItemInfo info, int ix, EffectMetaInfo *metaInfo, bool lastEffect, QWidget * parent) :
         QWidget(parent),
         m_paramWidget(NULL),
@@ -148,6 +165,19 @@ CollapsibleEffect::CollapsibleEffect(QDomElement effect, QDomElement original_ef
     connect(buttonDown, SIGNAL(clicked()), this, SLOT(slotEffectDown()));
     connect(buttonDel, SIGNAL(clicked()), this, SLOT(slotDeleteEffect()));
     setupWidget(info, ix, metaInfo);
+    Q_FOREACH( QSpinBox * sp, findChildren<QSpinBox*>() ) {
+        sp->installEventFilter( this );
+        sp->setFocusPolicy( Qt::StrongFocus );
+    }
+    Q_FOREACH( KComboBox * cb, findChildren<KComboBox*>() ) {
+       cb->installEventFilter( this );
+        cb->setFocusPolicy( Qt::StrongFocus );
+    }
+    Q_FOREACH( QProgressBar * cb, findChildren<QProgressBar*>() ) {
+       cb->installEventFilter( this );
+        cb->setFocusPolicy( Qt::StrongFocus );
+    }
+    
 }
 
 CollapsibleEffect::~CollapsibleEffect()
@@ -155,6 +185,49 @@ CollapsibleEffect::~CollapsibleEffect()
     if (m_paramWidget) delete m_paramWidget;
 }
 
+bool CollapsibleEffect::eventFilter( QObject * o, QEvent * e ) 
+{
+    if(e->type() == QEvent::Wheel) {
+       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 CollapsibleEffect::setActive(bool activate)
 {
@@ -357,6 +430,7 @@ ParameterContainer::ParameterContainer(QDomElement effect, ItemInfo info, Effect
 
             DoubleParameterWidget *doubleparam = new DoubleParameterWidget(paramName, value.toDouble(), min, max,
                     pa.attribute("default").toDouble(), comment, -1, pa.attribute("suffix"), pa.attribute("decimals").toInt(), parent);
+           doubleparam->setFocusPolicy(Qt::StrongFocus);
             m_vbox->addWidget(doubleparam);
             m_valueItems[paramName] = doubleparam;
             connect(doubleparam, SIGNAL(valueChanged(double)), this, SLOT(slotCollectAllParameters()));
@@ -364,6 +438,7 @@ ParameterContainer::ParameterContainer(QDomElement effect, ItemInfo info, Effect
         } else if (type == "list") {
             Listval *lsval = new Listval;
             lsval->setupUi(toFillin);
+           lsval->list->setFocusPolicy(Qt::StrongFocus);
             QStringList listitems = pa.attribute("paramlist").split(';');
             if (listitems.count() == 1) {
                 // probably custom effect created before change to ';' as separator
@@ -511,9 +586,9 @@ ParameterContainer::ParameterContainer(QDomElement effect, ItemInfo info, Effect
             }
             if (!points.isEmpty())
                 curve->setCurve(KisCubicCurve(points));
-            QSpinBox *spinin = new QSpinBox();
+            MySpinBox *spinin = new MySpinBox();
             spinin->setRange(0, 1000);
-            QSpinBox *spinout = new QSpinBox();
+            MySpinBox *spinout = new MySpinBox();
             spinout->setRange(0, 1000);
             curve->setupInOutControls(spinin, spinout, 0, 1000);
             m_vbox->addWidget(curve);
index 9aa714e83f1e332f8213b2b1fad04b5f3196cc52..f77a90fb7fb716e09d0f89bf303b7e166ae7e7c5 100644 (file)
@@ -42,6 +42,18 @@ struct EffectMetaInfo {
     bool trackMode;
 };
 
+class MySpinBox : public QSpinBox
+{
+    Q_OBJECT
+
+public:
+    MySpinBox(QWidget * parent = 0);
+    
+protected:
+    virtual void focusInEvent(QFocusEvent*);
+    virtual void focusOutEvent(QFocusEvent*);
+};
+
 class ParameterContainer : public QObject
 {
     Q_OBJECT
@@ -104,6 +116,7 @@ public:
     void setupWidget(ItemInfo info, int index, EffectMetaInfo *metaInfo);
     void updateTimecodeFormat();
     void setActive(bool activate);
+    virtual bool eventFilter( QObject * o, QEvent * e );
 
 public slots:
     void slotSyncEffectsPos(int pos);