Fix translations and refactor makeAlert calls

This commit is contained in:
Veronica Berglyd Olsen
2021-06-10 21:42:40 +02:00
parent 904ba9b1ca
commit 6e1e40f13e
15 changed files with 252 additions and 297 deletions
+25 -35
View File
@@ -315,17 +315,14 @@ class GuiDocEditor(QTextEdit):
docSize = len(theDoc)
if docSize > nwConst.MAX_DOCSIZE:
self.theParent.makeAlert(
self.tr(
"The document you are trying to open is too big. "
"The document size is {0} MB. "
"The maximum size allowed is {1} MB."
).format(
f"{docSize/1.0e6:.2f}",
f"{nwConst.MAX_DOCSIZE/1.0e6:.2f}"
),
nwAlert.ERROR
)
self.theParent.makeAlert(self.tr(
"The document you are trying to open is too big. "
"The document size is {0} MB. "
"The maximum size allowed is {1} MB."
).format(
f"{docSize/1.0e6:.2f}",
f"{nwConst.MAX_DOCSIZE/1.0e6:.2f}"
), nwAlert.ERROR)
self.clearEditor()
return False
@@ -413,17 +410,14 @@ class GuiDocEditor(QTextEdit):
"""
docSize = len(theText)
if docSize > nwConst.MAX_DOCSIZE:
self.theParent.makeAlert(
self.tr(
"The text you are trying to add is too big. "
"The text size is {0} MB. "
"The maximum size allowed is {1} MB."
).format(
f"{docSize/1.0e6:.2f}",
f"{nwConst.MAX_DOCSIZE/1.0e6:.2f}"
),
nwAlert.ERROR
)
self.theParent.makeAlert(self.tr(
"The text you are trying to add is too big. "
"The text size is {0} MB. "
"The maximum size allowed is {1} MB."
).format(
f"{docSize/1.0e6:.2f}",
f"{nwConst.MAX_DOCSIZE/1.0e6:.2f}"
), nwAlert.ERROR)
return False
qApp.setOverrideCursor(QCursor(Qt.WaitCursor))
@@ -1009,15 +1003,12 @@ class GuiDocEditor(QTextEdit):
self._lastFind = None
if self._qDocument.characterCount() > nwConst.MAX_DOCSIZE:
self.theParent.makeAlert(
self.tr(
"The document has grown too big and you cannot add more text to it. "
"The maximum size of a single novelWriter document is {0} MB."
).format(
f"{nwConst.MAX_DOCSIZE/1.0e6:.2f}"
),
nwAlert.ERROR
)
self.theParent.makeAlert(self.tr(
"The document has grown too big and you cannot add more text to it. "
"The maximum size of a single novelWriter document is {0} MB."
).format(
f"{nwConst.MAX_DOCSIZE/1.0e6:.2f}"
), nwAlert.ERROR)
self.undo()
return
@@ -1552,10 +1543,9 @@ class GuiDocEditor(QTextEdit):
self._allowAutoReplace(True)
else:
self.theParent.makeAlert(
self.tr("Please select some text before calling replace quotes."),
nwAlert.ERROR
)
self.theParent.makeAlert(self.tr(
"Please select some text before calling replace quotes."
), nwAlert.ERROR)
return