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
2 changes: 1 addition & 1 deletion include/widgets/dslider.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2011 - 2022 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2011 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: LGPL-3.0-or-later

Expand Down
10 changes: 9 additions & 1 deletion include/widgets/dspinbox.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2015 - 2022 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2015 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: LGPL-3.0-or-later

Expand All @@ -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
12 changes: 12 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 @@ -109,6 +110,7 @@
{
D_D(DComboBox);
d->init();
setFocusPolicy(Qt::StrongFocus);
}

DComboBox::DComboBox(DComboBoxPrivate &dd, QWidget *parent)
Expand All @@ -117,6 +119,16 @@
{
D_D(DComboBox);
d->init();
setFocusPolicy(Qt::StrongFocus);
}

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

/*!
Expand Down
8 changes: 6 additions & 2 deletions src/widgets/dslider.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2011 - 2022 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2011 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: LGPL-3.0-or-later

Expand Down 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
24 changes: 23 additions & 1 deletion src/widgets/dspinbox.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2015 - 2022 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2015 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: LGPL-3.0-or-later

Expand All @@ -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 @@ -63,6 +65,16 @@
DObject(*new DSpinBoxPrivate(this))
{
d_func()->init();
setFocusPolicy(Qt::StrongFocus);
}

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

/*!
Expand Down Expand Up @@ -180,6 +192,16 @@
DObject(*new DDoubleSpinBoxPrivate(this))
{
d_func()->init();
setFocusPolicy(Qt::StrongFocus);
}

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

bool DDoubleSpinBox::isAlert() const
Expand Down
Loading