Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dots/.config/quickshell/ii/modules/common/Config.qml
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,7 @@ Singleton {

property JsonObject pomodoro: JsonObject {
property int breakTime: 300
property bool clockPicker: false
property int cyclesBeforeLongBreak: 4
property int focus: 1500
property int longBreak: 900
Expand Down
135 changes: 135 additions & 0 deletions dots/.config/quickshell/ii/modules/common/widgets/ClockPicker.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
import QtQuick
import QtQuick.Layouts
import qs.modules.common
import qs.modules.common.widgets
import qs.modules.common.functions
import qs.services

Item {
id: root
implicitWidth: 200
implicitHeight: 200
property bool editable: false
property int value: 25
property bool running: false
signal dragFinished(int value)
signal dragStarted()
signal dragEnded()

readonly property real centerX: width / 2
readonly property real centerY: height / 2
readonly property real radius: Math.min(width, height) / 2 - 10
readonly property real angle: (value / 60) * 2 * Math.PI - Math.PI / 2

Rectangle { anchors.fill: parent; radius: width / 2; color: Appearance.colors.colLayer1 }

Repeater {
model: 12
delegate: Item {
required property int index
readonly property int minuteValue: (index + 1) * 5
readonly property real tickAngle: ((index + 1) / 12) * 2 * Math.PI - Math.PI / 2
readonly property real numberRadius: root.radius - 18
readonly property bool selected: root.value === minuteValue

Rectangle {
x: root.centerX + numberRadius * Math.cos(tickAngle) - width / 2
y: root.centerY + numberRadius * Math.sin(tickAngle) - height / 2
width: 28; height: 28; radius: 14
color: root.running && selected ? Appearance.colors.colPrimary : "transparent"
StyledText {
anchors.centerIn: parent
visible: !selected || root.running
text: minuteValue.toString()
font.pixelSize: 11; font.weight: 700
color: root.running && selected ? Appearance.colors.colOnPrimary : Appearance.colors.colSubtext
}
}
Rectangle {
readonly property real tickRadius: root.radius - 4
x: root.centerX + tickRadius * Math.cos(tickAngle) - width / 2
y: root.centerY + tickRadius * Math.sin(tickAngle) - height / 2
width: minuteValue % 15 === 0 ? 5 : 3
height: width; radius: width / 2
visible: !(root.running && selected)
color: selected ? Appearance.colors.colPrimary : ColorUtils.transparentize(Appearance.colors.colSubtext, 0.5)
}
}
}

Canvas {
id: handCanvas
anchors.fill: parent
visible: !root.running
onPaint: {
const context = getContext("2d");
context.clearRect(0, 0, width, height);
const handLength = root.radius - 30;
context.beginPath();
context.moveTo(root.centerX, root.centerY);
context.lineTo(root.centerX + handLength * Math.cos(root.angle), root.centerY + handLength * Math.sin(root.angle));
context.strokeStyle = Qt.rgba(Appearance.colors.colPrimary.r, Appearance.colors.colPrimary.g, Appearance.colors.colPrimary.b, 0.9);
context.lineWidth = 2;
context.lineCap = "round";
context.stroke();
}
Connections {
target: root
function onAngleChanged() { handCanvas.requestPaint() }
function onValueChanged() { handCanvas.requestPaint() }
}
Connections {
target: Appearance
function onColorsChanged() { handCanvas.requestPaint() }
}
}

Rectangle { anchors.centerIn: parent; width: 8; height: 8; radius: 4; color: Appearance.colors.colPrimary; visible: !root.running }
Rectangle {
width: 28; height: 28; radius: 14; color: Appearance.colors.colPrimary
visible: !root.running
x: root.centerX + (root.radius - 30) * Math.cos(root.angle) - width / 2
y: root.centerY + (root.radius - 30) * Math.sin(root.angle) - height / 2
StyledText { anchors.centerIn: parent; text: root.value.toString(); font.pixelSize: 9; font.weight: 700; color: Appearance.colors.colOnPrimary }
}

ColumnLayout {
anchors.centerIn: parent
visible: root.running
spacing: 2
StyledText {
Layout.alignment: Qt.AlignHCenter
text: `${Math.floor(TimerService.pomodoroSecondsLeft / 60).toString().padStart(2, "0")}:${Math.floor(TimerService.pomodoroSecondsLeft % 60).toString().padStart(2, "0")}`
font.pixelSize: 36; font.weight: 700; font.features: { "tnum": 1 }
color: Appearance.m3colors.m3onSurface
}
StyledText {
Layout.alignment: Qt.AlignHCenter
text: TimerService.pomodoroLongBreak ? Translation.tr("Long break") : TimerService.pomodoroBreak ? Translation.tr("Break") : Translation.tr("Focus")
font.pixelSize: Appearance.font.pixelSize.normal; color: Appearance.colors.colSubtext
}
}

MouseArea {
anchors.fill: parent
enabled: root.editable
preventStealing: true
cursorShape: Qt.PointingHandCursor
function valueForPoint(x, y) {
let angle = Math.atan2(y - root.centerY, x - root.centerX) + Math.PI / 2;
if (angle < 0) angle += 2 * Math.PI;
const snapped = Math.round((angle / (2 * Math.PI) * 60) / 5) * 5;
return snapped === 0 ? 60 : snapped;
}
onPressed: event => {
root.dragStarted()
root.value = valueForPoint(event.x, event.y)
}
onPositionChanged: event => { if (pressed) root.value = valueForPoint(event.x, event.y) }
onReleased: {
root.dragFinished(root.value)
root.dragEnded()
}
onCanceled: root.dragEnded()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ import Quickshell

Item {
id: root
signal clockPickerDragStarted()
signal clockPickerDragEnded()

readonly property bool canEditDuration: !TimerService.pomodoroRunning
&& !TimerService.pomodoroBreak
&& TimerService.pomodoroSecondsLeft === TimerService.focusTime

implicitHeight: contentColumn.implicitHeight
implicitWidth: contentColumn.implicitWidth
Expand All @@ -18,35 +24,64 @@ Item {
anchors.fill: parent
spacing: 0

// The Pomodoro timer circle
CircularProgress {
Item {
Layout.alignment: Qt.AlignHCenter
lineWidth: 8
value: {
return TimerService.pomodoroSecondsLeft / TimerService.pomodoroLapDuration;
implicitWidth: 200
implicitHeight: 200

Loader {
anchors.fill: parent
sourceComponent: Config.options.time.pomodoro.clockPicker ? clockPickerComponent : circularProgressComponent
}
implicitSize: 200
enableAnimation: true

ColumnLayout {
anchors.centerIn: parent
spacing: 0
Component {
id: clockPickerComponent

StyledText {
Layout.alignment: Qt.AlignHCenter
text: {
let minutes = Math.floor(TimerService.pomodoroSecondsLeft / 60).toString().padStart(2, '0');
let seconds = Math.floor(TimerService.pomodoroSecondsLeft % 60).toString().padStart(2, '0');
return `${minutes}:${seconds}`;
ClockPicker {
value: Math.round(TimerService.focusTime / 60)
editable: root.canEditDuration
running: !root.canEditDuration
onDragStarted: root.clockPickerDragStarted()
onDragEnded: root.clockPickerDragEnded()
onDragFinished: value => {
if (!root.canEditDuration) return;
Config.options.time.pomodoro.focus = value * 60;
TimerService.pomodoroSecondsLeft = value * 60;
}
font.pixelSize: 40
color: Appearance.m3colors.m3onSurface
}
StyledText {
Layout.alignment: Qt.AlignHCenter
text: TimerService.pomodoroLongBreak ? Translation.tr("Long break") : TimerService.pomodoroBreak ? Translation.tr("Break") : Translation.tr("Focus")
font.pixelSize: Appearance.font.pixelSize.normal
color: Appearance.colors.colSubtext
}

Component {
id: circularProgressComponent

CircularProgress {
lineWidth: 8
value: TimerService.pomodoroSecondsLeft / TimerService.pomodoroLapDuration
implicitSize: 200
enableAnimation: true

ColumnLayout {
anchors.centerIn: parent
spacing: 0

StyledText {
Layout.alignment: Qt.AlignHCenter
text: {
const minutes = Math.floor(TimerService.pomodoroSecondsLeft / 60).toString().padStart(2, "0");
const seconds = Math.floor(TimerService.pomodoroSecondsLeft % 60).toString().padStart(2, "0");
return `${minutes}:${seconds}`;
}
font.pixelSize: 40
color: Appearance.m3colors.m3onSurface
}

StyledText {
Layout.alignment: Qt.AlignHCenter
text: TimerService.pomodoroLongBreak ? Translation.tr("Long break") : TimerService.pomodoroBreak ? Translation.tr("Break") : Translation.tr("Focus")
font.pixelSize: Appearance.font.pixelSize.normal
color: Appearance.colors.colSubtext
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import QtQuick.Layouts

Item {
id: root
property bool clockPickerDragging: false
property var tabButtonList: [
{"name": Translation.tr("Pomodoro"), "icon": "search_activity"},
{"name": Translation.tr("Stopwatch"), "icon": "timer"}
Expand Down Expand Up @@ -66,9 +67,13 @@ Item {
spacing: 10
clip: true
currentIndex: tabBar.currentIndex
interactive: !root.clockPickerDragging

// Tabs
PomodoroTimer {}
PomodoroTimer {
onClockPickerDragStarted: root.clockPickerDragging = true
onClockPickerDragEnded: root.clockPickerDragging = false
}
Stopwatch {}
}
}
Expand Down
11 changes: 10 additions & 1 deletion dots/.config/quickshell/ii/modules/settings/GeneralConfig.qml
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,15 @@ ContentPage {
ContentSection {
icon: "nest_clock_farsight_analog"
title: Translation.tr("Time")

ConfigSwitch {
buttonIcon: "timer"
text: Translation.tr("Use clock picker for Pomodoro")
checked: Config.options.time.pomodoro.clockPicker
onCheckedChanged: {
Config.options.time.pomodoro.clockPicker = checked;
}
}

ConfigSwitch {
buttonIcon: "pace"
Expand Down Expand Up @@ -411,4 +420,4 @@ ContentPage {
}
}
}
}
}