From fae7f36a241fb15bb927b6eb043636bd474d32d9 Mon Sep 17 00:00:00 2001 From: bbedward Date: Sun, 27 Jul 2025 20:23:11 -0400 Subject: [PATCH] remove unused functions/dead code --- Services/AudioService.qml | 98 +++++++------------------------- Services/BatteryService.qml | 5 -- Services/BluetoothService.qml | 6 -- Services/BrightnessService.qml | 8 --- Services/NiriService.qml | 20 ------- Services/NotificationService.qml | 69 +--------------------- Services/SysMonitorService.qml | 25 -------- 7 files changed, 21 insertions(+), 210 deletions(-) diff --git a/Services/AudioService.qml b/Services/AudioService.qml index 89a93626..1be7eba9 100644 --- a/Services/AudioService.qml +++ b/Services/AudioService.qml @@ -14,55 +14,6 @@ Singleton { signal volumeChanged() - function displayName(node) { - if (!node) return "" - - if (node.properties && node.properties["device.description"]) { - return node.properties["device.description"] - } - - if (node.description && node.description !== node.name) { - return node.description - } - - if (node.nickname && node.nickname !== node.name) { - return node.nickname - } - - if (node.name.includes("analog-stereo")) return "Built-in Speakers" - else if (node.name.includes("bluez")) return "Bluetooth Audio" - else if (node.name.includes("usb")) return "USB Audio" - else if (node.name.includes("hdmi")) return "HDMI Audio" - - return node.name - } - - function subtitle(name) { - if (!name) return "" - - if (name.includes('usb-')) { - if (name.includes('SteelSeries')) { - return "USB Gaming Headset" - } else if (name.includes('Generic')) { - return "USB Audio Device" - } - return "USB Audio" - } else if (name.includes('pci-')) { - if (name.includes('01_00.1') || name.includes('01:00.1')) { - return "NVIDIA GPU Audio" - } - return "PCI Audio" - } else if (name.includes('bluez')) { - return "Bluetooth Audio" - } else if (name.includes('analog')) { - return "Built-in Audio" - } else if (name.includes('hdmi')) { - return "HDMI Audio" - } - - return "" - } - PwObjectTracker { objects: [Pipewire.defaultAudioSink, Pipewire.defaultAudioSource] } @@ -73,30 +24,13 @@ Singleton { if (root.sink && root.sink.audio) { const clampedVolume = Math.max(0, Math.min(100, percentage)); root.sink.audio.volume = clampedVolume / 100; + root.volumeChanged(); return "Volume set to " + clampedVolume + "%"; } return "No audio sink available"; } - function incrementVolume(step) { - if (root.sink && root.sink.audio) { - const currentVolume = Math.round(root.sink.audio.volume * 100); - const newVolume = Math.max(0, Math.min(100, currentVolume + step)); - root.sink.audio.volume = newVolume / 100; - return "Volume increased to " + newVolume + "%"; - } - return "No audio sink available"; - } - function decrementVolume(step) { - if (root.sink && root.sink.audio) { - const currentVolume = Math.round(root.sink.audio.volume * 100); - const newVolume = Math.max(0, Math.min(100, currentVolume - step)); - root.sink.audio.volume = newVolume / 100; - return "Volume decreased to " + newVolume + "%"; - } - return "No audio sink available"; - } function toggleMute() { if (root.sink && root.sink.audio) { @@ -128,27 +62,33 @@ Singleton { target: "audio" function setvolume(percentage: string): string { - const result = root.setVolume(parseInt(percentage)); - root.volumeChanged(); - return result; + return root.setVolume(parseInt(percentage)); } function increment(step: string): string { - const result = root.incrementVolume(parseInt(step || "5")); - root.volumeChanged(); - return result; + if (root.sink && root.sink.audio) { + const currentVolume = Math.round(root.sink.audio.volume * 100); + const newVolume = Math.max(0, Math.min(100, currentVolume + parseInt(step || "5"))); + root.sink.audio.volume = newVolume / 100; + root.volumeChanged(); + return "Volume increased to " + newVolume + "%"; + } + return "No audio sink available"; } function decrement(step: string): string { - const result = root.decrementVolume(parseInt(step || "5")); - root.volumeChanged(); - return result; + if (root.sink && root.sink.audio) { + const currentVolume = Math.round(root.sink.audio.volume * 100); + const newVolume = Math.max(0, Math.min(100, currentVolume - parseInt(step || "5"))); + root.sink.audio.volume = newVolume / 100; + root.volumeChanged(); + return "Volume decreased to " + newVolume + "%"; + } + return "No audio sink available"; } function mute(): string { - const result = root.toggleMute(); - root.volumeChanged(); - return result; + return root.toggleMute(); } function setmic(percentage: string): string { diff --git a/Services/BatteryService.qml b/Services/BatteryService.qml index ac2f9027..5cff752d 100644 --- a/Services/BatteryService.qml +++ b/Services/BatteryService.qml @@ -54,9 +54,4 @@ Singleton { else return minutes + "m"; } - - function getBluetoothDevices() { - return bluetoothDevices; - } - } diff --git a/Services/BluetoothService.qml b/Services/BluetoothService.qml index 3becab6c..e60465cf 100644 --- a/Services/BluetoothService.qml +++ b/Services/BluetoothService.qml @@ -114,9 +114,6 @@ Singleton { return !device.paired && !device.pairing && !device.blocked; } - function debugDevice(device) { - console.log("Device:", device.name, "paired:", device.paired, "connected:", device.connected, "signalStrength:", device.signalStrength); - } function getSignalStrength(device) { @@ -170,7 +167,4 @@ Singleton { device.trusted = true; device.connect(); } - - - } diff --git a/Services/BrightnessService.qml b/Services/BrightnessService.qml index b5f2e11d..914fb30e 100644 --- a/Services/BrightnessService.qml +++ b/Services/BrightnessService.qml @@ -27,14 +27,6 @@ Singleton { } } - function increaseBrightness() { - setBrightness(brightnessLevel + 10); - } - - function decreaseBrightness() { - setBrightness(brightnessLevel - 10); - } - Component.onCompleted: { ddcAvailabilityChecker.running = true; laptopBacklightChecker.running = true; diff --git a/Services/NiriService.qml b/Services/NiriService.qml index c3584829..7edb52a6 100644 --- a/Services/NiriService.qml +++ b/Services/NiriService.qml @@ -333,13 +333,6 @@ Singleton { return false } - function getWorkspaceByIndex(index) { - if (index >= 0 && index < allWorkspaces.length) { - return allWorkspaces[index] - } - return null - } - function getCurrentOutputWorkspaceNumbers() { return currentOutputWorkspaces.map(w => w.idx + 1) // niri uses 0-based, UI shows 1-based } @@ -350,17 +343,4 @@ Singleton { } return 1 } - - function isWorkspaceActive(workspaceNumber) { - return workspaceNumber === getCurrentWorkspaceNumber() - } - - // For compatibility with existing components - function getCurrentWorkspace() { - return getCurrentWorkspaceNumber() - } - - function getWorkspaceList() { - return getCurrentOutputWorkspaceNumbers() - } } \ No newline at end of file diff --git a/Services/NotificationService.qml b/Services/NotificationService.qml index 184ce1d9..46d7de23 100644 --- a/Services/NotificationService.qml +++ b/Services/NotificationService.qml @@ -17,8 +17,6 @@ Singleton { property list notificationQueue: [] property list visibleNotifications: [] - property list history: [] - property int maxHistory: 200 property int maxVisibleNotifications: 3 property bool addGateBusy: false property int enterAnimMs: 400 @@ -42,10 +40,6 @@ Singleton { property var expandedMessages: ({}) property bool popupsDisabled: false - // Notification persistence settings - property int maxStoredNotifications: 100 - property int maxNotificationAge: 7 * 24 * 60 * 60 * 1000 // 7 days in milliseconds - property var persistedNotifications: ([]) // Stored notification history NotificationServer { id: server @@ -71,7 +65,6 @@ Singleton { if (wrapper) { root.allWrappers.push(wrapper); root.notifications.push(wrapper); - addToPersistentStorage(wrapper); if (shouldShowPopup) { notificationQueue = [...notificationQueue, wrapper]; @@ -209,10 +202,6 @@ Singleton { wrapper.notification.dismiss(); } - function hidePopup(wrapper) { - wrapper.popup = false; - } - function disablePopups(disable) { popupsDisabled = disable; if (disable) { @@ -267,15 +256,8 @@ Singleton { notificationQueue = q; } - // Push to bounded history or destroy if non-persistent - if (w && w.isPersistent) { - let h = history.slice(); - h.push(w); - if (h.length > maxHistory) { - h.splice(0, h.length - maxHistory); - } - history = h; - } else if (w && w.destroy) { + // Destroy wrapper if non-persistent + if (w && w.destroy && !w.isPersistent) { w.destroy(); } } @@ -383,7 +365,6 @@ Singleton { } } - function clearGroupExpansionState(groupKey) { let newExpandedGroups = {}; for (const key in expandedGroups) { @@ -394,7 +375,6 @@ Singleton { expandedGroups = newExpandedGroups; } - function cleanupExpansionStates() { const currentGroupKeys = new Set(groupedNotifications.map(g => g.key)); const currentMessageIds = new Set(); @@ -428,48 +408,6 @@ Singleton { expandedMessages = newExpandedMessages; } - function getGroupTitle(group) { - if (group.count === 1) { - return group.latestNotification.summary; - } - return `${group.count} notifications`; - } - - function getGroupBody(group) { - if (group.count === 1) { - return group.latestNotification.htmlBody; // Use HTML body - } - return `Latest: ${group.latestNotification.summary}`; - } - - function addToPersistentStorage(wrapper) { - const persistedNotif = { - id: wrapper.notification.id, - appName: wrapper.appName, - summary: wrapper.summary, - body: wrapper.body, - htmlBody: wrapper.htmlBody, // Store HTML version too - appIcon: wrapper.appIcon, - image: wrapper.image, - urgency: wrapper.urgency, - timestamp: wrapper.time.getTime(), - }; - persistedNotifications.unshift(persistedNotif); - cleanupPersistentStorage(); - } - - function cleanupPersistentStorage() { - const now = new Date().getTime(); - let newPersisted = []; - for (let i = 0; i < persistedNotifications.length && i < maxStoredNotifications; i++) { - const notif = persistedNotifications[i]; - if (now - notif.timestamp < maxNotificationAge) { - newPersisted.push(notif); - } - } - persistedNotifications = newPersisted; - } - Connections { target: Prefs @@ -488,7 +426,4 @@ Singleton { } } - Component.onCompleted: { - cleanupPersistentStorage(); - } } \ No newline at end of file diff --git a/Services/SysMonitorService.qml b/Services/SysMonitorService.qml index ad23f68a..1ea5bd72 100644 --- a/Services/SysMonitorService.qml +++ b/Services/SysMonitorService.qml @@ -357,31 +357,6 @@ Singleton { return (mem / (1024 * 1024)).toFixed(1) + " GB"; } - function formatMemory(mb) { - const mem = mb || 0; - if (mem >= 1024) - return (mem / 1024).toFixed(1) + " GB"; - return mem.toFixed(0) + " MB"; - } - - function getCpuUsageColor() { - if (cpuUsage > 80) return "#e74c3c"; - if (cpuUsage > 60) return "#f39c12"; - return "#27ae60"; - } - - function getMemoryUsageColor() { - if (memoryUsage > 90) return "#e74c3c"; - if (memoryUsage > 75) return "#f39c12"; - return "#3498db"; - } - - function getTemperatureColor() { - if (cpuTemperature > 80) return "#e74c3c"; - if (cpuTemperature > 65) return "#f39c12"; - return "#27ae60"; - } - Timer { id: updateTimer interval: root.updateInterval