rename stuff

This commit is contained in:
end-4
2025-08-10 16:02:00 +07:00
parent c2d5d2b61a
commit 709415a6b4
3 changed files with 30 additions and 30 deletions
@@ -45,7 +45,7 @@ Item {
} }
StyledText { StyledText {
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
text: TimerService.isLongBreak ? Translation.tr("Long break") : TimerService.isBreak ? Translation.tr("Break") : Translation.tr("Focus") text: TimerService.pomodoroLongBreak ? Translation.tr("Long break") : TimerService.pomodoroBreak ? Translation.tr("Break") : Translation.tr("Focus")
font.pixelSize: Appearance.font.pixelSize.normal font.pixelSize: Appearance.font.pixelSize.normal
color: Appearance.colors.colSubtext color: Appearance.colors.colSubtext
} }
@@ -80,15 +80,15 @@ Item {
contentItem: StyledText { contentItem: StyledText {
anchors.centerIn: parent anchors.centerIn: parent
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
text: TimerService.isPomodoroRunning ? Translation.tr("Pause") : (TimerService.pomodoroSecondsLeft === TimerService.focusTime) ? Translation.tr("Start") : Translation.tr("Resume") text: TimerService.pomodoroRunning ? Translation.tr("Pause") : (TimerService.pomodoroSecondsLeft === TimerService.focusTime) ? Translation.tr("Start") : Translation.tr("Resume")
color: TimerService.isPomodoroRunning ? Appearance.colors.colOnSecondaryContainer : Appearance.colors.colOnPrimary color: TimerService.pomodoroRunning ? Appearance.colors.colOnSecondaryContainer : Appearance.colors.colOnPrimary
} }
implicitHeight: 35 implicitHeight: 35
implicitWidth: 90 implicitWidth: 90
font.pixelSize: Appearance.font.pixelSize.larger font.pixelSize: Appearance.font.pixelSize.larger
onClicked: TimerService.togglePomodoro() onClicked: TimerService.togglePomodoro()
colBackground: TimerService.isPomodoroRunning ? Appearance.colors.colSecondaryContainer : Appearance.colors.colPrimary colBackground: TimerService.pomodoroRunning ? Appearance.colors.colSecondaryContainer : Appearance.colors.colPrimary
colBackgroundHover: TimerService.isPomodoroRunning ? Appearance.colors.colSecondaryContainer : Appearance.colors.colPrimary colBackgroundHover: TimerService.pomodoroRunning ? Appearance.colors.colSecondaryContainer : Appearance.colors.colPrimary
} }
RippleButton { RippleButton {
@@ -96,7 +96,7 @@ Item {
implicitWidth: 90 implicitWidth: 90
onClicked: TimerService.resetPomodoro() onClicked: TimerService.resetPomodoro()
enabled: (TimerService.pomodoroSecondsLeft < TimerService.pomodoroLapDuration) || TimerService.pomodoroCycle > 0 || TimerService.isBreak enabled: (TimerService.pomodoroSecondsLeft < TimerService.pomodoroLapDuration) || TimerService.pomodoroCycle > 0 || TimerService.pomodoroBreak
font.pixelSize: Appearance.font.pixelSize.larger font.pixelSize: Appearance.font.pixelSize.larger
colBackground: Appearance.colors.colErrorContainer colBackground: Appearance.colors.colErrorContainer
@@ -169,14 +169,14 @@ Item {
TimerService.toggleStopwatch() TimerService.toggleStopwatch()
} }
colBackground: TimerService.isStopwatchRunning ? Appearance.colors.colSecondaryContainer : Appearance.colors.colPrimary colBackground: TimerService.stopwatchRunning ? Appearance.colors.colSecondaryContainer : Appearance.colors.colPrimary
colBackgroundHover: TimerService.isStopwatchRunning ? Appearance.colors.colSecondaryContainerHover : Appearance.colors.colPrimaryHover colBackgroundHover: TimerService.stopwatchRunning ? Appearance.colors.colSecondaryContainerHover : Appearance.colors.colPrimaryHover
colRipple: TimerService.isStopwatchRunning ? Appearance.colors.colSecondaryContainerActive : Appearance.colors.colPrimaryActive colRipple: TimerService.stopwatchRunning ? Appearance.colors.colSecondaryContainerActive : Appearance.colors.colPrimaryActive
contentItem: StyledText { contentItem: StyledText {
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
color: TimerService.isStopwatchRunning ? Appearance.colors.colOnSecondaryContainer : Appearance.colors.colOnPrimary color: TimerService.stopwatchRunning ? Appearance.colors.colOnSecondaryContainer : Appearance.colors.colOnPrimary
text: TimerService.isStopwatchRunning ? Translation.tr("Pause") : TimerService.stopwatchTime === 0 ? Translation.tr("Start") : Translation.tr("Resume") text: TimerService.stopwatchRunning ? Translation.tr("Pause") : TimerService.stopwatchTime === 0 ? Translation.tr("Start") : Translation.tr("Resume")
} }
} }
@@ -186,21 +186,21 @@ Item {
font.pixelSize: Appearance.font.pixelSize.larger font.pixelSize: Appearance.font.pixelSize.larger
onClicked: { onClicked: {
if (TimerService.isStopwatchRunning) if (TimerService.stopwatchRunning)
TimerService.stopwatchRecordLap() TimerService.stopwatchRecordLap()
else else
TimerService.stopwatchReset() TimerService.stopwatchReset()
} }
enabled: TimerService.stopwatchTime !== 0 enabled: TimerService.stopwatchTime !== 0
colBackground: TimerService.isStopwatchRunning ? Appearance.colors.colLayer2 : Appearance.colors.colErrorContainer colBackground: TimerService.stopwatchRunning ? Appearance.colors.colLayer2 : Appearance.colors.colErrorContainer
colBackgroundHover: TimerService.isStopwatchRunning ? Appearance.colors.colLayer2Hover : Appearance.colors.colErrorContainerHover colBackgroundHover: TimerService.stopwatchRunning ? Appearance.colors.colLayer2Hover : Appearance.colors.colErrorContainerHover
colRipple: TimerService.isStopwatchRunning ? Appearance.colors.colLayer2Active : Appearance.colors.colErrorContainerActive colRipple: TimerService.stopwatchRunning ? Appearance.colors.colLayer2Active : Appearance.colors.colErrorContainerActive
contentItem: StyledText { contentItem: StyledText {
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
text: TimerService.isStopwatchRunning ? Translation.tr("Lap") : Translation.tr("Reset") text: TimerService.stopwatchRunning ? Translation.tr("Lap") : Translation.tr("Reset")
color: TimerService.isStopwatchRunning ? Appearance.colors.colOnLayer2 : Appearance.colors.colOnErrorContainer color: TimerService.stopwatchRunning ? Appearance.colors.colOnLayer2 : Appearance.colors.colOnErrorContainer
} }
} }
} }
+13 -13
View File
@@ -20,21 +20,21 @@ Singleton {
property int cyclesBeforeLongBreak: Config.options.time.pomodoro.cyclesBeforeLongBreak property int cyclesBeforeLongBreak: Config.options.time.pomodoro.cyclesBeforeLongBreak
property string alertSound: Config.options.time.pomodoro.alertSound property string alertSound: Config.options.time.pomodoro.alertSound
property bool isPomodoroRunning: Persistent.states.timer.pomodoro.running property bool pomodoroRunning: Persistent.states.timer.pomodoro.running
property bool isBreak: Persistent.states.timer.pomodoro.isBreak property bool pomodoroBreak: Persistent.states.timer.pomodoro.isBreak
property bool isLongBreak: Persistent.states.timer.pomodoro.isBreak && (pomodoroCycle + 1 == cyclesBeforeLongBreak); property bool pomodoroLongBreak: Persistent.states.timer.pomodoro.isBreak && (pomodoroCycle + 1 == cyclesBeforeLongBreak);
property int pomodoroLapDuration: isBreak ? (isLongBreak ? longBreakTime : breakTime) : focusTime property int pomodoroLapDuration: pomodoroLongBreak ? longBreakTime : pomodoroBreak ? breakTime : focusTime // This is a binding that's to be kept
property int pomodoroSecondsLeft: isLongBreak ? longBreakTime : (isBreak ? breakTime : focusTime) property int pomodoroSecondsLeft: pomodoroLapDuration // Reasonable init value, to be changed
property int pomodoroCycle: Persistent.states.timer.pomodoro.cycle property int pomodoroCycle: Persistent.states.timer.pomodoro.cycle
property bool isStopwatchRunning: Persistent.states.timer.stopwatch.running property bool stopwatchRunning: Persistent.states.timer.stopwatch.running
property int stopwatchTime: 0 property int stopwatchTime: 0
property int stopwatchStart: Persistent.states.timer.stopwatch.start property int stopwatchStart: Persistent.states.timer.stopwatch.start
property var stopwatchLaps: Persistent.states.timer.stopwatch.laps property var stopwatchLaps: Persistent.states.timer.stopwatch.laps
// General // General
Component.onCompleted: { Component.onCompleted: {
if (!isStopwatchRunning) if (!stopwatchRunning)
stopwatchReset(); stopwatchReset();
} }
@@ -56,7 +56,7 @@ Singleton {
// Send notification // Send notification
let notificationMessage; let notificationMessage;
if (Persistent.states.timer.pomodoro.isLongBreak) { if (Persistent.states.timer.pomodoro.isBreak && (pomodoroCycle + 1 == cyclesBeforeLongBreak)) {
notificationMessage = Translation.tr(`🌿 Long break: %1 minutes`).arg(Math.floor(longBreakTime / 60)); notificationMessage = Translation.tr(`🌿 Long break: %1 minutes`).arg(Math.floor(longBreakTime / 60));
} else if (Persistent.states.timer.pomodoro.isBreak) { } else if (Persistent.states.timer.pomodoro.isBreak) {
notificationMessage = Translation.tr(` Break: %1 minutes`).arg(Math.floor(breakTime / 60)); notificationMessage = Translation.tr(` Break: %1 minutes`).arg(Math.floor(breakTime / 60));
@@ -68,7 +68,7 @@ Singleton {
if (alertSound) if (alertSound)
Quickshell.execDetached(["ffplay", "-nodisp", "-autoexit", alertSound]); Quickshell.execDetached(["ffplay", "-nodisp", "-autoexit", alertSound]);
if (!isBreak) { if (!pomodoroBreak) {
Persistent.states.timer.pomodoro.cycle = (Persistent.states.timer.pomodoro.cycle + 1) % root.cyclesBeforeLongBreak; Persistent.states.timer.pomodoro.cycle = (Persistent.states.timer.pomodoro.cycle + 1) % root.cyclesBeforeLongBreak;
} }
} }
@@ -79,13 +79,13 @@ Singleton {
Timer { Timer {
id: pomodoroTimer id: pomodoroTimer
interval: 200 interval: 200
running: root.isPomodoroRunning running: root.pomodoroRunning
repeat: true repeat: true
onTriggered: refreshPomodoro() onTriggered: refreshPomodoro()
} }
function togglePomodoro() { function togglePomodoro() {
Persistent.states.timer.pomodoro.running = !isPomodoroRunning; Persistent.states.timer.pomodoro.running = !pomodoroRunning;
if (Persistent.states.timer.pomodoro.running) { if (Persistent.states.timer.pomodoro.running) {
// Start/Resume // Start/Resume
Persistent.states.timer.pomodoro.start = getCurrentTimeInSeconds() + pomodoroSecondsLeft - pomodoroLapDuration; Persistent.states.timer.pomodoro.start = getCurrentTimeInSeconds() + pomodoroSecondsLeft - pomodoroLapDuration;
@@ -108,13 +108,13 @@ Singleton {
Timer { Timer {
id: stopwatchTimer id: stopwatchTimer
interval: 10 interval: 10
running: root.isStopwatchRunning running: root.stopwatchRunning
repeat: true repeat: true
onTriggered: refreshStopwatch() onTriggered: refreshStopwatch()
} }
function toggleStopwatch() { function toggleStopwatch() {
if (root.isStopwatchRunning) if (root.stopwatchRunning)
stopwatchPause(); stopwatchPause();
else else
stopwatchResume(); stopwatchResume();