60 lines
1.7 KiB
QML
60 lines
1.7 KiB
QML
import QtQuick
|
|
import Quickshell
|
|
import "." as M
|
|
import "../services" as S
|
|
import "../applets" as C
|
|
|
|
M.BarModule {
|
|
id: root
|
|
active: S.Modules.temperature.enable
|
|
spacing: Math.max(1, S.Theme.moduleSpacing - 2)
|
|
tooltip: "Temperature: " + _temp + "\u00B0C"
|
|
panelNamespace: "nova-temperature"
|
|
panelTitle: "Temperature"
|
|
panelContentWidth: 220
|
|
panelComponent: Component {
|
|
C.TemperatureApplet {
|
|
width: parent.width
|
|
temp: root._temp
|
|
warm: root._warm
|
|
hot: root._hot
|
|
history: S.SystemStats.tempHistory
|
|
devices: S.SystemStats.tempDevices
|
|
accentColor: root.accentColor
|
|
deviceFilter: root._deviceFilter
|
|
active: root._showPanel
|
|
}
|
|
}
|
|
|
|
readonly property int _warm: S.Modules.temperature.warm || 80
|
|
readonly property int _hot: S.Modules.temperature.hot || 90
|
|
readonly property string _deviceFilter: S.Modules.temperature.device || ""
|
|
|
|
readonly property int _temp: {
|
|
if (_deviceFilter !== "") {
|
|
const dev = S.SystemStats.tempDevices.find(d => d.name === _deviceFilter);
|
|
if (dev)
|
|
return dev.celsius;
|
|
}
|
|
return S.SystemStats.tempCelsius;
|
|
}
|
|
|
|
property color _stateColor: _temp > _hot ? S.Theme.base08 : _temp > _warm ? S.Theme.base0A : root.accentColor
|
|
Behavior on _stateColor {
|
|
ColorAnimation {
|
|
duration: 300
|
|
}
|
|
}
|
|
|
|
M.BarIcon {
|
|
icon: "\uF2C9"
|
|
color: root._stateColor
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
}
|
|
M.BarLabel {
|
|
label: root._temp + "\u00B0C"
|
|
minText: "100\u00B0C"
|
|
color: root._stateColor
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
}
|
|
}
|