|
39 | 39 | ConfigurationValue { |
40 | 40 | id: sliderToggles |
41 | 41 | key: "/desktop/asteroid/quicksettings/slider" |
42 | | - defaultValue: ["brightnessToggle", "bluetoothToggle", "hapticsToggle", "wifiToggle", "soundToggle", "cinemaToggle", "aodToggle", "powerOffToggle", "rebootToggle", "musicToggle", "flashlightToggle"] |
| 42 | + defaultValue: ["brightnessToggle", "bluetoothToggle", "hapticsToggle", "wifiToggle", "soundToggle", "cinemaToggle", "aodToggle", "powerOffToggle", "rebootToggle", "musicButton", "flashlightButton"] |
43 | 43 | } |
44 | 44 |
|
45 | 45 | ConfigurationValue { |
|
57 | 57 | "aodToggle": true, |
58 | 58 | "powerOffToggle": true, |
59 | 59 | "rebootToggle": true, |
60 | | - "musicToggle": false, |
61 | | - "flashlightToggle": false |
| 60 | + "musicButton": false, |
| 61 | + "flashlightButton": false |
62 | 62 | } |
63 | 63 | } |
64 | 64 |
|
|
97 | 97 | //% "Reboot" |
98 | 98 | { id: "rebootToggle", name: qsTrId("id-toggle-reboot"), icon: "ios-refresh", available: true }, |
99 | 99 | //% "Music Link" |
100 | | - { id: "musicToggle", name: qsTrId("id-toggle-music"), icon: "ios-musical-notes-outline", available: true }, |
| 100 | + { id: "musicButton", name: qsTrId("id-toggle-music"), icon: "ios-musical-notes-outline", available: true }, |
101 | 101 | //% "Flashlight Link" |
102 | | - { id: "flashlightToggle", name: qsTrId("id-toggle-flashlight"), icon: "ios-bulb-outline", available: true } |
| 102 | + { id: "flashlightButton", name: qsTrId("id-toggle-flashlight"), icon: "ios-bulb-outline", available: true } |
103 | 103 | ] |
104 | 104 |
|
105 | 105 | property real rowHeight: Dims.h(16) |
@@ -581,189 +581,33 @@ Item { |
581 | 581 | } |
582 | 582 | } |
583 | 583 |
|
584 | | - Item { |
585 | | - id: batteryMeter |
| 584 | + ValueMeter { |
| 585 | + id: valueMeter |
586 | 586 | visible: type === "display" |
587 | | - width: delegateItem.width |
588 | | - height: Math.max(rowHeight * 2, batteryDisplay.height + Dims.l(2)) |
589 | | - anchors.horizontalCenter: parent.horizontalCenter |
590 | | - |
591 | | - Item { |
592 | | - id: batteryDisplay |
593 | | - width: Dims.l(28) * 1.8 |
594 | | - height: Dims.l(8) |
595 | | - anchors { |
596 | | - top: parent.top |
597 | | - horizontalCenter: parent.horizontalCenter |
598 | | - topMargin: Dims.l(2) |
599 | | - } |
600 | | - |
601 | | - Rectangle { |
602 | | - id: batteryOutline |
603 | | - width: parent.width |
604 | | - height: parent.height |
605 | | - color: Qt.rgba(1, 1, 1, 0.2) |
606 | | - radius: height / 2 |
607 | | - } |
608 | | - |
609 | | - Rectangle { |
610 | | - id: batteryFill |
611 | | - height: parent.height |
612 | | - width: { |
613 | | - var baseWidth = parent.width * (batteryChargePercentage.percent / 100) |
614 | | - if (mceChargerType.type != MceChargerType.None && options.value.batteryAnimation && batteryFill.isVisible) { |
615 | | - var waveAmplitude = parent.width * 0.05 |
616 | | - return baseWidth + waveAmplitude * Math.sin(waveTime) |
617 | | - } |
618 | | - return baseWidth |
619 | | - } |
620 | | - color: { |
621 | | - if (!options.value.batteryColored) return Qt.rgba(1, 1, 1, 0.3) // Reduced alpha from 0.4 |
622 | | - var percent = batteryChargePercentage.percent |
623 | | - if (percent > 50) return Qt.rgba(0, 1, 0, 0.3) // Reduced alpha from 0.4 |
624 | | - if (percent > 20) { |
625 | | - var t = (50 - percent) / 30 |
626 | | - return Qt.rgba(t, 1 - (t * 0.35), 0, 0.3) // Reduced alpha from 0.4 |
627 | | - } |
628 | | - var t = (20 - percent) / 20 |
629 | | - return Qt.rgba(1, 0.65 * (1 - t), 0, 0.3) // Reduced alpha from 0.4 |
630 | | - } |
631 | | - anchors.left: parent.left |
632 | | - opacity: 1.0 |
633 | | - clip: true |
634 | | - |
635 | | - property real waveTime: 0 |
636 | | - property bool isVisible: quickSettingsPage.visible && Qt.application.active |
637 | | - |
638 | | - NumberAnimation on waveTime { |
639 | | - id: waveAnimation |
640 | | - running: mceChargerType.type != MceChargerType.None && batteryFill.isVisible |
641 | | - from: 0 |
642 | | - to: 2 * Math.PI |
643 | | - duration: 1500 |
644 | | - loops: Animation.Infinite |
645 | | - } |
646 | | - |
647 | | - SequentialAnimation on color { |
648 | | - running: mceChargerType.type == MceChargerType.None && options.value.batteryAnimation && batteryChargePercentage.percent < 30 && batteryFill.isVisible |
649 | | - loops: Animation.Infinite |
650 | | - ColorAnimation { |
651 | | - to: options.value.batteryColored ? Qt.rgba(1, 0, 0, 0.7) : Qt.rgba(1, 1, 1, 0.7) // Reduced alpha from 0.8 |
652 | | - duration: 500 |
653 | | - easing.type: Easing.InOutQuad |
654 | | - } |
655 | | - ColorAnimation { |
656 | | - to: options.value.batteryColored ? Qt.rgba(1, 0, 0, 0.3) : Qt.rgba(1, 1, 1, 0.3) // Reduced alpha from 0.4 |
657 | | - duration: 500 |
658 | | - easing.type: Easing.InOutQuad |
659 | | - } |
660 | | - } |
661 | | - |
662 | | - Item { |
663 | | - id: particleContainer |
664 | | - anchors.fill: parent |
665 | | - visible: options.value.batteryAnimation |
666 | | - |
667 | | - property int particleCount: 5 |
668 | | - property bool isCharging: mceChargerType.type != MceChargerType.None |
669 | | - property int activeParticles: 0 |
670 | | - // Track horizontal spawn alternation (0 = left half, 1 = right half) |
671 | | - property int nextHorizontalBand: 0 |
672 | | - // Dynamic spawn interval based on charging state |
673 | | - property int spawnInterval: 300 |
674 | | - |
675 | | - Component { |
676 | | - id: cleanupTimerComponent |
677 | | - Timer { |
678 | | - id: cleanupTimer |
679 | | - interval: 0 |
680 | | - running: true |
681 | | - repeat: false |
682 | | - onTriggered: { |
683 | | - particleContainer.activeParticles--; |
684 | | - } |
685 | | - } |
686 | | - } |
687 | | - |
688 | | - function createParticle() { |
689 | | - if (!particleContainer.visible || !batteryFill.isVisible || activeParticles >= 16) { |
690 | | - return; |
691 | | - } |
692 | | - var component = Qt.createComponent("qrc:///org/asteroid/controls/qml/BatteryParticles.qml"); |
693 | | - if (component.status === Component.Ready) { |
694 | | - var isCharging = mceChargerType.type != MceChargerType.None; |
695 | | - // Define speed (px/s) and calculate lifetime based on path length |
696 | | - var speed = isCharging ? 60 : 20; // 60px/s charging, 20px/s discharging |
697 | | - var pathLength = isCharging ? batteryFill.width / 2 : batteryFill.width; |
698 | | - var lifetime = isCharging ? 2500 : 8500; // Charging: +50% (~1667ms -> 2500ms), Discharging: -15% (~10000ms -> 8500ms) |
699 | | - particleContainer.spawnInterval = isCharging ? 200 : 750; |
700 | | - var maxSize = batteryFill.height / 2; |
701 | | - var minSize = batteryFill.height / 6; |
702 | | - var designType = options.value.particleDesign || "diamonds"; |
703 | | - var isLogoOrFlash = designType === "logos" || designType === "flashes"; |
704 | | - var sizeMultiplier = isLogoOrFlash ? 1.3 : 1.0; |
705 | | - var opacity = 0.6; // Unified maxOpacity |
706 | | - |
707 | | - // Horizontal stratification: alternate between left (0) and right (1) halves |
708 | | - var horizontalBand = particleContainer.nextHorizontalBand; |
709 | | - var startX = isCharging ? |
710 | | - (horizontalBand === 0 ? Math.random() * (batteryFill.width / 4) : (batteryFill.width / 4) + Math.random() * (batteryFill.width / 4)) : |
711 | | - (horizontalBand === 0 ? batteryFill.width / 2 + Math.random() * (batteryFill.width / 4) : (3 * batteryFill.width / 4) + Math.random() * (batteryFill.width / 4)); |
712 | | - particleContainer.nextHorizontalBand = (horizontalBand + 1) % 2; // Alternate |
713 | | - |
714 | | - var endX = isCharging ? |
715 | | - startX + pathLength : |
716 | | - startX - pathLength; |
717 | | - |
718 | | - var band = Math.floor(Math.random() * 3); // 0, 1, 2 |
719 | | - var startY = (band * batteryFill.height / 3) + (Math.random() * batteryFill.height / 3); |
720 | | - |
721 | | - var size = (minSize + Math.random() * (maxSize - minSize)) * sizeMultiplier; |
722 | | - |
723 | | - var particle = component.createObject(particleContainer, { |
724 | | - "x": startX, |
725 | | - "y": startY, |
726 | | - "targetX": endX, |
727 | | - "maxSize": size, |
728 | | - "lifetime": lifetime, |
729 | | - "isCharging": isCharging, |
730 | | - "design": designType, |
731 | | - "opacity": opacity, |
732 | | - // Destroy if outside batteryFill bounds |
733 | | - "clipBounds": Qt.rect(0, 0, batteryFill.width, batteryFill.height) |
734 | | - }); |
735 | | - if (particle !== null) { |
736 | | - activeParticles++; |
737 | | - var cleanupTimer = cleanupTimerComponent.createObject(particleContainer, { |
738 | | - "interval": lifetime |
739 | | - }); |
740 | | - } |
741 | | - } else { |
742 | | - // Handle component loading failure silently |
743 | | - } |
744 | | - } |
745 | | - |
746 | | - Timer { |
747 | | - id: particleTimer |
748 | | - interval: particleContainer.spawnInterval |
749 | | - running: batteryFill.width > 0 && options.value.batteryAnimation && particleContainer.visible && batteryFill.isVisible && !slotList.dragging && !slotList.moving |
750 | | - repeat: true |
751 | | - triggeredOnStart: true |
752 | | - onTriggered: { |
753 | | - particleContainer.createParticle(); |
754 | | - } |
755 | | - } |
756 | | - } |
757 | | - } |
758 | | - |
759 | | - layer.enabled: true |
760 | | - layer.effect: OpacityMask { |
761 | | - maskSource: Item { |
762 | | - width: batteryDisplay.width |
763 | | - height: batteryDisplay.height |
764 | | - Rectangle { anchors.fill: parent; radius: batteryOutline.radius } |
765 | | - } |
| 587 | + width: Dims.l(28) * 1.8 |
| 588 | + height: Dims.l(8) |
| 589 | + valueLowerBound: 0 |
| 590 | + valueUpperBound: 100 |
| 591 | + value: batteryChargePercentage.percent |
| 592 | + isIncreasing: mceChargerType.type != MceChargerType.None |
| 593 | + enableAnimations: options.value.batteryAnimation |
| 594 | + enableColoredFill: options.value.batteryColored |
| 595 | + particleDesign: options.value.particleDesign |
| 596 | + fillColor: { |
| 597 | + if (!options.value.batteryColored) return Qt.rgba(1, 1, 1, 0.3) |
| 598 | + var percent = batteryChargePercentage.percent |
| 599 | + if (percent > 50) return Qt.rgba(0, 1, 0, 0.3) |
| 600 | + if (percent > 20) { |
| 601 | + var t = (50 - percent) / 30 |
| 602 | + return Qt.rgba(t, 1 - (t * 0.35), 0, 0.3) |
766 | 603 | } |
| 604 | + var t = (20 - percent) / 20 |
| 605 | + return Qt.rgba(1, 0.65 * (1 - t), 0, 0.3) |
| 606 | + } |
| 607 | + anchors { |
| 608 | + top: parent.top |
| 609 | + horizontalCenter: parent.horizontalCenter |
| 610 | + topMargin: Dims.l(2) |
767 | 611 | } |
768 | 612 | } |
769 | 613 |
|
|
0 commit comments