qmlfmt with 120 chars width (rulers)

This commit is contained in:
quadbyte 2025-08-10 14:39:25 -04:00
parent def932c447
commit d3f66b1737
17 changed files with 77 additions and 126 deletions

View file

@ -4,4 +4,4 @@
# Can be installed from AUR "qmlfmt-git" # Can be installed from AUR "qmlfmt-git"
# Requires qt6-5compat # Requires qt6-5compat
find . -name "*.qml" -exec qmlfmt -t 2 -i 2 -w {} \; find . -name "*.qml" -exec qmlfmt -e -b 120 -t 2 -i 2 -w {} \;

View file

@ -8,8 +8,7 @@ Variants {
delegate: PanelWindow { delegate: PanelWindow {
required property ShellScreen modelData required property ShellScreen modelData
property string wallpaperSource: Qt.resolvedUrl( property string wallpaperSource: Qt.resolvedUrl("../../Assets/Tests/wallpaper.png")
"../../Assets/Tests/wallpaper.png")
visible: wallpaperSource !== "" visible: wallpaperSource !== ""
color: "transparent" color: "transparent"

View file

@ -9,8 +9,7 @@ Variants {
delegate: PanelWindow { delegate: PanelWindow {
required property ShellScreen modelData required property ShellScreen modelData
property string wallpaperSource: Qt.resolvedUrl( property string wallpaperSource: Qt.resolvedUrl("../../Assets/Tests/wallpaper.png")
"../../Assets/Tests/wallpaper.png")
visible: wallpaperSource !== "" visible: wallpaperSource !== ""
color: "transparent" color: "transparent"
@ -50,8 +49,7 @@ Variants {
Rectangle { Rectangle {
anchors.fill: parent anchors.fill: parent
color: Qt.rgba(Colors.backgroundPrimary.r, Colors.backgroundPrimary.g, color: Qt.rgba(Colors.backgroundPrimary.r, Colors.backgroundPrimary.g, Colors.backgroundPrimary.b, 0.5)
Colors.backgroundPrimary.b, 0.5)
} }
} }
} }

View file

@ -17,8 +17,7 @@ Variants {
screen: modelData screen: modelData
implicitHeight: Style.barHeight * scaling implicitHeight: Style.barHeight * scaling
color: "transparent" color: "transparent"
visible: Settings.data.bar.monitors.includes(modelData.name) visible: Settings.data.bar.monitors.includes(modelData.name) || (Settings.data.bar.monitors.length === 0)
|| (Settings.data.bar.monitors.length === 0)
anchors { anchors {
top: true top: true

View file

@ -6,7 +6,7 @@ import qs.Services
import qs.Widgets import qs.Widgets
import "../../Helpers/Duration.js" as Duration import "../../Helpers/Duration.js" as Duration
Item { NPill {
id: root id: root
// Test mode // Test mode
@ -15,9 +15,7 @@ Item {
property bool testCharging: false property bool testCharging: false
property var battery: UPower.displayDevice property var battery: UPower.displayDevice
property bool isReady: testMode ? true : (battery && battery.ready property bool isReady: testMode ? true : (battery && battery.ready && battery.isLaptopBattery && battery.isPresent)
&& battery.isLaptopBattery
&& battery.isPresent)
property real percent: testMode ? testPercent : (isReady ? (battery.percentage * 100) : 0) property real percent: testMode ? testPercent : (isReady ? (battery.percentage * 100) : 0)
property bool charging: testMode ? testCharging : (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
@ -51,11 +49,7 @@ Item {
} }
visible: testMode || (isReady && battery.isLaptopBattery) visible: testMode || (isReady && battery.isLaptopBattery)
width: pill.width
height: pill.height
NPill {
id: pill
icon: root.batteryIcon() icon: root.batteryIcon()
text: Math.round(root.percent) + "%" text: Math.round(root.percent) + "%"
pillColor: Colors.surfaceVariant pillColor: Colors.surfaceVariant
@ -69,21 +63,17 @@ Item {
} }
if (root.battery.timeToEmpty > 0) { if (root.battery.timeToEmpty > 0) {
lines.push("Time left: " + Time.formatVagueHumanReadableTime( lines.push("Time left: " + Time.formatVagueHumanReadableTime(root.battery.timeToEmpty))
root.battery.timeToEmpty))
} }
if (root.battery.timeToFull > 0) { if (root.battery.timeToFull > 0) {
lines.push("Time until full: " + Time.formatVagueHumanReadableTime( lines.push("Time until full: " + Time.formatVagueHumanReadableTime(root.battery.timeToFull))
root.battery.timeToFull))
} }
if (root.battery.changeRate !== undefined) { if (root.battery.changeRate !== undefined) {
const rate = root.battery.changeRate const rate = root.battery.changeRate
if (rate > 0) { if (rate > 0) {
lines.push( lines.push(root.charging ? "Charging rate: " + rate.toFixed(2) + " W" : "Discharging rate: " + rate.toFixed(
root.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")
@ -94,11 +84,9 @@ Item {
lines.push(root.charging ? "Charging" : "Discharging") lines.push(root.charging ? "Charging" : "Discharging")
} }
if (root.battery.healthPercentage !== undefined if (root.battery.healthPercentage !== undefined && root.battery.healthPercentage > 0) {
&& root.battery.healthPercentage > 0) {
lines.push("Health: " + Math.round(root.battery.healthPercentage) + "%") lines.push("Health: " + Math.round(root.battery.healthPercentage) + "%")
} }
return lines.join("\n") return lines.join("\n")
} }
} }
}

View file

@ -123,8 +123,7 @@ Item {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
radius: Math.round(12 * s) radius: Math.round(12 * s)
color: Colors.surfaceVariant color: Colors.surfaceVariant
border.color: Qt.rgba(Colors.textPrimary.r, Colors.textPrimary.g, border.color: Qt.rgba(Colors.textPrimary.r, Colors.textPrimary.g, Colors.textPrimary.b, 0.1)
Colors.textPrimary.b, 0.1)
border.width: Math.max(1, Math.round(1 * s)) border.width: Math.max(1, Math.round(1 * s))
layer.enabled: true layer.enabled: true
layer.effect: MultiEffect { layer.effect: MultiEffect {
@ -252,10 +251,8 @@ Item {
radius: width / 2 radius: width / 2
color: "transparent" color: "transparent"
border.color: root.effectColor border.color: root.effectColor
border.width: Math.max(1, Math.round( border.width: Math.max(1, Math.round((2 + 6 * (1.0 - root.masterProgress)) * s))
(2 + 6 * (1.0 - root.masterProgress)) * s)) opacity: root.effectsActive && model.isFocused ? (1.0 - root.masterProgress) * 0.7 : 0
opacity: root.effectsActive
&& model.isFocused ? (1.0 - root.masterProgress) * 0.7 : 0
visible: root.effectsActive && model.isFocused visible: root.effectsActive && model.isFocused
z: 1 z: 1
} }

View file

@ -59,8 +59,7 @@ NLoader {
// Place the panel just below the bar (overlay content starts below bar due to topMargin) // Place the panel just below the bar (overlay content starts below bar due to topMargin)
y: Style.marginSmall * scaling y: Style.marginSmall * scaling
// Center horizontally under the anchorX, clamped to the screen bounds // Center horizontally under the anchorX, clamped to the screen bounds
x: Math.max(Style.marginSmall * scaling, Math.min( x: Math.max(Style.marginSmall * scaling, Math.min(parent.width - width - Style.marginSmall * scaling,
parent.width - width - Style.marginSmall * scaling,
Math.round(anchorX - width / 2))) Math.round(anchorX - width / 2)))
// Prevent closing when clicking in the panel bg // Prevent closing when clicking in the panel bg

View file

@ -17,8 +17,7 @@ Singleton {
function updateFocusedWindowTitle() { function updateFocusedWindowTitle() {
if (focusedWindowIndex >= 0 && focusedWindowIndex < windows.length) { if (focusedWindowIndex >= 0 && focusedWindowIndex < windows.length) {
focusedWindowTitle = windows[focusedWindowIndex].title focusedWindowTitle = windows[focusedWindowIndex].title || "(Unnamed window)"
|| "(Unnamed window)"
} else { } else {
focusedWindowTitle = "(No active window)" focusedWindowTitle = "(No active window)"
} }
@ -113,8 +112,7 @@ Singleton {
try { try {
const focusedId = event.WindowFocusChanged.id const focusedId = event.WindowFocusChanged.id
if (focusedId) { if (focusedId) {
root.focusedWindowIndex = root.windows.findIndex( root.focusedWindowIndex = root.windows.findIndex(w => w.id === focusedId)
w => w.id === focusedId)
if (root.focusedWindowIndex < 0) { if (root.focusedWindowIndex < 0) {
root.focusedWindowIndex = 0 root.focusedWindowIndex = 0
} }

View file

@ -7,13 +7,10 @@ pragma Singleton
Singleton { Singleton {
property string shellName: "noctalia" property string shellName: "noctalia"
property string settingsDir: Quickshell.env("NOCTALIA_SETTINGS_DIR") property string settingsDir: Quickshell.env("NOCTALIA_SETTINGS_DIR")
|| (Quickshell.env("XDG_CONFIG_HOME") || (Quickshell.env("XDG_CONFIG_HOME") || Quickshell.env(
|| Quickshell.env(
"HOME") + "/.config") + "/" + shellName + "/" "HOME") + "/.config") + "/" + shellName + "/"
property string settingsFile: Quickshell.env("NOCTALIA_SETTINGS_FILE") property string settingsFile: Quickshell.env("NOCTALIA_SETTINGS_FILE") || (settingsDir + "settings.json")
|| (settingsDir + "settings.json") property string colorsFile: Quickshell.env("NOCTALIA_COLORS_FILE") || (settingsDir + "colors.json")
property string colorsFile: Quickshell.env("NOCTALIA_COLORS_FILE")
|| (settingsDir + "colors.json")
property var data: settingAdapter property var data: settingAdapter
// Needed to only have one NPanel loaded at a time. // Needed to only have one NPanel loaded at a time.

View file

@ -8,9 +8,7 @@ Singleton {
id: root id: root
property var date: new Date() property var date: new Date()
property string time: Settings.data.location.use12HourClock ? Qt.formatDateTime( property string time: Settings.data.location.use12HourClock ? Qt.formatDateTime(date, "h:mm AP") : Qt.formatDateTime(
date,
"h:mm AP") : Qt.formatDateTime(
date, "HH:mm") date, "HH:mm")
property string dateString: { property string dateString: {
let now = date let now = date
@ -36,7 +34,8 @@ Singleton {
} }
let month = now.toLocaleDateString(Qt.locale(), "MMMM") let month = now.toLocaleDateString(Qt.locale(), "MMMM")
let year = now.toLocaleDateString(Qt.locale(), "yyyy") let year = now.toLocaleDateString(Qt.locale(), "yyyy")
return `${dayName}, ` + (Settings.data.location.reverseDayMonth ? `${month} ${day}${suffix} ${year}` : `${day}${suffix} ${month} ${year}`) return `${dayName}, `
+ (Settings.data.location.reverseDayMonth ? `${month} ${day}${suffix} ${year}` : `${day}${suffix} ${month} ${year}`)
} }
Timer { Timer {

View file

@ -26,8 +26,7 @@ Singleton {
scanning = true scanning = true
wallpaperList = [] wallpaperList = []
folderModel.folder = "" folderModel.folder = ""
folderModel.folder = "file://" + (Settings.data.wallpaper.directory folderModel.folder = "file://" + (Settings.data.wallpaper.directory !== undefined ? Settings.data.wallpaper.directory : "")
!== undefined ? Settings.data.wallpaper.directory : "")
} }
function changeWallpaper(path) { function changeWallpaper(path) {
@ -41,8 +40,7 @@ Singleton {
} }
if (Settings.data.swww.enabled) { if (Settings.data.swww.enabled) {
if (Settings.data.swww.transitionType === "random") { if (Settings.data.swww.transitionType === "random") {
transitionType = randomChoices[Math.floor(Math.random( transitionType = randomChoices[Math.floor(Math.random() * randomChoices.length)]
) * randomChoices.length)]
} else { } else {
transitionType = Settings.data.swww.transitionType transitionType = Settings.data.swww.transitionType
} }
@ -107,8 +105,7 @@ Singleton {
var files = [] var files = []
var filesSwww = [] var filesSwww = []
for (var i = 0; i < count; i++) { for (var i = 0; i < count; i++) {
var filepath = (Settings.data.wallpaper.folder var filepath = (Settings.data.wallpaper.folder !== undefined ? Settings.data.wallpaper.folder : "") + "/" + get(
!== undefined ? Settings.data.wallpaper.folder : "") + "/" + get(
i, "fileName") i, "fileName")
files.push(filepath) files.push(filepath)
} }

View file

@ -143,9 +143,7 @@ Singleton {
} }
} else if (isNiri) { } else if (isNiri) {
try { try {
Quickshell.execDetached( Quickshell.execDetached(["niri", "msg", "action", "focus-workspace", workspaceId.toString()])
["niri", "msg", "action", "focus-workspace", workspaceId.toString(
)])
} catch (e) { } catch (e) {
console.error("Error switching Niri workspace:", e) console.error("Error switching Niri workspace:", e)
} }

View file

@ -20,8 +20,7 @@ PanelWindow {
function show() { function show() {
// Ensure only one panel is visible at a time using Settings as ephemeral store // Ensure only one panel is visible at a time using Settings as ephemeral store
try { try {
if (Settings.openPanel && Settings.openPanel !== outerPanel if (Settings.openPanel && Settings.openPanel !== outerPanel && Settings.openPanel.hide) {
&& Settings.openPanel.hide) {
Settings.openPanel.hide() Settings.openPanel.hide()
} }
Settings.openPanel = outerPanel Settings.openPanel = outerPanel

View file

@ -27,9 +27,7 @@ Item {
readonly property int iconSize: Style.baseWidgetSize * sizeMultiplier * scaling readonly property int iconSize: Style.baseWidgetSize * sizeMultiplier * scaling
readonly property int pillPaddingHorizontal: 14 * scaling readonly property int pillPaddingHorizontal: 14 * scaling
readonly property int pillOverlap: iconSize * 0.5 readonly property int pillOverlap: iconSize * 0.5
readonly property int maxPillWidth: Math.max( readonly property int maxPillWidth: Math.max(1, textItem.implicitWidth + pillPaddingHorizontal * 2 + pillOverlap)
1, textItem.implicitWidth
+ pillPaddingHorizontal * 2 + pillOverlap)
// TBC, do we use those ? // TBC, do we use those ?
signal shown signal shown

View file

@ -52,9 +52,7 @@ Slider {
height: knobDiameter + cutoutExtra height: knobDiameter + cutoutExtra
radius: width / 2 radius: width / 2
color: root.cutoutColor !== undefined ? root.cutoutColor : Colors.backgroundPrimary color: root.cutoutColor !== undefined ? root.cutoutColor : Colors.backgroundPrimary
x: Math.max( x: Math.max(0, Math.min(parent.width - width,
0, Math.min(
parent.width - width,
root.visualPosition * (parent.width - root.knobDiameter) - cutoutExtra / 2)) root.visualPosition * (parent.width - root.knobDiameter) - cutoutExtra / 2))
y: (parent.height - height) / 2 y: (parent.height - height) / 2
} }

View file

@ -24,26 +24,17 @@ Item {
command: ["sh", "-c", // Outputs: {"cpu":<int>,"memper":<int>,"cputemp":<int>} command: ["sh", "-c", // Outputs: {"cpu":<int>,"memper":<int>,"cputemp":<int>}
"interval=" + intervalSeconds + "; " + "while true; do " + // First /proc/stat snapshot "interval=" + intervalSeconds + "; " + "while true; do " + // First /proc/stat snapshot
"read _ u1 n1 s1 id1 iw1 ir1 si1 st1 gs1 < /proc/stat; " "read _ u1 n1 s1 id1 iw1 ir1 si1 st1 gs1 < /proc/stat; "
+ "t1=$((u1+n1+s1+id1+iw1+ir1+si1+st1)); i1=$((id1+iw1)); " + "t1=$((u1+n1+s1+id1+iw1+ir1+si1+st1)); i1=$((id1+iw1)); " + "sleep $interval; " + // Second /proc/stat snapshot
+ "sleep $interval; " + // Second /proc/stat snapshot "read _ u2 n2 s2 id2 iw2 ir2 si2 st2 gs2 < /proc/stat; " + "t2=$((u2+n2+s2+id2+iw2+ir2+si2+st2)); i2=$((id2+iw2)); "
"read _ u2 n2 s2 id2 iw2 ir2 si2 st2 gs2 < /proc/stat; " + "dt=$((t2 - t1)); di=$((i2 - i1)); " + "cpu=$(( (100*(dt - di)) / (dt>0?dt:1) )); " + // Memory percent via /proc/meminfo (kB)
+ "t2=$((u2+n2+s2+id2+iw2+ir2+si2+st2)); i2=$((id2+iw2)); " "mt=$(awk '/MemTotal/ {print $2}' /proc/meminfo); " + "ma=$(awk '/MemAvailable/ {print $2}' /proc/meminfo); "
+ "dt=$((t2 - t1)); di=$((i2 - i1)); " + "cpu=$(( (100*(dt - di)) / (dt>0?dt:1) )); " + "mm=$((mt - ma)); mp=$(( (100*mm) / (mt>0?mt:1) )); " + // Temperature: scan hwmon and thermal zones, choose max; convert m°C °C
+ // Memory percent via /proc/meminfo (kB) "ct=0; " + "for f in /sys/class/hwmon/hwmon*/temp*_input /sys/class/thermal/thermal_zone*/temp; do "
"mt=$(awk '/MemTotal/ {print $2}' /proc/meminfo); "
+ "ma=$(awk '/MemAvailable/ {print $2}' /proc/meminfo); "
+ "mm=$((mt - ma)); mp=$(( (100*mm) / (mt>0?mt:1) )); "
+ // Temperature: scan hwmon and thermal zones, choose max; convert m°C °C
"ct=0; "
+ "for f in /sys/class/hwmon/hwmon*/temp*_input /sys/class/thermal/thermal_zone*/temp; do "
+ "[ -r \"$f\" ] || continue; v=$(cat \"$f\" 2>/dev/null); " + "[ -z \"$v\" ] && continue; " + "[ -r \"$f\" ] || continue; v=$(cat \"$f\" 2>/dev/null); " + "[ -z \"$v\" ] && continue; "
+ "if [ \"$v\" -gt 1000 ] 2>/dev/null; then v=$((v/1000)); fi; " + "if [ \"$v\" -gt 1000 ] 2>/dev/null; then v=$((v/1000)); fi; " + "[ \"$v\" -gt \"$ct\" ] 2>/dev/null && ct=$v; "
+ "[ \"$v\" -gt \"$ct\" ] 2>/dev/null && ct=$v; " + "done; " + "done; " + // Disk usage percent for root filesystem
+ // Disk usage percent for root filesystem "dp=$(df -P / 2>/dev/null | awk 'NR==2{gsub(/%/,\"\",$5); print $5}'); " + "[ -z \"$dp\" ] && dp=0; " + // Emit JSON line
"dp=$(df -P / 2>/dev/null | awk 'NR==2{gsub(/%/,\"\",$5); print $5}'); " "echo \"{\\\"cpu\\\":$cpu,\\\"memper\\\":$mp,\\\"cputemp\\\":$ct,\\\"diskper\\\":$dp}\"; " + "done"]
+ "[ -z \"$dp\" ] && dp=0; " + // Emit JSON line
"echo \"{\\\"cpu\\\":$cpu,\\\"memper\\\":$mp,\\\"cputemp\\\":$ct,\\\"diskper\\\":$dp}\"; "
+ "done"]
stdout: SplitParser { stdout: SplitParser {
onRead: function (line) { onRead: function (line) {

View file

@ -37,12 +37,8 @@ Window {
function _showNow() { function _showNow() {
// Compute new size everytime we show the tooltip // Compute new size everytime we show the tooltip
width = Math.max( width = Math.max(50 * scaling, tooltipText.implicitWidth + Style.marginLarge * 2 * scaling)
50 * scaling, height = Math.max(50 * scaling, tooltipText.implicitHeight + Style.marginSmall * 2 * scaling)
tooltipText.implicitWidth + Style.marginLarge * 2 * scaling)
height = Math.max(
50 * scaling,
tooltipText.implicitHeight + Style.marginSmall * 2 * scaling)
if (!target) { if (!target) {
return return