Move clock tick timer to main GUI
This commit is contained in:
+2
-13
@@ -29,7 +29,6 @@ import logging
|
|||||||
|
|
||||||
from time import time
|
from time import time
|
||||||
|
|
||||||
from PyQt5.QtCore import QTimer
|
|
||||||
from PyQt5.QtGui import QColor, QPainter
|
from PyQt5.QtGui import QColor, QPainter
|
||||||
from PyQt5.QtWidgets import qApp, QStatusBar, QLabel, QAbstractButton
|
from PyQt5.QtWidgets import qApp, QStatusBar, QLabel, QAbstractButton
|
||||||
|
|
||||||
@@ -110,12 +109,6 @@ class GuiMainStatus(QStatusBar):
|
|||||||
# Other Settings
|
# Other Settings
|
||||||
self.setSizeGripEnabled(True)
|
self.setSizeGripEnabled(True)
|
||||||
|
|
||||||
# Start the Clock
|
|
||||||
self.sessionTimer = QTimer()
|
|
||||||
self.sessionTimer.setInterval(1000)
|
|
||||||
self.sessionTimer.timeout.connect(self._updateTime)
|
|
||||||
self.sessionTimer.start()
|
|
||||||
|
|
||||||
logger.debug("GuiMainStatus initialisation complete")
|
logger.debug("GuiMainStatus initialisation complete")
|
||||||
|
|
||||||
self.clearStatus()
|
self.clearStatus()
|
||||||
@@ -130,7 +123,7 @@ class GuiMainStatus(QStatusBar):
|
|||||||
self.setStats(0, 0)
|
self.setStats(0, 0)
|
||||||
self.setProjectStatus(None)
|
self.setProjectStatus(None)
|
||||||
self.setDocumentStatus(None)
|
self.setDocumentStatus(None)
|
||||||
self._updateTime()
|
self.updateTime()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
##
|
##
|
||||||
@@ -182,11 +175,7 @@ class GuiMainStatus(QStatusBar):
|
|||||||
self.statsText.setToolTip("Project word count (session change)")
|
self.statsText.setToolTip("Project word count (session change)")
|
||||||
return
|
return
|
||||||
|
|
||||||
##
|
def updateTime(self):
|
||||||
# Internal Functions
|
|
||||||
##
|
|
||||||
|
|
||||||
def _updateTime(self):
|
|
||||||
"""Update the session clock.
|
"""Update the session clock.
|
||||||
"""
|
"""
|
||||||
if self.refTime is None:
|
if self.refTime is None:
|
||||||
|
|||||||
@@ -86,6 +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.lastActive = 0
|
||||||
|
|
||||||
# Prepare Main Window
|
# Prepare Main Window
|
||||||
self.resize(*self.mainConf.getWinSize())
|
self.resize(*self.mainConf.getWinSize())
|
||||||
@@ -241,6 +243,12 @@ class GuiMain(QMainWindow):
|
|||||||
self.asDocTimer = QTimer()
|
self.asDocTimer = QTimer()
|
||||||
self.asDocTimer.timeout.connect(self._autoSaveDocument)
|
self.asDocTimer.timeout.connect(self._autoSaveDocument)
|
||||||
|
|
||||||
|
# Main Clock
|
||||||
|
self.mainTimer = QTimer()
|
||||||
|
self.mainTimer.setInterval(1000)
|
||||||
|
self.mainTimer.timeout.connect(self._timeTick)
|
||||||
|
self.mainTimer.start()
|
||||||
|
|
||||||
# Shortcuts and Actions
|
# Shortcuts and Actions
|
||||||
self._connectMenuActions()
|
self._connectMenuActions()
|
||||||
|
|
||||||
@@ -1414,6 +1422,13 @@ class GuiMain(QMainWindow):
|
|||||||
# Slots
|
# Slots
|
||||||
##
|
##
|
||||||
|
|
||||||
|
@pyqtSlot()
|
||||||
|
def _timeTick(self):
|
||||||
|
"""Triggered on every tick of the timer.
|
||||||
|
"""
|
||||||
|
self.statusBar.updateTime()
|
||||||
|
return
|
||||||
|
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
def _treeSingleClick(self):
|
def _treeSingleClick(self):
|
||||||
"""Single click on a project tree item just updates the details
|
"""Single click on a project tree item just updates the details
|
||||||
|
|||||||
Reference in New Issue
Block a user