Files
metabuilder/fakemui/qml-components/feedback/CSpinner.qml
JohnDoe6345789 58a94d0489 feat(styles): add component-specific styles for TaskDetail, SearchDialog, and Documentation
feat(styles): create global styles entry point and organize global styles

feat(styles): implement base HTML element styles and utility classes for flexbox

feat(styles): establish layout, position, spacing, and text utility classes

feat(styles): introduce mixins for animations, cards, dialogs, flexbox, grid, and responsive design

test(quick_guide): add component and metadata validation tests for quick_guide package

test(ui_level6): implement metadata validation tests for ui_level6 package
2025-12-30 02:29:58 +00:00

70 lines
1.7 KiB
QML

import QtQuick
/**
* CSpinner.qml - Loading spinner (mirrors _spinner.scss)
* Simple rotating loading indicator
*
* Usage:
* CSpinner {}
* CSpinner { size: "lg"; color: Theme.success }
*/
Item {
id: root
// Public properties
property string size: "md" // sm, md, lg
property color color: Theme.primary
property int strokeWidth: size === "sm" ? 2 : (size === "lg" ? 4 : 3)
// Size
implicitWidth: _size
implicitHeight: _size
readonly property int _size: {
switch (size) {
case "sm": return 20
case "lg": return 48
default: return 32
}
}
// Spinning animation
Canvas {
id: canvas
anchors.fill: parent
property real angle: 0
RotationAnimation on angle {
from: 0
to: 360
duration: 1000
loops: Animation.Infinite
running: root.visible
}
onAngleChanged: requestPaint()
onPaint: {
var ctx = getContext("2d")
ctx.reset()
var centerX = width / 2
var centerY = height / 2
var radius = (Math.min(width, height) - root.strokeWidth) / 2
// Draw arc
ctx.strokeStyle = root.color
ctx.lineWidth = root.strokeWidth
ctx.lineCap = "round"
var startAngle = (angle - 90) * Math.PI / 180
var endAngle = startAngle + 1.5 * Math.PI
ctx.beginPath()
ctx.arc(centerX, centerY, radius, startAngle, endAngle)
ctx.stroke()
}
}
}