pomodoro: move timers to service, specific button logic to widget

This commit is contained in:
end-4
2025-08-09 19:45:26 +07:00
parent 1f4568d22f
commit 5bf80dae4e
4 changed files with 67 additions and 61 deletions
@@ -49,6 +49,7 @@ Singleton {
property JsonObject pomodoro: JsonObject {
property bool running: false
property int start: 0
property bool isBreak: false
}
property JsonObject stopwatch: JsonObject {
property bool running: false
@@ -45,23 +45,6 @@ Item {
}
}
Timer {
id: pomodoroTimer
interval: 200
running: Pomodoro.isPomodoroRunning
repeat: true
onTriggered: Pomodoro.refreshPomodoro()
}
Timer {
id: stopwatchTimer
interval: 10
running: Pomodoro.isStopwatchRunning
repeat: true
onTriggered: Pomodoro.refreshStopwatch()
}
ColumnLayout {
anchors.fill: parent
spacing: 0
@@ -61,7 +61,9 @@ Item {
Layout.preferredWidth: 90
font.pixelSize: Appearance.font.pixelSize.larger
onClicked: Pomodoro.toggleStopwatch()
onClicked: {
Pomodoro.toggleStopwatch()
}
colBackground: Pomodoro.isStopwatchRunning ? Appearance.colors.colSecondaryContainer : Appearance.colors.colPrimary
colBackgroundHover: Pomodoro.isStopwatchRunning ? Appearance.colors.colSecondaryContainerHover : Appearance.colors.colPrimaryHover
@@ -79,7 +81,12 @@ Item {
implicitWidth: 90
font.pixelSize: Appearance.font.pixelSize.larger
onClicked: Pomodoro.stopwatchResetOrLaps()
onClicked: {
if (Pomodoro.isStopwatchRunning)
Pomodoro.stopwatchRecordLap()
else
Pomodoro.stopwatchReset()
}
enabled: Pomodoro.stopwatchTime !== 0
colBackground: Pomodoro.isStopwatchRunning ? Appearance.colors.colLayer2 : Appearance.colors.colErrorContainer