Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions include/widgets/dcombobox.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ class LIBDTKWIDGETSHARED_EXPORT DComboBox : public QComboBox, public DCORE_NAMES
protected:
DComboBox(DComboBoxPrivate &dd, QWidget *parent);

void wheelEvent(QWheelEvent *event) override;

// QComboBox interface
public:
virtual void showPopup() override;
Expand Down
8 changes: 8 additions & 0 deletions include/widgets/dspinbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ class LIBDTKWIDGETSHARED_EXPORT DSpinBox : public QSpinBox, public DTK_CORE_NAME
public:
explicit DSpinBox(QWidget *parent = nullptr);

protected:
void wheelEvent(QWheelEvent *event) override;

public:
QLineEdit *lineEdit() const;

bool isAlert() const;
Expand Down Expand Up @@ -65,6 +69,10 @@ class LIBDTKWIDGETSHARED_EXPORT DDoubleSpinBox : public QDoubleSpinBox, public D
public:
explicit DDoubleSpinBox(QWidget *parent = nullptr);

protected:
void wheelEvent(QWheelEvent *event) override;

public:
bool isAlert() const;
void showAlertMessage(const QString &text, int duration = 3000);
void showAlertMessage(const QString &text, QWidget *follower, int duration = 3000);
Expand Down
10 changes: 10 additions & 0 deletions src/widgets/dcombobox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@
#include <QScrollBar>
#include <QHeaderView>
#include <QCursor>
#include <QScreen>

Check warning on line 32 in src/widgets/dcombobox.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QScreen> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 32 in src/widgets/dcombobox.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <QScreen> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QStack>

Check warning on line 33 in src/widgets/dcombobox.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QStack> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 33 in src/widgets/dcombobox.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <QStack> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QWindow>

Check warning on line 34 in src/widgets/dcombobox.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QWindow> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 34 in src/widgets/dcombobox.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <QWindow> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QWheelEvent>

Check warning on line 35 in src/widgets/dcombobox.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QWheelEvent> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 35 in src/widgets/dcombobox.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <QWheelEvent> not found. Please note: Cppcheck does not need standard library headers to get proper results.

DWIDGET_BEGIN_NAMESPACE

Expand Down Expand Up @@ -119,6 +120,15 @@
d->init();
}

void DComboBox::wheelEvent(QWheelEvent *event)
{
if (hasFocus()) {
QComboBox::wheelEvent(event);
} else {
QWidget::wheelEvent(event);
}
}

/*!
* @~english
@brief Override QComboBox::showPopup to limit the maximum display height according to maxVisibleItems(), which has a default value of 16. The maximum display height can be changed using setMaxVisibleItems(), which makes the setMaximumHeight() interface ineffective.
Expand Down
6 changes: 5 additions & 1 deletion src/widgets/dslider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,11 @@ bool DSlider::eventFilter(QObject *watched, QEvent *e)
Q_D(DSlider);

if ((watched == d->slider) && (e->type() == QEvent::Wheel)) {
return !d->mouseWheelEnabled;
if (d->mouseWheelEnabled && d->slider->hasFocus()) {
return false; // let QSlider::wheelEvent handle it (stepBy + accept)
}
e->ignore(); // Qt6: un-accept so event propagates to parent (e.g. scrollarea)
return true; // block delivery to the inner QSlider
}

if (e->type() == QEvent::MouseButtonRelease) {
Expand Down
20 changes: 20 additions & 0 deletions src/widgets/dspinbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@

#include "dspinbox.h"
#include "private/dspinbox_p.h"
#include "dlineedit.h"

Check warning on line 9 in src/widgets/dspinbox.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "dlineedit.h" not found.

Check warning on line 9 in src/widgets/dspinbox.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: "dlineedit.h" not found.

#include <QWheelEvent>

Check warning on line 11 in src/widgets/dspinbox.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QWheelEvent> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 11 in src/widgets/dspinbox.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <QWheelEvent> not found. Please note: Cppcheck does not need standard library headers to get proper results.

DWIDGET_BEGIN_NAMESPACE

DSpinBoxPrivate::DSpinBoxPrivate(DSpinBox *parent) :
Expand Down Expand Up @@ -65,6 +67,15 @@
d_func()->init();
}

void DSpinBox::wheelEvent(QWheelEvent *event)
{
if (hasFocus()) {
QSpinBox::wheelEvent(event);
} else {
QWidget::wheelEvent(event);
}
}

/*!
@~english
@brief get the input line widget
Expand Down Expand Up @@ -182,6 +193,15 @@
d_func()->init();
}

void DDoubleSpinBox::wheelEvent(QWheelEvent *event)
{
if (hasFocus()) {
QDoubleSpinBox::wheelEvent(event);
} else {
QWidget::wheelEvent(event);
}
}

bool DDoubleSpinBox::isAlert() const
{
D_DC(DDoubleSpinBox);
Expand Down
Loading