aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortassaron2017-08-20 18:36:43 -0400
committertassaron2017-08-20 18:36:43 -0400
commit6bf8a553d6170e0ca6e7d2002e46ae327a6e5e81 (patch)
treeb97c9c2d334772fff1c38c5a6a2a4a5b3e6863e4 /src
parentbe9eb9077b2234e6d91c78d70bb8e1d8347b03aa (diff)
don't merge undos when setting text with a button
plus changes to life.py for pep8 compliance
Diffstat (limited to 'src')
-rw-r--r--src/component.py5
-rw-r--r--src/components/image.py2
-rw-r--r--src/components/life.py46
-rw-r--r--src/components/sound.py2
-rw-r--r--src/components/video.py2
-rw-r--r--src/gui/actions.py1
6 files changed, 37 insertions, 21 deletions
diff --git a/src/component.py b/src/component.py
index 0ff2fbd..1f55a19 100644
--- a/src/component.py
+++ b/src/component.py
@@ -285,6 +285,7 @@ class Component(QtCore.QObject, metaclass=ComponentMetaclass):
# LOCKING VARIABLES
self.openingPreset = False
+ self.mergeUndo = True
self._lockedProperties = None
self._lockedError = None
self._lockedSize = None
@@ -587,10 +588,12 @@ class Component(QtCore.QObject, metaclass=ComponentMetaclass):
if kwarg == 'colorWidgets':
def makeColorFunc(attr):
def pickColor_():
+ self.mergeUndo = False
self.pickColor(
self._trackedWidgets[attr],
self._colorWidgets[attr]
)
+ self.mergeUndo = True
return pickColor_
self._colorFuncs = {
attr: makeColorFunc(attr) for attr in kwargs[kwarg]
@@ -850,7 +853,7 @@ class ComponentUpdate(QtWidgets.QUndoCommand):
# Determine if this update is mergeable
self.id_ = -1
- if len(self.modifiedVals) == 1:
+ if len(self.modifiedVals) == 1 and self.parent.mergeUndo:
attr, val = self.modifiedVals.popitem()
self.id_ = sum([ord(letter) for letter in attr[-14:]])
self.modifiedVals[attr] = val
diff --git a/src/components/image.py b/src/components/image.py
index c57b69c..dd363bf 100644
--- a/src/components/image.py
+++ b/src/components/image.py
@@ -83,7 +83,9 @@ class Component(Component):
"Image Files (%s)" % " ".join(self.core.imageFormats))
if filename:
self.settings.setValue("componentDir", os.path.dirname(filename))
+ self.mergeUndo = False
self.page.lineEdit_image.setText(filename)
+ self.mergeUndo = True
def command(self, arg):
if '=' in arg:
diff --git a/src/components/life.py b/src/components/life.py
index 5d00987..d4a455d 100644
--- a/src/components/life.py
+++ b/src/components/life.py
@@ -35,6 +35,7 @@ class Component(Component):
self.page.toolButton_left,
self.page.toolButton_right,
)
+
def shiftFunc(i):
def shift():
self.shiftGrid(i)
@@ -52,7 +53,9 @@ class Component(Component):
"Image Files (%s)" % " ".join(self.core.imageFormats))
if filename:
self.settings.setValue("componentDir", os.path.dirname(filename))
+ self.mergeUndo = False
self.page.lineEdit_image.setText(filename)
+ self.mergeUndo = True
def shiftGrid(self, d):
def newGrid(Xchange, Ychange):
@@ -197,7 +200,7 @@ class Component(Component):
# Circle
if shape == 'circle':
drawer.ellipse(outlineShape, fill=self.color)
- drawer.ellipse(smallerShape, fill=(0,0,0,0))
+ drawer.ellipse(smallerShape, fill=(0, 0, 0, 0))
# Lilypad
elif shape == 'lilypad':
@@ -207,9 +210,9 @@ class Component(Component):
elif shape == 'pac-man':
drawer.pieslice(outlineShape, 35, 320, fill=self.color)
- hX, hY = scale(50, self.pxWidth, self.pxHeight, int) # halfline
- tX, tY = scale(33, self.pxWidth, self.pxHeight, int) # thirdline
- qX, qY = scale(20, self.pxWidth, self.pxHeight, int) # quarterline
+ hX, hY = scale(50, self.pxWidth, self.pxHeight, int) # halfline
+ tX, tY = scale(33, self.pxWidth, self.pxHeight, int) # thirdline
+ qX, qY = scale(20, self.pxWidth, self.pxHeight, int) # quarterline
# Path
if shape == 'path':
@@ -245,19 +248,19 @@ class Component(Component):
sect = (
(drawPtX, drawPtY + hY),
(drawPtX + self.pxWidth,
- drawPtY + self.pxHeight)
+ drawPtY + self.pxHeight)
)
elif direction == 'left':
sect = (
(drawPtX, drawPtY),
(drawPtX + hX,
- drawPtY + self.pxHeight)
+ drawPtY + self.pxHeight)
)
elif direction == 'right':
sect = (
(drawPtX + hX, drawPtY),
(drawPtX + self.pxWidth,
- drawPtY + self.pxHeight)
+ drawPtY + self.pxHeight)
)
drawer.rectangle(sect, fill=self.color)
@@ -287,20 +290,25 @@ class Component(Component):
# Peace
elif shape == 'peace':
- line = (
- (drawPtX + hX - int(tenthX / 2), drawPtY + int(tenthY / 2)),
+ line = ((
+ drawPtX + hX - int(tenthX / 2), drawPtY + int(tenthY / 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(smallerShape, fill=(0,0,0,0))
+ drawer.ellipse(smallerShape, fill=(0, 0, 0, 0))
drawer.rectangle(line, fill=self.color)
- slantLine = lambda difference: (
- ((drawPtX + difference),
- (drawPtY + self.pxHeight - qY)),
- ((drawPtX + hX),
- (drawPtY + hY)),
- )
+
+ def slantLine(difference):
+ return (
+ (drawPtX + difference),
+ (drawPtY + self.pxHeight - qY)
+ ),
+ (
+ (drawPtX + hX),
+ (drawPtY + hY)
+ )
+
drawer.line(
slantLine(qX),
fill=self.color,
@@ -337,13 +345,13 @@ class Component(Component):
for x in range(self.pxWidth, self.width, self.pxWidth):
drawer.rectangle(
((x, 0),
- (x + w, self.height)),
+ (x + w, self.height)),
fill=self.color,
)
for y in range(self.pxHeight, self.height, self.pxHeight):
drawer.rectangle(
((0, y),
- (self.width, y + h)),
+ (self.width, y + h)),
fill=self.color,
)
diff --git a/src/components/sound.py b/src/components/sound.py
index b86f40c..18d2a65 100644
--- a/src/components/sound.py
+++ b/src/components/sound.py
@@ -52,7 +52,9 @@ class Component(Component):
"Audio Files (%s)" % " ".join(self.core.audioFormats))
if filename:
self.settings.setValue("componentDir", os.path.dirname(filename))
+ self.mergeUndo = False
self.page.lineEdit_sound.setText(filename)
+ self.mergeUndo = True
def commandHelp(self):
print('Path to audio file:\n path=/filepath/to/sound.ogg')
diff --git a/src/components/video.py b/src/components/video.py
index 9c0d608..e6486ea 100644
--- a/src/components/video.py
+++ b/src/components/video.py
@@ -117,7 +117,9 @@ class Component(Component):
)
if filename:
self.settings.setValue("componentDir", os.path.dirname(filename))
+ self.mergeUndo = False
self.page.lineEdit_video.setText(filename)
+ self.mergeUndo = True
def getPreviewFrame(self, width, height):
if not self.videoPath or not os.path.exists(self.videoPath):
diff --git a/src/gui/actions.py b/src/gui/actions.py
index f101bd7..ebd9702 100644
--- a/src/gui/actions.py
+++ b/src/gui/actions.py
@@ -32,7 +32,6 @@ class AddComponent(QUndoCommand):
self.parent.core.insertComponent(
self.compI, self.comp, self.parent)
-
def undo(self):
self.comp = self.parent.core.selectedComponents[self.compI]
self.parent._removeComponent(self.compI)