mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-28 23:42:51 -05:00
refactor: perf improvement stopping singletons with ref
Also switch to scale+opacity anims with custom curve
This commit is contained in:
@@ -116,6 +116,25 @@ Singleton {
|
||||
return Array.from(mappedCategories)
|
||||
}
|
||||
|
||||
// Category icon mappings
|
||||
property var categoryIcons: ({
|
||||
"All": "apps",
|
||||
"Recents": "history",
|
||||
"Media": "music_video",
|
||||
"Development": "code",
|
||||
"Games": "sports_esports",
|
||||
"Graphics": "photo_library",
|
||||
"Internet": "web",
|
||||
"Office": "content_paste",
|
||||
"Settings": "settings",
|
||||
"System": "host",
|
||||
"Utilities": "build"
|
||||
})
|
||||
|
||||
function getCategoryIcon(category) {
|
||||
return categoryIcons[category] || "folder"
|
||||
}
|
||||
|
||||
function getAllCategories() {
|
||||
var categories = new Set(["All"])
|
||||
|
||||
|
||||
@@ -6,14 +6,13 @@ import Quickshell
|
||||
import Quickshell.Io
|
||||
|
||||
Singleton {
|
||||
// console.log("ProcessMonitorService: Updated - CPU:", root.totalCpuUsage.toFixed(1) + "%", "Memory:", memoryPercent.toFixed(1) + "%", "History length:", root.cpuHistory.length)
|
||||
|
||||
id: root
|
||||
|
||||
property int refCount
|
||||
|
||||
property var processes: []
|
||||
property bool isUpdating: false
|
||||
property int processUpdateInterval: 3000
|
||||
property bool monitoringEnabled: false
|
||||
property int totalMemoryKB: 0
|
||||
property int usedMemoryKB: 0
|
||||
property int totalSwapKB: 0
|
||||
@@ -43,47 +42,8 @@ Singleton {
|
||||
property bool sortDescending: true
|
||||
property int maxProcesses: 20
|
||||
|
||||
function updateSystemInfo() {
|
||||
if (!systemInfoProcess.running && root.monitoringEnabled)
|
||||
systemInfoProcess.running = true;
|
||||
|
||||
}
|
||||
|
||||
function enableMonitoring(enabled) {
|
||||
console.log("ProcessMonitorService: Monitoring", enabled ? "enabled" : "disabled");
|
||||
root.monitoringEnabled = enabled;
|
||||
if (enabled) {
|
||||
root.cpuHistory = [];
|
||||
root.memoryHistory = [];
|
||||
root.networkHistory = ({
|
||||
"rx": [],
|
||||
"tx": []
|
||||
});
|
||||
root.diskHistory = ({
|
||||
"read": [],
|
||||
"write": []
|
||||
});
|
||||
updateSystemInfo();
|
||||
updateProcessList();
|
||||
updateNetworkStats();
|
||||
updateDiskStats();
|
||||
}
|
||||
}
|
||||
|
||||
function updateNetworkStats() {
|
||||
if (!networkStatsProcess.running && root.monitoringEnabled)
|
||||
networkStatsProcess.running = true;
|
||||
|
||||
}
|
||||
|
||||
function updateDiskStats() {
|
||||
if (!diskStatsProcess.running && root.monitoringEnabled)
|
||||
diskStatsProcess.running = true;
|
||||
|
||||
}
|
||||
|
||||
function updateProcessList() {
|
||||
if (!root.isUpdating && root.monitoringEnabled) {
|
||||
if (!root.isUpdating) {
|
||||
root.isUpdating = true;
|
||||
let sortOption = "";
|
||||
switch (root.sortBy) {
|
||||
@@ -315,10 +275,17 @@ Singleton {
|
||||
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
console.log("ProcessMonitorService: Starting initialization...");
|
||||
updateProcessList();
|
||||
console.log("ProcessMonitorService: Initialization complete");
|
||||
Timer {
|
||||
running: root.refCount > 0
|
||||
interval: root.processUpdateInterval
|
||||
repeat: true
|
||||
triggeredOnStart: true
|
||||
onTriggered: {
|
||||
systemInfoProcess.running = true;
|
||||
updateProcessList();
|
||||
networkStatsProcess.running = true;
|
||||
diskStatsProcess.running = true;
|
||||
}
|
||||
}
|
||||
|
||||
Process {
|
||||
@@ -441,20 +408,4 @@ Singleton {
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: processTimer
|
||||
|
||||
interval: root.processUpdateInterval
|
||||
running: root.monitoringEnabled
|
||||
repeat: true
|
||||
onTriggered: {
|
||||
if (root.monitoringEnabled) {
|
||||
updateSystemInfo();
|
||||
updateProcessList();
|
||||
updateNetworkStats();
|
||||
updateDiskStats();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@ import qs.Common
|
||||
Singleton {
|
||||
id: root
|
||||
|
||||
property int refCount: 0
|
||||
|
||||
property var weather: ({
|
||||
available: false,
|
||||
loading: true,
|
||||
@@ -95,7 +97,27 @@ Singleton {
|
||||
return url
|
||||
}
|
||||
|
||||
function addRef() {
|
||||
refCount++;
|
||||
console.log("WeatherService: addRef, refCount now:", refCount);
|
||||
if (refCount === 1 && !weather.available) {
|
||||
// Start fetching when first consumer appears
|
||||
fetchWeather();
|
||||
}
|
||||
}
|
||||
|
||||
function removeRef() {
|
||||
refCount = Math.max(0, refCount - 1);
|
||||
console.log("WeatherService: removeRef, refCount now:", refCount);
|
||||
}
|
||||
|
||||
function fetchWeather() {
|
||||
// Only fetch if someone is consuming the data
|
||||
if (root.refCount === 0) {
|
||||
console.log("WeatherService: Skipping fetch - no consumers");
|
||||
return;
|
||||
}
|
||||
|
||||
if (weatherFetcher.running) {
|
||||
console.log("Weather fetch already in progress, skipping")
|
||||
return
|
||||
@@ -217,7 +239,7 @@ Singleton {
|
||||
Timer {
|
||||
id: updateTimer
|
||||
interval: root.updateInterval
|
||||
running: true
|
||||
running: root.refCount > 0
|
||||
repeat: true
|
||||
triggeredOnStart: true
|
||||
onTriggered: {
|
||||
|
||||
Reference in New Issue
Block a user