mirror of https://github.com/wayvr-org/wayvr.git
toast when no keymaps configured
This commit is contained in:
parent
7b8fadfaf2
commit
a7ff06f38a
|
|
@ -127,6 +127,8 @@
|
|||
"MAXIMUM_SETS_REACHED": "Maximum number of sets reached.",
|
||||
"NO_SET_SELECTED": "No set is selected.",
|
||||
"ONE_CONTROLLER_ON_FLOOR": "Place one controller on the floor!"
|
||||
"NO_KEYMAPS_CONFIGURED": "No keymaps configured."
|
||||
"NO_KEYMAPS_CONFIGURED_HELP": "Check the wayvr.org on how to set up your keymaps!"
|
||||
},
|
||||
"WATCH": {
|
||||
"ADD_NEW_SET": "Add a new set",
|
||||
|
|
|
|||
|
|
@ -109,12 +109,7 @@ pub(super) fn create_keyboard_panel(
|
|||
has_altgr,
|
||||
col,
|
||||
row,
|
||||
&app.session
|
||||
.config
|
||||
.keyboard_layouts
|
||||
.iter()
|
||||
.map(|s| s.to_string())
|
||||
.collect::<Vec<_>>(),
|
||||
&app.session.config.keyboard_layouts,
|
||||
) else {
|
||||
let _ = panel.layout.add_child(
|
||||
div.id,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use std::{collections::HashMap, str::FromStr, sync::LazyLock};
|
||||
use std::{collections::HashMap, str::FromStr, sync::Arc, sync::LazyLock};
|
||||
|
||||
use regex::Regex;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
|
@ -66,7 +66,7 @@ impl Layout {
|
|||
has_altgr: bool,
|
||||
col: usize,
|
||||
row: usize,
|
||||
keyboard_layouts: &[String],
|
||||
keyboard_layouts: &[Arc<str>],
|
||||
) -> Option<KeyData> {
|
||||
let key = self.main_layout[row][col].as_ref()?;
|
||||
let mut label = Vec::with_capacity(3);
|
||||
|
|
|
|||
|
|
@ -2,9 +2,10 @@ use std::{
|
|||
cell::Cell,
|
||||
collections::HashMap,
|
||||
process::{Child, Command},
|
||||
sync::atomic::Ordering,
|
||||
sync::{Arc, atomic::Ordering},
|
||||
};
|
||||
|
||||
use crate::overlays::toast::Toast;
|
||||
use crate::{
|
||||
KEYMAP_CHANGE,
|
||||
backend::{
|
||||
|
|
@ -40,7 +41,7 @@ use wgui::{
|
|||
use wlx_common::windowing::{OverlayWindowState, Positioning};
|
||||
use wlx_common::{
|
||||
config::AltModifier,
|
||||
overlays::{BackendAttrib, BackendAttribValue},
|
||||
overlays::{BackendAttrib, BackendAttribValue, ToastTopic},
|
||||
};
|
||||
|
||||
pub mod builder;
|
||||
|
|
@ -75,13 +76,7 @@ pub fn create_keyboard(app: &mut AppState) -> anyhow::Result<OverlayWindowConfig
|
|||
overlay_list: OverlayList::default(),
|
||||
set_list: SetList::default(),
|
||||
clock_12h: app.session.config.clock_12h,
|
||||
keymap_switch_layouts: app
|
||||
.session
|
||||
.config
|
||||
.keyboard_layouts
|
||||
.iter()
|
||||
.map(|s| s.to_string())
|
||||
.collect(),
|
||||
keymap_switch_layouts: app.session.config.keyboard_layouts.clone(),
|
||||
keymap_switch_index: 0,
|
||||
keymap_switch_pending: false,
|
||||
};
|
||||
|
|
@ -396,7 +391,7 @@ struct KeyboardState {
|
|||
overlay_list: OverlayList,
|
||||
set_list: SetList,
|
||||
clock_12h: bool,
|
||||
keymap_switch_layouts: Vec<String>,
|
||||
keymap_switch_layouts: Vec<Arc<str>>,
|
||||
keymap_switch_index: usize,
|
||||
keymap_switch_pending: bool,
|
||||
}
|
||||
|
|
@ -467,7 +462,7 @@ enum KeyButtonData {
|
|||
release_args: Vec<String>,
|
||||
},
|
||||
KeymapSwitch {
|
||||
layouts: Vec<String>,
|
||||
layouts: Vec<Arc<str>>,
|
||||
},
|
||||
}
|
||||
|
||||
|
|
@ -518,6 +513,15 @@ fn handle_press(
|
|||
play_key_click(app);
|
||||
}
|
||||
KeyButtonData::KeymapSwitch { layouts } => {
|
||||
if layouts.is_empty() {
|
||||
Toast::new(
|
||||
ToastTopic::System,
|
||||
"NO_KEYMAPS_CONFIGURED".into(),
|
||||
"NO_KEYMAPS_CONFIGURED_HELP".into(),
|
||||
)
|
||||
.submit(app);
|
||||
return;
|
||||
}
|
||||
keyboard.keymap_switch_index = (keyboard.keymap_switch_index + 1) % layouts.len();
|
||||
keyboard.keymap_switch_pending = true;
|
||||
play_key_click(app);
|
||||
|
|
|
|||
Loading…
Reference in New Issue