Record idle time
This commit is contained in:
+2
-2
@@ -175,13 +175,13 @@ class GuiMainStatus(QStatusBar):
|
|||||||
self.statsText.setToolTip("Project word count (session change)")
|
self.statsText.setToolTip("Project word count (session change)")
|
||||||
return
|
return
|
||||||
|
|
||||||
def updateTime(self):
|
def updateTime(self, idleTime=0.0):
|
||||||
"""Update the session clock.
|
"""Update the session clock.
|
||||||
"""
|
"""
|
||||||
if self.refTime is None:
|
if self.refTime is None:
|
||||||
self.timeText.setText("00:00:00")
|
self.timeText.setText("00:00:00")
|
||||||
else:
|
else:
|
||||||
self.timeText.setText(formatTime(round(time() - self.refTime)))
|
self.timeText.setText(formatTime(round(time() - self.refTime - idleTime)))
|
||||||
return
|
return
|
||||||
|
|
||||||
# END Class GuiMainStatus
|
# END Class GuiMainStatus
|
||||||
|
|||||||
+19
-4
@@ -86,8 +86,8 @@ class GuiMain(QMainWindow):
|
|||||||
self.theIndex = NWIndex(self.theProject, self)
|
self.theIndex = NWIndex(self.theProject, self)
|
||||||
self.hasProject = False
|
self.hasProject = False
|
||||||
self.isFocusMode = False
|
self.isFocusMode = False
|
||||||
self.userActive = False
|
self.idleRefTime = time()
|
||||||
self.lastActive = 0
|
self.idleTime = 0.0
|
||||||
|
|
||||||
# Prepare Main Window
|
# Prepare Main Window
|
||||||
self.resize(*self.mainConf.getWinSize())
|
self.resize(*self.mainConf.getWinSize())
|
||||||
@@ -485,7 +485,9 @@ class GuiMain(QMainWindow):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
# Project is loaded
|
# Project is loaded
|
||||||
self.hasProject = True
|
self.hasProject = True
|
||||||
|
self.idleRefTime = time()
|
||||||
|
self.idleTime = 0.0
|
||||||
|
|
||||||
# Load the tag index
|
# Load the tag index
|
||||||
self.theIndex.loadIndex()
|
self.theIndex.loadIndex()
|
||||||
@@ -1426,7 +1428,20 @@ class GuiMain(QMainWindow):
|
|||||||
def _timeTick(self):
|
def _timeTick(self):
|
||||||
"""Triggered on every tick of the timer.
|
"""Triggered on every tick of the timer.
|
||||||
"""
|
"""
|
||||||
self.statusBar.updateTime()
|
if not self.hasProject:
|
||||||
|
return
|
||||||
|
|
||||||
|
currTime = time()
|
||||||
|
editIdle = currTime - self.docEditor.lastEdit > 30.0
|
||||||
|
userIdle = qApp.applicationState() != Qt.ApplicationActive
|
||||||
|
|
||||||
|
if editIdle or userIdle:
|
||||||
|
self.idleTime += currTime - self.idleRefTime
|
||||||
|
|
||||||
|
self.idleRefTime = currTime
|
||||||
|
self.statusBar.updateTime(idleTime=self.idleTime)
|
||||||
|
# print(editIdle, userIdle, self.idleTime)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
|
|||||||
Reference in New Issue
Block a user