87 lines
2.4 KiB
QML
87 lines
2.4 KiB
QML
import QtQuick
|
|
import Quickshell
|
|
import "." as M
|
|
import "../services" as S
|
|
import "../applets" as C
|
|
|
|
M.BarSection {
|
|
id: root
|
|
spacing: Math.max(1, S.Theme.moduleSpacing - 2)
|
|
tooltip: ""
|
|
|
|
readonly property var _cores: S.SystemStats.cpuCores
|
|
readonly property var _coreMaxFreq: S.SystemStats.cpuCoreMaxFreq
|
|
readonly property var _coreTypes: S.SystemStats.cpuCoreTypes
|
|
|
|
property bool _pinned: false
|
|
readonly property bool _anyHover: root._hovered || hoverPanel.panelHovered
|
|
readonly property bool _showPanel: _anyHover || _pinned
|
|
|
|
property bool _coreConsumerActive: false
|
|
|
|
on_ShowPanelChanged: {
|
|
if (_showPanel && !_coreConsumerActive) {
|
|
_coreConsumerActive = true;
|
|
S.SystemStats.coreConsumers++;
|
|
} else if (!_showPanel && _coreConsumerActive) {
|
|
_coreConsumerActive = false;
|
|
S.SystemStats.coreConsumers--;
|
|
}
|
|
}
|
|
|
|
property M.ProcessList _procs: M.ProcessList {
|
|
sortBy: "cpu"
|
|
active: root._showPanel
|
|
onProcessesChanged: hoverPanel.keepOpen(300)
|
|
}
|
|
|
|
on_AnyHoverChanged: {
|
|
if (_anyHover)
|
|
_unpinTimer.stop();
|
|
else if (_pinned)
|
|
_unpinTimer.start();
|
|
}
|
|
|
|
Timer {
|
|
id: _unpinTimer
|
|
interval: 500
|
|
onTriggered: root._pinned = false
|
|
}
|
|
|
|
M.BarIcon {
|
|
icon: "\uF2DB"
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
TapHandler {
|
|
onTapped: root._pinned = !root._pinned
|
|
}
|
|
}
|
|
M.BarLabel {
|
|
label: S.SystemStats.cpuUsage.toString().padStart(2) + "%@" + S.SystemStats.cpuFreqGhz.toFixed(2)
|
|
minText: "99%@9.99"
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
TapHandler {
|
|
onTapped: root._pinned = !root._pinned
|
|
}
|
|
}
|
|
|
|
M.HoverPanel {
|
|
id: hoverPanel
|
|
showPanel: root._showPanel
|
|
screen: QsWindow.window?.screen ?? null
|
|
anchorItem: root
|
|
accentColor: root.accentColor
|
|
panelNamespace: "nova-cpu"
|
|
panelTitle: "CPU"
|
|
contentWidth: 260
|
|
|
|
C.CpuApplet {
|
|
width: hoverPanel.contentWidth
|
|
cores: root._cores
|
|
coreMaxFreq: root._coreMaxFreq
|
|
coreTypes: root._coreTypes
|
|
processes: root._procs.processes
|
|
accentColor: root.accentColor
|
|
active: root._showPanel
|
|
}
|
|
}
|
|
}
|