forked from Shinonome/dots-hyprland
pomodoro: add cycle indicator, make long break work, fix reset button
This commit is contained in:
@@ -11,18 +11,35 @@ Singleton {
|
||||
property string fileName: "states.json"
|
||||
property string filePath: `${root.fileDir}/${root.fileName}`
|
||||
|
||||
Timer {
|
||||
id: fileReloadTimer
|
||||
interval: 100
|
||||
repeat: false
|
||||
onTriggered: {
|
||||
persistentStatesFileView.reload()
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: fileWriteTimer
|
||||
interval: 100
|
||||
repeat: false
|
||||
onTriggered: {
|
||||
persistentStatesFileView.writeAdapter()
|
||||
}
|
||||
}
|
||||
|
||||
FileView {
|
||||
id: persistentStatesFileView
|
||||
path: root.filePath
|
||||
|
||||
watchChanges: true
|
||||
onFileChanged: reload()
|
||||
onAdapterUpdated: {
|
||||
writeAdapter()
|
||||
}
|
||||
onFileChanged: fileReloadTimer.restart()
|
||||
onAdapterUpdated: fileWriteTimer.restart()
|
||||
onLoadFailed: error => {
|
||||
console.log("Failed to load persistent states file:", error);
|
||||
if (error == FileViewError.FileNotFound) {
|
||||
writeAdapter();
|
||||
fileWriteTimer.restart();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,6 +67,7 @@ Singleton {
|
||||
property bool running: false
|
||||
property int start: 0
|
||||
property bool isBreak: false
|
||||
property bool isLongBreak: false
|
||||
property int cycle: 0
|
||||
}
|
||||
property JsonObject stopwatch: JsonObject {
|
||||
|
||||
@@ -23,14 +23,10 @@ Item {
|
||||
CircularProgress {
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
lineWidth: 8
|
||||
gapAngle: Math.PI / 14
|
||||
value: {
|
||||
let pomodoroTotalTime = Pomodoro.isBreak ? Pomodoro.breakTime : Pomodoro.focusTime;
|
||||
return Pomodoro.pomodoroSecondsLeft / pomodoroTotalTime;
|
||||
return Pomodoro.pomodoroSecondsLeft / Pomodoro.pomodoroLapDuration;
|
||||
}
|
||||
size: 200
|
||||
primaryColor: Appearance.m3colors.m3onSecondaryContainer
|
||||
secondaryColor: Appearance.colors.colSecondaryContainer
|
||||
enableAnimation: true
|
||||
|
||||
ColumnLayout {
|
||||
@@ -49,11 +45,30 @@ Item {
|
||||
}
|
||||
StyledText {
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
text: Pomodoro.isBreak ? Translation.tr("Break") : Translation.tr("Focus")
|
||||
text: Pomodoro.isLongBreak ? Translation.tr("Long break") : Pomodoro.isBreak ? Translation.tr("Break") : Translation.tr("Focus")
|
||||
font.pixelSize: Appearance.font.pixelSize.normal
|
||||
color: Appearance.colors.colSubtext
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
radius: Appearance.rounding.full
|
||||
color: Appearance.colors.colLayer2
|
||||
|
||||
anchors {
|
||||
right: parent.right
|
||||
bottom: parent.bottom
|
||||
}
|
||||
implicitWidth: 36
|
||||
implicitHeight: implicitWidth
|
||||
|
||||
StyledText {
|
||||
id: cycleText
|
||||
anchors.centerIn: parent
|
||||
color: Appearance.colors.colOnLayer2
|
||||
text: Pomodoro.pomodoroCycle + 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The Start/Stop and Reset buttons
|
||||
@@ -81,7 +96,7 @@ Item {
|
||||
implicitWidth: 90
|
||||
|
||||
onClicked: Pomodoro.resetPomodoro()
|
||||
enabled: (Pomodoro.pomodoroSecondsLeft < (Pomodoro.isBreak ? Pomodoro.breakTime : Pomodoro.focusTime))
|
||||
enabled: (Pomodoro.pomodoroSecondsLeft < Pomodoro.pomodoroLapDuration) || Pomodoro.pomodoroCycle > 0 || Pomodoro.isBreak
|
||||
|
||||
font.pixelSize: Appearance.font.pixelSize.larger
|
||||
colBackground: Appearance.colors.colErrorContainer
|
||||
|
||||
Reference in New Issue
Block a user