This commit is contained in:
Ly-sec 2025-08-31 07:35:13 +02:00
commit 560f601190
7 changed files with 39 additions and 51 deletions

View file

@ -48,10 +48,10 @@ NIconButton {
let tooltip = header let tooltip = header
if (pacmanTooltip !== "") { if (pacmanTooltip !== "") {
tooltip += "\n" + pacmanTooltip tooltip += "<br/>" + pacmanTooltip
} }
if (aurTooltip !== "") { if (aurTooltip !== "") {
tooltip += "\n" + aurTooltip tooltip += "<br/>" + aurTooltip
} }
return tooltip return tooltip
} }

View file

@ -102,25 +102,25 @@ Item {
tooltipText: { tooltipText: {
let lines = [] let lines = []
if (testMode) { if (testMode) {
lines.push("Time Left: " + Time.formatVagueHumanReadableDuration(12345)) lines.push("Time left: " + Time.formatVagueHumanReadableDuration(12345))
return lines.join("\n") return lines.join("<br/>")
} }
if (!isReady || !battery.isLaptopBattery) { if (!isReady || !battery.isLaptopBattery) {
return "No Battery Detected" return "No battery detected"
} }
if (battery.timeToEmpty > 0) { if (battery.timeToEmpty > 0) {
lines.push("Time Left: " + Time.formatVagueHumanReadableDuration(battery.timeToEmpty)) lines.push("Time left: " + Time.formatVagueHumanReadableDuration(battery.timeToEmpty))
} }
if (battery.timeToFull > 0) { if (battery.timeToFull > 0) {
lines.push("Time Until Full: " + Time.formatVagueHumanReadableDuration(battery.timeToFull)) lines.push("Time until full: " + Time.formatVagueHumanReadableDuration(battery.timeToFull))
} }
if (battery.changeRate !== undefined) { if (battery.changeRate !== undefined) {
const rate = battery.changeRate const rate = battery.changeRate
if (rate > 0) { if (rate > 0) {
lines.push(charging ? "Charging Rate: " + rate.toFixed(2) + " W" : "Discharging Rate: " + rate.toFixed( lines.push(charging ? "Charging rate: " + rate.toFixed(2) + " W" : "Discharging rate: " + rate.toFixed(
2) + " W") 2) + " W")
} else if (rate < 0) { } else if (rate < 0) {
lines.push("Discharging Rate: " + Math.abs(rate).toFixed(2) + " W") lines.push("Discharging rate: " + Math.abs(rate).toFixed(2) + " W")
} else { } else {
lines.push("Estimating...") lines.push("Estimating...")
} }
@ -130,7 +130,7 @@ Item {
if (battery.healthPercentage !== undefined && battery.healthPercentage > 0) { if (battery.healthPercentage !== undefined && battery.healthPercentage > 0) {
lines.push("Health: " + Math.round(battery.healthPercentage) + "%") lines.push("Health: " + Math.round(battery.healthPercentage) + "%")
} }
return lines.join("\n") return lines.join("<br/>")
} }
} }
} }

View file

