This repository was archived by the owner on Aug 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhandlePomodoro.py
71 lines (59 loc) · 2.18 KB
/
handlePomodoro.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import time
from datetime import date, timedelta
from PyQt5.QtCore import QThread, pyqtSignal
from qgis.core import QgsSettings
from .userHistoric import UserHistoric
class HandlePomodoro(QThread, UserHistoric):
updateTimer = pyqtSignal(int)
updateHistoric = pyqtSignal(list)
# TODO Start this thread just after pressing the pomodoro button
def __init__(self, parent=None):
super(HandlePomodoro, self).__init__(parent)
self.running = True
# TODO: Use QTimer()
self.duration = 1500
self.today = date.today
self.isTimerRunning = False
# TODO: use a simple array
self.session = {
'historic': []
}
def run(self):
while self.running:
if self.duration:
for i in range(self.duration):
if self.isTimerRunning:
self.updateTimer.emit(i)
self.duration -= 1
if not self.duration:
self.triggerSuccess()
self.isTimerRunning = False
QThread.sleep(1)
else:
QThread.sleep(1)
continue
# timer = QTimer(self)
# timer.setInterval(1000)
# timer.timeout.connect(self.updateText)
# timer.start()
def refreshPomodoroByButton(self, isMonitoring=True):
# TODO: append the pixmap itself
if isMonitoring and self.duration and self.duration != 1500:
self.triggerFail()
self.duration = 1500
self.isTimerRunning = True
def refreshPomodoroByMonitor(self, isMonitoring=True):
self.isTimerRunning = False
if self.duration:
self.triggerFail()
def triggerSuccess(self):
self.updateSucess()
self.session['historic'].append(True)
self.updateHistoric.emit(self.session['historic'])
def triggerFail(self):
self.updateFail()
if self.duration:
self.session['historic'].append(False)
self.updateHistoric.emit(self.session['historic'])
def lcdString(self):
return '{:2}:{:0>2}'.format(self.duration // 60, self.duration % 60)