pomodoroooooo
This commit is contained in:
parent
97c40a7302
commit
2d1de46031
7 changed files with 244 additions and 0 deletions
62
services/Pomodoro.qml
Normal file
62
services/Pomodoro.qml
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
pragma Singleton
|
||||
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
|
||||
Singleton {
|
||||
id: root
|
||||
|
||||
readonly property alias running: properties.running
|
||||
readonly property alias initialTime: properties.initialTime
|
||||
readonly property alias remainingTime: properties.remainingTime
|
||||
readonly property alias state: properties.state
|
||||
|
||||
function toggle() {
|
||||
properties.running = !properties.running;
|
||||
}
|
||||
|
||||
function reset() {
|
||||
properties.running = false;
|
||||
properties.setTimer();
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: timer
|
||||
|
||||
interval: 10
|
||||
repeat: true
|
||||
running: properties.running
|
||||
onTriggered: {
|
||||
if (properties.remainingTime <= 0) {
|
||||
properties.state == "timer" ? properties.setRest() : properties.setTimer();
|
||||
|
||||
}
|
||||
properties.remainingTime -= interval;
|
||||
}
|
||||
}
|
||||
|
||||
PersistentProperties {
|
||||
id: properties
|
||||
reloadableId: "Pomodoro"
|
||||
|
||||
readonly property int timerAmount: 25 * 60 * 1000
|
||||
readonly property int restAmount: 10 * 60 * 1000
|
||||
|
||||
property bool running: false
|
||||
property string state: "timer"
|
||||
property int initialTime: 0
|
||||
property int remainingTime: 0
|
||||
|
||||
function setTimer() {
|
||||
properties.state = "timer";
|
||||
properties.initialTime = timerAmount;
|
||||
properties.remainingTime = timerAmount;
|
||||
}
|
||||
|
||||
function setRest() {
|
||||
properties.state = "rest";
|
||||
properties.initialTime = restAmount;
|
||||
properties.remainingTime = restAmount;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue