extract loadColor gradient function into Theme service
This commit is contained in:
parent
1db16b435c
commit
7d9800374f
5 changed files with 16 additions and 39 deletions
|
|
@ -12,14 +12,6 @@ Column {
|
|||
|
||||
property bool active: true
|
||||
|
||||
function _loadColor(pct) {
|
||||
const t = Math.max(0, Math.min(100, pct)) / 100;
|
||||
const a = t < 0.5 ? S.Theme.base0B : S.Theme.base0A;
|
||||
const b = t < 0.5 ? S.Theme.base0A : S.Theme.base08;
|
||||
const u = t < 0.5 ? t * 2 : (t - 0.5) * 2;
|
||||
return Qt.rgba(a.r + (b.r - a.r) * u, a.g + (b.g - a.g) * u, a.b + (b.b - a.b) * u, 1);
|
||||
}
|
||||
|
||||
// Per-core rows
|
||||
Repeater {
|
||||
model: root.cores.length
|
||||
|
|
@ -30,7 +22,7 @@ Column {
|
|||
|
||||
readonly property int _u: root.cores[index]?.usage ?? 0
|
||||
readonly property real _f: root.cores[index]?.freq_ghz ?? 0
|
||||
readonly property color _barColor: root._loadColor(_u)
|
||||
readonly property color _barColor: S.Theme.loadColor(_u)
|
||||
readonly property bool _throttled: {
|
||||
const maxF = root.coreMaxFreq[index] ?? 0;
|
||||
return maxF > 0 && _f < maxF * 0.85 && _u >= 60;
|
||||
|
|
@ -218,7 +210,7 @@ Column {
|
|||
anchors.rightMargin: 12
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: modelData.cpu.toFixed(1) + "%"
|
||||
color: root._loadColor(modelData.cpu)
|
||||
color: S.Theme.loadColor(modelData.cpu)
|
||||
font.pixelSize: S.Theme.fontSize - 2
|
||||
font.family: S.Theme.fontFamily
|
||||
width: 36
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue