Autoformating

This commit is contained in:
LemmyCook 2025-08-21 21:24:30 -04:00
parent 18484f6686
commit cb554f106b
15 changed files with 170 additions and 103 deletions

View file

@ -43,9 +43,11 @@ Loader {
}
margins {
top: ((modelData && Settings.data.bar.monitors.includes(modelData.name)) || (Settings.data.bar.monitors.length === 0))
top: ((modelData && Settings.data.bar.monitors.includes(modelData.name))
|| (Settings.data.bar.monitors.length === 0))
&& Settings.data.bar.position === "top" ? Math.floor(Style.barHeight * scaling) : 0
bottom: ((modelData && Settings.data.bar.monitors.includes(modelData.name)) || (Settings.data.bar.monitors.length === 0))
bottom: ((modelData && Settings.data.bar.monitors.includes(modelData.name))
|| (Settings.data.bar.monitors.length === 0))
&& Settings.data.bar.position === "bottom" ? Math.floor(Style.barHeight * scaling) : 0
}

View file

@ -77,7 +77,8 @@ NPill {
if (root.battery.changeRate !== undefined) {
const rate = root.battery.changeRate
if (rate > 0) {
lines.push(root.charging ? "Charging rate: " + rate.toFixed(2) + " W" : "Discharging rate: " + rate.toFixed(2) + " W")
lines.push(root.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")
} else {

View file

@ -22,7 +22,8 @@ Item {
function getIcon() {
var monitor = getMonitor()
var brightness = monitor ? monitor.brightness : 0
return brightness <= 0 ? "brightness_1" : brightness < 0.33 ? "brightness_low" : brightness < 0.66 ? "brightness_medium" : "brightness_high"
return brightness <= 0 ? "brightness_1" : brightness < 0.33 ? "brightness_low" : brightness
< 0.66 ? "brightness_medium" : "brightness_high"
}
// Connection used to open the pill when brightness changes
@ -64,13 +65,16 @@ Item {
}
tooltipText: {
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."
if (!monitor)
return ""
return "Brightness: " + Math.round(monitor.brightness * 100) + "%\nMethod: " + monitor.method
+ "\nLeft click for advanced settings.\nScroll up/down to change brightness."
}
onWheel: function (angle) {
var monitor = getMonitor()
if (!monitor) return
if (!monitor)
return
if (angle > 0) {
monitor.increaseBrightness()
} else if (angle < 0) {

View file

@ -9,8 +9,14 @@ QtObject {
function parseImageMeta(preview) {
const re = /\[\[\s*binary data\s+([\d\.]+\s*(?:KiB|MiB|GiB|B))\s+(\w+)\s+(\d+)x(\d+)\s*\]\]/i
const m = (preview || "").match(re)
if (!m) return null
return { size: m[1], fmt: (m[2] || "").toUpperCase(), w: Number(m[3]), h: Number(m[4]) }
if (!m)
return null
return {
"size": m[1],
"fmt": (m[2] || "").toUpperCase(),
"w": Number(m[3]),
"h": Number(m[4])
}
}
function formatTextPreview(preview) {
@ -23,7 +29,10 @@ QtObject {
} else {
subtitle = `${normalized.length} chars`
}
return { title, subtitle }
return {
"title": title,
"subtitle": subtitle
}
}
function createClipboardEntry(item) {

View file

@ -351,10 +351,12 @@ Loader {
model: CavaService.values.length * 2
Rectangle {
property int mirroredValueIndex: index < CavaService.values.length ? index : (CavaService.values.length * 2 - 1 - index)
property int mirroredValueIndex: index < CavaService.values.length ? index : (CavaService.values.length
* 2 - 1 - index)
property real mirroredAngle: (index / (CavaService.values.length * 2)) * 2 * Math.PI
property real mirroredRadius: 70 * scaling
property real mirroredBarLength: Math.max(2, CavaService.values[mirroredValueIndex] * 30 * scaling)
property real mirroredBarLength: Math.max(2,
CavaService.values[mirroredValueIndex] * 30 * scaling)
property real mirroredBarWidth: 3 * scaling
width: mirroredBarWidth

View file

@ -176,8 +176,6 @@ NPanel {
hoverEnabled: true
}
}
}
}
}

View file

@ -49,7 +49,11 @@ ColumnLayout {
}
}
NDivider { Layout.fillWidth: true; Layout.topMargin: Style.marginL * scaling; Layout.bottomMargin: Style.marginS * scaling }
NDivider {
Layout.fillWidth: true
Layout.topMargin: Style.marginL * scaling
Layout.bottomMargin: Style.marginS * scaling
}
NText {
text: "Launcher Position"
@ -65,21 +69,33 @@ ColumnLayout {
description: "Choose where the Launcher panel appears."
Layout.fillWidth: true
model: ListModel {
ListElement { key: "center"; name: "Center (default)" }
ListElement { key: "top_left"; name: "Top Left" }
ListElement { key: "top_right"; name: "Top Right" }
ListElement { key: "bottom_left"; name: "Bottom Left" }
ListElement { key: "bottom_right"; name: "Bottom Right" }
ListElement {
key: "center"
name: "Center (default)"
}
ListElement {
key: "top_left"
name: "Top Left"
}
ListElement {
key: "top_right"
name: "Top Right"
}
ListElement {
key: "bottom_left"
name: "Bottom Left"
}
ListElement {
key: "bottom_right"
name: "Bottom Right"
}
}
currentKey: Settings.data.appLauncher.position
onSelected: function (key) {
Settings.data.appLauncher.position = key
}
}
}
}
}
}

View file

@ -37,8 +37,8 @@ Singleton {
Process {
id: process
stdinEnabled: true
running: (Settings.data.audio.visualizerType !== "none") && (PanelService.sidePanel.active
|| Settings.data.audio.showMiniplayerCava
running: (Settings.data.audio.visualizerType !== "none")
&& (PanelService.sidePanel.active || Settings.data.audio.showMiniplayerCava
|| (PanelService.lockScreen && PanelService.lockScreen.active))
command: ["cava", "-p", "/dev/stdin"]
onExited: {

View file

@ -34,7 +34,8 @@ Singleton {
// Start/stop watchers when enabled changes
Component.onCompleted: {
if (root.active) startWatchers()
if (root.active)
startWatchers()
}
onActiveChanged: {
if (root.active) {
@ -80,13 +81,23 @@ Singleton {
// Best-effort mime guess from preview
var mime = "text/plain"
if (isImage) {
if (lower.includes(" png")) mime = "image/png"
else if (lower.includes(" jpg") || lower.includes(" jpeg")) mime = "image/jpeg"
else if (lower.includes(" webp")) mime = "image/webp"
else if (lower.includes(" gif")) mime = "image/gif"
else mime = "image/*"
if (lower.includes(" png"))
mime = "image/png"
else if (lower.includes(" jpg") || lower.includes(" jpeg"))
mime = "image/jpeg"
else if (lower.includes(" webp"))
mime = "image/webp"
else if (lower.includes(" gif"))
mime = "image/gif"
else
mime = "image/*"
}
return {
"id": id,
"preview": preview,
"isImage": isImage,
"mime": mime
}
return { id, preview, isImage, mime }
})
items = parsed
loading = false
@ -99,7 +110,11 @@ Singleton {
onExited: (exitCode, exitStatus) => {
const out = String(stdout.text)
if (root._decodeCallback) {
try { root._decodeCallback(out) } finally { root._decodeCallback = null }
try {
root._decodeCallback(out)
} finally {
root._decodeCallback = null
}
}
}
}
@ -117,7 +132,11 @@ Singleton {
const b64 = String(stdout.text).trim()
if (root._b64CurrentCb) {
const url = `data:${root._b64CurrentMime};base64,${b64}`
try { root._b64CurrentCb(url) } finally { /* noop */ }
try {
root._b64CurrentCb(url)
} finally {
/* noop */ }
}
if (root._b64CurrentId !== "") {
root.imageDataById[root._b64CurrentId] = `data:${root._b64CurrentMime};base64,${b64}`
@ -136,19 +155,26 @@ Singleton {
stdout: StdioCollector {}
onExited: (exitCode, exitStatus) => {
// Auto-restart if watcher dies
if (root.autoWatch) Qt.callLater(() => { running = true })
if (root.autoWatch)
Qt.callLater(() => {
running = true
})
}
}
Process {
id: watchImage
stdout: StdioCollector {}
onExited: (exitCode, exitStatus) => {
if (root.autoWatch) Qt.callLater(() => { running = true })
if (root.autoWatch)
Qt.callLater(() => {
running = true
})
}
}
function startWatchers() {
if (!root.active || !autoWatch || watchersStarted) return
if (!root.active || !autoWatch || watchersStarted)
return
watchersStarted = true
// Start text watcher
watchText.command = ["wl-paste", "--type", "text", "--watch", "cliphist", "store"]
@ -159,15 +185,19 @@ Singleton {
}
function stopWatchers() {
if (!watchersStarted) return
if (!watchersStarted)
return
watchText.running = false
watchImage.running = false
watchersStarted = false
}
function list(maxPreviewWidth) {
if (!root.active) { return }
if (listProc.running) return
if (!root.active) {
return
}
if (listProc.running)
return
loading = true
const width = maxPreviewWidth || 100
listProc.command = ["cliphist", "list", "-preview-width", String(width)]
@ -183,18 +213,24 @@ Singleton {
function decodeToDataUrl(id, mime, cb) {
// If cached, return immediately
if (root.imageDataById[id]) {
if (cb) cb(root.imageDataById[id])
if (cb)
cb(root.imageDataById[id])
return
}
// Queue request; ensures single process handles sequentially
root._b64Queue.push({ id, mime: mime || "image/*", cb })
root._b64Queue.push({
"id": id,
"mime": mime || "image/*",
"cb": cb
})
if (!decodeB64Proc.running && root._b64CurrentCb === null) {
_startNextB64()
}
}
function _startNextB64() {
if (root._b64Queue.length === 0) return
if (root._b64Queue.length === 0)
return
const job = root._b64Queue.shift()
root._b64CurrentCb = job.cb
root._b64CurrentMime = job.mime
@ -219,5 +255,3 @@ Singleton {
Qt.callLater(() => list())
}
}

View file

@ -131,6 +131,7 @@ Singleton {
}
}
} catch (e2) {
// ignore occupancy errors; fall back to false
}
for (var i = 0; i < hlWorkspaces.length; i++) {