+4
-4
@@ -471,14 +471,14 @@ class NWProject():
|
|||||||
# read the file. Introduced in version 0.10.
|
# read the file. Introduced in version 0.10.
|
||||||
|
|
||||||
if fileVersion == "1.0":
|
if fileVersion == "1.0":
|
||||||
msgRes = self.theParent.askQuestion("Old Project Version", (
|
msgYes = self.theParent.askQuestion("Old Project Version", (
|
||||||
"The project file and data is created by a novelWriter version "
|
"The project file and data is created by a novelWriter version "
|
||||||
"lower than 0.7. Do you want to upgrade the project to the "
|
"lower than 0.7. Do you want to upgrade the project to the "
|
||||||
"most recent format?<br><br>Note that after the upgrade, you "
|
"most recent format?<br><br>Note that after the upgrade, you "
|
||||||
"cannot open the project with an older version of novelWriter "
|
"cannot open the project with an older version of novelWriter "
|
||||||
"any more, so make sure you have a recent backup."
|
"any more, so make sure you have a recent backup."
|
||||||
))
|
))
|
||||||
if not msgRes:
|
if not msgYes:
|
||||||
self.clearProject()
|
self.clearProject()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@@ -497,7 +497,7 @@ class NWProject():
|
|||||||
# =========================
|
# =========================
|
||||||
|
|
||||||
if int(hexVersion, 16) > int(nw.__hexversion__, 16):
|
if int(hexVersion, 16) > int(nw.__hexversion__, 16):
|
||||||
msgRes = self.theParent.askQuestion("Version Conflict", (
|
msgYes = self.theParent.askQuestion("Version Conflict", (
|
||||||
"This project was saved by a newer version of novelWriter, version %s. "
|
"This project was saved by a newer version of novelWriter, version %s. "
|
||||||
"This is version %s. If you continue to open the project, some attributes "
|
"This is version %s. If you continue to open the project, some attributes "
|
||||||
"and settings may not be preserved, but the overall project should be fine. "
|
"and settings may not be preserved, but the overall project should be fine. "
|
||||||
@@ -505,7 +505,7 @@ class NWProject():
|
|||||||
) % (
|
) % (
|
||||||
appVersion, nw.__version__
|
appVersion, nw.__version__
|
||||||
))
|
))
|
||||||
if not msgRes:
|
if not msgYes:
|
||||||
self.clearProject()
|
self.clearProject()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -1114,8 +1114,8 @@ class GuiBuildNovelDocView(QTextBrowser):
|
|||||||
self.qDocument.setDocumentMargin(self.mainConf.getTextMargin())
|
self.qDocument.setDocumentMargin(self.mainConf.getTextMargin())
|
||||||
self.setPlaceholderText(
|
self.setPlaceholderText(
|
||||||
"This area will show the content of the document to be "
|
"This area will show the content of the document to be "
|
||||||
"exported or printed. Press the \"Build Novel Project\" "
|
"exported or printed. Press the \"Build Project\" button "
|
||||||
"button to generate content."
|
"to generate content."
|
||||||
)
|
)
|
||||||
|
|
||||||
theFont = QFont()
|
theFont = QFont()
|
||||||
|
|||||||
+7
-10
@@ -31,7 +31,7 @@ import logging
|
|||||||
from PyQt5.QtCore import Qt
|
from PyQt5.QtCore import Qt
|
||||||
from PyQt5.QtWidgets import (
|
from PyQt5.QtWidgets import (
|
||||||
QDialog, QVBoxLayout, QComboBox, QListWidget, QAbstractItemView,
|
QDialog, QVBoxLayout, QComboBox, QListWidget, QAbstractItemView,
|
||||||
QListWidgetItem, QDialogButtonBox, QLabel, QMessageBox
|
QListWidgetItem, QDialogButtonBox, QLabel
|
||||||
)
|
)
|
||||||
|
|
||||||
from nw.core import NWDoc
|
from nw.core import NWDoc
|
||||||
@@ -163,15 +163,12 @@ class GuiDocSplit(QDialog):
|
|||||||
), nwAlert.ERROR)
|
), nwAlert.ERROR)
|
||||||
return
|
return
|
||||||
|
|
||||||
msgBox = QMessageBox()
|
msgYes = self.theParent.askQuestion("Split Document", (
|
||||||
msgRes = msgBox.question(
|
"The document will be split into %d file(s) in a new folder. "
|
||||||
self, "Split Document", (
|
"The original document will remain intact.<br><br>"
|
||||||
"The document will be split into %d file(s) in a new folder. "
|
"Continue with the splitting process?"
|
||||||
"The original document will remain intact.<br><br>"
|
) % nFiles)
|
||||||
"Continue with the splitting process?"
|
if not msgYes:
|
||||||
) % nFiles
|
|
||||||
)
|
|
||||||
if msgRes != QMessageBox.Yes:
|
|
||||||
return
|
return
|
||||||
|
|
||||||
# Create the folder
|
# Create the folder
|
||||||
|
|||||||
+4
-5
@@ -36,7 +36,7 @@ from PyQt5.QtGui import QKeySequence
|
|||||||
from PyQt5.QtWidgets import (
|
from PyQt5.QtWidgets import (
|
||||||
QDialog, QHBoxLayout, QVBoxLayout, QGridLayout, QPushButton, QTreeWidget,
|
QDialog, QHBoxLayout, QVBoxLayout, QGridLayout, QPushButton, QTreeWidget,
|
||||||
QAbstractItemView, QTreeWidgetItem, QDialogButtonBox, QLabel, QShortcut,
|
QAbstractItemView, QTreeWidgetItem, QDialogButtonBox, QLabel, QShortcut,
|
||||||
QFileDialog, QLineEdit, QMessageBox
|
QFileDialog, QLineEdit
|
||||||
)
|
)
|
||||||
|
|
||||||
from nw.common import formatInt
|
from nw.common import formatInt
|
||||||
@@ -218,12 +218,11 @@ class GuiProjectLoad(QDialog):
|
|||||||
"""
|
"""
|
||||||
selList = self.listBox.selectedItems()
|
selList = self.listBox.selectedItems()
|
||||||
if selList:
|
if selList:
|
||||||
msgBox = QMessageBox()
|
msgYes = self.theParent.askQuestion(
|
||||||
msgRes = msgBox.question(
|
"Remove Entry",
|
||||||
self, "Remove Entry",
|
|
||||||
"Remove the selected entry from the recent projects list?"
|
"Remove the selected entry from the recent projects list?"
|
||||||
)
|
)
|
||||||
if msgRes == QMessageBox.Yes:
|
if msgYes:
|
||||||
self.mainConf.removeFromRecentCache(
|
self.mainConf.removeFromRecentCache(
|
||||||
selList[0].data(self.C_NAME, Qt.UserRole)
|
selList[0].data(self.C_NAME, Qt.UserRole)
|
||||||
)
|
)
|
||||||
|
|||||||
+45
-35
@@ -32,8 +32,7 @@ import logging
|
|||||||
from PyQt5.QtCore import Qt, QSize
|
from PyQt5.QtCore import Qt, QSize
|
||||||
from PyQt5.QtGui import QIcon
|
from PyQt5.QtGui import QIcon
|
||||||
from PyQt5.QtWidgets import (
|
from PyQt5.QtWidgets import (
|
||||||
qApp, QTreeWidget, QTreeWidgetItem, QAbstractItemView, QMessageBox,
|
qApp, QTreeWidget, QTreeWidgetItem, QAbstractItemView, QMenu, QAction
|
||||||
QMenu, QAction
|
|
||||||
)
|
)
|
||||||
|
|
||||||
from nw.core import NWDoc
|
from nw.core import NWDoc
|
||||||
@@ -391,13 +390,12 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
self.makeAlert("The Trash folder is already empty.", nwAlert.INFO)
|
self.makeAlert("The Trash folder is already empty.", nwAlert.INFO)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
msgBox = QMessageBox()
|
msgYes = self.theParent.askQuestion(
|
||||||
msgRes = msgBox.question(
|
"Empty Trash", "Permanently delete %d file%s from Trash?" % (
|
||||||
self, "Empty Trash", "Permanently delete %d file%s from Trash?" % (
|
|
||||||
nTrash, "s" if nTrash > 1 else ""
|
nTrash, "s" if nTrash > 1 else ""
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
if msgRes != QMessageBox.Yes:
|
if not msgYes:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
logger.verbose("Deleting %d files from Trash" % nTrash)
|
logger.verbose("Deleting %d files from Trash" % nTrash)
|
||||||
@@ -449,11 +447,10 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
# user if they want to permanently delete the file.
|
# user if they want to permanently delete the file.
|
||||||
doPermanent = False
|
doPermanent = False
|
||||||
if not alreadyAsked:
|
if not alreadyAsked:
|
||||||
msgBox = QMessageBox()
|
msgYes = self.theParent.askQuestion(
|
||||||
msgRes = msgBox.question(
|
"Delete File", "Permanently delete file '%s'?" % nwItemS.itemName
|
||||||
self, "Delete File", "Permanently delete file '%s'?" % nwItemS.itemName
|
|
||||||
)
|
)
|
||||||
if msgRes == QMessageBox.Yes:
|
if msgYes:
|
||||||
doPermanent = True
|
doPermanent = True
|
||||||
else:
|
else:
|
||||||
doPermanent = True
|
doPermanent = True
|
||||||
@@ -478,11 +475,10 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
# move it there.
|
# move it there.
|
||||||
doTrash = False
|
doTrash = False
|
||||||
if askForTrash:
|
if askForTrash:
|
||||||
msgBox = QMessageBox()
|
msgYes = self.theParent.askQuestion(
|
||||||
msgRes = msgBox.question(
|
"Delete File", "Move file '%s' to Trash?" % nwItemS.itemName
|
||||||
self, "Delete File", "Move file '%s' to Trash?" % nwItemS.itemName
|
|
||||||
)
|
)
|
||||||
if msgRes == QMessageBox.Yes:
|
if msgYes:
|
||||||
doTrash = True
|
doTrash = True
|
||||||
else:
|
else:
|
||||||
doTrash = True
|
doTrash = True
|
||||||
@@ -994,6 +990,10 @@ class GuiProjectTreeMenu(QMenu):
|
|||||||
self.theTree = theTree
|
self.theTree = theTree
|
||||||
self.theItem = None
|
self.theItem = None
|
||||||
|
|
||||||
|
self.editItem = QAction("Edit Project Item", self)
|
||||||
|
self.editItem.triggered.connect(self._doEditItem)
|
||||||
|
self.addAction(self.editItem)
|
||||||
|
|
||||||
self.openItem = QAction("Open Document", self)
|
self.openItem = QAction("Open Document", self)
|
||||||
self.openItem.triggered.connect(self._doOpenItem)
|
self.openItem.triggered.connect(self._doOpenItem)
|
||||||
self.addAction(self.openItem)
|
self.addAction(self.openItem)
|
||||||
@@ -1002,10 +1002,6 @@ class GuiProjectTreeMenu(QMenu):
|
|||||||
self.viewItem.triggered.connect(self._doViewItem)
|
self.viewItem.triggered.connect(self._doViewItem)
|
||||||
self.addAction(self.viewItem)
|
self.addAction(self.viewItem)
|
||||||
|
|
||||||
self.editItem = QAction("Edit Project Item", self)
|
|
||||||
self.editItem.triggered.connect(self._doEditItem)
|
|
||||||
self.addAction(self.editItem)
|
|
||||||
|
|
||||||
self.toggleExp = QAction("Toggle Included Flag", self)
|
self.toggleExp = QAction("Toggle Included Flag", self)
|
||||||
self.toggleExp.triggered.connect(self._doToggleExported)
|
self.toggleExp.triggered.connect(self._doToggleExported)
|
||||||
self.addAction(self.toggleExp)
|
self.addAction(self.toggleExp)
|
||||||
@@ -1026,6 +1022,14 @@ class GuiProjectTreeMenu(QMenu):
|
|||||||
self.emptyTrash.triggered.connect(self._doEmptyTrash)
|
self.emptyTrash.triggered.connect(self._doEmptyTrash)
|
||||||
self.addAction(self.emptyTrash)
|
self.addAction(self.emptyTrash)
|
||||||
|
|
||||||
|
self.moveUp = QAction("Move Item Up", self)
|
||||||
|
self.moveUp.triggered.connect(self._doMoveUp)
|
||||||
|
self.addAction(self.moveUp)
|
||||||
|
|
||||||
|
self.moveDown = QAction("Move Item Down", self)
|
||||||
|
self.moveDown.triggered.connect(self._doMoveDown)
|
||||||
|
self.addAction(self.moveDown)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def filterActions(self, theItem):
|
def filterActions(self, theItem):
|
||||||
@@ -1045,23 +1049,17 @@ class GuiProjectTreeMenu(QMenu):
|
|||||||
isFile = theItem.itemType == nwItemType.FILE
|
isFile = theItem.itemType == nwItemType.FILE
|
||||||
isOrph = isFile and theItem.itemParent is None
|
isOrph = isFile and theItem.itemParent is None
|
||||||
|
|
||||||
showOpen = isFile
|
allowEdit = not (isTrash or isOrph)
|
||||||
showView = isFile
|
allowNew = not (isTrash or inTrash or isOrph)
|
||||||
showEdit = not isTrash and not isOrph
|
|
||||||
showExport = isFile
|
|
||||||
showNewFile = not (isTrash or inTrash or isOrph)
|
|
||||||
showNewFolder = not (isTrash or inTrash or isOrph)
|
|
||||||
showDelete = not isTrash
|
|
||||||
showEmpty = isTrash
|
|
||||||
|
|
||||||
self.openItem.setVisible(showOpen)
|
self.editItem.setVisible(allowEdit)
|
||||||
self.viewItem.setVisible(showView)
|
self.openItem.setVisible(isFile)
|
||||||
self.editItem.setVisible(showEdit)
|
self.viewItem.setVisible(isFile)
|
||||||
self.toggleExp.setVisible(showExport)
|
self.toggleExp.setVisible(isFile)
|
||||||
self.newFile.setVisible(showNewFile)
|
self.newFile.setVisible(allowNew)
|
||||||
self.newFolder.setVisible(showNewFolder)
|
self.newFolder.setVisible(allowNew)
|
||||||
self.deleteItem.setVisible(showDelete)
|
self.deleteItem.setVisible(not isTrash)
|
||||||
self.emptyTrash.setVisible(showEmpty)
|
self.emptyTrash.setVisible(isTrash)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@@ -1120,9 +1118,21 @@ class GuiProjectTreeMenu(QMenu):
|
|||||||
return
|
return
|
||||||
|
|
||||||
def _doEmptyTrash(self):
|
def _doEmptyTrash(self):
|
||||||
"""Forward the delete item call to the project tree.
|
"""Forward the empty trash call to the project tree.
|
||||||
"""
|
"""
|
||||||
self.theTree.emptyTrash()
|
self.theTree.emptyTrash()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def _doMoveUp(self):
|
||||||
|
"""Forward the move item call to the project tree.
|
||||||
|
"""
|
||||||
|
self.theTree.moveTreeItem(-1)
|
||||||
|
return
|
||||||
|
|
||||||
|
def _doMoveDown(self):
|
||||||
|
"""Forward the move item call to the project tree.
|
||||||
|
"""
|
||||||
|
self.theTree.moveTreeItem(1)
|
||||||
|
return
|
||||||
|
|
||||||
# END Class GuiProjectTreeMenu
|
# END Class GuiProjectTreeMenu
|
||||||
|
|||||||
@@ -403,8 +403,12 @@ class GuiWritingStats(QDialog):
|
|||||||
ttNotes = 0
|
ttNotes = 0
|
||||||
ttTime = 0
|
ttTime = 0
|
||||||
|
|
||||||
|
logFile = os.path.join(self.theProject.projMeta, nwFiles.SESS_STATS)
|
||||||
|
if not os.path.isfile(logFile):
|
||||||
|
logger.info("This project has no writing stats logfile")
|
||||||
|
return False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
logFile = os.path.join(self.theProject.projMeta, nwFiles.SESS_STATS)
|
|
||||||
with open(logFile, mode="r", encoding="utf8") as inFile:
|
with open(logFile, mode="r", encoding="utf8") as inFile:
|
||||||
for inLine in inFile:
|
for inLine in inFile:
|
||||||
if inLine.startswith("#"):
|
if inLine.startswith("#"):
|
||||||
|
|||||||
+11
-15
@@ -320,12 +320,11 @@ class GuiMain(QMainWindow):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
if not isYes:
|
if not isYes:
|
||||||
msgBox = QMessageBox()
|
msgYes = self.askQuestion(
|
||||||
msgRes = msgBox.question(
|
"Close Project",
|
||||||
self, "Close Project",
|
|
||||||
"Close the current project?<br>Changes are saved automatically."
|
"Close the current project?<br>Changes are saved automatically."
|
||||||
)
|
)
|
||||||
if msgRes != QMessageBox.Yes:
|
if not msgYes:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if self.docEditor.docChanged:
|
if self.docEditor.docChanged:
|
||||||
@@ -337,11 +336,10 @@ class GuiMain(QMainWindow):
|
|||||||
if self.theProject.doBackup and self.mainConf.backupOnClose:
|
if self.theProject.doBackup and self.mainConf.backupOnClose:
|
||||||
doBackup = True
|
doBackup = True
|
||||||
if self.mainConf.askBeforeBackup:
|
if self.mainConf.askBeforeBackup:
|
||||||
msgBox = QMessageBox()
|
msgYes = self.askQuestion(
|
||||||
msgRes = msgBox.question(
|
"Backup Project", "Backup the current project?"
|
||||||
self, "Backup Project", "Backup the current project?"
|
|
||||||
)
|
)
|
||||||
if msgRes != QMessageBox.Yes:
|
if not msgYes:
|
||||||
doBackup = False
|
doBackup = False
|
||||||
if doBackup:
|
if doBackup:
|
||||||
self.theProject.zipIt(False)
|
self.theProject.zipIt(False)
|
||||||
@@ -640,12 +638,11 @@ class GuiMain(QMainWindow):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
if not self.docEditor.isEmpty():
|
if not self.docEditor.isEmpty():
|
||||||
msgBox = QMessageBox()
|
msgYes = self.askQuestion("Import Document", (
|
||||||
msgRes = msgBox.question(self, "Import Document", (
|
|
||||||
"Importing the file will overwrite the current content of the document. "
|
"Importing the file will overwrite the current content of the document. "
|
||||||
"Do you want to proceed?"
|
"Do you want to proceed?"
|
||||||
))
|
))
|
||||||
if msgRes != QMessageBox.Yes:
|
if not msgYes:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
self.docEditor.replaceText(theText)
|
self.docEditor.replaceText(theText)
|
||||||
@@ -1007,12 +1004,11 @@ class GuiMain(QMainWindow):
|
|||||||
"""Save everything, and close novelWriter.
|
"""Save everything, and close novelWriter.
|
||||||
"""
|
"""
|
||||||
if self.hasProject:
|
if self.hasProject:
|
||||||
msgBox = QMessageBox()
|
msgYes = self.askQuestion(
|
||||||
msgRes = msgBox.question(
|
"Exit",
|
||||||
self, "Exit",
|
|
||||||
"Do you want to exit novelWriter?<br>Changes are saved automatically."
|
"Do you want to exit novelWriter?<br>Changes are saved automatically."
|
||||||
)
|
)
|
||||||
if msgRes != QMessageBox.Yes:
|
if not msgYes:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
logger.info("Exiting novelWriter")
|
logger.info("Exiting novelWriter")
|
||||||
|
|||||||
@@ -203,6 +203,7 @@ def testGuiWritingStats_Dialog(qtbot, monkeypatch, nwGUI, fncDir, fncProj):
|
|||||||
# IOError
|
# IOError
|
||||||
# =======
|
# =======
|
||||||
monkeypatch.setattr("builtins.open", causeOSError)
|
monkeypatch.setattr("builtins.open", causeOSError)
|
||||||
|
assert not sessLog._loadLogFile()
|
||||||
assert not sessLog._saveData(sessLog.FMT_CSV)
|
assert not sessLog._saveData(sessLog.FMT_CSV)
|
||||||
|
|
||||||
# qtbot.stopForInteraction()
|
# qtbot.stopForInteraction()
|
||||||
|
|||||||
Reference in New Issue
Block a user