NightLight/Bar: left click toggle, converted to NIconButton
+ Adapted some tooltip to the new richtext NText
This commit is contained in:
parent
87f9afbd85
commit
80f6570f04
7 changed files with 39 additions and 51 deletions
|
|
@ -48,10 +48,10 @@ NIconButton {
|
|||
|
||||
let tooltip = header
|
||||
if (pacmanTooltip !== "") {
|
||||
tooltip += "\n" + pacmanTooltip
|
||||
tooltip += "<br/>" + pacmanTooltip
|
||||
}
|
||||
if (aurTooltip !== "") {
|
||||
tooltip += "\n" + aurTooltip
|
||||
tooltip += "<br/>" + aurTooltip
|
||||
}
|
||||
return tooltip
|
||||
}
|
||||
|
|
|
|||
|
|
@ -102,25 +102,25 @@ Item {
|
|||
tooltipText: {
|
||||
let lines = []
|
||||
if (testMode) {
|
||||
lines.push("Time Left: " + Time.formatVagueHumanReadableDuration(12345))
|
||||
return lines.join("\n")
|
||||
lines.push("Time left: " + Time.formatVagueHumanReadableDuration(12345))
|
||||
return lines.join("<br/>")
|
||||
}
|
||||
if (!isReady || !battery.isLaptopBattery) {
|
||||
return "No Battery Detected"
|
||||
return "No battery detected"
|
||||
}
|
||||
if (battery.timeToEmpty > 0) {
|
||||
lines.push("Time Left: " + Time.formatVagueHumanReadableDuration(battery.timeToEmpty))
|
||||
lines.push("Time left: " + Time.formatVagueHumanReadableDuration(battery.timeToEmpty))
|
||||
}
|
||||
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) {
|
||||
const rate = battery.changeRate
|
||||
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")
|
||||
} 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 {
|
||||
lines.push("Estimating...")
|
||||
}
|
||||
|
|
@ -130,7 +130,7 @@ Item {
|
|||
if (battery.healthPercentage !== undefined && battery.healthPercentage > 0) {
|
||||
lines.push("Health: " + Math.round(battery.healthPercentage) + "%")
|
||||
}
|
||||
return lines.join("\n")
|
||||
return lines.join("<br/>")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,8 +70,8 @@ Item {
|
|||
var monitor = getMonitor()
|
||||
if (!monitor)
|
||||
return ""
|
||||
return "Brightness: " + Math.round(monitor.brightness * 100) + "%\nMethod: " + monitor.method
|
||||
+ "\nLeft click for advanced settings.\nScroll up/down to change brightness."
|
||||
return "Brightness: " + Math.round(monitor.brightness * 100) + "%<br/>Method: " + monitor.method
|
||||
+ "<br/>Left click for advanced settings.<br/>Scroll up/down to change brightness."
|
||||
}
|
||||
|
||||
onWheel: function (angle) {
|
||||
|
|
|
|||
|
|
@ -200,10 +200,10 @@ Row {
|
|||
text: {
|
||||
var str = ""
|
||||
if (MediaService.canGoNext) {
|
||||
str += "Right click for next\n"
|
||||
str += "Right click for next<br/>"
|
||||
}
|
||||
if (MediaService.canGoPrevious) {
|
||||
str += "Middle click for previous\n"
|
||||
str += "Middle click for previous<br/>"
|
||||
}
|
||||
return str
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,50 +1,32 @@
|
|||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import QtQuick.Controls
|
||||
import Quickshell
|
||||
import Quickshell.Wayland
|
||||
import qs.Commons
|
||||
import qs.Modules.SettingsPanel
|
||||
import qs.Services
|
||||
import qs.Widgets
|
||||
|
||||
Item {
|
||||
NIconButton {
|
||||
id: root
|
||||
|
||||
property ShellScreen screen
|
||||
property real scaling: ScalingService.scale(screen)
|
||||
|
||||
implicitWidth: pill.width
|
||||
implicitHeight: pill.height
|
||||
visible: true
|
||||
sizeRatio: 0.8
|
||||
|
||||
colorBg: Color.mSurfaceVariant
|
||||
colorFg: Color.mOnSurface
|
||||
colorBorder: Color.transparent
|
||||
colorBorderHover: Color.transparent
|
||||
|
||||
NPill {
|
||||
id: pill
|
||||
icon: Settings.data.nightLight.enabled ? "bedtime" : "bedtime_off"
|
||||
iconCircleColor: Settings.data.nightLight.enabled ? Color.mSecondary : Color.mOnSurfaceVariant
|
||||
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."
|
||||
}
|
||||
tooltipText: `Night Light: ${Settings.data.nightLight.enabled ? "enabled" : "disabled"}<br/>Left click to toggle.<br/>Right click to access settings.`
|
||||
onClicked: Settings.data.nightLight.enabled = !Settings.data.nightLight.enabled
|
||||
|
||||
var intensity = Math.round(Settings.data.nightLight.intensity * 100)
|
||||
var schedule = Settings.data.nightLight.autoSchedule ? `Auto schedule` : `Manual: ${Settings.data.nightLight.startTime} - ${Settings.data.nightLight.stopTime}`
|
||||
return `Night Light: Enabled\nIntensity: ${intensity}%\n${schedule}\nLeft click to open settings.\nRight click to toggle.`
|
||||
}
|
||||
|
||||
onClicked: {
|
||||
// Left click - open settings
|
||||
onRightClicked: {
|
||||
var settingsPanel = PanelService.getPanel("settingsPanel")
|
||||
settingsPanel.requestedTab = SettingsPanel.Tab.Display
|
||||
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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ Item {
|
|||
autoHide: false // Important to be false so we can hover as long as we want
|
||||
text: Math.floor(AudioService.volume * 100) + "%"
|
||||
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) {
|
||||
wheelAccumulator += delta
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ Rectangle {
|
|||
signal entered
|
||||
signal exited
|
||||
signal clicked
|
||||
signal rightClicked
|
||||
|
||||
implicitWidth: size
|
||||
implicitHeight: size
|
||||
|
|
@ -57,6 +58,7 @@ Rectangle {
|
|||
MouseArea {
|
||||
anchors.fill: parent
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||
hoverEnabled: true
|
||||
onEntered: {
|
||||
hovering = true
|
||||
|
|
@ -72,11 +74,15 @@ Rectangle {
|
|||
}
|
||||
root.exited()
|
||||
}
|
||||
onClicked: {
|
||||
onClicked: function (mouse) {
|
||||
if (tooltipText) {
|
||||
tooltip.hide()
|
||||
}
|
||||
if (mouse.button === Qt.LeftButton) {
|
||||
root.clicked()
|
||||
} else if (mouse.button === Qt.RightButton) {
|
||||
root.rightClicked()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue