forked from Shinonome/dots-hyprland
add config option to use old sine wave cookie clock
This commit is contained in:
@@ -83,8 +83,9 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
property bool useSineCookie: Config.options.background.clock.cookie.useSineCookie
|
||||||
DropShadow {
|
DropShadow {
|
||||||
source: cookie
|
source: useSineCookie ? sineCookieLoader : roundedPolygonCookieLoader
|
||||||
anchors.fill: source
|
anchors.fill: source
|
||||||
radius: 8
|
radius: 8
|
||||||
samples: radius * 2 + 1
|
samples: radius * 2 + 1
|
||||||
@@ -100,14 +101,27 @@ Item {
|
|||||||
to: 0
|
to: 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loader {
|
||||||
MaterialCookie {
|
id: sineCookieLoader
|
||||||
id: cookie
|
|
||||||
z: 0
|
z: 0
|
||||||
visible: false // The DropShadow already draws it
|
visible: false // The DropShadow already draws it
|
||||||
implicitSize: root.implicitSize
|
active: useSineCookie
|
||||||
sides: Config.options.background.clock.cookie.sides
|
sourceComponent: SineCookie {
|
||||||
color: root.colBackground
|
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
|
// Hour/minutes numbers/dots/lines
|
||||||
|
|||||||
@@ -164,6 +164,7 @@ Singleton {
|
|||||||
property bool hourMarks: false
|
property bool hourMarks: false
|
||||||
property bool dateInClock: true
|
property bool dateInClock: true
|
||||||
property bool constantlyRotate: false
|
property bool constantlyRotate: false
|
||||||
|
property bool useSineCookie: false
|
||||||
}
|
}
|
||||||
property JsonObject digital: JsonObject {
|
property JsonObject digital: JsonObject {
|
||||||
property bool animateChange: true
|
property bool animateChange: true
|
||||||
|
|||||||
@@ -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
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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 {
|
ConfigSpinBox {
|
||||||
icon: "add_triangle"
|
icon: "add_triangle"
|
||||||
text: Translation.tr("Sides")
|
text: Translation.tr("Sides")
|
||||||
|
|||||||
Reference in New Issue
Block a user