Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Multimedia
Kdenlive
Commits
cfe9c071
Commit
cfe9c071
authored
Mar 07, 2022
by
Jean-Baptiste Mardelle
Browse files
Fix mouse wheel behavior on effect parameters.
Related to
#1359
parent
b8309bbc
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/effects/effectstack/view/collapsibleeffectview.cpp
View file @
cfe9c071
...
...
@@ -312,39 +312,30 @@ bool CollapsibleEffectView::eventFilter(QObject *o, QEvent *e)
if
(
e
->
type
()
==
QEvent
::
Wheel
)
{
auto
*
we
=
static_cast
<
QWheelEvent
*>
(
e
);
if
(
!
m_blockWheel
||
we
->
modifiers
()
!=
Qt
::
NoModifier
)
{
e
->
accept
();
return
false
;
}
if
(
qobject_cast
<
QAbstractSpinBox
*>
(
o
))
{
if
(
!
qobject_cast
<
QAbstractSpinBox
*>
(
o
)
->
hasFocus
())
{
e
->
ignore
();
if
(
m_blockWheel
&&
!
qobject_cast
<
QAbstractSpinBox
*>
(
o
)
->
hasFocus
())
{
return
true
;
}
e
->
accept
();
return
false
;
}
if
(
qobject_cast
<
QComboBox
*>
(
o
))
{
if
(
qobject_cast
<
QComboBox
*>
(
o
)
->
focusPolicy
()
==
Qt
::
WheelFocus
)
{
e
->
accept
();
return
false
;
}
e
->
ignore
();
return
true
;
}
if
(
qobject_cast
<
QProgressBar
*>
(
o
))
{
if
(
!
qobject_cast
<
QProgressBar
*>
(
o
)
->
hasFocus
())
{
e
->
ignore
();
return
true
;
}
e
->
accept
();
return
false
;
}
if
(
qobject_cast
<
WheelContainer
*>
(
o
))
{
if
(
!
qobject_cast
<
WheelContainer
*>
(
o
)
->
hasFocus
())
{
e
->
ignore
();
return
true
;
}
e
->
accept
();
return
false
;
}
}
...
...
@@ -885,6 +876,27 @@ void CollapsibleEffectView::enableView(bool enabled)
void
CollapsibleEffectView
::
blockWheelEvent
(
bool
block
)
{
m_blockWheel
=
block
;
Qt
::
FocusPolicy
policy
=
block
?
Qt
::
StrongFocus
:
Qt
::
WheelFocus
;
foreach
(
QSpinBox
*
sp
,
findChildren
<
QSpinBox
*>
())
{
sp
->
installEventFilter
(
this
);
sp
->
setFocusPolicy
(
policy
);
}
foreach
(
QComboBox
*
cb
,
findChildren
<
QComboBox
*>
())
{
cb
->
installEventFilter
(
this
);
cb
->
setFocusPolicy
(
policy
);
}
foreach
(
QProgressBar
*
cb
,
findChildren
<
QProgressBar
*>
())
{
cb
->
installEventFilter
(
this
);
cb
->
setFocusPolicy
(
policy
);
}
foreach
(
WheelContainer
*
cb
,
findChildren
<
WheelContainer
*>
())
{
cb
->
installEventFilter
(
this
);
cb
->
setFocusPolicy
(
policy
);
}
foreach
(
QDoubleSpinBox
*
cb
,
findChildren
<
QDoubleSpinBox
*>
())
{
cb
->
installEventFilter
(
this
);
cb
->
setFocusPolicy
(
policy
);
}
}
void
CollapsibleEffectView
::
switchInOut
(
bool
checked
)
...
...
src/widgets/dragvalue.cpp
View file @
cfe9c071
...
...
@@ -73,6 +73,7 @@ DragValue::DragValue(const QString &label, double defaultValue, int decimals, do
connect
(
m_intEdit
,
static_cast
<
void
(
QSpinBox
::*
)(
int
)
>
(
&
QSpinBox
::
valueChanged
),
this
,
static_cast
<
void
(
DragValue
::*
)(
int
)
>
(
&
DragValue
::
slotSetValue
));
connect
(
m_intEdit
,
&
QAbstractSpinBox
::
editingFinished
,
this
,
&
DragValue
::
slotEditingFinished
);
m_intEdit
->
installEventFilter
(
this
);
}
else
{
m_doubleEdit
=
new
QDoubleSpinBox
(
this
);
m_doubleEdit
->
setDecimals
(
decimals
);
...
...
@@ -96,6 +97,7 @@ DragValue::DragValue(const QString &label, double defaultValue, int decimals, do
//m_label->setStep(1);
l
->
addWidget
(
m_doubleEdit
);
m_doubleEdit
->
setValue
(
m_default
);
m_doubleEdit
->
installEventFilter
(
this
);
connect
(
m_doubleEdit
,
SIGNAL
(
valueChanged
(
double
)),
this
,
SLOT
(
slotSetValue
(
double
)));
connect
(
m_doubleEdit
,
&
QAbstractSpinBox
::
editingFinished
,
this
,
&
DragValue
::
slotEditingFinished
);
}
...
...
@@ -151,6 +153,33 @@ DragValue::~DragValue()
// delete m_directUpdate;
}
bool
DragValue
::
eventFilter
(
QObject
*
watched
,
QEvent
*
event
)
{
if
(
event
->
type
()
==
QEvent
::
Wheel
)
{
// Check if we should ignore the event
bool
useEvent
=
false
;
if
(
m_intEdit
)
{
useEvent
=
m_intEdit
->
hasFocus
();
}
else
if
(
m_doubleEdit
)
{
useEvent
=
m_doubleEdit
->
hasFocus
();
}
if
(
!
useEvent
)
{
return
true
;
}
auto
*
we
=
static_cast
<
QWheelEvent
*>
(
event
);
if
(
we
->
angleDelta
().
y
()
>
0
)
{
m_label
->
slotValueInc
();
}
else
{
m_label
->
slotValueDec
();
}
// Stop processing, event accepted
return
false
;
}
return
QObject
::
eventFilter
(
watched
,
event
);
}
bool
DragValue
::
hasEditFocus
()
const
{
QWidget
*
fWidget
=
QApplication
::
focusWidget
();
...
...
@@ -305,36 +334,9 @@ void DragValue::setValue(double value, bool final)
}
}
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
());
}
}
else
{
QWidget
::
focusInEvent
(
e
);
}
}
void
DragValue
::
slotEditingFinished
()
{
qDebug
()
<<
"::: EDITING FINISHED..."
;
if
(
m_intEdit
)
{
int
newValue
=
m_intEdit
->
value
();
m_intEdit
->
blockSignals
(
true
);
...
...
@@ -529,6 +531,7 @@ void CustomLabel::wheelEvent(QWheelEvent *e)
#if QT_VERSION < QT_VERSION_CHECK(5,15,0)
if
(
e
->
delta
()
>
0
)
{
#else
qDebug
()
<<
":::: GOT WHEEL DELTA: "
<<
e
->
angleDelta
().
y
();
if
(
e
->
angleDelta
().
y
()
>
0
)
{
#endif
if
(
e
->
modifiers
()
==
Qt
::
ControlModifier
)
{
...
...
@@ -577,13 +580,3 @@ void CustomLabel::setStep(double step)
{
m_step
=
step
;
}
void
CustomLabel
::
focusInEvent
(
QFocusEvent
*
)
{
setFocusPolicy
(
Qt
::
WheelFocus
);
}
void
CustomLabel
::
focusOutEvent
(
QFocusEvent
*
)
{
setFocusPolicy
(
Qt
::
StrongFocus
);
}
src/widgets/dragvalue.h
View file @
cfe9c071
...
...
@@ -23,6 +23,8 @@ public:
explicit
CustomLabel
(
const
QString
&
label
,
bool
showSlider
=
true
,
int
range
=
1000
,
QWidget
*
parent
=
nullptr
);
void
setProgressValue
(
double
value
);
void
setStep
(
double
step
);
void
slotValueInc
(
double
factor
=
1
);
void
slotValueDec
(
double
factor
=
1
);
protected:
// virtual void mouseDoubleClickEvent(QMouseEvent * event);
...
...
@@ -31,8 +33,6 @@ protected:
void
mouseMoveEvent
(
QMouseEvent
*
event
)
override
;
// virtual void paintEvent(QPaintEvent *event);
void
wheelEvent
(
QWheelEvent
*
event
)
override
;
void
focusInEvent
(
QFocusEvent
*
e
)
override
;
void
focusOutEvent
(
QFocusEvent
*
e
)
override
;
private:
QPoint
m_dragStartPosition
;
...
...
@@ -41,8 +41,6 @@ private:
bool
m_showSlider
;
double
m_step
;
double
m_value
;
void
slotValueInc
(
double
factor
=
1
);
void
slotValueDec
(
double
factor
=
1
);
void
setNewValue
(
double
,
bool
);
signals:
...
...
@@ -121,8 +119,8 @@ protected:
virtual void mouseMoveEvent(QMouseEvent *e);
virtual void mouseReleaseEvent(QMouseEvent *e);*/
/** @brief Forwards tab focus to lineedit since it is disabled. */
void
focusInEvent
(
QFocus
Event
*
e
)
override
;
void
focusOutEvent
(
QFocusEvent
*
e
)
override
;
bool
eventFilter
(
QObject
*
watched
,
Q
Event
*
e
vent
)
override
;
// virtual void keyPressEvent(QKeyEvent *e);
// virtual void wheelEvent(QWheelEvent *e);
// virtual void paintEvent( QPaintEvent * event );
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment