mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-05-16 10:52:29 +12:00
Fixes: Create new project ignores changes made to template levels before Create #171
This commit is contained in:
parent
e393848bc0
commit
4d82963eba
|
@ -131,7 +131,7 @@ class welcome(QWidget, Ui_welcome):
|
|||
self.mw.loadProject(filename)
|
||||
|
||||
def saveAsFile(self):
|
||||
"""File dialog that request a file, existing or not.
|
||||
"""File dialog that request a file, existing or not.
|
||||
Save datas to that file, which then becomes the current project."""
|
||||
filename = QFileDialog.getSaveFileName(self,
|
||||
self.tr("Save project as..."),
|
||||
|
@ -248,6 +248,10 @@ class welcome(QWidget, Ui_welcome):
|
|||
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.valueChanged.connect(self.updateWordCount)
|
||||
|
||||
if d[1] != None:
|
||||
|
@ -299,11 +303,26 @@ class welcome(QWidget, Ui_welcome):
|
|||
self.updateTemplate()
|
||||
|
||||
def updateWordCount(self):
|
||||
"""
|
||||
Updates the word count of the template, and displays it in a label.
|
||||
|
||||
Also, updates self.template, which is used to create the items when
|
||||
calling self.createFile.
|
||||
"""
|
||||
total = 1
|
||||
|
||||
# Searching for every spinboxes on the widget, and multiplying
|
||||
# their values to get the number of words.
|
||||
for s in self.findChildren(QSpinBox, QRegExp(".*"),
|
||||
Qt.FindChildrenRecursively):
|
||||
total = total * s.value()
|
||||
|
||||
# Update self.template to reflect the changed values
|
||||
templateIndex = s.property("templateIndex")
|
||||
self.template[1][templateIndex] = (
|
||||
s.value(),
|
||||
self.template[1][templateIndex][1])
|
||||
|
||||
if total == 1:
|
||||
total = 0
|
||||
|
||||
|
|
Loading…
Reference in a new issue