mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
rog-gui: add reset-curve button
This commit is contained in:
@@ -174,6 +174,30 @@ impl ProfileZbus {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Reset the stored (self) and device curve to the defaults of the platform.
|
||||||
|
///
|
||||||
|
/// Each platform_profile has a different default and the defualt can be read
|
||||||
|
/// only for the currently active profile.
|
||||||
|
fn reset_profile_curves(&self, profile: Profile) -> zbus::fdo::Result<()> {
|
||||||
|
if let Ok(mut ctrl) = self.inner.try_lock() {
|
||||||
|
ctrl.config.read();
|
||||||
|
let active = Profile::get_active_profile().unwrap_or(Profile::Balanced);
|
||||||
|
|
||||||
|
Profile::set_profile(profile)
|
||||||
|
.map_err(|e| warn!("set_profile, {}", e))
|
||||||
|
.ok();
|
||||||
|
ctrl.set_active_curve_to_defaults()
|
||||||
|
.map_err(|e| warn!("Profile::set_active_curve_to_defaults, {}", e))
|
||||||
|
.ok();
|
||||||
|
|
||||||
|
Profile::set_profile(active)
|
||||||
|
.map_err(|e| warn!("set_profile, {}", e))
|
||||||
|
.ok();
|
||||||
|
ctrl.save_config();
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
#[dbus_interface(signal)]
|
#[dbus_interface(signal)]
|
||||||
async fn notify_profile(signal_ctxt: &SignalContext<'_>, profile: Profile) -> zbus::Result<()> {
|
async fn notify_profile(signal_ctxt: &SignalContext<'_>, profile: Profile) -> zbus::Result<()> {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ impl<'a> RogApp<'a> {
|
|||||||
ui,
|
ui,
|
||||||
);
|
);
|
||||||
|
|
||||||
fan_graphs(&mut states.profiles, &mut states.fan_curves, dbus, &mut states.error, ui);
|
fan_graphs(supported, &mut states.profiles, &mut states.fan_curves, dbus, &mut states.error, ui);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
use egui::{plot::Points, Ui};
|
use egui::{plot::Points, Ui};
|
||||||
|
use rog_platform::supported::SupportedFunctions;
|
||||||
use rog_profiles::{FanCurvePU, Profile};
|
use rog_profiles::{FanCurvePU, Profile};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
@@ -7,6 +8,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
pub fn fan_graphs(
|
pub fn fan_graphs(
|
||||||
|
supported: &SupportedFunctions,
|
||||||
profiles: &mut ProfilesState,
|
profiles: &mut ProfilesState,
|
||||||
curves: &mut FanCurvesState,
|
curves: &mut FanCurvesState,
|
||||||
dbus: &RogDbusClientBlocking,
|
dbus: &RogDbusClientBlocking,
|
||||||
@@ -108,15 +110,36 @@ pub fn fan_graphs(
|
|||||||
plot_ui.points(points)
|
plot_ui.points(points)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let mut set = false;
|
||||||
|
let mut reset = false;
|
||||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::TOP), |ui| {
|
ui.with_layout(egui::Layout::right_to_left(egui::Align::TOP), |ui| {
|
||||||
if ui.add(egui::Button::new("Apply Fan-curve")).clicked() {
|
set = ui.add(egui::Button::new("Apply Fan-curve")).clicked();
|
||||||
dbus.proxies()
|
reset = ui.add(egui::Button::new("Reset Profile")).clicked();
|
||||||
.profile()
|
|
||||||
.set_fan_curve(profiles.current, data.clone())
|
|
||||||
.map_err(|err| {
|
|
||||||
*do_error = Some(err.to_string());
|
|
||||||
})
|
|
||||||
.ok();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if set {
|
||||||
|
dbus.proxies()
|
||||||
|
.profile()
|
||||||
|
.set_fan_curve(profiles.current, data.clone())
|
||||||
|
.map_err(|err| {
|
||||||
|
*do_error = Some(err.to_string());
|
||||||
|
})
|
||||||
|
.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
if reset {
|
||||||
|
dbus.proxies()
|
||||||
|
.profile()
|
||||||
|
.reset_profile_curves(profiles.current)
|
||||||
|
.map_err(|err| {
|
||||||
|
*do_error = Some(err.to_string());
|
||||||
|
})
|
||||||
|
.ok();
|
||||||
|
|
||||||
|
let notif = curves.was_notified.clone();
|
||||||
|
match FanCurvesState::new(notif, supported, dbus) {
|
||||||
|
Ok(f) => *curves = f,
|
||||||
|
Err(e) => *do_error = Some(e.to_string()),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,10 @@ impl<'a> RogApp<'a> {
|
|||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
ui.spacing_mut().item_spacing.x = 0.0;
|
ui.spacing_mut().item_spacing.x = 0.0;
|
||||||
ui.label("Source code ");
|
ui.label("Source code ");
|
||||||
ui.hyperlink_to("rog-gui.", "https://gitlab.com/asus-linux/asusctl/-/tree/main/rog-control-center");
|
ui.hyperlink_to(
|
||||||
|
"rog-gui.",
|
||||||
|
"https://gitlab.com/asus-linux/asusctl/-/tree/main/rog-control-center",
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -62,6 +62,12 @@ trait Profile {
|
|||||||
/// only for the currently active profile.
|
/// only for the currently active profile.
|
||||||
fn set_active_curve_to_defaults(&self) -> zbus::Result<()>;
|
fn set_active_curve_to_defaults(&self) -> zbus::Result<()>;
|
||||||
|
|
||||||
|
/// Reset the stored (self) and device curve to the defaults of the platform.
|
||||||
|
///
|
||||||
|
/// Each platform_profile has a different default and the defualt can be read
|
||||||
|
/// only for the currently active profile.
|
||||||
|
fn reset_profile_curves(&self, profile: Profile) -> zbus::fdo::Result<()>;
|
||||||
|
|
||||||
/// NotifyProfile signal
|
/// NotifyProfile signal
|
||||||
#[dbus_proxy(signal)]
|
#[dbus_proxy(signal)]
|
||||||
fn notify_profile(&self, profile: Profile) -> zbus::Result<Profile>;
|
fn notify_profile(&self, profile: Profile) -> zbus::Result<Profile>;
|
||||||
|
|||||||
Reference in New Issue
Block a user