mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
Sysmon: tooltip (untranslated for now)
This commit is contained in:
@@ -67,6 +67,39 @@ Rectangle {
|
||||
return Math.min(100, Math.max(0, (Math.log10(kb) / 5) * 100));
|
||||
}
|
||||
|
||||
// Build comprehensive tooltip text with all stats
|
||||
function buildTooltipText() {
|
||||
let lines = [];
|
||||
|
||||
// CPU
|
||||
lines.push(`CPU Usage: ${Math.round(SystemStatService.cpuUsage)}%`);
|
||||
if (SystemStatService.cpuTemp > 0) {
|
||||
lines.push(`CPU Temp: ${Math.round(SystemStatService.cpuTemp)}°C`);
|
||||
}
|
||||
|
||||
// GPU (if available)
|
||||
if (SystemStatService.gpuAvailable) {
|
||||
lines.push(`GPU Temp: ${Math.round(SystemStatService.gpuTemp)}°C`);
|
||||
}
|
||||
|
||||
// Memory
|
||||
lines.push(`Memory: ${Math.round(SystemStatService.memPercent)}% (${SystemStatService.formatMemoryGb(SystemStatService.memGb)})`);
|
||||
|
||||
// Network
|
||||
lines.push(`Download Speed: ${SystemStatService.formatSpeed(SystemStatService.rxSpeed)}`);
|
||||
lines.push(`Upload Speed: ${SystemStatService.formatSpeed(SystemStatService.txSpeed)}`);
|
||||
|
||||
// Disk
|
||||
const diskPercent = SystemStatService.diskPercents[diskPath];
|
||||
if (diskPercent !== undefined) {
|
||||
const usedGb = SystemStatService.diskUsedGb[diskPath] || 0;
|
||||
const sizeGb = SystemStatService.diskSizeGb[diskPath] || 0;
|
||||
lines.push(`Disk: ${usedGb.toFixed(1)}G / ${sizeGb.toFixed(1)}G (${diskPercent}%)`);
|
||||
}
|
||||
|
||||
return lines.join("\n");
|
||||
}
|
||||
|
||||
// Match Workspace widget pill sizing: base ratio depends on bar density
|
||||
readonly property real pillBaseRatio: (density === "compact") ? 0.85 : 0.65
|
||||
readonly property int pillHeight: Math.round(Style.capsuleHeight * pillBaseRatio)
|
||||
@@ -133,8 +166,10 @@ Rectangle {
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: tooltipArea
|
||||
anchors.fill: parent
|
||||
acceptedButtons: Qt.RightButton
|
||||
hoverEnabled: true
|
||||
onClicked: mouse => {
|
||||
if (mouse.button === Qt.RightButton) {
|
||||
var popupMenuWindow = PanelService.getPopupMenuWindow(screen);
|
||||
@@ -144,6 +179,25 @@ Rectangle {
|
||||
}
|
||||
}
|
||||
}
|
||||
onEntered: {
|
||||
TooltipService.show(root, buildTooltipText(), BarService.getTooltipDirection());
|
||||
tooltipRefreshTimer.start();
|
||||
}
|
||||
onExited: {
|
||||
tooltipRefreshTimer.stop();
|
||||
TooltipService.hide();
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: tooltipRefreshTimer
|
||||
interval: 1000
|
||||
repeat: true
|
||||
onTriggered: {
|
||||
if (tooltipArea.containsMouse) {
|
||||
TooltipService.updateText(buildTooltipText());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Status indicator component definition
|
||||
@@ -797,17 +851,6 @@ Rectangle {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
onEntered: {
|
||||
TooltipService.show(diskContent, diskPath, BarService.getTooltipDirection());
|
||||
}
|
||||
onExited: {
|
||||
TooltipService.hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,8 @@ Singleton {
|
||||
property real memGb: 0
|
||||
property real memPercent: 0
|
||||
property var diskPercents: ({})
|
||||
property var diskUsedGb: ({}) // Used space in GB per mount point
|
||||
property var diskSizeGb: ({}) // Total size in GB per mount point
|
||||
property real rxSpeed: 0
|
||||
property real txSpeed: 0
|
||||
property real zfsArcSizeKb: 0 // ZFS ARC cache size in KB
|
||||
@@ -224,27 +226,37 @@ Singleton {
|
||||
}
|
||||
|
||||
// --------------------------------------------
|
||||
// Process to fetch disk usage in percent
|
||||
// Process to fetch disk usage (percent, used, size)
|
||||
// Uses 'df' aka 'disk free'
|
||||
// "-x efivarfs' skips efivarfs mountpoints, for which the `statfs` syscall may cause system-wide stuttering
|
||||
// --block-size=1 gives us bytes for precise GB calculation
|
||||
Process {
|
||||
id: dfProcess
|
||||
command: ["df", "--output=target,pcent", "-x", "efivarfs"]
|
||||
command: ["df", "--output=target,pcent,used,size", "--block-size=1", "-x", "efivarfs"]
|
||||
running: false
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: {
|
||||
const lines = text.trim().split('\n');
|
||||
const newPercents = {};
|
||||
const newUsedGb = {};
|
||||
const newSizeGb = {};
|
||||
const bytesPerGb = 1024 * 1024 * 1024;
|
||||
// Start from line 1 (skip header)
|
||||
for (var i = 1; i < lines.length; i++) {
|
||||
const parts = lines[i].trim().split(/\s+/);
|
||||
if (parts.length >= 2) {
|
||||
if (parts.length >= 4) {
|
||||
const target = parts[0];
|
||||
const percent = parseInt(parts[1].replace(/[^0-9]/g, '')) || 0;
|
||||
const usedBytes = parseFloat(parts[2]) || 0;
|
||||
const sizeBytes = parseFloat(parts[3]) || 0;
|
||||
newPercents[target] = percent;
|
||||
newUsedGb[target] = usedBytes / bytesPerGb;
|
||||
newSizeGb[target] = sizeBytes / bytesPerGb;
|
||||
}
|
||||
}
|
||||
root.diskPercents = newPercents;
|
||||
root.diskUsedGb = newUsedGb;
|
||||
root.diskSizeGb = newSizeGb;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user