forked from Shinonome/dots-hyprland
make pomodoro timer persistent
This commit is contained in:
@@ -255,7 +255,6 @@ Singleton {
|
|||||||
property string dateFormat: "ddd, dd/MM"
|
property string dateFormat: "ddd, dd/MM"
|
||||||
property JsonObject pomodoro: JsonObject {
|
property JsonObject pomodoro: JsonObject {
|
||||||
property string alertSound: ""
|
property string alertSound: ""
|
||||||
property bool autoRun: false
|
|
||||||
property int breakTime: 300
|
property int breakTime: 300
|
||||||
property int cycle: 4
|
property int cycle: 4
|
||||||
property int focus: 1500
|
property int focus: 1500
|
||||||
|
|||||||
@@ -44,6 +44,13 @@ Singleton {
|
|||||||
property bool allowNsfw: false
|
property bool allowNsfw: false
|
||||||
property string provider: "yandere"
|
property string provider: "yandere"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
property JsonObject timer: JsonObject {
|
||||||
|
property JsonObject pomodoro: JsonObject {
|
||||||
|
property bool running: false
|
||||||
|
property int start: 0
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,12 +20,12 @@ Singleton {
|
|||||||
property int longBreakCycle: Config.options.time.pomodoro.cycle
|
property int longBreakCycle: Config.options.time.pomodoro.cycle
|
||||||
property string alertSound: Config.options.time.pomodoro.alertSound
|
property string alertSound: Config.options.time.pomodoro.alertSound
|
||||||
|
|
||||||
property bool isPomodoroRunning: Config.options.time.pomodoro.autoRun
|
property bool isPomodoroRunning: Persistent.states.timer.pomodoro.running
|
||||||
property bool isBreak: false
|
property bool isBreak: false
|
||||||
property bool isPomodoroReset: !isPomodoroRunning
|
property bool isPomodoroReset: !isPomodoroRunning
|
||||||
property int timeLeft: focusTime
|
property int timeLeft: focusTime
|
||||||
property int getPomodoroSecondsLeft: focusTime
|
property int getPomodoroSecondsLeft: focusTime
|
||||||
property int pomodoroStartTime: getCurrentTimeInSeconds() // The time pomodoro was last Resumed
|
property int pomodoroStartTime: Persistent.states.timer.pomodoro.start
|
||||||
property int pomodoroCycle: 1
|
property int pomodoroCycle: 1
|
||||||
|
|
||||||
property bool isStopwatchRunning: false
|
property bool isStopwatchRunning: false
|
||||||
@@ -36,9 +36,9 @@ Singleton {
|
|||||||
// Start and Stop button
|
// Start and Stop button
|
||||||
function togglePomodoro() {
|
function togglePomodoro() {
|
||||||
isPomodoroReset = false
|
isPomodoroReset = false
|
||||||
isPomodoroRunning = !isPomodoroRunning
|
Persistent.states.timer.pomodoro.running = !isPomodoroRunning
|
||||||
if (isPomodoroRunning) { // Pressed Start button
|
if (isPomodoroRunning) { // Pressed Start button
|
||||||
pomodoroStartTime = getCurrentTimeInSeconds()
|
Persistent.states.timer.pomodoro.start = getCurrentTimeInSeconds()
|
||||||
} else { // Pressed Stop button
|
} else { // Pressed Stop button
|
||||||
timeLeft -= (getCurrentTimeInSeconds() - pomodoroStartTime)
|
timeLeft -= (getCurrentTimeInSeconds() - pomodoroStartTime)
|
||||||
}
|
}
|
||||||
@@ -46,11 +46,11 @@ Singleton {
|
|||||||
|
|
||||||
// Reset button
|
// Reset button
|
||||||
function pomodoroReset() {
|
function pomodoroReset() {
|
||||||
isPomodoroRunning = false
|
Persistent.states.timer.pomodoro.running = false
|
||||||
isBreak = false
|
isBreak = false
|
||||||
isPomodoroReset = true
|
isPomodoroReset = true
|
||||||
timeLeft = focusTime
|
timeLeft = focusTime
|
||||||
pomodoroStartTime = getCurrentTimeInSeconds()
|
Persistent.states.timer.pomodoro.start = getCurrentTimeInSeconds()
|
||||||
pomodoroCycle = 1
|
pomodoroCycle = 1
|
||||||
refreshPomodoro()
|
refreshPomodoro()
|
||||||
}
|
}
|
||||||
@@ -58,7 +58,7 @@ Singleton {
|
|||||||
function refreshPomodoro() {
|
function refreshPomodoro() {
|
||||||
if (getCurrentTimeInSeconds() >= pomodoroStartTime + timeLeft) {
|
if (getCurrentTimeInSeconds() >= pomodoroStartTime + timeLeft) {
|
||||||
isBreak = !isBreak
|
isBreak = !isBreak
|
||||||
pomodoroStartTime += timeLeft
|
Persistent.states.timer.pomodoro.start += timeLeft
|
||||||
timeLeft = isBreak ? breakTime : focusTime
|
timeLeft = isBreak ? breakTime : focusTime
|
||||||
|
|
||||||
let notificationTitle, notificationMessage
|
let notificationTitle, notificationMessage
|
||||||
|
|||||||
Reference in New Issue
Block a user