From f440da0e6811bb3ce54e62fb075380563c86f65b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=20Go=C3=B1i?= Date: Sun, 27 Oct 2024 20:08:38 +0100 Subject: [PATCH] Don't show the boost option on the GUI if the laptop doesn't support it --- razer_control_gui/src/lib.rs | 12 ++++++++++++ .../src/razer-settings/razer-settings.rs | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/razer_control_gui/src/lib.rs b/razer_control_gui/src/lib.rs index 475fad7..16f315f 100644 --- a/razer_control_gui/src/lib.rs +++ b/razer_control_gui/src/lib.rs @@ -12,3 +12,15 @@ pub struct SupportedDevice { pub features: Vec, pub fan: Vec, } + +impl SupportedDevice { + + pub fn has_feature(&self, feature: &str) -> bool { + self.features.iter().any(|f| f == feature) + } + + pub fn can_boost(&self) -> bool { + self.has_feature("boost") + } + +} diff --git a/razer_control_gui/src/razer-settings/razer-settings.rs b/razer_control_gui/src/razer-settings/razer-settings.rs index 3eac520..6b18b3e 100644 --- a/razer_control_gui/src/razer-settings/razer-settings.rs +++ b/razer_control_gui/src/razer-settings/razer-settings.rs @@ -408,7 +408,7 @@ fn make_page(ac: bool, device: SupportedDevice) -> SettingsPage { cpu_boost.append_text("Low"); cpu_boost.append_text("Medium"); cpu_boost.append_text("High"); - cpu_boost.append_text("Boost"); + if device.can_boost() { cpu_boost.append_text("Boost") }; cpu_boost.set_active(Some(power.1 as u32)); cpu_boost.set_width_request(100); let row = SettingsRow::new(&label, &cpu_boost);