Add idle time to session log and writing stats dialog

This commit is contained in:
Veronica K. B. Olsen
2021-02-08 23:17:33 +01:00
parent 407f12760c
commit 3521d4a4f7
4 changed files with 63 additions and 32 deletions
+1
View File
@@ -47,6 +47,7 @@ class OptionState():
"widthCol0",
"widthCol1",
"widthCol2",
"widthCol3",
"sortCol",
"sortOrder",
"incNovel",
+7 -6
View File
@@ -726,12 +726,12 @@ class NWProject():
return True
def closeProject(self):
def closeProject(self, idleTime=0):
"""Close the current project and clear all meta data.
"""
self.optState.saveSettings()
self.projTree.writeToCFile()
self._appendSessionStats()
self._appendSessionStats(idleTime)
self._clearLockFile()
self.clearProject()
self.lockedBy = None
@@ -1389,7 +1389,7 @@ class NWProject():
return True
def _appendSessionStats(self):
def _appendSessionStats(self, idleTime):
"""Append session statistics to the sessions log file.
"""
if not self.ensureFolderStructure():
@@ -1404,15 +1404,16 @@ class NWProject():
# It's a new file, so add a header
if self.lastWCount > 0:
outFile.write("# Offset %d\n" % self.lastWCount)
outFile.write("# %-17s %-19s %8s %8s\n" % (
"Start Time", "End Time", "Novel", "Notes"
outFile.write("# %-17s %-19s %8s %8s %8s\n" % (
"Start Time", "End Time", "Novel", "Notes", "Idle"
))
outFile.write("%-19s %-19s %8d %8d\n" % (
outFile.write("%-19s %-19s %8d %8d %8d\n" % (
formatTimeStamp(self.projOpened),
formatTimeStamp(time()),
self.novelWCount,
self.notesWCount,
int(idleTime),
))
except Exception: