Formatting: Brightness, wifi, network

This commit is contained in:
quadbyte 2025-08-15 10:23:40 -04:00
parent 13df665f94
commit 838962e448
4 changed files with 66 additions and 69 deletions

View file

@ -19,9 +19,7 @@ Item {
return "brightness_auto"
}
var brightness = BrightnessService.brightness
return brightness <= 0 ? "brightness_1" :
brightness < 33 ? "brightness_low" :
brightness < 66 ? "brightness_medium" : "brightness_high"
return brightness <= 0 ? "brightness_1" : brightness < 33 ? "brightness_low" : brightness < 66 ? "brightness_medium" : "brightness_high"
}
// Connection used to open the pill when brightness changes
@ -46,8 +44,6 @@ Item {
}
}
NPill {
id: pill
icon: getIcon()
@ -55,10 +51,13 @@ Item {
collapsedIconColor: Colors.mOnSurface
autoHide: true
text: Math.round(BrightnessService.brightness) + "%"
tooltipText: "Brightness: " + Math.round(BrightnessService.brightness) + "%\nMethod: " + BrightnessService.currentMethod + "\nLeft click for advanced settings.\nScroll up/down to change brightness."
tooltipText: "Brightness: " + Math.round(
BrightnessService.brightness) + "%\nMethod: " + BrightnessService.currentMethod
+ "\nLeft click for advanced settings.\nScroll up/down to change brightness."
onWheel: function (angle) {
if (!BrightnessService.available) return
if (!BrightnessService.available)
return
if (angle > 0) {
BrightnessService.increaseBrightness()

View file

@ -1,5 +1,6 @@
pragma Singleton
pragma ComponentBehavior: Bound
pragma ComponentBehavior
import QtQuick
import Quickshell
@ -17,15 +18,16 @@ Singleton {
readonly property bool available: focusedMonitor !== null
readonly property string currentMethod: focusedMonitor ? focusedMonitor.method : Settings.data.brightness.lastMethod
readonly property var detectedDisplays: monitors.map(m => ({
name: m.modelData.name,
type: m.isDdc ? "external" : "internal",
method: m.method,
index: m.busNum
"name": m.modelData.name,
"type": m.isDdc ? "external" : "internal",
"method": m.method,
"index": m.busNum
}))
// Get the currently focused monitor
readonly property Monitor focusedMonitor: {
if (monitors.length === 0) return null
if (monitors.length === 0)
return null
// For now, return the first monitor. Could be enhanced to detect focused monitor
return monitors[0]
}
@ -61,8 +63,7 @@ Singleton {
}
// Backward compatibility functions
function updateBrightness(): void {
// No longer needed with the new architecture
function updateBrightness(): void {// No longer needed with the new architecture
}
function setDisplay(displayIndex: int): bool {
@ -72,18 +73,21 @@ Singleton {
function getDisplayInfo(): var {
return focusedMonitor ? {
name: focusedMonitor.modelData.name,
type: focusedMonitor.isDdc ? "external" : "internal",
method: focusedMonitor.method,
index: focusedMonitor.busNum
"name": focusedMonitor.modelData.name,
"type": focusedMonitor.isDdc ? "external" : "internal",
"method": focusedMonitor.method,
"index": focusedMonitor.busNum
} : null
}
function getAvailableMethods(): list<string> {
var methods = []
if (monitors.some(m => m.isDdc)) methods.push("ddcutil")
if (monitors.some(m => !m.isDdc)) methods.push("internal")
if (appleDisplayPresent) methods.push("apple")
if (monitors.some(m => m.isDdc))
methods.push("ddcutil")
if (monitors.some(m => !m.isDdc))
methods.push("internal")
if (appleDisplayPresent)
methods.push("apple")
return methods
}
@ -124,16 +128,14 @@ Singleton {
var modelMatch = d.match(/Monitor:.*:(.*):.*/)
var busMatch = d.match(/I2C bus:[ ]*\/dev\/i2c-([0-9]+)/)
return {
model: modelMatch ? modelMatch[1] : "",
busNum: busMatch ? busMatch[1] : ""
"model": modelMatch ? modelMatch[1] : "",
"busNum": busMatch ? busMatch[1] : ""
}
})
}
}
}
component Monitor: QtObject {
id: monitor
@ -204,8 +206,6 @@ Singleton {
}
}
function getStoredBrightness(): real {
// Try to get stored brightness for this specific monitor
var stored = Settings.data.brightness.monitorBrightness.find(m => m.name === modelData.name)
@ -226,9 +226,9 @@ Singleton {
// Update monitor-specific brightness
var monitorIndex = Settings.data.brightness.monitorBrightness.findIndex(m => m.name === modelData.name)
var monitorData = {
name: modelData.name,
brightness: brightnessPercent,
method: method
"name": modelData.name,
"brightness": brightnessPercent,
"method": method
}
if (monitorIndex >= 0) {
@ -242,7 +242,8 @@ Singleton {
value = Math.max(0, Math.min(1, value))
var rounded = Math.round(value * 100)
if (Math.round(brightness * 100) === rounded) return
if (Math.round(brightness * 100) === rounded)
return
if (isDdc && timer.running) {
queuedBrightness = value
@ -285,8 +286,6 @@ Singleton {
initProc.running = true
}
onBusNumChanged: initBrightness()
Component.onCompleted: initBrightness()
}

View file

@ -135,8 +135,7 @@ QtObject {
}
}
function onMenuClosed() {
// No need to do anything special on close
function onMenuClosed() {// No need to do anything special on close
}
// Process to enable WiFi radio