mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-25 21:32:15 +01:00
Only allow scroll wheel edits when spinbox is active
(cherry picked from commit ebc3d626d152a07692f2de598c294348ad199597)
This commit is contained in:
parent
13266d005c
commit
a5273cb758
2 changed files with 31 additions and 3 deletions
|
|
@ -2,7 +2,9 @@ from Qt import QtWidgets, QtCore
|
|||
|
||||
from .widgets import (
|
||||
NameTextEdit,
|
||||
FilterComboBox
|
||||
FilterComboBox,
|
||||
SpinBoxScrollFixed,
|
||||
DoubleSpinBoxScrollFixed
|
||||
)
|
||||
from .multiselection_combobox import MultiSelectionComboBox
|
||||
|
||||
|
|
@ -89,9 +91,9 @@ class NumberDelegate(QtWidgets.QStyledItemDelegate):
|
|||
|
||||
def createEditor(self, parent, option, index):
|
||||
if self.decimals > 0:
|
||||
editor = QtWidgets.QDoubleSpinBox(parent)
|
||||
editor = DoubleSpinBoxScrollFixed(parent)
|
||||
else:
|
||||
editor = QtWidgets.QSpinBox(parent)
|
||||
editor = SpinBoxScrollFixed(parent)
|
||||
|
||||
editor.setObjectName("NumberEditor")
|
||||
# Set min/max
|
||||
|
|
|
|||
|
|
@ -429,3 +429,29 @@ class ConfirmProjectDeletion(QtWidgets.QDialog):
|
|||
def _on_confirm_text_change(self):
|
||||
enabled = self._confirm_input.text() == self._project_name
|
||||
self._confirm_btn.setEnabled(enabled)
|
||||
|
||||
|
||||
class SpinBoxScrollFixed(QtWidgets.QSpinBox):
|
||||
"""QSpinBox which only allow edits change with scroll wheel when active"""
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(SpinBoxScrollFixed, self).__init__(*args, **kwargs)
|
||||
self.setFocusPolicy(QtCore.Qt.StrongFocus)
|
||||
|
||||
def wheelEvent(self, event):
|
||||
if not self.hasFocus():
|
||||
event.ignore()
|
||||
else:
|
||||
super(SpinBoxScrollFixed, self).wheelEvent(event)
|
||||
|
||||
|
||||
class DoubleSpinBoxScrollFixed(QtWidgets.QDoubleSpinBox):
|
||||
"""QDoubleSpinBox which only allow edits with scroll wheel when active"""
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(DoubleSpinBoxScrollFixed, self).__init__(*args, **kwargs)
|
||||
self.setFocusPolicy(QtCore.Qt.StrongFocus)
|
||||
|
||||
def wheelEvent(self, event):
|
||||
if not self.hasFocus():
|
||||
event.ignore()
|
||||
else:
|
||||
super(DoubleSpinBoxScrollFixed, self).wheelEvent(event)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue