fix(suite): prevent wheel changes in generation settings
This commit is contained in:
@@ -12,6 +12,7 @@ from PySide6.QtCore import (
|
||||
QByteArray,
|
||||
QBuffer,
|
||||
QIODevice,
|
||||
QPointF,
|
||||
QRect,
|
||||
QSize,
|
||||
Qt,
|
||||
@@ -19,7 +20,16 @@ from PySide6.QtCore import (
|
||||
Signal,
|
||||
Slot,
|
||||
)
|
||||
from PySide6.QtGui import QColor, QIcon, QImage, QImageReader, QKeySequence, QPainter, QPixmap
|
||||
from PySide6.QtGui import (
|
||||
QColor,
|
||||
QIcon,
|
||||
QImage,
|
||||
QImageReader,
|
||||
QKeySequence,
|
||||
QPainter,
|
||||
QPixmap,
|
||||
QWheelEvent,
|
||||
)
|
||||
from PySide6.QtWidgets import (
|
||||
QApplication,
|
||||
QCheckBox,
|
||||
@@ -146,6 +156,38 @@ class AutoHeightPlainTextEdit(QPlainTextEdit):
|
||||
self.schedule_height_update()
|
||||
|
||||
|
||||
class SuiteSettingsComboBox(QComboBox):
|
||||
"""Keep wheel scrolling from silently changing a suite generation setting."""
|
||||
|
||||
def wheelEvent(self, event):
|
||||
target = self.view().viewport() if self.view().isVisible() else self._outer_scroll_viewport()
|
||||
if target is None:
|
||||
event.ignore()
|
||||
return
|
||||
global_position = event.globalPosition()
|
||||
local_position = target.mapFromGlobal(global_position.toPoint())
|
||||
forwarded = QWheelEvent(
|
||||
QPointF(local_position),
|
||||
global_position,
|
||||
event.pixelDelta(),
|
||||
event.angleDelta(),
|
||||
event.buttons(),
|
||||
event.modifiers(),
|
||||
event.phase(),
|
||||
event.inverted(),
|
||||
)
|
||||
QApplication.sendEvent(target, forwarded)
|
||||
event.accept()
|
||||
|
||||
def _outer_scroll_viewport(self):
|
||||
parent = self.parentWidget()
|
||||
while parent is not None:
|
||||
if isinstance(parent, QScrollArea):
|
||||
return parent.viewport()
|
||||
parent = parent.parentWidget()
|
||||
return None
|
||||
|
||||
|
||||
def _asset_usable(asset):
|
||||
path = str(getattr(asset, "local_path", "") or "")
|
||||
return (
|
||||
@@ -2173,7 +2215,7 @@ class ProductSuiteTab(QWidget):
|
||||
return frame
|
||||
|
||||
def _value_combo(self, object_name, label, values):
|
||||
combo = QComboBox()
|
||||
combo = SuiteSettingsComboBox()
|
||||
combo.setObjectName(object_name)
|
||||
combo.setToolTip("%s设置" % label)
|
||||
combo.setAccessibleName("%s设置" % label)
|
||||
|
||||
Reference in New Issue
Block a user