From: Jean-Baptiste Mardelle Date: Tue, 20 Mar 2012 16:10:27 +0000 (+0100) Subject: Effect stack: do not change parameter value on mousewheel when scrolling. X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=8e3f6524aff0346990394f3f690d8f55ca48a311;p=kdenlive Effect stack: do not change parameter value on mousewheel when scrolling. User now needs to click once in the parameter to change value with mouse wheel --- diff --git a/src/doubleparameterwidget.h b/src/doubleparameterwidget.h index a3262ae1..d18ad11e 100644 --- a/src/doubleparameterwidget.h +++ b/src/doubleparameterwidget.h @@ -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. */ diff --git a/src/dragvalue.cpp b/src/dragvalue.cpp index a69f6bd0..e94b43c5 100644 --- a/src/dragvalue.cpp +++ b/src/dragvalue.cpp @@ -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" diff --git a/src/dragvalue.h b/src/dragvalue.h index 22e9916c..49dc0555 100644 --- a/src/dragvalue.h +++ b/src/dragvalue.h @@ -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 ); diff --git a/src/effectstack/collapsibleeffect.cpp b/src/effectstack/collapsibleeffect.cpp index 987ce4e6..d4b36530 100644 --- a/src/effectstack/collapsibleeffect.cpp +++ b/src/effectstack/collapsibleeffect.cpp @@ -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() ) { + sp->installEventFilter( this ); + sp->setFocusPolicy( Qt::StrongFocus ); + } + Q_FOREACH( KComboBox * cb, findChildren() ) { + cb->installEventFilter( this ); + cb->setFocusPolicy( Qt::StrongFocus ); + } + Q_FOREACH( QProgressBar * cb, findChildren() ) { + 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(o)) { + if(qobject_cast(o)->focusPolicy() == Qt::WheelFocus) + { + e->accept(); + return false; + } + else + { + e->ignore(); + return true; + } + } + if (qobject_cast(o)) { + if(qobject_cast(o)->focusPolicy() == Qt::WheelFocus) + { + e->accept(); + return false; + } + else + { + e->ignore(); + return true; + } + } + if (qobject_cast(o)) { + if(qobject_cast(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); diff --git a/src/effectstack/collapsibleeffect.h b/src/effectstack/collapsibleeffect.h index 9aa714e8..f77a90fb 100644 --- a/src/effectstack/collapsibleeffect.h +++ b/src/effectstack/collapsibleeffect.h @@ -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);