Skip to content

Commit

Permalink
gui/menuspinbox: Add MouseWheelGuard to MenuSpinBox and MenuComboBox
Browse files Browse the repository at this point in the history
Signed-off-by: Andrei-Fabian-Pop <[email protected]>
  • Loading branch information
Andrei-Fabian-Pop committed Oct 2, 2024
1 parent 258b130 commit 8c70563
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions gui/include/gui/widgets/menucombo.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include <scopy-gui_export.h>
#include <utils.h>
#include <mousewheelwidgetguard.h>

namespace scopy {

Expand All @@ -25,6 +26,7 @@ class SCOPY_GUI_EXPORT MenuCombo : public QWidget
private:
QLabel *m_label;
QComboBox *m_combo;
MouseWheelWidgetGuard *m_mouseWheelGuard;
};

class SCOPY_GUI_EXPORT MenuComboWidget : public QWidget
Expand Down
4 changes: 3 additions & 1 deletion gui/include/gui/widgets/menuspinbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
#define MENUSPINBOX_H

#include "plot_utils.hpp"
#include "qboxlayout.h"
#include "utils.h"
#include "mousewheelwidgetguard.h"
#include <cmath>
#include <scopy-gui_export.h>
#include <QWidget>
#include <QLineEdit>
#include <QComboBox>
#include <QPushButton>
#include <QLabel>
#include <QBoxLayout>

namespace scopy {
namespace gui {
Expand Down Expand Up @@ -167,6 +168,7 @@ private Q_SLOTS:
QPushButton *m_plus;
QPushButton *m_minus;
QFrame *m_line; // underline
MouseWheelWidgetGuard *m_mouseWheelGuard;

IncrementStrategy *m_incrementStrategy;
IncrementMode m_im;
Expand Down
2 changes: 2 additions & 0 deletions gui/src/widgets/menucombo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ MenuCombo::MenuCombo(QString title, QWidget *parent)
: QWidget(parent)
{
auto lay = new QVBoxLayout(this);
m_mouseWheelGuard = new MouseWheelWidgetGuard(this);

setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
setLayout(lay);
Expand All @@ -43,6 +44,7 @@ MenuCombo::MenuCombo(QString title, QWidget *parent)
lay->addWidget(m_label);
lay->addWidget(m_combo);
applyStylesheet();
m_mouseWheelGuard->installEventRecursively(this);
}

MenuCombo::~MenuCombo() {}
Expand Down
2 changes: 2 additions & 0 deletions gui/src/widgets/menuspinbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ MenuSpinbox::MenuSpinbox(QString name, double val, QString unit, double min, dou
m_scaleCb = new QComboBox(parent);
m_plus = new QPushButton("+", parent);
m_minus = new QPushButton("-", parent);
m_mouseWheelGuard = new MouseWheelWidgetGuard(this);

m_plus->setAutoRepeat(true);
m_plus->setAutoRepeatDelay(300);
Expand Down Expand Up @@ -59,6 +60,7 @@ MenuSpinbox::MenuSpinbox(QString name, double val, QString unit, double min, dou
setValue(val);
m_scalingEnabled = true;
setLineVisible(false);
m_mouseWheelGuard->installEventRecursively(this);
}

MenuSpinbox::~MenuSpinbox() { delete m_incrementStrategy; }
Expand Down

0 comments on commit 8c70563

Please sign in to comment.