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
|
height: parent.height / 4
|
||||||
|
|
||||||
NCircleStat {
|
NCircleStat {
|
||||||
|
id: cpuUsageGauge
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
ratio: SystemStatService.cpuUsage / 100
|
ratio: SystemStatService.cpuUsage / 100
|
||||||
icon: "cpu-usage"
|
icon: "cpu-usage"
|
||||||
@@ -33,6 +34,15 @@ NBox {
|
|||||||
fillColor: SystemStatService.cpuColor
|
fillColor: SystemStatService.cpuColor
|
||||||
tooltipText: I18n.tr("system-monitor.cpu-usage") + `: ${Math.round(SystemStatService.cpuUsage)}%`
|
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 {
|
Item {
|
||||||
@@ -40,6 +50,7 @@ NBox {
|
|||||||
height: parent.height / 4
|
height: parent.height / 4
|
||||||
|
|
||||||
NCircleStat {
|
NCircleStat {
|
||||||
|
id: cpuTempGauge
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
ratio: SystemStatService.cpuTemp / 100
|
ratio: SystemStatService.cpuTemp / 100
|
||||||
suffix: "°C"
|
suffix: "°C"
|
||||||
@@ -48,6 +59,15 @@ NBox {
|
|||||||
fillColor: SystemStatService.tempColor
|
fillColor: SystemStatService.tempColor
|
||||||
tooltipText: I18n.tr("system-monitor.cpu-temp") + `: ${Math.round(SystemStatService.cpuTemp)}°C`
|
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 {
|
Item {
|
||||||
@@ -55,6 +75,7 @@ NBox {
|
|||||||
height: parent.height / 4
|
height: parent.height / 4
|
||||||
|
|
||||||
NCircleStat {
|
NCircleStat {
|
||||||
|
id: memPercentGauge
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
ratio: SystemStatService.memPercent / 100
|
ratio: SystemStatService.memPercent / 100
|
||||||
icon: "memory"
|
icon: "memory"
|
||||||
@@ -62,6 +83,15 @@ NBox {
|
|||||||
fillColor: SystemStatService.memColor
|
fillColor: SystemStatService.memColor
|
||||||
tooltipText: I18n.tr("common.memory") + `: ${Math.round(SystemStatService.memPercent)}%`
|
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 {
|
Item {
|
||||||
@@ -69,6 +99,7 @@ NBox {
|
|||||||
height: parent.height / 4
|
height: parent.height / 4
|
||||||
|
|
||||||
NCircleStat {
|
NCircleStat {
|
||||||
|
id: diskPercentsGauge
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
ratio: (SystemStatService.diskPercents[root.diskPath] ?? 0) / 100
|
ratio: (SystemStatService.diskPercents[root.diskPath] ?? 0) / 100
|
||||||
icon: "storage"
|
icon: "storage"
|
||||||
@@ -76,6 +107,15 @@ NBox {
|
|||||||
fillColor: SystemStatService.getDiskColor(root.diskPath)
|
fillColor: SystemStatService.getDiskColor(root.diskPath)
|
||||||
tooltipText: I18n.tr("system-monitor.disk") + `: ${SystemStatService.diskPercents[root.diskPath] || 0}%\n${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
|
spacing: Style.marginS
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
NIcon {
|
RowLayout {
|
||||||
icon: BatteryService.getIcon(BatteryService.getPercentage(modelData), BatteryService.isCharging(modelData), BatteryService.isPluggedIn(modelData), BatteryService.isDeviceReady(modelData))
|
NIcon {
|
||||||
color: (BatteryService.isCharging(modelData) || BatteryService.isPluggedIn(modelData)) ? Color.mPrimary : (BatteryService.isCriticalBattery(modelData) || BatteryService.isLowBattery(modelData)) ? Color.mError : Color.mOnSurface
|
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 {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
@@ -161,11 +170,7 @@ SmartPanel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NText {
|
Item {
|
||||||
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
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user