mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
BatteryPanel: extend battery health hover area & SystemMonitorCard: live tooltips
This commit is contained in:
@@ -26,6 +26,7 @@ NBox {
|
||||
height: parent.height / 4
|
||||
|
||||
NCircleStat {
|
||||
id: cpuUsageGauge
|
||||
anchors.centerIn: parent
|
||||
ratio: SystemStatService.cpuUsage / 100
|
||||
icon: "cpu-usage"
|
||||
@@ -33,6 +34,15 @@ NBox {
|
||||
fillColor: SystemStatService.cpuColor
|
||||
tooltipText: I18n.tr("system-monitor.cpu-usage") + `: ${Math.round(SystemStatService.cpuUsage)}%`
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: SystemStatService
|
||||
function onCpuUsageChanged() {
|
||||
if (TooltipService.activeTooltip && TooltipService.activeTooltip.targetItem === cpuUsageGauge) {
|
||||
TooltipService.updateText(I18n.tr("system-monitor.cpu-usage") + `: ${Math.round(SystemStatService.cpuUsage)}%`)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
@@ -40,6 +50,7 @@ NBox {
|
||||
height: parent.height / 4
|
||||
|
||||
NCircleStat {
|
||||
id: cpuTempGauge
|
||||
anchors.centerIn: parent
|
||||
ratio: SystemStatService.cpuTemp / 100
|
||||
suffix: "°C"
|
||||
@@ -48,6 +59,15 @@ NBox {
|
||||
fillColor: SystemStatService.tempColor
|
||||
tooltipText: I18n.tr("system-monitor.cpu-temp") + `: ${Math.round(SystemStatService.cpuTemp)}°C`
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: SystemStatService
|
||||
function onCpuTempChanged() {
|
||||
if (TooltipService.activeTooltip && TooltipService.activeTooltip.targetItem === cpuTempGauge) {
|
||||
TooltipService.updateText(I18n.tr("system-monitor.cpu-temp") + `: ${Math.round(SystemStatService.cpuTemp)}%`)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
@@ -55,6 +75,7 @@ NBox {
|
||||
height: parent.height / 4
|
||||
|
||||
NCircleStat {
|
||||
id: memPercentGauge
|
||||
anchors.centerIn: parent
|
||||
ratio: SystemStatService.memPercent / 100
|
||||
icon: "memory"
|
||||
@@ -62,6 +83,15 @@ NBox {
|
||||
fillColor: SystemStatService.memColor
|
||||
tooltipText: I18n.tr("common.memory") + `: ${Math.round(SystemStatService.memPercent)}%`
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: SystemStatService
|
||||
function onMemPercentChanged() {
|
||||
if (TooltipService.activeTooltip && TooltipService.activeTooltip.targetItem === memPercentGauge) {
|
||||
TooltipService.updateText(I18n.tr("common.memory") + `: ${Math.round(SystemStatService.memPercent)}%`)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
@@ -69,6 +99,7 @@ NBox {
|
||||
height: parent.height / 4
|
||||
|
||||
NCircleStat {
|
||||
id: diskPercentsGauge
|
||||
anchors.centerIn: parent
|
||||
ratio: (SystemStatService.diskPercents[root.diskPath] ?? 0) / 100
|
||||
icon: "storage"
|
||||
@@ -76,6 +107,15 @@ NBox {
|
||||
fillColor: SystemStatService.getDiskColor(root.diskPath)
|
||||
tooltipText: I18n.tr("system-monitor.disk") + `: ${SystemStatService.diskPercents[root.diskPath] || 0}%\n${root.diskPath}`
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: SystemStatService
|
||||
function onDiskPercentsChanged() {
|
||||
if (TooltipService.activeTooltip && TooltipService.activeTooltip.targetItem === diskPercentsGauge) {
|
||||
TooltipService.updateText(I18n.tr("system-monitor.disk") + `: ${SystemStatService.diskPercents[panelContent.diskPath] || 0}%\n${panelContent.diskPath}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,9 +145,18 @@ SmartPanel {
|
||||
spacing: Style.marginS
|
||||
|
||||
RowLayout {
|
||||
NIcon {
|
||||
icon: BatteryService.getIcon(BatteryService.getPercentage(modelData), BatteryService.isCharging(modelData), BatteryService.isPluggedIn(modelData), BatteryService.isDeviceReady(modelData))
|
||||
color: (BatteryService.isCharging(modelData) || BatteryService.isPluggedIn(modelData)) ? Color.mPrimary : (BatteryService.isCriticalBattery(modelData) || BatteryService.isLowBattery(modelData)) ? Color.mError : Color.mOnSurface
|
||||
RowLayout {
|
||||
NIcon {
|
||||
icon: BatteryService.getIcon(BatteryService.getPercentage(modelData), BatteryService.isCharging(modelData), BatteryService.isPluggedIn(modelData), BatteryService.isDeviceReady(modelData))
|
||||
color: (BatteryService.isCharging(modelData) || BatteryService.isPluggedIn(modelData)) ? Color.mPrimary : (BatteryService.isCriticalBattery(modelData) || BatteryService.isLowBattery(modelData)) ? Color.mError : Color.mOnSurface
|
||||
}
|
||||
|
||||
NText {
|
||||
readonly property string dName: BatteryService.getDeviceName(modelData)
|
||||
text: dName ? dName : I18n.tr("common.battery")
|
||||
color: (BatteryService.isCharging(modelData) || BatteryService.isPluggedIn(modelData)) ? Color.mPrimary : (BatteryService.isCriticalBattery(modelData) || BatteryService.isLowBattery(modelData)) ? Color.mError : Color.mOnSurface
|
||||
pointSize: Style.fontSizeS
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
@@ -161,11 +170,7 @@ SmartPanel {
|
||||
}
|
||||
}
|
||||
|
||||
NText {
|
||||
readonly property string dName: BatteryService.getDeviceName(modelData)
|
||||
text: dName ? dName : I18n.tr("common.battery")
|
||||
color: (BatteryService.isCharging(modelData) || BatteryService.isPluggedIn(modelData)) ? Color.mPrimary : (BatteryService.isCriticalBattery(modelData) || BatteryService.isLowBattery(modelData)) ? Color.mError : Color.mOnSurface
|
||||
pointSize: Style.fontSizeS
|
||||
Item {
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user