Fix translations and refactor makeAlert calls
This commit is contained in:
+15
-15
@@ -102,9 +102,9 @@ class GuiDocMerge(QDialog):
|
||||
finalOrder.append(self.listBox.item(i).data(Qt.UserRole))
|
||||
|
||||
if len(finalOrder) == 0:
|
||||
self.theParent.makeAlert(
|
||||
self.tr("No source documents found. Nothing to do."), nwAlert.ERROR
|
||||
)
|
||||
self.theParent.makeAlert(self.tr(
|
||||
"No source documents found. Nothing to do."
|
||||
), nwAlert.ERROR)
|
||||
return False
|
||||
|
||||
theText = ""
|
||||
@@ -113,16 +113,16 @@ class GuiDocMerge(QDialog):
|
||||
docText = inDoc.readDocument()
|
||||
docErr = inDoc.getError()
|
||||
if docText is None and docErr:
|
||||
self.theParent.makeAlert(
|
||||
[self.tr("Failed to open document file."), docErr], nwAlert.ERROR
|
||||
)
|
||||
self.theParent.makeAlert([
|
||||
self.tr("Failed to open document file."), docErr
|
||||
], nwAlert.ERROR)
|
||||
if docText:
|
||||
theText += docText.rstrip("\n")+"\n\n"
|
||||
|
||||
if self.sourceItem is None:
|
||||
self.theParent.makeAlert(
|
||||
self.tr("No source folder selected. Nothing to do."), nwAlert.ERROR
|
||||
)
|
||||
self.theParent.makeAlert(self.tr(
|
||||
"No source folder selected. Nothing to do."
|
||||
), nwAlert.ERROR)
|
||||
return False
|
||||
|
||||
srcItem = self.theProject.projTree[self.sourceItem]
|
||||
@@ -136,9 +136,9 @@ class GuiDocMerge(QDialog):
|
||||
|
||||
outDoc = NWDoc(self.theProject, nHandle)
|
||||
if not outDoc.writeDocument(theText):
|
||||
self.theParent.makeAlert(
|
||||
[self.tr("Could not save document."), outDoc.getError()], nwAlert.ERROR
|
||||
)
|
||||
self.theParent.makeAlert([
|
||||
self.tr("Could not save document."), outDoc.getError()
|
||||
], nwAlert.ERROR)
|
||||
return False
|
||||
|
||||
self.theParent.treeView.revealNewTreeItem(nHandle)
|
||||
@@ -174,9 +174,9 @@ class GuiDocMerge(QDialog):
|
||||
return False
|
||||
|
||||
if nwItem.itemType is not nwItemType.FOLDER:
|
||||
self.theParent.makeAlert(
|
||||
self.tr("Element selected in the project tree must be a folder."), nwAlert.ERROR
|
||||
)
|
||||
self.theParent.makeAlert(self.tr(
|
||||
"Element selected in the project tree must be a folder."
|
||||
), nwAlert.ERROR)
|
||||
return False
|
||||
|
||||
for sHandle in self.theParent.treeView.getTreeFromHandle(tHandle):
|
||||
|
||||
+23
-25
@@ -117,16 +117,16 @@ class GuiDocSplit(QDialog):
|
||||
logger.verbose("GuiDocSplit split button clicked")
|
||||
|
||||
if self.sourceItem is None:
|
||||
self.theParent.makeAlert(
|
||||
self.tr("No source document selected. Nothing to do."), nwAlert.ERROR
|
||||
)
|
||||
self.theParent.makeAlert(self.tr(
|
||||
"No source document selected. Nothing to do."
|
||||
), nwAlert.ERROR)
|
||||
return False
|
||||
|
||||
srcItem = self.theProject.projTree[self.sourceItem]
|
||||
if srcItem is None:
|
||||
self.theParent.makeAlert(
|
||||
self.tr("Could not parse source document."), nwAlert.ERROR
|
||||
)
|
||||
self.theParent.makeAlert(self.tr(
|
||||
"Could not parse source document."
|
||||
), nwAlert.ERROR)
|
||||
return False
|
||||
|
||||
inDoc = NWDoc(self.theProject, self.sourceItem)
|
||||
@@ -134,9 +134,9 @@ class GuiDocSplit(QDialog):
|
||||
|
||||
docErr = inDoc.getError()
|
||||
if theText is None and docErr:
|
||||
self.theParent.makeAlert(
|
||||
[self.tr("Failed to open document file."), docErr], nwAlert.ERROR
|
||||
)
|
||||
self.theParent.makeAlert([
|
||||
self.tr("Failed to open document file."), docErr
|
||||
], nwAlert.ERROR)
|
||||
|
||||
if theText is None:
|
||||
theText = ""
|
||||
@@ -157,21 +157,19 @@ class GuiDocSplit(QDialog):
|
||||
|
||||
nFiles = len(finalOrder)
|
||||
if nFiles == 0:
|
||||
self.theParent.makeAlert(
|
||||
self.tr("No headers found. Nothing to do."), nwAlert.ERROR
|
||||
)
|
||||
self.theParent.makeAlert(self.tr(
|
||||
"No headers found. Nothing to do."
|
||||
), nwAlert.ERROR)
|
||||
return False
|
||||
|
||||
# Check that another folder can be created
|
||||
parTree = self.theProject.projTree.getItemPath(srcItem.itemParent)
|
||||
if len(parTree) >= nwConst.MAX_DEPTH - 1:
|
||||
self.theParent.makeAlert(
|
||||
self.tr(
|
||||
"Cannot add new folder for the document split. "
|
||||
"Maximum folder depth has been reached. "
|
||||
"Please move the file to another level in the project tree."
|
||||
), nwAlert.ERROR
|
||||
)
|
||||
self.theParent.makeAlert(self.tr(
|
||||
"Cannot add new folder for the document split. "
|
||||
"Maximum folder depth has been reached. "
|
||||
"Please move the file to another level in the project tree."
|
||||
), nwAlert.ERROR)
|
||||
return False
|
||||
|
||||
msgYes = self.theParent.askQuestion(
|
||||
@@ -227,9 +225,9 @@ class GuiDocSplit(QDialog):
|
||||
|
||||
outDoc = NWDoc(self.theProject, nHandle)
|
||||
if not outDoc.writeDocument(theText):
|
||||
self.theParent.makeAlert(
|
||||
[self.tr("Could not save document."), outDoc.getError()], nwAlert.ERROR
|
||||
)
|
||||
self.theParent.makeAlert([
|
||||
self.tr("Could not save document."), outDoc.getError()
|
||||
], nwAlert.ERROR)
|
||||
return False
|
||||
|
||||
self.theParent.treeView.revealNewTreeItem(nHandle)
|
||||
@@ -267,9 +265,9 @@ class GuiDocSplit(QDialog):
|
||||
return False
|
||||
|
||||
if nwItem.itemType is not nwItemType.FILE:
|
||||
self.theParent.makeAlert(
|
||||
self.tr("Element selected in the project tree must be a file."), nwAlert.ERROR
|
||||
)
|
||||
self.theParent.makeAlert(self.tr(
|
||||
"Element selected in the project tree must be a file."
|
||||
), nwAlert.ERROR)
|
||||
return False
|
||||
|
||||
inDoc = NWDoc(self.theProject, self.sourceItem)
|
||||
|
||||
@@ -104,10 +104,9 @@ class GuiPreferences(PagedDialog):
|
||||
self.tabQuote.saveValues()
|
||||
|
||||
if needsRestart:
|
||||
self.theParent.makeAlert(
|
||||
self.tr("Some changes will not be applied until novelWriter has been restarted."),
|
||||
nwAlert.INFO
|
||||
)
|
||||
self.theParent.makeAlert(self.tr(
|
||||
"Some changes will not be applied until novelWriter has been restarted."
|
||||
), nwAlert.INFO)
|
||||
|
||||
self._saveWindowSize()
|
||||
self.accept()
|
||||
|
||||
@@ -397,9 +397,9 @@ class GuiProjectEditStatus(QWidget):
|
||||
self.listBox.takeTopLevelItem(iRow)
|
||||
self.colChanged = True
|
||||
else:
|
||||
self.theParent.makeAlert(
|
||||
self.tr("Cannot delete a status item that is in use."), nwAlert.ERROR
|
||||
)
|
||||
self.theParent.makeAlert(self.tr(
|
||||
"Cannot delete a status item that is in use."
|
||||
), nwAlert.ERROR)
|
||||
return
|
||||
|
||||
def _saveItem(self):
|
||||
|
||||
@@ -122,14 +122,15 @@ class GuiWordList(QDialog):
|
||||
"""
|
||||
newWord = self.newEntry.text().strip()
|
||||
if newWord == "":
|
||||
self.theParent.makeAlert(self.tr("Cannot add a blank word."), nwAlert.ERROR)
|
||||
self.theParent.makeAlert(self.tr(
|
||||
"Cannot add a blank word."
|
||||
), nwAlert.ERROR)
|
||||
return False
|
||||
|
||||
if self.listBox.findItems(newWord, Qt.MatchExactly):
|
||||
self.theParent.makeAlert(
|
||||
self.tr("The word '{0}' is already in the word list.").format(newWord),
|
||||
nwAlert.ERROR
|
||||
)
|
||||
self.theParent.makeAlert(self.tr(
|
||||
"The word '{0}' is already in the word list."
|
||||
).format(newWord), nwAlert.ERROR)
|
||||
return False
|
||||
|
||||
self.listBox.addItem(newWord)
|
||||
|
||||
Reference in New Issue
Block a user