Skip to content

Commit 9e88708

Browse files
committed
fix: Show brightness/color only if keyboard supports it
If no backlight, LEDs tab isn't shown.
1 parent 236dc90 commit 9e88708

2 files changed

Lines changed: 22 additions & 20 deletions

File tree

src/backlight.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,11 +295,11 @@ impl Backlight {
295295
} else if row == &*inner.speed_row {
296296
layout.meta.has_mode && self.mode().has_speed
297297
} else if row == &*inner.color_row {
298-
!layout.meta.has_mode || self.mode().has_hue
298+
layout.meta.has_color && (!layout.meta.has_mode || self.mode().has_hue)
299299
} else if row == &*inner.saturation_row {
300300
!self.mode().has_hue && !self.mode().is_disabled()
301301
} else if row == &*inner.brightness_row {
302-
!layout.meta.has_mode || !self.mode().is_disabled()
302+
layout.meta.has_brightness && (!layout.meta.has_mode || !self.mode().is_disabled())
303303
} else {
304304
true
305305
}

src/keyboard.rs

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -208,24 +208,26 @@ impl Keyboard {
208208
keyboard
209209
.bind_property("selected", &backlight, "selected")
210210
.build();
211-
stack.add_titled(
212-
&cascade! {
213-
gtk::Box::new(gtk::Orientation::Vertical, 32);
214-
..add(&cascade! {
215-
gtk::Label::new(Some(concat!(
216-
"Select a key on the keymap to change its settings. ",
217-
"Choose per key Solid Pattern to customize each key's LED color. ",
218-
"Shift + click to select more than one key. ",
219-
"Your settings are automatically saved to firmware.")));
220-
..set_line_wrap(true);
221-
..set_max_width_chars(100);
222-
..set_halign(gtk::Align::Center);
223-
});
224-
..add(&backlight);
225-
},
226-
"leds",
227-
"LEDs",
228-
);
211+
if board.layout().meta.has_brightness {
212+
stack.add_titled(
213+
&cascade! {
214+
gtk::Box::new(gtk::Orientation::Vertical, 32);
215+
..add(&cascade! {
216+
gtk::Label::new(Some(concat!(
217+
"Select a key on the keymap to change its settings. ",
218+
"Choose per key Solid Pattern to customize each key's LED color. ",
219+
"Shift + click to select more than one key. ",
220+
"Your settings are automatically saved to firmware.")));
221+
..set_line_wrap(true);
222+
..set_max_width_chars(100);
223+
..set_halign(gtk::Align::Center);
224+
});
225+
..add(&backlight);
226+
},
227+
"leds",
228+
"LEDs",
229+
);
230+
}
229231

230232
keyboard.inner().board.set(board);
231233
keyboard.inner().backlight.set(backlight);

0 commit comments

Comments
 (0)