mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
fix: keep order of keyboard mappings in prefs view stable
This commit is contained in:
parent
251649bd44
commit
83d67a663b
1 changed files with 12 additions and 9 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::wifi;
|
use crate::wifi;
|
||||||
use locales::t;
|
use locales::t;
|
||||||
use num_traits::*;
|
use num_traits::*;
|
||||||
use std::{fmt::Display, collections::HashMap};
|
use std::fmt::Display;
|
||||||
use userprefs::Manager;
|
use userprefs::Manager;
|
||||||
|
|
||||||
pub trait PrefHandler {
|
pub trait PrefHandler {
|
||||||
|
|
@ -238,15 +238,15 @@ impl DevicePrefs {
|
||||||
fn keyboard_layout(&mut self) -> Result<(), DevicePrefsError> {
|
fn keyboard_layout(&mut self) -> Result<(), DevicePrefsError> {
|
||||||
let kl = self.up.keyboard_layout_or_default()?;
|
let kl = self.up.keyboard_layout_or_default()?;
|
||||||
|
|
||||||
let mut mappings = HashMap::new();
|
let mappings = vec![
|
||||||
|
"QWERTY",
|
||||||
mappings.insert("QWERTY", 0 as usize);
|
"AZERTY",
|
||||||
mappings.insert("AZERTY", 1);
|
"QWERTZ",
|
||||||
mappings.insert("QWERTZ", 2);
|
"Dvorak",
|
||||||
mappings.insert("Dvorak", 3);
|
];
|
||||||
|
|
||||||
self.modals
|
self.modals
|
||||||
.add_list(mappings.keys().cloned().collect())
|
.add_list(mappings.clone())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let new_result = self
|
let new_result = self
|
||||||
|
|
@ -254,7 +254,10 @@ impl DevicePrefs {
|
||||||
.get_radiobutton(&format!("Current layout: {}", keyboard::KeyMap::from(kl)))
|
.get_radiobutton(&format!("Current layout: {}", keyboard::KeyMap::from(kl)))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let new_result = mappings[new_result.as_str()];
|
let new_result = match mappings.iter().position(|&elem| elem == new_result.as_str()) {
|
||||||
|
Some(val) => val,
|
||||||
|
None => 0,
|
||||||
|
};
|
||||||
|
|
||||||
self.up.set_keyboard_layout(new_result)?;
|
self.up.set_keyboard_layout(new_result)?;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue