Revert "workaround missing setStops binding"

This reverts commit c4addbeaea.
This commit is contained in:
KIU Shueng Chuan 2021-01-22 12:30:49 +08:00
parent 2e688cf672
commit d0c062d7e5
2 changed files with 2 additions and 14 deletions

View File

@ -359,13 +359,7 @@ class ColorMap(object):
pos, color = self.getStops(mode=self.BYTE)
color = [QtGui.QColor(*x) for x in color]
stops = zip(pos, color)
if hasattr(g, 'setStops'):
g.setStops(list(stops))
else:
# PySide6 has a missing setStops binding
for pos, col in stops:
g.setColorAt(pos, col)
g.setStops(list(zip(pos, color)))
return g
def getColors(self, mode=None):

View File

@ -626,10 +626,9 @@ class GradientEditorItem(TickSliderItem):
def getGradient(self):
"""Return a QLinearGradient object."""
g = QtGui.QLinearGradient(QtCore.QPointF(0,0), QtCore.QPointF(self.length,0))
stops = []
if self.colorMode == 'rgb':
ticks = self.listTicks()
stops = [(x, QtGui.QColor(t.color)) for t,x in ticks]
g.setStops([(x, QtGui.QColor(t.color)) for t,x in ticks])
elif self.colorMode == 'hsv': ## HSV mode is approximated for display by interpolating 10 points between each stop
ticks = self.listTicks()
stops = []
@ -642,12 +641,7 @@ class GradientEditorItem(TickSliderItem):
x = x1 + dx*j
stops.append((x, self.getColor(x)))
stops.append((x2, self.getColor(x2)))
if hasattr(g, 'setStops'):
g.setStops(stops)
else:
# PySide6 has a missing setStops binding
for pos, col in stops:
g.setColorAt(pos, col)
return g
def getColor(self, x, toQColor=True):