forked from PCSX2/pcsx2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Qt: Ignore mouse wheel event in combo and spin boxes
- Loading branch information
1 parent
d9dbf2c
commit 0be6400
Showing
47 changed files
with
632 additions
and
321 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#pragma once | ||
#include <QtWidgets/QComboBox> | ||
|
||
class NoScrollQComboBox : public QComboBox | ||
{ | ||
Q_OBJECT | ||
void wheelEvent(QWheelEvent* event) override | ||
{ | ||
if (hasFocus()) | ||
{ | ||
QComboBox::wheelEvent(event); | ||
} | ||
else | ||
((QEvent*)event)->ignore(); | ||
}; | ||
void focusInEvent(QFocusEvent* event) override | ||
{ | ||
QComboBox::focusInEvent(event); | ||
setPalette(HighlightPalette); | ||
}; | ||
void focusOutEvent(QFocusEvent* event) override | ||
{ | ||
QComboBox::focusOutEvent(event); | ||
setPalette(DefaultPalette); | ||
}; | ||
QPalette DefaultPalette; | ||
QPalette HighlightPalette; | ||
public: | ||
explicit NoScrollQComboBox(QWidget *parent = nullptr) : QComboBox(parent) | ||
{ | ||
setFocusPolicy(Qt::StrongFocus); | ||
DefaultPalette = QPalette(); | ||
HighlightPalette = QPalette(); | ||
HighlightPalette.setColor(QPalette::Window, Qt::black); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#pragma once | ||
#include <QtWidgets/QDoubleSpinBox> | ||
|
||
class NoScrollQDoubleSpinBox : public QDoubleSpinBox | ||
{ | ||
Q_OBJECT | ||
void wheelEvent(QWheelEvent* event) override | ||
{ | ||
if (hasFocus()) | ||
{ | ||
QDoubleSpinBox::wheelEvent(event); | ||
} | ||
else | ||
((QEvent*)event)->ignore(); | ||
}; | ||
public: | ||
explicit NoScrollQDoubleSpinBox(QWidget *parent = nullptr) : QDoubleSpinBox(parent) | ||
{ | ||
setFocusPolicy(Qt::StrongFocus); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#pragma once | ||
#include <QtWidgets/QSlider> | ||
|
||
class NoScrollQSlider : public QSlider | ||
{ | ||
Q_OBJECT | ||
void wheelEvent(QWheelEvent* event) override | ||
{ | ||
if (hasFocus()) | ||
{ | ||
QSlider::wheelEvent(event); | ||
} | ||
else | ||
((QEvent*)event)->ignore(); | ||
}; | ||
void focusInEvent(QFocusEvent* event) override | ||
{ | ||
QSlider::focusInEvent(event); | ||
setPalette(HighlightPalette); | ||
}; | ||
void focusOutEvent(QFocusEvent* event) override | ||
{ | ||
QSlider::focusOutEvent(event); | ||
setPalette(DefaultPalette); | ||
}; | ||
QPalette DefaultPalette; | ||
QPalette HighlightPalette; | ||
public: | ||
explicit NoScrollQSlider(QWidget *parent = nullptr) : QSlider(parent) | ||
{ | ||
setFocusPolicy(Qt::StrongFocus); | ||
DefaultPalette = QPalette(); | ||
HighlightPalette = QPalette(); | ||
HighlightPalette.setColor(QPalette::Window, Qt::black); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#pragma once | ||
#include <QtWidgets/QSpinBox> | ||
|
||
class NoScrollQSpinBox : public QSpinBox | ||
{ | ||
Q_OBJECT | ||
void wheelEvent(QWheelEvent* event) override | ||
{ | ||
if (hasFocus()) | ||
{ | ||
QSpinBox::wheelEvent(event); | ||
} | ||
else | ||
((QEvent*)event)->ignore(); | ||
}; | ||
public: | ||
explicit NoScrollQSpinBox(QWidget *parent = nullptr) : QSpinBox(parent) | ||
{ | ||
setFocusPolicy(Qt::StrongFocus); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.