@ -70,8 +70,8 @@ Item {
var monitor = getMonitor() var monitor = getMonitor()
if (!monitor) if (!monitor)
return "" return ""
return "Brightness: " + Math.round(monitor.brightness * 100) + "%\nMethod: " + monitor.method return "Brightness: " + Math.round(monitor.brightness * 100) + "%<br/>Method: " + monitor.method
+ "\nLeft click for advanced settings.\nScroll up/down to change brightness." + "<br/>Left click for advanced settings.<br/>Scroll up/down to change brightness."
} }
onWheel: function (angle) { onWheel: function (angle) {

View file

@ -200,10 +200,10 @@ Row {
text: { text: {
var str = "" var str = ""
if (MediaService.canGoNext) { if (MediaService.canGoNext) {
str += "Right click for next\n" str += "Right click for next<br/>"
} }
if (MediaService.canGoPrevious) { if (MediaService.canGoPrevious) {
str += "Middle click for previous\n" str += "Middle click for previous<br/>"
} }
return str return str
} }

View file

@ -1,50 +1,32 @@
import QtQuick import QtQuick
import QtQuick.Layouts
import QtQuick.Controls
import Quickshell import Quickshell
import Quickshell.Wayland
import qs.Commons import qs.Commons
import qs.Modules.SettingsPanel
import qs.Services import qs.Services
import qs.Widgets import qs.Widgets
Item { NIconButton {
id: root id: root
property ShellScreen screen property ShellScreen screen
property real scaling: ScalingService.scale(screen) property real scaling: ScalingService.scale(screen)
implicitWidth: pill.width sizeRatio: 0.8
implicitHeight: pill.height
visible: true
NPill { colorBg: Color.mSurfaceVariant
id: pill colorFg: Color.mOnSurface
icon: Settings.data.nightLight.enabled ? "bedtime" : "bedtime_off" colorBorder: Color.transparent
iconCircleColor: Settings.data.nightLight.enabled ? Color.mSecondary : Color.mOnSurfaceVariant colorBorderHover: Color.transparent
collapsedIconColor: Settings.data.nightLight.enabled ? Color.mOnSecondary : Color.mOnSurface
autoHide: false
text: Settings.data.nightLight.enabled ? "On" : "Off"
tooltipText: {
if (!Settings.isLoaded || !Settings.data.nightLight.enabled) {
return "Night Light: Disabled\nLeft click to open settings.\nRight click to enable."
}
var intensity = Math.round(Settings.data.nightLight.intensity * 100) icon: Settings.data.nightLight.enabled ? "bedtime" : "bedtime_off"
var schedule = Settings.data.nightLight.autoSchedule ? `Auto schedule` : `Manual: ${Settings.data.nightLight.startTime} - ${Settings.data.nightLight.stopTime}` tooltipText: `Night Light: ${Settings.data.nightLight.enabled ? "enabled" : "disabled"}<br/>Left click to toggle.<br/>Right click to access settings.`
return `Night Light: Enabled\nIntensity: ${intensity}%\n${schedule}\nLeft click to open settings.\nRight click to toggle.` onClicked: Settings.data.nightLight.enabled = !Settings.data.nightLight.enabled
}
onClicked: { onRightClicked: {
// Left click - open settings var settingsPanel = PanelService.getPanel("settingsPanel")
var settingsPanel = PanelService.getPanel("settingsPanel") settingsPanel.requestedTab = SettingsPanel.Tab.Display
settingsPanel.requestedTab = SettingsPanel.Tab.Display settingsPanel.open(screen)
settingsPanel.open(screen)
}
onRightClicked: {
// Right click - toggle night light (debounced apply handled by service)
Settings.data.nightLight.enabled = !Settings.data.nightLight.enabled
NightLightService.apply()
}
// Wheel handler removed to avoid frequent rapid restarts/flicker
} }
} }

View file

@ -59,7 +59,7 @@ Item {
autoHide: false // Important to be false so we can hover as long as we want autoHide: false // Important to be false so we can hover as long as we want
text: Math.floor(AudioService.volume * 100) + "%" text: Math.floor(AudioService.volume * 100) + "%"
tooltipText: "Volume: " + Math.round( tooltipText: "Volume: " + Math.round(
AudioService.volume * 100) + "%\nLeft click for advanced settings.\nScroll up/down to change volume." AudioService.volume * 100) + "%<br/>Left click for advanced settings.<br/>Scroll up/down to change volume."
onWheel: function (delta) { onWheel: function (delta) {
wheelAccumulator += delta wheelAccumulator += delta

View file

@ -27,6 +27,7 @@ Rectangle {
signal entered signal entered
signal exited signal exited
signal clicked signal clicked
signal rightClicked
implicitWidth: size implicitWidth: size
implicitHeight: size implicitHeight: size
@ -57,6 +58,7 @@ Rectangle {
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
acceptedButtons: Qt.LeftButton | Qt.RightButton
hoverEnabled: true hoverEnabled: true
onEntered: { onEntered: {
hovering = true hovering = true
@ -72,11 +74,15 @@ Rectangle {
} }
root.exited() root.exited()
} }
onClicked: { onClicked: function (mouse) {
if (tooltipText) { if (tooltipText) {
tooltip.hide() tooltip.hide()
} }
root.clicked() if (mouse.button === Qt.LeftButton) {
root.clicked()
} else if (mouse.button === Qt.RightButton) {
root.rightClicked()
}
} }
} }
} }