Added a log file that appends session stats.
This commit is contained in:
@@ -17,6 +17,7 @@ class nwFiles():
|
||||
APP_ICON = "novelWriter.svg"
|
||||
PROJ_FILE = "nwProject.nwx"
|
||||
PROJ_DICT = "wordlist.txt"
|
||||
SESS_INFO = "sessionInfo.log"
|
||||
|
||||
# END Class nwFiles
|
||||
|
||||
|
||||
+2
-1
@@ -237,7 +237,7 @@ class GuiMain(QMainWindow):
|
||||
saveOK = True
|
||||
|
||||
if saveOK:
|
||||
self.theProject.clearProject()
|
||||
self.theProject.closeProject()
|
||||
self.clearGUI()
|
||||
self.hasProject = False
|
||||
|
||||
@@ -451,6 +451,7 @@ class GuiMain(QMainWindow):
|
||||
self.saveDocument()
|
||||
if self._takeProjectAction():
|
||||
self.saveProject()
|
||||
self.theProject.closeProject()
|
||||
self.mainConf.setWinSize(self.width(), self.height())
|
||||
self.mainConf.setTreeColWidths(self.treeView.getColumnSizes())
|
||||
self.mainConf.setMainPanePos(self.splitMain.sizes())
|
||||
|
||||
@@ -35,6 +35,7 @@ class NWProject():
|
||||
self.theParent = theParent
|
||||
self.mainConf = self.theParent.mainConf
|
||||
self.projChanged = None
|
||||
self.projOpened = None
|
||||
|
||||
# Debug
|
||||
self.handleSeed = None
|
||||
@@ -135,6 +136,7 @@ class NWProject():
|
||||
def clearProject(self):
|
||||
|
||||
self.projChanged = None
|
||||
self.projOpened = None
|
||||
|
||||
# Project Settings
|
||||
self.projTree = {}
|
||||
@@ -251,6 +253,7 @@ class NWProject():
|
||||
|
||||
self._scanProjectFolder()
|
||||
self.setProjectChanged(False)
|
||||
self.projOpened = time()
|
||||
|
||||
return True
|
||||
|
||||
@@ -321,6 +324,11 @@ class NWProject():
|
||||
|
||||
return True
|
||||
|
||||
def closeProject(self):
|
||||
self._appendSessionStats()
|
||||
self.clearProject()
|
||||
return True
|
||||
|
||||
##
|
||||
# Set Functions
|
||||
##
|
||||
@@ -594,6 +602,24 @@ class NWProject():
|
||||
|
||||
return
|
||||
|
||||
def _appendSessionStats(self):
|
||||
|
||||
if self.projMeta is None:
|
||||
return False
|
||||
|
||||
with open(path.join(self.projMeta, nwFiles.SESS_INFO), mode="a+") as outFile:
|
||||
print((
|
||||
"Start: {opened:s} "
|
||||
"End: {closed:s} "
|
||||
"Words: {words:8d}"
|
||||
).format(
|
||||
opened = datetime.fromtimestamp(self.projOpened).strftime("%Y-%m-%d %H:%M:%S"),
|
||||
closed = datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
|
||||
words = self.getSessionWordCount(),
|
||||
), file=outFile)
|
||||
|
||||
return True
|
||||
|
||||
def _makeHandle(self, addSeed=""):
|
||||
if self.handleSeed is None:
|
||||
newSeed = str(time()) + addSeed
|
||||
|
||||
@@ -13,8 +13,12 @@ Some text here would look good as well, and maybe some "dialogue"?
|
||||
|
||||
So, this is some __text__ that we’ve been adding to this document. It is utterly meaningless text, _but_ since this is just dummy text, that doesn’t really matter. The text is perfectly happy to live in this document regardless.
|
||||
|
||||
This paragraph is also meaningless. At least a bit. It’s also very short.
|
||||
This paragraph is also meaningless. At least a bit. It’s also very short. But we could make it less meaningless if we wanted to …
|
||||
|
||||
This one is a bit longer. “It also has some dialogue in it” she said, before she moved on to check if the spellchecker worked. It did. “Cool,” she concluded.
|
||||
|
||||
|
||||
@ToDo: Stuff that will be done at some point
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
Start: 2019-05-26 14:28:28 End: 2019-05-26 14:28:38 Words: -23
|
||||
Start: 2019-05-26 14:31:12 End: 2019-05-26 14:31:34 Words: 12
|
||||
Start: 2019-05-26 14:33:27 End: 2019-05-26 14:33:31 Words: 0
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<novelWriterXML appVersion="0.1.4" fileVersion="1.0" timeStamp="2019-05-25 23:24:06">
|
||||
<novelWriterXML appVersion="0.1.4" fileVersion="1.0" timeStamp="2019-05-26 14:33:31">
|
||||
<project>
|
||||
<name>Sample Project</name>
|
||||
<title>Sample Project</title>
|
||||
@@ -10,7 +10,7 @@
|
||||
<spellCheck>True</spellCheck>
|
||||
<lastEdited>636b6aa9b697b</lastEdited>
|
||||
<lastViewed>None</lastViewed>
|
||||
<lastWordCount>523</lastWordCount>
|
||||
<lastWordCount>535</lastWordCount>
|
||||
<status>
|
||||
<entry blue="100" green="100" red="100">New</entry>
|
||||
<entry blue="0" green="50" red="200">Notes</entry>
|
||||
@@ -73,10 +73,10 @@
|
||||
<status>Notes</status>
|
||||
<expanded>False</expanded>
|
||||
<layout>SCENE</layout>
|
||||
<charCount>577</charCount>
|
||||
<wordCount>104</wordCount>
|
||||
<charCount>633</charCount>
|
||||
<wordCount>116</wordCount>
|
||||
<paraCount>5</paraCount>
|
||||
<cursorPos>655</cursorPos>
|
||||
<cursorPos>551</cursorPos>
|
||||
</item>
|
||||
<item handle="bc0cbd2a407f3" order="2" parent="e7ded148d6e4a">
|
||||
<name>New File</name>
|
||||
|
||||
Reference in New Issue
Block a user