don't merge undos when setting text with a button
plus changes to life.py for pep8 compliance
This commit is contained in:
parent
be9eb9077b
commit
6bf8a553d6
|
@ -285,6 +285,7 @@ class Component(QtCore.QObject, metaclass=ComponentMetaclass):
|
||||||
|
|
||||||
# LOCKING VARIABLES
|
# LOCKING VARIABLES
|
||||||
self.openingPreset = False
|
self.openingPreset = False
|
||||||
|
self.mergeUndo = True
|
||||||
self._lockedProperties = None
|
self._lockedProperties = None
|
||||||
self._lockedError = None
|
self._lockedError = None
|
||||||
self._lockedSize = None
|
self._lockedSize = None
|
||||||
|
@ -587,10 +588,12 @@ class Component(QtCore.QObject, metaclass=ComponentMetaclass):
|
||||||
if kwarg == 'colorWidgets':
|
if kwarg == 'colorWidgets':
|
||||||
def makeColorFunc(attr):
|
def makeColorFunc(attr):
|
||||||
def pickColor_():
|
def pickColor_():
|
||||||
|
self.mergeUndo = False
|
||||||
self.pickColor(
|
self.pickColor(
|
||||||
self._trackedWidgets[attr],
|
self._trackedWidgets[attr],
|
||||||
self._colorWidgets[attr]
|
self._colorWidgets[attr]
|
||||||
)
|
)
|
||||||
|
self.mergeUndo = True
|
||||||
return pickColor_
|
return pickColor_
|
||||||
self._colorFuncs = {
|
self._colorFuncs = {
|
||||||
attr: makeColorFunc(attr) for attr in kwargs[kwarg]
|
attr: makeColorFunc(attr) for attr in kwargs[kwarg]
|
||||||
|
@ -850,7 +853,7 @@ class ComponentUpdate(QtWidgets.QUndoCommand):
|
||||||
|
|
||||||
# Determine if this update is mergeable
|
# Determine if this update is mergeable
|
||||||
self.id_ = -1
|
self.id_ = -1
|
||||||
if len(self.modifiedVals) == 1:
|
if len(self.modifiedVals) == 1 and self.parent.mergeUndo:
|
||||||
attr, val = self.modifiedVals.popitem()
|
attr, val = self.modifiedVals.popitem()
|
||||||
self.id_ = sum([ord(letter) for letter in attr[-14:]])
|
self.id_ = sum([ord(letter) for letter in attr[-14:]])
|
||||||
self.modifiedVals[attr] = val
|
self.modifiedVals[attr] = val
|
||||||
|
|
|
@ -83,7 +83,9 @@ class Component(Component):
|
||||||
"Image Files (%s)" % " ".join(self.core.imageFormats))
|
"Image Files (%s)" % " ".join(self.core.imageFormats))
|
||||||
if filename:
|
if filename:
|
||||||
self.settings.setValue("componentDir", os.path.dirname(filename))
|
self.settings.setValue("componentDir", os.path.dirname(filename))
|
||||||
|
self.mergeUndo = False
|
||||||
self.page.lineEdit_image.setText(filename)
|
self.page.lineEdit_image.setText(filename)
|
||||||
|
self.mergeUndo = True
|
||||||
|
|
||||||
def command(self, arg):
|
def command(self, arg):
|
||||||
if '=' in arg:
|
if '=' in arg:
|
||||||
|
|
|
@ -35,6 +35,7 @@ class Component(Component):
|
||||||
self.page.toolButton_left,
|
self.page.toolButton_left,
|
||||||
self.page.toolButton_right,
|
self.page.toolButton_right,
|
||||||
)
|
)
|
||||||
|
|
||||||
def shiftFunc(i):
|
def shiftFunc(i):
|
||||||
def shift():
|
def shift():
|
||||||
self.shiftGrid(i)
|
self.shiftGrid(i)
|
||||||
|
@ -52,7 +53,9 @@ class Component(Component):
|
||||||
"Image Files (%s)" % " ".join(self.core.imageFormats))
|
"Image Files (%s)" % " ".join(self.core.imageFormats))
|
||||||
if filename:
|
if filename:
|
||||||
self.settings.setValue("componentDir", os.path.dirname(filename))
|
self.settings.setValue("componentDir", os.path.dirname(filename))
|
||||||
|
self.mergeUndo = False
|
||||||
self.page.lineEdit_image.setText(filename)
|
self.page.lineEdit_image.setText(filename)
|
||||||
|
self.mergeUndo = True
|
||||||
|
|
||||||
def shiftGrid(self, d):
|
def shiftGrid(self, d):
|
||||||
def newGrid(Xchange, Ychange):
|
def newGrid(Xchange, Ychange):
|
||||||
|
@ -197,7 +200,7 @@ class Component(Component):
|
||||||
# Circle
|
# Circle
|
||||||
if shape == 'circle':
|
if shape == 'circle':
|
||||||
drawer.ellipse(outlineShape, fill=self.color)
|
drawer.ellipse(outlineShape, fill=self.color)
|
||||||
drawer.ellipse(smallerShape, fill=(0,0,0,0))
|
drawer.ellipse(smallerShape, fill=(0, 0, 0, 0))
|
||||||
|
|
||||||
# Lilypad
|
# Lilypad
|
||||||
elif shape == 'lilypad':
|
elif shape == 'lilypad':
|
||||||
|
@ -207,9 +210,9 @@ class Component(Component):
|
||||||
elif shape == 'pac-man':
|
elif shape == 'pac-man':
|
||||||
drawer.pieslice(outlineShape, 35, 320, fill=self.color)
|
drawer.pieslice(outlineShape, 35, 320, fill=self.color)
|
||||||
|
|
||||||
hX, hY = scale(50, self.pxWidth, self.pxHeight, int) # halfline
|
hX, hY = scale(50, self.pxWidth, self.pxHeight, int) # halfline
|
||||||
tX, tY = scale(33, self.pxWidth, self.pxHeight, int) # thirdline
|
tX, tY = scale(33, self.pxWidth, self.pxHeight, int) # thirdline
|
||||||
qX, qY = scale(20, self.pxWidth, self.pxHeight, int) # quarterline
|
qX, qY = scale(20, self.pxWidth, self.pxHeight, int) # quarterline
|
||||||
|
|
||||||
# Path
|
# Path
|
||||||
if shape == 'path':
|
if shape == 'path':
|
||||||
|
@ -245,19 +248,19 @@ class Component(Component):
|
||||||
sect = (
|
sect = (
|
||||||
(drawPtX, drawPtY + hY),
|
(drawPtX, drawPtY + hY),
|
||||||
(drawPtX + self.pxWidth,
|
(drawPtX + self.pxWidth,
|
||||||
drawPtY + self.pxHeight)
|
drawPtY + self.pxHeight)
|
||||||
)
|
)
|
||||||
elif direction == 'left':
|
elif direction == 'left':
|
||||||
sect = (
|
sect = (
|
||||||
(drawPtX, drawPtY),
|
(drawPtX, drawPtY),
|
||||||
(drawPtX + hX,
|
(drawPtX + hX,
|
||||||
drawPtY + self.pxHeight)
|
drawPtY + self.pxHeight)
|
||||||
)
|
)
|
||||||
elif direction == 'right':
|
elif direction == 'right':
|
||||||
sect = (
|
sect = (
|
||||||
(drawPtX + hX, drawPtY),
|
(drawPtX + hX, drawPtY),
|
||||||
(drawPtX + self.pxWidth,
|
(drawPtX + self.pxWidth,
|
||||||
drawPtY + self.pxHeight)
|
drawPtY + self.pxHeight)
|
||||||
)
|
)
|
||||||
drawer.rectangle(sect, fill=self.color)
|
drawer.rectangle(sect, fill=self.color)
|
||||||
|
|
||||||
|
@ -287,20 +290,25 @@ class Component(Component):
|
||||||
|
|
||||||
# Peace
|
# Peace
|
||||||
elif shape == 'peace':
|
elif shape == 'peace':
|
||||||
line = (
|
line = ((
|
||||||
(drawPtX + hX - int(tenthX / 2), drawPtY + int(tenthY / 2)),
|
drawPtX + hX - int(tenthX / 2), drawPtY + int(tenthY / 2)),
|
||||||
(drawPtX + hX + int(tenthX / 2),
|
(drawPtX + hX + int(tenthX / 2),
|
||||||
drawPtY + self.pxHeight - int(tenthY / 2))
|
drawPtY + self.pxHeight - int(tenthY / 2))
|
||||||
)
|
)
|
||||||
drawer.ellipse(outlineShape, fill=self.color)
|
drawer.ellipse(outlineShape, fill=self.color)
|
||||||
drawer.ellipse(smallerShape, fill=(0,0,0,0))
|
drawer.ellipse(smallerShape, fill=(0, 0, 0, 0))
|
||||||
drawer.rectangle(line, fill=self.color)
|
drawer.rectangle(line, fill=self.color)
|
||||||
slantLine = lambda difference: (
|
|
||||||
((drawPtX + difference),
|
def slantLine(difference):
|
||||||
(drawPtY + self.pxHeight - qY)),
|
return (
|
||||||
((drawPtX + hX),
|
(drawPtX + difference),
|
||||||
(drawPtY + hY)),
|
(drawPtY + self.pxHeight - qY)
|
||||||
)
|
),
|
||||||
|
(
|
||||||
|
(drawPtX + hX),
|
||||||
|
(drawPtY + hY)
|
||||||
|
)
|
||||||
|
|
||||||
drawer.line(
|
drawer.line(
|
||||||
slantLine(qX),
|
slantLine(qX),
|
||||||
fill=self.color,
|
fill=self.color,
|
||||||
|
@ -337,13 +345,13 @@ class Component(Component):
|
||||||
for x in range(self.pxWidth, self.width, self.pxWidth):
|
for x in range(self.pxWidth, self.width, self.pxWidth):
|
||||||
drawer.rectangle(
|
drawer.rectangle(
|
||||||
((x, 0),
|
((x, 0),
|
||||||
(x + w, self.height)),
|
(x + w, self.height)),
|
||||||
fill=self.color,
|
fill=self.color,
|
||||||
)
|
)
|
||||||
for y in range(self.pxHeight, self.height, self.pxHeight):
|
for y in range(self.pxHeight, self.height, self.pxHeight):
|
||||||
drawer.rectangle(
|
drawer.rectangle(
|
||||||
((0, y),
|
((0, y),
|
||||||
(self.width, y + h)),
|
(self.width, y + h)),
|
||||||
fill=self.color,
|
fill=self.color,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,9 @@ class Component(Component):
|
||||||
"Audio Files (%s)" % " ".join(self.core.audioFormats))
|
"Audio Files (%s)" % " ".join(self.core.audioFormats))
|
||||||
if filename:
|
if filename:
|
||||||
self.settings.setValue("componentDir", os.path.dirname(filename))
|
self.settings.setValue("componentDir", os.path.dirname(filename))
|
||||||
|
self.mergeUndo = False
|
||||||
self.page.lineEdit_sound.setText(filename)
|
self.page.lineEdit_sound.setText(filename)
|
||||||
|
self.mergeUndo = True
|
||||||
|
|
||||||
def commandHelp(self):
|
def commandHelp(self):
|
||||||
print('Path to audio file:\n path=/filepath/to/sound.ogg')
|
print('Path to audio file:\n path=/filepath/to/sound.ogg')
|
||||||
|
|
|
@ -117,7 +117,9 @@ class Component(Component):
|
||||||
)
|
)
|
||||||
if filename:
|
if filename:
|
||||||
self.settings.setValue("componentDir", os.path.dirname(filename))
|
self.settings.setValue("componentDir", os.path.dirname(filename))
|
||||||
|
self.mergeUndo = False
|
||||||
self.page.lineEdit_video.setText(filename)
|
self.page.lineEdit_video.setText(filename)
|
||||||
|
self.mergeUndo = True
|
||||||
|
|
||||||
def getPreviewFrame(self, width, height):
|
def getPreviewFrame(self, width, height):
|
||||||
if not self.videoPath or not os.path.exists(self.videoPath):
|
if not self.videoPath or not os.path.exists(self.videoPath):
|
||||||
|
|
|
@ -32,7 +32,6 @@ class AddComponent(QUndoCommand):
|
||||||
self.parent.core.insertComponent(
|
self.parent.core.insertComponent(
|
||||||
self.compI, self.comp, self.parent)
|
self.compI, self.comp, self.parent)
|
||||||
|
|
||||||
|
|
||||||
def undo(self):
|
def undo(self):
|
||||||
self.comp = self.parent.core.selectedComponents[self.compI]
|
self.comp = self.parent.core.selectedComponents[self.compI]
|
||||||
self.parent._removeComponent(self.compI)
|
self.parent._removeComponent(self.compI)
|
||||||
|
|
Reference in New Issue