Several changes, fix messy behaviour for PillIndicator, fix System Settings size, fix logout button

This commit is contained in:
Ly-sec 2025-08-01 16:58:54 +02:00
parent 8c2df56fb5
commit 7e52df59bc
8 changed files with 81 additions and 37 deletions

View file

@ -8,10 +8,15 @@ import qs.Settings
Item { Item {
id: batteryWidget id: batteryWidget
// Test mode
property bool testMode: false
property int testPercent: 49
property bool testCharging: true
property var battery: UPower.displayDevice property var battery: UPower.displayDevice
property bool isReady: battery && battery.ready && battery.isLaptopBattery && battery.isPresent property bool isReady: testMode ? true : (battery && battery.ready && battery.isLaptopBattery && battery.isPresent)
property real percent: isReady ? (battery.percentage * 100) : 0 property real percent: testMode ? testPercent : (isReady ? (battery.percentage * 100) : 0)
property bool charging: isReady ? battery.state === UPowerDeviceState.Charging : false property bool charging: testMode ? testCharging : (isReady ? battery.state === UPowerDeviceState.Charging : false)
property bool show: isReady && percent > 0 property bool show: isReady && percent > 0
// Choose icon based on charge and charging state // Choose icon based on charge and charging state
@ -25,26 +30,40 @@ Item {
if (percent >= 95) if (percent >= 95)
return "battery_android_full"; return "battery_android_full";
var step = Math.round(percent / (100 / 6)); // Hardcoded battery symbols
return "battery_android_" + step if (percent >= 85)
return "battery_android_6";
if (percent >= 70)
return "battery_android_5";
if (percent >= 55)
return "battery_android_4";
if (percent >= 40)
return "battery_android_3";
if (percent >= 25)
return "battery_android_2";
if (percent >= 10)
return "battery_android_1";
if (percent >= 0)
return "battery_android_0";
} }
visible: isReady && battery.isLaptopBattery visible: testMode || (isReady && battery.isLaptopBattery)
width: pill.width width: pill.width
height: pill.height height: pill.height
PillIndicator { PillIndicator {
id: pill id: pill
icon: batteryIcon() icon: batteryWidget.batteryIcon()
text: Math.round(batteryWidget.percent) + "%" text: Math.round(batteryWidget.percent) + "%"
pillColor: Theme.surfaceVariant pillColor: Theme.surfaceVariant
iconCircleColor: Theme.accentPrimary iconCircleColor: Theme.accentPrimary
iconTextColor: Theme.backgroundPrimary
textColor: charging ? Theme.accentPrimary : Theme.textPrimary textColor: charging ? Theme.accentPrimary : Theme.textPrimary
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
hoverEnabled: true hoverEnabled: true
onEntered: { onEntered: {
pill.show(); pill.showDelayed();
batteryTooltip.tooltipVisible = true; batteryTooltip.tooltipVisible = true;
} }
onExited: { onExited: {

View file

@ -106,14 +106,13 @@ Item {
iconCircleColor: Theme.accentPrimary iconCircleColor: Theme.accentPrimary
iconTextColor: Theme.backgroundPrimary iconTextColor: Theme.backgroundPrimary
textColor: Theme.textPrimary textColor: Theme.textPrimary
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
hoverEnabled: true hoverEnabled: true
onEntered: { onEntered: {
getBrightness() getBrightness()
brightnessTooltip.tooltipVisible = true brightnessTooltip.tooltipVisible = true
pill.show() pill.showDelayed()
} }
onExited: { onExited: {
brightnessTooltip.tooltipVisible = false brightnessTooltip.tooltipVisible = false

View file

@ -85,7 +85,7 @@ Item {
onEntered: { onEntered: {
volumeDisplay.containsMouse = true volumeDisplay.containsMouse = true
pillIndicator.autoHide = false; pillIndicator.autoHide = false;
pillIndicator.show() pillIndicator.showDelayed()
} }
onExited: { onExited: {
volumeDisplay.containsMouse = false volumeDisplay.containsMouse = false

View file

@ -180,5 +180,30 @@ Item {
if (showPill) { if (showPill) {
hideAnim.start(); hideAnim.start();
} }
// Stop the show timer if it's running
showTimer.stop();
}
function showDelayed() {
if (!showPill) {
shouldAnimateHide = autoHide;
// Add a 500ms delay before showing
showTimer.start();
} else {
// Reset hide timer if already shown
hideAnim.stop();
delayedHideAnim.restart();
}
}
// Timer for delayed show
Timer {
id: showTimer
interval: 500 // 500ms delay
onTriggered: {
if (!showPill) {
showAnim.start();
}
}
} }
} }

View file

@ -211,7 +211,7 @@ Contributions are welcome! Feel free to open issues or submit pull requests.
#### Donation #### Donation
--- ---
While I actually didn't want to accept donations, more and more people are asking to donate so... I still feel weird about taking any donations for this. However if you really feel like donating then I obviously highly appreciate it but **PLEASE** never feel forced to donate or anything. It won't change how I work on Noctalia, it's a project that I work on for fun in the end. While I actually didn't want to accept donations, more and more people are asking to donate so... I don't know, if you really feel like donating then I obviously highly appreciate it but **PLEASE** never feel forced to donate or anything. It won't change how I work on Noctalia, it's a project that I work on for fun in the end.
[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/R6R01IX85B) [![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/R6R01IX85B)
--- ---

View file

@ -7,7 +7,7 @@ import qs.Settings
Rectangle { Rectangle {
id: profileSettingsCard id: profileSettingsCard
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredHeight: 580 Layout.preferredHeight: 650
color: Theme.surface color: Theme.surface
radius: 18 radius: 18

View file

@ -7,6 +7,7 @@ import Quickshell.Io
import qs.Settings import qs.Settings
import qs.Widgets import qs.Widgets
import qs.Helpers import qs.Helpers
import qs.Services
import qs.Components import qs.Components
Rectangle { Rectangle {