Skip to content
Snippets Groups Projects
Commit 61a06b3c authored by Matthias Puchner's avatar Matthias Puchner
Browse files

prevent accidental value change when scrolling the whole window with the mouse wheel

parent c72d9dc6
No related branches found
No related tags found
1 merge request!417Layer editor improvements
......@@ -14,10 +14,12 @@
#include "GUI/Views/CommonWidgets/DoubleSpinBox.h"
#include "GUI/Views/CommonWidgets/GUIHelpers.h"
#include <QWheelEvent>
DoubleSpinBox::DoubleSpinBox(QWidget* parent, const DoubleDescriptor& d)
: QDoubleSpinBox(parent), m_valueDescriptor(d)
{
setFocusPolicy(Qt::StrongFocus);
GUI::View::Helpers::configSpinbox(this, d.decimals, d.limits);
setToolTip(d.tooltip);
setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
......@@ -75,6 +77,14 @@ void DoubleSpinBox::setBaseValue(double baseValue)
setValue(toDisplayValue(baseValue));
}
void DoubleSpinBox::wheelEvent(QWheelEvent* event)
{
if (!hasFocus())
event->ignore();
else
QDoubleSpinBox::wheelEvent(event);
}
void DoubleSpinBox::onDisplayValueChanged(double newDisplayValue)
{
emit baseValueChanged(toBaseValue(newDisplayValue));
......
......@@ -51,6 +51,9 @@ signals:
//! newBaseValue is in the unit of the valueDescriptor.
void baseValueChanged(double newBaseValue);
protected:
virtual void wheelEvent(QWheelEvent* event) override;
private:
void onDisplayValueChanged(double newValue);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment