Merge branch 'dev' into text_align
This commit is contained in:
+25
-35
@@ -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
|
||||
|
||||
|
||||
+7
-8
@@ -246,14 +246,13 @@ class GuiDocViewer(QTextBrowser):
|
||||
logger.debug("Loading document from tag '%s'" % theTag)
|
||||
tHandle, _, sTitle = self.theParent.theIndex.getTagSource(theTag)
|
||||
if tHandle is None:
|
||||
self.theParent.makeAlert(
|
||||
self.tr(
|
||||
"Could not find the reference for tag '{0}'. It either doesn't "
|
||||
"exist, or the index is out of date. The index can be updated "
|
||||
"from the Tools menu, or by pressing {1}."
|
||||
).format(theTag, "F9"),
|
||||
nwAlert.ERROR
|
||||
)
|
||||
self.theParent.makeAlert(self.tr(
|
||||
"Could not find the reference for tag '{0}'. It either doesn't "
|
||||
"exist, or the index is out of date. The index can be updated "
|
||||
"from the Tools menu, or by pressing {1}."
|
||||
).format(
|
||||
theTag, "F9"
|
||||
), nwAlert.ERROR)
|
||||
return False
|
||||
else:
|
||||
# Let the parent handle the opening as it also ensures that
|
||||
|
||||
+16
-4
@@ -468,28 +468,40 @@ class GuiMainMenu(QMenuBar):
|
||||
# View > TreeView
|
||||
self.aFocusTree = QAction(self.tr("Focus Project Tree"), self)
|
||||
self.aFocusTree.setStatusTip(self.tr("Move focus to project tree"))
|
||||
self.aFocusTree.setShortcut("Alt+1")
|
||||
if self.mainConf.osWindows:
|
||||
self.aFocusTree.setShortcut("Ctrl+Alt+1")
|
||||
else:
|
||||
self.aFocusTree.setShortcut("Alt+1")
|
||||
self.aFocusTree.triggered.connect(lambda: self.theParent.switchFocus(nwWidget.TREE))
|
||||
self.viewMenu.addAction(self.aFocusTree)
|
||||
|
||||
# View > Document Pane 1
|
||||
self.aFocusEditor = QAction(self.tr("Focus Document Editor"), self)
|
||||
self.aFocusEditor.setStatusTip(self.tr("Move focus to left document pane"))
|
||||
self.aFocusEditor.setShortcut("Alt+2")
|
||||
if self.mainConf.osWindows:
|
||||
self.aFocusEditor.setShortcut("Ctrl+Alt+2")
|
||||
else:
|
||||
self.aFocusEditor.setShortcut("Alt+2")
|
||||
self.aFocusEditor.triggered.connect(lambda: self.theParent.switchFocus(nwWidget.EDITOR))
|
||||
self.viewMenu.addAction(self.aFocusEditor)
|
||||
|
||||
# View > Document Pane 2
|
||||
self.aFocusView = QAction(self.tr("Focus Document Viewer"), self)
|
||||
self.aFocusView.setStatusTip(self.tr("Move focus to right document pane"))
|
||||
self.aFocusView.setShortcut("Alt+3")
|
||||
if self.mainConf.osWindows:
|
||||
self.aFocusView.setShortcut("Ctrl+Alt+3")
|
||||
else:
|
||||
self.aFocusView.setShortcut("Alt+3")
|
||||
self.aFocusView.triggered.connect(lambda: self.theParent.switchFocus(nwWidget.VIEWER))
|
||||
self.viewMenu.addAction(self.aFocusView)
|
||||
|
||||
# View > Outline
|
||||
self.aFocusOutline = QAction(self.tr("Focus Outline"), self)
|
||||
self.aFocusOutline.setStatusTip(self.tr("Move focus to outline"))
|
||||
self.aFocusOutline.setShortcut("Alt+4")
|
||||
if self.mainConf.osWindows:
|
||||
self.aFocusOutline.setShortcut("Ctrl+Alt+4")
|
||||
else:
|
||||
self.aFocusOutline.setShortcut("Alt+4")
|
||||
self.aFocusOutline.triggered.connect(lambda: self.theParent.switchFocus(nwWidget.OUTLINE))
|
||||
self.viewMenu.addAction(self.aFocusOutline)
|
||||
|
||||
|
||||
@@ -99,9 +99,6 @@ class GuiNovelTree(QTreeWidget):
|
||||
|
||||
logger.debug("GuiNovelTree initialisation complete")
|
||||
|
||||
# Internal Mapping
|
||||
self.makeAlert = self.theParent.makeAlert
|
||||
|
||||
return
|
||||
|
||||
def initTree(self):
|
||||
|
||||
+33
-31
@@ -197,15 +197,13 @@ class GuiProjectTree(QTreeWidget):
|
||||
# If class is still not set, alert the user and exit
|
||||
if itemClass is None:
|
||||
if itemType == nwItemType.FILE:
|
||||
self.makeAlert(
|
||||
self.tr("Please select a valid location in the tree to add the document."),
|
||||
nwAlert.ERROR
|
||||
)
|
||||
self.makeAlert(self.tr(
|
||||
"Please select a valid location in the tree to add the document."
|
||||
), nwAlert.ERROR)
|
||||
else:
|
||||
self.makeAlert(
|
||||
self.tr("Please select a valid location in the tree to add the folder."),
|
||||
nwAlert.ERROR
|
||||
)
|
||||
self.makeAlert(self.tr(
|
||||
"Please select a valid location in the tree to add the folder."
|
||||
), nwAlert.ERROR)
|
||||
return False
|
||||
|
||||
# Everything is fine, we have what we need, so we proceed
|
||||
@@ -227,9 +225,9 @@ class GuiProjectTree(QTreeWidget):
|
||||
|
||||
# If still nothing, give up
|
||||
if pHandle is None:
|
||||
self.makeAlert(
|
||||
self.tr("Did not find anywhere to add the file or folder!"), nwAlert.ERROR
|
||||
)
|
||||
self.makeAlert(self.tr(
|
||||
"Did not find anywhere to add the file or folder!"
|
||||
), nwAlert.ERROR)
|
||||
return False
|
||||
|
||||
# Now check if the selected item is a file, in which case
|
||||
@@ -241,15 +239,15 @@ class GuiProjectTree(QTreeWidget):
|
||||
|
||||
# If we again have no home, give up
|
||||
if pHandle is None:
|
||||
self.makeAlert(
|
||||
self.tr("Did not find anywhere to add the file or folder!"), nwAlert.ERROR
|
||||
)
|
||||
self.makeAlert(self.tr(
|
||||
"Did not find anywhere to add the file or folder!"
|
||||
), nwAlert.ERROR)
|
||||
return False
|
||||
|
||||
if self.theProject.projTree.isTrashRoot(pHandle):
|
||||
self.makeAlert(
|
||||
self.tr("Cannot add new files or folders to the Trash folder."), nwAlert.ERROR
|
||||
)
|
||||
self.makeAlert(self.tr(
|
||||
"Cannot add new files or folders to the Trash folder."
|
||||
), nwAlert.ERROR)
|
||||
return False
|
||||
|
||||
parTree = self.theProject.projTree.getItemPath(pHandle)
|
||||
@@ -262,9 +260,9 @@ class GuiProjectTree(QTreeWidget):
|
||||
if len(parTree) >= nwConst.MAX_DEPTH - 1:
|
||||
# Folders cannot be deeper than MAX_DEPTH - 1, leaving room
|
||||
# for one more level of files.
|
||||
self.makeAlert((
|
||||
self.tr("Cannot add new folder to this item."),
|
||||
self.tr("Maximum folder depth has been reached.")
|
||||
self.makeAlert(self.tr(
|
||||
"Cannot add new folder to this item. "
|
||||
"Maximum folder depth has been reached."
|
||||
), nwAlert.ERROR)
|
||||
return False
|
||||
tHandle = self.theProject.newFolder(self.tr("New Folder"), itemClass, pHandle)
|
||||
@@ -433,9 +431,9 @@ class GuiProjectTree(QTreeWidget):
|
||||
|
||||
logger.debug("Emptying Trash folder")
|
||||
if trashHandle is None:
|
||||
self.makeAlert(
|
||||
self.tr("There is currently no Trash folder in this project."), nwAlert.INFO
|
||||
)
|
||||
self.makeAlert(self.tr(
|
||||
"There is currently no Trash folder in this project."
|
||||
), nwAlert.INFO)
|
||||
return False
|
||||
|
||||
theTrash = self.getTreeFromHandle(trashHandle)
|
||||
@@ -444,7 +442,9 @@ class GuiProjectTree(QTreeWidget):
|
||||
|
||||
nTrash = len(theTrash)
|
||||
if nTrash == 0:
|
||||
self.makeAlert(self.tr("The Trash folder is already empty."), nwAlert.INFO)
|
||||
self.makeAlert(self.tr(
|
||||
"The Trash folder is already empty."
|
||||
), nwAlert.INFO)
|
||||
return False
|
||||
|
||||
msgYes = self.askQuestion(
|
||||
@@ -857,7 +857,9 @@ class GuiProjectTree(QTreeWidget):
|
||||
snItem = self.theProject.projTree[sHandle]
|
||||
dnItem = self.theProject.projTree[dHandle]
|
||||
if dnItem is None:
|
||||
self.makeAlert(self.tr("The item cannot be moved to that location."), nwAlert.ERROR)
|
||||
self.makeAlert(self.tr(
|
||||
"The item cannot be moved to that location."
|
||||
), nwAlert.ERROR)
|
||||
return
|
||||
|
||||
pItem = sItem.parent()
|
||||
@@ -888,7 +890,9 @@ class GuiProjectTree(QTreeWidget):
|
||||
else:
|
||||
theEvent.ignore()
|
||||
logger.debug("Drag'n'drop of item %s not accepted" % sHandle)
|
||||
self.makeAlert(self.tr("The item cannot be moved to that location."), nwAlert.ERROR)
|
||||
self.makeAlert(self.tr(
|
||||
"The item cannot be moved to that location."
|
||||
), nwAlert.ERROR)
|
||||
|
||||
return
|
||||
|
||||
@@ -985,11 +989,9 @@ class GuiProjectTree(QTreeWidget):
|
||||
elif nwItem.itemType == nwItemType.TRASH:
|
||||
self.addTopLevelItem(newItem)
|
||||
else:
|
||||
self.makeAlert(
|
||||
self.tr(
|
||||
"There is nowhere to add item with name '{0}'."
|
||||
).format(nwItem.itemName), nwAlert.ERROR
|
||||
)
|
||||
self.makeAlert(self.tr(
|
||||
"There is nowhere to add item with name '{0}'."
|
||||
).format(nwItem.itemName), nwAlert.ERROR)
|
||||
del self._treeMap[tHandle]
|
||||
return None
|
||||
|
||||
|
||||
+9
-9
@@ -397,9 +397,9 @@ class GuiTheme:
|
||||
with open(themeConf, mode="r", encoding="utf8") as inFile:
|
||||
confParser.read_file(inFile)
|
||||
except Exception as e:
|
||||
self.makeAlert(
|
||||
[self.tr("Could not load theme config file."), str(e)], nwAlert.ERROR
|
||||
)
|
||||
self.makeAlert([
|
||||
self.tr("Could not load theme config file."), str(e)
|
||||
], nwAlert.ERROR)
|
||||
continue
|
||||
themeName = ""
|
||||
if confParser.has_section("Main"):
|
||||
@@ -430,9 +430,9 @@ class GuiTheme:
|
||||
with open(syntaxPath, mode="r", encoding="utf8") as inFile:
|
||||
confParser.read_file(inFile)
|
||||
except Exception as e:
|
||||
self.makeAlert(
|
||||
[self.tr("Could not load syntax file."), str(e)], nwAlert.ERROR
|
||||
)
|
||||
self.makeAlert([
|
||||
self.tr("Could not load syntax file."), str(e)
|
||||
], nwAlert.ERROR)
|
||||
return []
|
||||
syntaxName = ""
|
||||
if confParser.has_section("Main"):
|
||||
@@ -745,9 +745,9 @@ class GuiIcons:
|
||||
with open(themeConf, mode="r", encoding="utf8") as inFile:
|
||||
confParser.read_file(inFile)
|
||||
except Exception as e:
|
||||
self.makeAlert(
|
||||
[self.tr("Could not load theme config file."), str(e)], nwAlert.ERROR
|
||||
)
|
||||
self.makeAlert([
|
||||
self.tr("Could not load theme config file."), str(e)
|
||||
], nwAlert.ERROR)
|
||||
continue
|
||||
themeName = ""
|
||||
if confParser.has_section("Main"):
|
||||
|
||||
Reference in New Issue
Block a user