diff --git a/dots/.config/quickshell/ii/modules/background/cookieClock/CookieClock.qml b/dots/.config/quickshell/ii/modules/background/cookieClock/CookieClock.qml index 12a4d9b96..07f83401d 100644 --- a/dots/.config/quickshell/ii/modules/background/cookieClock/CookieClock.qml +++ b/dots/.config/quickshell/ii/modules/background/cookieClock/CookieClock.qml @@ -83,8 +83,9 @@ Item { } } + property bool useSineCookie: Config.options.background.clock.cookie.useSineCookie DropShadow { - source: cookie + source: useSineCookie ? sineCookieLoader : roundedPolygonCookieLoader anchors.fill: source radius: 8 samples: radius * 2 + 1 @@ -100,14 +101,27 @@ Item { to: 0 } } - - MaterialCookie { - id: cookie + Loader { + id: sineCookieLoader z: 0 visible: false // The DropShadow already draws it - implicitSize: root.implicitSize - sides: Config.options.background.clock.cookie.sides - color: root.colBackground + active: useSineCookie + sourceComponent: SineCookie { + implicitSize: root.implicitSize + sides: Config.options.background.clock.cookie.sides + color: root.colBackground + } + } + Loader { + id: roundedPolygonCookieLoader + z: 0 + visible: false // The DropShadow already draws it + active: !useSineCookie + sourceComponent: MaterialCookie { + implicitSize: root.implicitSize + sides: Config.options.background.clock.cookie.sides + color: root.colBackground + } } // Hour/minutes numbers/dots/lines diff --git a/dots/.config/quickshell/ii/modules/common/Config.qml b/dots/.config/quickshell/ii/modules/common/Config.qml index f43b86187..f6c183b2a 100644 --- a/dots/.config/quickshell/ii/modules/common/Config.qml +++ b/dots/.config/quickshell/ii/modules/common/Config.qml @@ -164,6 +164,7 @@ Singleton { property bool hourMarks: false property bool dateInClock: true property bool constantlyRotate: false + property bool useSineCookie: false } property JsonObject digital: JsonObject { property bool animateChange: true diff --git a/dots/.config/quickshell/ii/modules/common/widgets/SineCookie.qml b/dots/.config/quickshell/ii/modules/common/widgets/SineCookie.qml new file mode 100644 index 000000000..79048ca63 --- /dev/null +++ b/dots/.config/quickshell/ii/modules/common/widgets/SineCookie.qml @@ -0,0 +1,70 @@ +import QtQuick +import QtQuick.Shapes +import Quickshell +import qs.modules.common + +Item { + id: root + + property real sides: 12 + property int implicitSize: 100 + property real amplitude: implicitSize / 50 + property int renderPoints: 360 + property color color: "#605790" + property alias strokeWidth: shapePath.strokeWidth + property bool constantlyRotate: false + + implicitWidth: implicitSize + implicitHeight: implicitSize + + property real shapeRotation: 0 + + Loader { + active: constantlyRotate + sourceComponent: FrameAnimation { + running: true + onTriggered: { + shapeRotation += 0.05 + } + } + } + + Behavior on sides { + animation: Appearance.animation.elementMoveFast.numberAnimation.createObject(this) + } + + Shape { + id: shape + anchors.fill: parent + preferredRendererType: Shape.CurveRenderer + + ShapePath { + id: shapePath + strokeWidth: 0 + fillColor: root.color + pathHints: ShapePath.PathSolid & ShapePath.PathNonIntersecting + + PathPolyline { + property var pointsList: { + var points = [] + var cx = shape.width / 2 // center x + var cy = shape.height / 2 // center y + var steps = root.renderPoints + var radius = root.implicitSize / 2 - root.amplitude + for (var i = 0; i <= steps; i++) { + var angle = (i / steps) * 2 * Math.PI + var rotatedAngle = angle * root.sides + Math.PI/2 + (root.shapeRotation * root.constantlyRotate) + var wave = Math.sin(rotatedAngle) * root.amplitude + var x = Math.cos(angle) * (radius + wave) + cx + var y = Math.sin(angle) * (radius + wave) + cy + points.push(Qt.point(x, y)) + } + return points + } + + path: pointsList + } + + } + } +} diff --git a/dots/.config/quickshell/ii/modules/settings/InterfaceConfig.qml b/dots/.config/quickshell/ii/modules/settings/InterfaceConfig.qml index cf7e98171..9dee53acc 100644 --- a/dots/.config/quickshell/ii/modules/settings/InterfaceConfig.qml +++ b/dots/.config/quickshell/ii/modules/settings/InterfaceConfig.qml @@ -85,6 +85,18 @@ ContentPage { } } + ConfigSwitch { + buttonIcon: "airwave" + text: Translation.tr("Use old sine wave cookie implementation") + checked: Config.options.background.clock.cookie.useSineCookie + onCheckedChanged: { + Config.options.background.clock.cookie.useSineCookie = checked; + } + StyledToolTip { + text: "Looks a bit softer and more consistent with different number of sides,\nbut has less impressive morphing" + } + } + ConfigSpinBox { icon: "add_triangle" text: Translation.tr("Sides")