mirror of
https://github.com/ilya-zlobintsev/LACT.git
synced 2025-02-25 18:55:26 -06:00
feat: add and remove curve points
This commit is contained in:
parent
3e66a59d07
commit
1b3cc4c5e7
@ -264,7 +264,7 @@ impl GpuController {
|
||||
break;
|
||||
}
|
||||
}
|
||||
info!("exited fan control task");
|
||||
debug!("exited fan control task");
|
||||
});
|
||||
|
||||
*notify_guard = Some((notify, handle, curve));
|
||||
|
@ -78,14 +78,40 @@ impl FanCurveFrame {
|
||||
curve_frame.set_curve(&curve);
|
||||
}));
|
||||
|
||||
add_button.connect_clicked(clone!(@strong curve_frame => move |_| {
|
||||
curve_frame.add_point();
|
||||
}));
|
||||
|
||||
remove_button.connect_clicked(clone!(@strong curve_frame => move |_| {
|
||||
curve_frame.remove_point();
|
||||
}));
|
||||
|
||||
curve_frame
|
||||
}
|
||||
|
||||
fn add_point(&self) {
|
||||
let mut curve = self.get_curve();
|
||||
if let Some((temperature, ratio)) = curve.iter().last() {
|
||||
curve.insert(temperature + 5, *ratio);
|
||||
self.set_curve(&curve);
|
||||
}
|
||||
}
|
||||
|
||||
fn remove_point(&self) {
|
||||
let mut curve = self.get_curve();
|
||||
curve.pop_last();
|
||||
self.set_curve(&curve);
|
||||
}
|
||||
|
||||
fn notify_changed(&self) {
|
||||
if let Some(point) = self.points.borrow().first() {
|
||||
point.ratio.emit_by_name::<()>("value-changed", &[]);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_curve(&self, curve: &FanCurveMap) {
|
||||
// Notify that the values were changed when the entire curve is overwritten, e.g. when resetting to default
|
||||
if let Some(point) = self.points.borrow().first() {
|
||||
point.ratio.emit_by_name::<()>("value-changed", &[]);
|
||||
}
|
||||
self.notify_changed();
|
||||
|
||||
let points_container = Box::builder()
|
||||
.orientation(Orientation::Horizontal)
|
||||
|
Loading…
Reference in New Issue
Block a user