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

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

parent 61a06b3c
No related branches found
No related tags found
1 merge request!417Layer editor improvements
......@@ -19,6 +19,7 @@
#include "GUI/Views/SampleDesigner/FormLayouter.h"
#include "GUI/Views/SampleDesigner/SampleEditorController.h"
#include "GUI/Views/SampleDesigner/SelectionContainerForm.h"
#include "GUI/utils/CustomEventFilters.h"
InterferenceForm::InterferenceForm(QWidget* parent, ParticleLayoutItem* layoutItem,
SampleEditorController* ec)
......@@ -31,6 +32,7 @@ InterferenceForm::InterferenceForm(QWidget* parent, ParticleLayoutItem* layoutIt
m_collapser = GroupBoxCollapser::installIntoGroupBox(this);
m_interferenceTypeCombo = new QComboBox(this);
WheelEventEater::install(m_interferenceTypeCombo);
auto d = layoutItem->interference();
m_interferenceTypeCombo->addItems(d.options);
m_interferenceTypeCombo->setCurrentIndex(d.currentIndex());
......
......@@ -63,6 +63,7 @@ MesoCrystalForm::MesoCrystalForm(QWidget* parent, MesoCrystalItem* item, SampleE
QComboBox* MesoCrystalForm::createBasisCombo(QWidget* parent, ItemWithParticles* current)
{
auto combo = new QComboBox(parent);
WheelEventEater::install(combo);
combo->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
const auto modelTypes = ItemCatalog::formFactorHardParticleTypes()
......
......@@ -32,6 +32,7 @@ namespace {
QComboBox* createFormFactorCombo(QWidget* parent, FormFactorItem* current)
{
auto* combo = new QComboBox(parent);
WheelEventEater::install(combo);
combo->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
combo->addItem(QIcon(), "None", "");
......
......@@ -17,6 +17,7 @@
#include "GUI/Views/SampleDesigner/LayerEditorUtils.h"
#include "GUI/Views/SampleDesigner/SampleEditorController.h"
#include "GUI/utils/CustomEventFilters.h"
#include "GUI/utils/LayoutUtils.h"
#include <QComboBox>
#include <QGridLayout>
......@@ -60,6 +61,7 @@ public:
m_gridLayout->setSpacing(6);
m_combo = new QComboBox;
WheelEventEater::install(m_combo);
m_combo->addItems(d.options);
m_combo->setCurrentIndex(d.currentIndex());
m_combo->setMaxVisibleItems(m_combo->count());
......
......@@ -36,6 +36,12 @@ bool SpaceKeyEater::eventFilter(QObject* obj, QEvent* event)
WheelEventEater::WheelEventEater(QObject* parent) : QObject(parent) {}
void WheelEventEater::install(QObject* obj)
{
auto* p = new WheelEventEater(obj);
obj->installEventFilter(p);
}
bool WheelEventEater::eventFilter(QObject* obj, QEvent* event)
{
if (QAbstractSpinBox* spinBox = qobject_cast<QAbstractSpinBox*>(obj)) {
......
......@@ -34,6 +34,7 @@ protected:
class WheelEventEater : public QObject {
Q_OBJECT
public:
static void install(QObject* obj);
WheelEventEater(QObject* parent = 0);
protected:
......
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