62 lines
1.5 KiB
QML
62 lines
1.5 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: ""
|
|
visible: S.Modules.gpu.enable && S.SystemStats.gpuAvailable
|
|
|
|
property bool _pinned: false
|
|
readonly property bool _anyHover: root._hovered || hoverPanel.panelHovered
|
|
readonly property bool _showPanel: _anyHover || _pinned
|
|
|
|
on_AnyHoverChanged: {
|
|
if (_anyHover)
|
|
_unpinTimer.stop();
|
|
else if (_pinned)
|
|
_unpinTimer.start();
|
|
}
|
|
|
|
Timer {
|
|
id: _unpinTimer
|
|
interval: 500
|
|
onTriggered: root._pinned = false
|
|
}
|
|
|
|
M.BarIcon {
|
|
icon: "\uEB4C"
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
TapHandler {
|
|
onTapped: root._pinned = !root._pinned
|
|
}
|
|
}
|
|
M.BarLabel {
|
|
label: S.SystemStats.gpuUsage + "%"
|
|
minText: "100%"
|
|
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-gpu"
|
|
panelTitle: "GPU"
|
|
contentWidth: 240
|
|
|
|
C.GpuApplet {
|
|
width: hoverPanel.contentWidth
|
|
active: root._showPanel
|
|
accentColor: root.accentColor
|
|
}
|
|
}
|
|
}
|