| 1 |
// SPDX-License-Identifier: GPL-3.0-or-later |
| 2 |
// Copyright 2019 Juan Palacios <[email protected]> |
| 3 |
|
| 4 |
import QtQuick 2.15 |
| 5 |
import QtQuick.Controls 2.15 |
| 6 |
import QtQuick.Layouts 1.15 |
| 7 |
import CoreCtrl.UIComponents 1.0 |
| 8 |
import "Style.js" as Style |
| 9 |
|
| 10 |
AMD_FAN_CURVE { |
| 11 |
id: fanCurve |
| 12 |
objectName: "AMD_FAN_CURVE" |
| 13 |
|
| 14 |
width: contents.width |
| 15 |
height: contents.height |
| 16 |
|
| 17 |
onCurveChanged: points => { |
| 18 |
curveControl.removeCurve("curve") |
| 19 |
curveControl.addCurve("curve", Style.Theme.accent, points) |
| 20 |
} |
| 21 |
|
| 22 |
onFanStopChanged: enabled => { |
| 23 |
if (enabled) |
| 24 |
p.showFanStartCurve() |
| 25 |
else |
| 26 |
p.hideFanStartCurve() |
| 27 |
|
| 28 |
fanStop.checked = enabled |
| 29 |
} |
| 30 |
|
| 31 |
onFanStartValueChanged: value => { |
| 32 |
if (fanCurve.fanStop) { |
| 33 |
p.hideFanStartCurve() |
| 34 |
p.showFanStartCurve() |
| 35 |
} |
| 36 |
|
| 37 |
fanStartValue.value = value |
| 38 |
} |
| 39 |
|
| 40 |
onTemperatureRangeChanged: (min, max) => { |
| 41 |
curveControl.configureAxes(qsTr("Temperature"), "\u00B0C", min, max, |
| 42 |
qsTr("PWM"), "%", 0, 100) |
| 43 |
|
| 44 |
// Reposition fanStart curve as its control point position depends |
| 45 |
// on temperature range |
| 46 |
if (fanCurve.fanStop) { |
| 47 |
p.hideFanStartCurve() |
| 48 |
p.showFanStartCurve() |
| 49 |
} |
| 50 |
} |
| 51 |
|
| 52 |
QtObject { // private stuff |
| 53 |
id: p |
| 54 |
|
| 55 |
function hideFanStartCurve() { |
| 56 |
curveControl.removeCurve("fanStart") |
| 57 |
} |
| 58 |
|
| 59 |
function showFanStartCurve() { |
| 60 |
var points = [] |
| 61 |
points.push(Qt.point(fanCurve.maxTemp - |
| 62 |
(fanCurve.maxTemp - fanCurve.minTemp) * .15, |
| 63 |
fanCurve.fanStartValue)) |
| 64 |
curveControl.addCurve("fanStart", |
| 65 |
Style.CurveControl.curve_amd_start_color, |
| 66 |
points) |
| 67 |
} |
| 68 |
} |
| 69 |
|
| 70 |
TextMetrics { |
| 71 |
id: tFMetrics |
| 72 |
text: "100" |
| 73 |
} |
| 74 |
|
| 75 |
CPane { |
| 76 |
id: contents |
| 77 |
|
| 78 |
ColumnLayout { |
| 79 |
spacing: 8 |
| 80 |
|
| 81 |
CurveControl { |
| 82 |
id: curveControl |
| 83 |
minXDistance: 5 |
| 84 |
clampPointsYCoordinate: true |
| 85 |
width: 480 |
| 86 |
height: 240 |
| 87 |
|
| 88 |
onCurveChanged: (name, oldPoint, newPoint) => { |
| 89 |
if (name === "curve") |
| 90 |
fanCurve.updateCurvePoint(oldPoint, newPoint) |
| 91 |
else if (name === "fanStart") |
| 92 |
fanCurve.fanStartValue = parseInt(Math.round(newPoint.y)) |
| 93 |
} |
| 94 |
} |
| 95 |
|
| 96 |
RowLayout { |
| 97 |
spacing: 8 |
| 98 |
|
| 99 |
Item { |
| 100 |
Layout.fillWidth: true |
| 101 |
} |
| 102 |
|
| 103 |
Item { |
| 104 |
implicitWidth: fanStop.width / (1 + Style.g_tweakScale) |
| 105 |
|
| 106 |
Switch { |
| 107 |
id: fanStop |
| 108 |
|
| 109 |
scale: Style.g_tweakScale |
| 110 |
anchors.centerIn: parent |
| 111 |
|
| 112 |
onToggled: fanCurve.fanStop = checked |
| 113 |
} |
| 114 |
} |
| 115 |
|
| 116 |
Label { |
| 117 |
text: qsTr("Fan start") |
| 118 |
enabled: fanStop.checked |
| 119 |
} |
| 120 |
|
| 121 |
CIntInput { |
| 122 |
id: fanStartValue |
| 123 |
|
| 124 |
minValue: 0 |
| 125 |
maxValue: 100 |
| 126 |
|
| 127 |
enabled: fanStop.checked |
| 128 |
Layout.preferredWidth: tFMetrics.width + padding * 2 |
| 129 |
|
| 130 |
onValueChanged: fanCurve.fanStartValue = value |
| 131 |
} |
| 132 |
} |
| 133 |
} |
| 134 |
} |
| 135 |
} |