Skip to content

Commit

Permalink
fix issue olivierkes#468 'unit' is reset
Browse files Browse the repository at this point in the history
  • Loading branch information
SOLIDFred committed May 27, 2019
1 parent a8ec651 commit 87360a5
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions manuskript/ui/welcome.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ def changeTemplate(self, item, column):
self.mw.loadProject(appPath("sample-projects/{}".format(name)))

def updateTemplate(self):

# Clear layout
def clearLayout(l):
while l.count() != 0:
Expand All @@ -286,18 +287,19 @@ def clearLayout(l):

k = 0
hasWC = False
for d in self.template[1]:
for templateIndex, d in enumerate(self.template[1]):
spin = QSpinBox(self)
spin.setRange(0, 999999)
spin.setValue(d[0])
# Storing the level of the template in that spinbox, so we can use
# it to update the template when valueChanged on that spinbox
# (we do that in self.updateWordCount for convenience).
spin.setProperty("templateIndex", self.template[1].index(d))
spin.setProperty("templateIndex", templateIndex)
spin.valueChanged.connect(self.updateWordCount)

if d[1] != None:
txt = QLineEdit(self)
txt.setProperty("templateIndex", templateIndex)
txt.textEdited.connect(self.updateWordCount)
txt.setText(d[1])

else:
Expand Down Expand Up @@ -360,12 +362,23 @@ def updateWordCount(self):
Qt.FindChildrenRecursively):
total = total * s.value()

# Update self.template to reflect the changed values
# Update self.template to reflect the changed count values
templateIndex = s.property("templateIndex")
self.template[1][templateIndex] = (
s.value(),
self.template[1][templateIndex][1])

for t in self.findChildren(QLineEdit, QRegExp(".*"),
Qt.FindChildrenRecursively):
# Update self.template to reflect the changed name values
templateIndex = t.property("templateIndex")
if templateIndex is not None :
self.template[1][templateIndex] = (
self.template[1][templateIndex][0],
t.text())
print(t.text())


if total == 1:
total = 0

Expand Down

0 comments on commit 87360a5

Please sign in to comment.