From c07ab79b5ab4ec973bc8dc982164cfd12fc526a9 Mon Sep 17 00:00:00 2001 From: Lemmy Date: Thu, 25 Dec 2025 17:56:33 -0500 Subject: [PATCH] autoformat --- Commons/Migrations/Migration33.qml | 1 - Modules/LockScreen/LockScreen.qml | 1 - Services/Media/ScreenRecorderService.qml | 3 +- Services/Networking/BluetoothService.qml | 3 +- Services/Noctalia/GitHubService.qml | 4 +- Services/System/NotificationService.qml | 5 +- Services/UI/ImageCacheService.qml | 58 ++++++------- Widgets/NClock.qml | 102 ++++++++++++----------- Widgets/NImageCached.qml | 5 +- 9 files changed, 90 insertions(+), 92 deletions(-) diff --git a/Commons/Migrations/Migration33.qml b/Commons/Migrations/Migration33.qml index 4f0b730d7..f012fa114 100644 --- a/Commons/Migrations/Migration33.qml +++ b/Commons/Migrations/Migration33.qml @@ -24,4 +24,3 @@ QtObject { return true; } } - diff --git a/Modules/LockScreen/LockScreen.qml b/Modules/LockScreen/LockScreen.qml index bbc396ae5..d6aac579a 100644 --- a/Modules/LockScreen/LockScreen.qml +++ b/Modules/LockScreen/LockScreen.qml @@ -190,7 +190,6 @@ Loader { resolvedWallpaperPath = originalPath; } }); - } // Black backgound, in case image fails to load or takes a while diff --git a/Services/Media/ScreenRecorderService.qml b/Services/Media/ScreenRecorderService.qml index 80f79dd8c..3c5385fb9 100644 --- a/Services/Media/ScreenRecorderService.qml +++ b/Services/Media/ScreenRecorderService.qml @@ -157,8 +157,7 @@ Singleton { if (stderr.length > 0) { ToastService.showError(I18n.tr("toast.recording.failed-start"), stderr); Logger.e(stderr); - } - else { + } else { ToastService.showError(I18n.tr("toast.recording.failed-start"), I18n.tr("toast.recording.failed-general")); } } diff --git a/Services/Networking/BluetoothService.qml b/Services/Networking/BluetoothService.qml index 27775c710..9c1639215 100644 --- a/Services/Networking/BluetoothService.qml +++ b/Services/Networking/BluetoothService.qml @@ -203,7 +203,8 @@ BluetoothAgent { interval: 1000 repeat: false onTriggered: { - if (adapter) adapter.discovering = true + if (adapter) + adapter.discovering = true; } } diff --git a/Services/Noctalia/GitHubService.qml b/Services/Noctalia/GitHubService.qml index 8d214b240..00a33597b 100644 --- a/Services/Noctalia/GitHubService.qml +++ b/Services/Noctalia/GitHubService.qml @@ -177,8 +177,8 @@ Singleton { var avatarUrl = contributor.avatar_url; // Use closure to capture username - (function(uname, url) { - ImageCacheService.getCircularAvatar(url, uname, function(cachedPath, success) { + (function (uname, url) { + ImageCacheService.getCircularAvatar(url, uname, function (cachedPath, success) { if (success) { cachedAvatars[uname] = "file://" + cachedPath; cachedAvatarsChanged(); diff --git a/Services/System/NotificationService.qml b/Services/System/NotificationService.qml index 845e05823..3ffb550ec 100644 --- a/Services/System/NotificationService.qml +++ b/Services/System/NotificationService.qml @@ -394,7 +394,8 @@ Singleton { "timestamp": time, "progress": 1.0, "originalImage": image, - "cachedImage": image, // Start with original, update when cached + "cachedImage": image // Start with original, update when cached + , "actionsJson": JSON.stringify((n.actions || []).map(a => ({ "text": a.text || "Action", "identifier": a.identifier || "" @@ -500,7 +501,7 @@ Singleton { if (!path || !path.startsWith("image://") || !notificationId) return; - ImageCacheService.getNotificationIcon(path, appName, summary, function(cachedPath, success) { + ImageCacheService.getNotificationIcon(path, appName, summary, function (cachedPath, success) { if (success && cachedPath) { updateImagePath(notificationId, "file://" + cachedPath); } diff --git a/Services/UI/ImageCacheService.qml b/Services/UI/ImageCacheService.qml index a32482d03..9da04cdad 100644 --- a/Services/UI/ImageCacheService.qml +++ b/Services/UI/ImageCacheService.qml @@ -25,16 +25,7 @@ Singleton { // Supported image formats - extended list when ImageMagick is available readonly property var basicImageFilters: ["*.jpg", "*.jpeg", "*.png", "*.gif", "*.bmp"] - readonly property var extendedImageFilters: [ - "*.jpg", "*.jpeg", "*.png", "*.gif", "*.bmp", - "*.webp", "*.avif", "*.heic", "*.heif", - "*.tiff", "*.tif", "*.pnm", "*.pgm", "*.ppm", "*.pbm", - "*.svg", "*.svgz", - "*.ico", "*.icns", - "*.jxl", "*.jp2", "*.j2k", - "*.exr", "*.hdr", - "*.dds", "*.tga" - ] + readonly property var extendedImageFilters: ["*.jpg", "*.jpeg", "*.png", "*.gif", "*.bmp", "*.webp", "*.avif", "*.heic", "*.heif", "*.tiff", "*.tif", "*.pnm", "*.pgm", "*.ppm", "*.pbm", "*.svg", "*.svgz", "*.ico", "*.icns", "*.jxl", "*.jp2", "*.j2k", "*.exr", "*.hdr", "*.dds", "*.tga"] readonly property var imageFilters: imageMagickAvailable ? extendedImageFilters : basicImageFilters // Check if a file format needs conversion (not natively supported by Qt) @@ -83,11 +74,11 @@ Singleton { return; } - getMtime(sourcePath, function(mtime) { + getMtime(sourcePath, function (mtime) { const cacheKey = generateThumbnailKey(sourcePath, mtime); const cachedPath = wpThumbDir + cacheKey + ".jpg"; - processRequest(cacheKey, cachedPath, sourcePath, callback, function() { + processRequest(cacheKey, cachedPath, sourcePath, callback, function () { if (imageMagickAvailable) { startThumbnailProcessing(sourcePath, cachedPath, cacheKey); } else { @@ -113,7 +104,7 @@ Singleton { } // Fast dimension check - skip processing if image fits screen AND format is Qt-native - getImageDimensions(sourcePath, function(imgWidth, imgHeight) { + getImageDimensions(sourcePath, function (imgWidth, imgHeight) { const fitsScreen = imgWidth > 0 && imgHeight > 0 && imgWidth <= width && imgHeight <= height; if (fitsScreen) { @@ -130,11 +121,11 @@ Singleton { const targetWidth = fitsScreen ? imgWidth : width; const targetHeight = fitsScreen ? imgHeight : height; - getMtime(sourcePath, function(mtime) { + getMtime(sourcePath, function (mtime) { const cacheKey = generateLargeKey(sourcePath, screenName, width, height, mtime); const cachedPath = wpLargeDir + cacheKey + ".jpg"; - processRequest(cacheKey, cachedPath, sourcePath, callback, function() { + processRequest(cacheKey, cachedPath, sourcePath, callback, function () { startLargeProcessing(sourcePath, cachedPath, targetWidth, targetHeight, cacheKey); }); }); @@ -159,7 +150,7 @@ Singleton { const cacheKey = generateNotificationKey(imageUri, appName, summary); const cachedPath = notificationsDir + cacheKey + ".png"; - processRequest(cacheKey, cachedPath, imageUri, callback, function() { + processRequest(cacheKey, cachedPath, imageUri, callback, function () { // Notifications always use Qt fallback (image:// URIs can't be read by ImageMagick) queueFallbackProcessing(imageUri, cachedPath, cacheKey, 64); }); @@ -177,7 +168,7 @@ Singleton { const cacheKey = username; const cachedPath = contributorsDir + username + "_circular.png"; - processRequest(cacheKey, cachedPath, url, callback, function() { + processRequest(cacheKey, cachedPath, url, callback, function () { if (imageMagickAvailable) { downloadAndProcessAvatar(url, username, cachedPath, cacheKey); } else { @@ -220,7 +211,7 @@ Singleton { } // Check cache first - checkFileExists(cachedPath, function(exists) { + checkFileExists(cachedPath, function (exists) { if (exists) { Logger.d("ImageCache", "Cache hit:", cachedPath); callback(cachedPath, true); @@ -249,7 +240,7 @@ Singleton { function notifyCallbacks(cacheKey, path, success) { const request = pendingRequests[cacheKey]; if (request) { - request.callbacks.forEach(function(cb) { + request.callbacks.forEach(function (cb) { cb(path, success); }); delete pendingRequests[cacheKey]; @@ -313,7 +304,7 @@ Singleton { const downloadProcess = Qt.createQmlObject(processString, root, "DownloadProcess_" + cacheKey); downloadProcess.command = ["bash", "-c", downloadCmd]; - downloadProcess.exited.connect(function(exitCode) { + downloadProcess.exited.connect(function (exitCode) { downloadProcess.destroy(); if (exitCode !== 0) { @@ -354,7 +345,7 @@ Singleton { const processObj = Qt.createQmlObject(processString, root, "CircularProcess_" + cacheKey); processObj.command = ["bash", "-c", command]; - processObj.exited.connect(function(exitCode) { + processObj.exited.connect(function (exitCode) { // Clean up temp file Quickshell.execDetached(["rm", "-f", inputPath]); @@ -399,7 +390,7 @@ Singleton { processObj.cachedPath = outputPath; processObj.command = ["bash", "-c", command]; - processObj.exited.connect(function(exitCode) { + processObj.exited.connect(function (exitCode) { if (exitCode !== 0) { const stderrText = processObj.stderr.text || ""; Logger.e("ImageCache", "Processing failed:", stderrText); @@ -447,10 +438,11 @@ Singleton { antialiasing: true onStatusChanged: { - if (!cacheKey) return; + if (!cacheKey) + return; if (status === Image.Ready) { - grabToImage(function(result) { + grabToImage(function (result) { if (result.saveToFile(destPath)) { Logger.d("ImageCache", "Fallback cache created:", destPath); root.notifyCallbacks(cacheKey, destPath, true); @@ -487,11 +479,11 @@ Singleton { function queueFallbackProcessing(sourcePath, destPath, cacheKey, size) { fallbackQueue.push({ - sourcePath: sourcePath, - destPath: destPath, - cacheKey: cacheKey, - size: size - }); + sourcePath: sourcePath, + destPath: destPath, + cacheKey: cacheKey, + size: size + }); if (!fallbackProcessing) { fallbackProcessing = true; @@ -521,7 +513,7 @@ Singleton { try { const processObj = Qt.createQmlObject(processString, root, "MtimeProcess"); - processObj.exited.connect(function(exitCode) { + processObj.exited.connect(function (exitCode) { const mtime = exitCode === 0 ? processObj.stdout.text.trim() : ""; processObj.destroy(); callback(mtime); @@ -549,7 +541,7 @@ Singleton { try { const processObj = Qt.createQmlObject(processString, root, "FileExistsProcess"); - processObj.exited.connect(function(exitCode) { + processObj.exited.connect(function (exitCode) { processObj.destroy(); callback(exitCode === 0); }); @@ -576,7 +568,7 @@ Singleton { try { const processObj = Qt.createQmlObject(processString, root, "IdentifyProcess"); - processObj.exited.connect(function(exitCode) { + processObj.exited.connect(function (exitCode) { let width = 0, height = 0; if (exitCode === 0) { const parts = processObj.stdout.text.trim().split(" "); @@ -667,7 +659,7 @@ Singleton { stdout: StdioCollector {} stderr: StdioCollector {} - onExited: function(exitCode) { + onExited: function (exitCode) { root.imageMagickAvailable = (exitCode === 0); root.initialized = true; if (root.imageMagickAvailable) { diff --git a/Widgets/NClock.qml b/Widgets/NClock.qml index 9f94ba7d4..b938962cc 100644 --- a/Widgets/NClock.qml +++ b/Widgets/NClock.qml @@ -61,8 +61,10 @@ Item { anchors.fill: parent sourceComponent: { - if (root.clockStyle === "analog") return analogClockComponent; - if (root.clockStyle === "binary") return binaryClockComponent; + if (root.clockStyle === "analog") + return analogClockComponent; + if (root.clockStyle === "binary") + return binaryClockComponent; return digitalClockComponent; } @@ -279,11 +281,11 @@ Item { // Binary Clock Component component NClockBinary: Item { property var now - property color backgroundColor + property color backgroundColor property color clockColor: Color.mOnPrimary - + anchors.fill: parent - + readonly property int h: now.getHours() readonly property int m: now.getMinutes() readonly property int s: now.getSeconds() @@ -300,61 +302,61 @@ Item { RowLayout { anchors.centerIn: parent spacing: parent.width * 0.05 - + // Hours RowLayout { spacing: parent.parent.width * 0.02 - BinaryColumn { - value: Math.floor(h / 10) - bits: 2 - dotSize: root.width * 0.08 - activeColor: clockColor - Layout.alignment: Qt.AlignBottom + BinaryColumn { + value: Math.floor(h / 10) + bits: 2 + dotSize: root.width * 0.08 + activeColor: clockColor + Layout.alignment: Qt.AlignBottom } - BinaryColumn { - value: h % 10 - bits: 4 - dotSize: root.width * 0.08 - activeColor: clockColor - Layout.alignment: Qt.AlignBottom + BinaryColumn { + value: h % 10 + bits: 4 + dotSize: root.width * 0.08 + activeColor: clockColor + Layout.alignment: Qt.AlignBottom } } - + // Minutes RowLayout { spacing: parent.parent.width * 0.02 - BinaryColumn { - value: Math.floor(m / 10) - bits: 3 - dotSize: root.width * 0.08 - activeColor: clockColor - Layout.alignment: Qt.AlignBottom + BinaryColumn { + value: Math.floor(m / 10) + bits: 3 + dotSize: root.width * 0.08 + activeColor: clockColor + Layout.alignment: Qt.AlignBottom } - BinaryColumn { - value: m % 10 - bits: 4 - dotSize: root.width * 0.08 - activeColor: clockColor - Layout.alignment: Qt.AlignBottom + BinaryColumn { + value: m % 10 + bits: 4 + dotSize: root.width * 0.08 + activeColor: clockColor + Layout.alignment: Qt.AlignBottom } } // Seconds RowLayout { spacing: parent.parent.width * 0.02 - BinaryColumn { - value: Math.floor(s / 10) - bits: 3 - dotSize: root.width * 0.08 - activeColor: clockColor - Layout.alignment: Qt.AlignBottom + BinaryColumn { + value: Math.floor(s / 10) + bits: 3 + dotSize: root.width * 0.08 + activeColor: clockColor + Layout.alignment: Qt.AlignBottom } - BinaryColumn { - value: s % 10 - bits: 4 - dotSize: root.width * 0.08 - activeColor: clockColor - Layout.alignment: Qt.AlignBottom + BinaryColumn { + value: s % 10 + bits: 4 + dotSize: root.width * 0.08 + activeColor: clockColor + Layout.alignment: Qt.AlignBottom } } } @@ -367,20 +369,24 @@ Item { property color activeColor: "white" spacing: dotSize * 0.4 - + Repeater { model: bits - + Rectangle { property int bitIndex: (bits - 1) - index property bool isActive: (value >> bitIndex) & 1 - + width: dotSize height: dotSize radius: dotSize / 2 color: isActive ? activeColor : Qt.alpha(activeColor, 0.2) - - Behavior on color { ColorAnimation { duration: 200 } } + + Behavior on color { + ColorAnimation { + duration: 200 + } + } } } } diff --git a/Widgets/NImageCached.qml b/Widgets/NImageCached.qml index 88035caa7..8651cb13e 100644 --- a/Widgets/NImageCached.qml +++ b/Widgets/NImageCached.qml @@ -26,8 +26,9 @@ Image { return; } - ImageCacheService.getThumbnail(imagePath, function(cachedPath, success) { - if (!root) return; // Component was destroyed + ImageCacheService.getThumbnail(imagePath, function (cachedPath, success) { + if (!root) + return; // Component was destroyed if (success) { root.source = cachedPath; } else {