Browse Source

ParamSpinBox: Don't allow to change values of read-only params

tags/v1.9.11
falkTX 6 years ago
parent
commit
aac9b5943e
1 changed files with 19 additions and 0 deletions
  1. +19
    -0
      source/widgets/paramspinbox.py

+ 19
- 0
source/widgets/paramspinbox.py View File

@@ -123,6 +123,7 @@ class ParamProgressBar(QProgressBar):

self.fLeftClickDown = False
self.fIsInteger = False
self.fIsReadOnly = False

self.fMinimum = 0.0
self.fMaximum = 1.0
@@ -184,6 +185,9 @@ class ParamProgressBar(QProgressBar):
def setName(self, name):
self.fName = name

def setReadOnly(self, yesNo):
self.fIsReadOnly = yesNo

def setTextCall(self, textCall):
self.fTextCall = textCall

@@ -191,6 +195,9 @@ class ParamProgressBar(QProgressBar):
self.fValueCall = valueCall

def handleMouseEventPos(self, pos):
if self.fIsReadOnly:
return

xper = float(pos.x()) / float(self.width())
value = xper * (self.fMaximum - self.fMinimum) + self.fMinimum

@@ -206,19 +213,30 @@ class ParamProgressBar(QProgressBar):
self.valueChanged.emit(value)

def mousePressEvent(self, event):
if self.fIsReadOnly:
return

if event.button() == Qt.LeftButton:
self.handleMouseEventPos(event.pos())
self.fLeftClickDown = True
else:
self.fLeftClickDown = False

QProgressBar.mousePressEvent(self, event)

def mouseMoveEvent(self, event):
if self.fIsReadOnly:
return

if self.fLeftClickDown:
self.handleMouseEventPos(event.pos())

QProgressBar.mouseMoveEvent(self, event)

def mouseReleaseEvent(self, event):
if self.fIsReadOnly:
return

self.fLeftClickDown = False
QProgressBar.mouseReleaseEvent(self, event)

@@ -353,6 +371,7 @@ class ParamSpinBox(QAbstractSpinBox):

def setReadOnly(self, yesNo):
self.fIsReadOnly = yesNo
self.fBar.setReadOnly(yesNo)
self.setButtonSymbols(QAbstractSpinBox.UpDownArrows if yesNo else QAbstractSpinBox.NoButtons)
QAbstractSpinBox.setReadOnly(self, yesNo)



Loading…
Cancel
Save