More work on install stage. Trying to implement keyboard layout test by Dbus switching, not working properly, dead end

This commit is contained in:
kira committed 2026-11-29 16:57:38 +01:00
1 parent 740bbdb4d8
commit 1186932625
7 files changed
+316 -60

No files matched your search

Generated
+79 -2
View File
@@ -1753,7 +1753,9 @@ dependencies = [
"rust-i18n", "rust-i18n",
"serde", "serde",
"serde_json", "serde_json",
"smol",
"time-format", "time-format",
"zbus 6.5.0",
] ]
[[package]] [[package]]
@@ -1993,7 +1995,7 @@ dependencies = [
"wasm-bindgen-futures", "wasm-bindgen-futures",
"web-sys", "web-sys",
"windows", "windows",
"zbus", "zbus 5.19.0",
] ]
[[package]] [[package]]
@@ -3335,6 +3337,16 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "socket2"
version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3d1e2c7f27f8d4cb10542a02c49005dbd6e93095799d6f3be745fae9f8fedd4"
dependencies = [
"libc",
"windows-sys 0.61.2",
]
[[package]] [[package]]
name = "softbuffer" name = "softbuffer"
version = "0.4.8" version = "0.4.8"
@@ -4351,11 +4363,38 @@ dependencies = [
"uuid", "uuid",
"windows-sys 0.61.2", "windows-sys 0.61.2",
"winnow 1.0.5", "winnow 1.0.5",
"zbus_macros", "zbus_macros 5.19.0",
"zbus_names", "zbus_names",
"zvariant", "zvariant",
] ]
[[package]]
name = "zbus"
version = "6.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a7f9f5dd97fa527c1202ba1cb35d48e07f77d4de8542317c854f7aef22b0668"
dependencies = [
"async-trait",
"bitflags 2.13.2",
"endi",
"futures-core",
"hex",
"libc",
"ordered-stream",
"rustix 1.1.6",
"serde",
"serde_repr",
"socket2",
"uds_windows",
"uuid",
"windows-sys 0.61.2",
"winnow 1.0.5",
"zbus_macros 6.5.0",
"zbus_utils",
"zcheapstr",
"zruntime",
]
[[package]] [[package]]
name = "zbus_macros" name = "zbus_macros"
version = "5.19.0" version = "5.19.0"
@@ -4371,6 +4410,18 @@ dependencies = [
"zvariant_utils", "zvariant_utils",
] ]
[[package]]
name = "zbus_macros"
version = "6.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2f5aa7f2c4ea81b7ccfb26bafefdb4d1a44dd9d4f82c8426173a3727311743e4"
dependencies = [
"proc-macro2",
"quote",
"syn 3.0.10",
"zbus_utils",
]
[[package]] [[package]]
name = "zbus_names" name = "zbus_names"
version = "4.3.5" version = "4.3.5"
@@ -4382,6 +4433,19 @@ dependencies = [
"zvariant", "zvariant",
] ]
[[package]]
name = "zbus_utils"
version = "6.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af55e52da295311b368c45bcae221f020e28e97a2420360170ce389218e76ec7"
dependencies = [
"proc-macro2",
"quote",
"serde",
"syn 3.0.10",
"winnow 1.0.5",
]
[[package]] [[package]]
name = "zcheapstr" name = "zcheapstr"
version = "1.3.0" version = "1.3.0"
@@ -4429,6 +4493,19 @@ version = "1.0.23"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b" checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b"
[[package]]
name = "zruntime"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac67096b97c00742108c4674db6bb6178adb78c4b66a506b0e4a7a9593aa5d9e"
dependencies = [
"futures-core",
"futures-io",
"rustix 1.1.6",
"socket2",
"windows-sys 0.61.2",
]
[[package]] [[package]]
name = "zune-core" name = "zune-core"
version = "0.5.3" version = "0.5.3"
+2
View File
@@ -8,8 +8,10 @@ edition = "2024"
[dependencies] [dependencies]
blocking = "1.6" blocking = "1.6"
smol = "2"
iced = { version = "0.14", default-features = false, features = ["crisp", "linux-theme-detection", "tiny-skia", "x11", "smol", "image"] } iced = { version = "0.14", default-features = false, features = ["crisp", "linux-theme-detection", "tiny-skia", "x11", "smol", "image"] }
#iced = { git = "https://github.com/iced-rs/iced", branch = "vello_cpu", default-features = false, features = ["crisp", "linux-theme-detection", "vello-cpu", "x11", "smol", "image"]} #iced = { git = "https://github.com/iced-rs/iced", branch = "vello_cpu", default-features = false, features = ["crisp", "linux-theme-detection", "vello-cpu", "x11", "smol", "image"]}
zbus = { version = "6", default-features = false, features = ["default-rt", "comms"] }
iced_moving_picture = "0" iced_moving_picture = "0"
log = "0.4" log = "0.4"
rust-i18n = "4" rust-i18n = "4"
+94
View File
@@ -22,6 +22,7 @@ use crate::kira_disk_layout::*;
use crate::kira_size::KiraSize; use crate::kira_size::KiraSize;
use std::fmt::format; use std::fmt::format;
use std::fs; use std::fs;
use std::io::Read;
use std::path::Path; use std::path::Path;
use std::process::Command; use std::process::Command;
@@ -103,6 +104,51 @@ impl std::fmt::Display for ExecCommandError {
// Implement std::error::Error // Implement std::error::Error
impl std::error::Error for ExecCommandError {} impl std::error::Error for ExecCommandError {}
/// exec given sommand with arguments, capturing stderr in case or failure
pub fn exec_command_stdin(
cmd: &str,
args: &Vec<&str>,
stdin_data: &str,
) -> Result<(), ExecCommandError> {
use std::io::Write;
use std::process::{Command, Stdio};
use std::thread;
let mut child = Command::new(cmd)
.args(args)
.stdin(Stdio::piped())
.stderr(Stdio::piped())
.spawn()?;
let mut stdin = child
.stdin
.take()
.ok_or("Failed to capture stdin".to_string())?;
let mut stderr = child
.stderr
.take()
.ok_or("Failed to capture stderr".to_string())?;
let stderr_handle = thread::spawn(move || {
let mut buf = Vec::new();
use std::io::Read;
let _ = stderr.read_to_end(&mut buf);
buf
});
stdin.write_all(stdin_data.as_bytes())?;
let status = child.wait()?;
let stderr_output = stderr_handle.join().unwrap();
if status.success() {
Ok(())
} else {
Err(CommandFailed::new(cmd, args, stderr_output).into())
}
}
/// exec given sommand with arguments, capturing stderr in case or failure /// exec given sommand with arguments, capturing stderr in case or failure
pub fn exec_command(cmd: &str, args: &Vec<&str>) -> Result<(), ExecCommandError> { pub fn exec_command(cmd: &str, args: &Vec<&str>) -> Result<(), ExecCommandError> {
let out = Command::new(cmd).args(args).output()?; let out = Command::new(cmd).args(args).output()?;
@@ -466,3 +512,51 @@ pub fn fstabgen(mnt_dir: &str) -> Result<(), ExecCommandError> {
fs::write(&fstab_file_name, fstab)?; fs::write(&fstab_file_name, fstab)?;
Ok(()) Ok(())
} }
///
/// Executes passwd --stdin --root chroot_dir root
/// To set new root password in specified chroot env
///
pub fn set_root_passwd(chroot_dir: &str, root_passwd: &str) -> Result<(), ExecCommandError> {
exec_command_stdin(
"passwd",
&vec!["--stdin", "--root", chroot_dir, "root"],
root_passwd,
)
}
///
/// Sends Dbus message locale1 to change input method
/// SetX11Keyboard(layout: s, model: s, variant: s, options: s, convert: b, interactive: b)
///
pub async fn set_input_method(
layout: &str,
model: &str,
variant: &str,
options: &str,
) -> zbus::Result<()> {
use zbus::Connection;
let conn = Connection::system().await?;
log::info!("Sending dbus message to change layout");
log::info!(
"layout: {}, model: {}, variant: {}, options: {}",
layout,
model,
variant,
options
);
let resp = conn
.call_method(
Some("org.freedesktop.locale1"),
"/org/freedesktop/locale1",
Some("org.freedesktop.locale1"),
"SetX11Keyboard",
&(layout, model, variant, options, true, false),
)
.await?;
log::info!("Dbus response: {}", resp.to_string());
Ok(())
}
+47 -34
View File
@@ -20,7 +20,7 @@
stages loading, switching between stages, and stuff. stages loading, switching between stages, and stuff.
*/ */
use iced::widget; use iced::{keyboard, widget};
use log; use log;
use std::process::ExitCode; use std::process::ExitCode;
@@ -33,14 +33,14 @@ use crate::stages::welcome;
use crate::stages::welcome::WelcomeStage; use crate::stages::welcome::WelcomeStage;
rust_i18n::i18n!("src/locales", fallback = "en"); rust_i18n::i18n!("src/locales", fallback = "en");
mod kira_include;
mod kira_color_bar; mod kira_color_bar;
mod kira_disk_layout; mod kira_disk_layout;
mod kira_system; mod kira_include;
mod kira_logger; mod kira_logger;
mod kira_scroll_list; mod kira_scroll_list;
mod kira_size; mod kira_size;
mod kira_sysinfo; mod kira_sysinfo;
mod kira_system;
mod kira_theming; mod kira_theming;
mod stage; mod stage;
mod stages; mod stages;
@@ -97,7 +97,7 @@ impl KiraState {
( (
Self { Self {
current_view: Views::Start, current_view: Views::Start,
k_config: KiraConfig ::default(), k_config: KiraConfig::default(),
stages_save: Vec::new(), stages_save: Vec::new(),
}, },
Task::done(Message::Start), Task::done(Message::Start),
@@ -123,10 +123,10 @@ fn view(k_state: &KiraState) -> Element<'_, Message> {
fn update(k_state: &mut KiraState, message: Message) -> Task<Message> { fn update(k_state: &mut KiraState, message: Message) -> Task<Message> {
match message { match message {
Message::Start => { Message::Start => {
log::info!("Starting!"); log::info!("Starting!");
k_state.current_view = Views::Welcome(WelcomeStage::new(k_state.k_config.clone())); k_state.current_view = Views::Welcome(WelcomeStage::new(k_state.k_config.clone()));
Task::none() Task::none()
}, }
Message::Welcome(wlc_msg) => { Message::Welcome(wlc_msg) => {
if let Views::Welcome(wlc_view) = &mut k_state.current_view { if let Views::Welcome(wlc_view) = &mut k_state.current_view {
match wlc_view.update(wlc_msg) { match wlc_view.update(wlc_msg) {
@@ -164,7 +164,7 @@ fn update(k_state: &mut KiraState, message: Message) -> Task<Message> {
k_state.current_view = k_state.stages_save.pop().unwrap(); k_state.current_view = k_state.stages_save.pop().unwrap();
Task::none() Task::none()
} }
StageAction::None => Task::none(), _ => Task::none(),
} }
} else { } else {
Task::none() Task::none()
@@ -180,7 +180,9 @@ fn update(k_state: &mut KiraState, message: Message) -> Task<Message> {
k_state.k_config = network_res; k_state.k_config = network_res;
let s_state = std::mem::replace( let s_state = std::mem::replace(
&mut k_state.current_view, &mut k_state.current_view,
Views::TimeZone(stages::timezone::TimeZoneStage::new(k_state.k_config.clone())), Views::TimeZone(stages::timezone::TimeZoneStage::new(
k_state.k_config.clone(),
)),
); );
k_state.stages_save.push(s_state); k_state.stages_save.push(s_state);
Task::none() Task::none()
@@ -204,7 +206,9 @@ fn update(k_state: &mut KiraState, message: Message) -> Task<Message> {
k_state.k_config = tz_res; k_state.k_config = tz_res;
let s_state = std::mem::replace( let s_state = std::mem::replace(
&mut k_state.current_view, &mut k_state.current_view,
Views::Locale(stages::locale::LocaleStage::new(k_state.k_config.clone())), Views::Locale(stages::locale::LocaleStage::new(
k_state.k_config.clone(),
)),
); );
k_state.stages_save.push(s_state); k_state.stages_save.push(s_state);
Task::none() Task::none()
@@ -214,7 +218,7 @@ fn update(k_state: &mut KiraState, message: Message) -> Task<Message> {
k_state.current_view = k_state.stages_save.pop().unwrap(); k_state.current_view = k_state.stages_save.pop().unwrap();
Task::none() Task::none()
} }
StageAction::None => Task::none(), _ => Task::none(),
} }
} else { } else {
Task::none() Task::none()
@@ -227,7 +231,9 @@ fn update(k_state: &mut KiraState, message: Message) -> Task<Message> {
k_state.k_config = locale_res; k_state.k_config = locale_res;
let s_state = std::mem::replace( let s_state = std::mem::replace(
&mut k_state.current_view, &mut k_state.current_view,
Views::Keyboard(stages::keyboard::KeyboardStage::new(k_state.k_config.clone())), Views::Keyboard(stages::keyboard::KeyboardStage::new(
k_state.k_config.clone(),
)),
); );
k_state.stages_save.push(s_state); k_state.stages_save.push(s_state);
Task::none() Task::none()
@@ -245,27 +251,30 @@ fn update(k_state: &mut KiraState, message: Message) -> Task<Message> {
Message::Keyboard(keyboard_msg) => { Message::Keyboard(keyboard_msg) => {
if let Views::Keyboard(keyboard_view) = &mut k_state.current_view { if let Views::Keyboard(keyboard_view) = &mut k_state.current_view {
match keyboard_view.update(keyboard_msg) { match keyboard_view.update(keyboard_msg) {
StageAction::Next(keyboard_res) => { stages::keyboard::Update::Task(t) => t.map(Message::Keyboard),
k_state.k_config = keyboard_res; stages::keyboard::Update::StgAct(action) => match action {
match stages::partition::PartitionStage::new(k_state.k_config.clone()) { StageAction::Next(keyboard_res) => {
Ok(part_stage) => { k_state.k_config = keyboard_res;
let s_state = std::mem::replace( match stages::partition::PartitionStage::new(k_state.k_config.clone()) {
&mut k_state.current_view, Ok(part_stage) => {
Views::Partition(part_stage), let s_state = std::mem::replace(
); &mut k_state.current_view,
k_state.stages_save.push(s_state); Views::Partition(part_stage),
} );
Err(ex) => { k_state.stages_save.push(s_state);
log::error!("Error, cannot init partition stage: {}", ex); }
Err(ex) => {
log::error!("Error, cannot init partition stage: {}", ex);
}
} }
Task::none()
} }
Task::none() StageAction::Back => {
} k_state.current_view = k_state.stages_save.pop().unwrap();
StageAction::Back => { Task::none()
k_state.current_view = k_state.stages_save.pop().unwrap(); }
Task::none() _ => Task::none(),
} },
_ => Task::none(),
} }
} else { } else {
Task::none() Task::none()
@@ -278,7 +287,9 @@ fn update(k_state: &mut KiraState, message: Message) -> Task<Message> {
k_state.k_config = partition_res; k_state.k_config = partition_res;
let s_state = std::mem::replace( let s_state = std::mem::replace(
&mut k_state.current_view, &mut k_state.current_view,
Views::Security(stages::security::SecurityStage::new(k_state.k_config.clone())), Views::Security(stages::security::SecurityStage::new(
k_state.k_config.clone(),
)),
); );
k_state.stages_save.push(s_state); k_state.stages_save.push(s_state);
Task::none() Task::none()
@@ -300,7 +311,9 @@ fn update(k_state: &mut KiraState, message: Message) -> Task<Message> {
k_state.k_config = security_res; k_state.k_config = security_res;
let s_state = std::mem::replace( let s_state = std::mem::replace(
&mut k_state.current_view, &mut k_state.current_view,
Views::Install(stages::install::InstallStage::new(k_state.k_config.clone())), Views::Install(stages::install::InstallStage::new(
k_state.k_config.clone(),
)),
); );
k_state.stages_save.push(s_state); k_state.stages_save.push(s_state);
Task::none() Task::none()
+2 -3
View File
@@ -19,7 +19,7 @@
*/ */
use crate::stages; use crate::stages;
use iced::Task;
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct KiraConfig { pub struct KiraConfig {
@@ -50,8 +50,7 @@ impl Default for KiraConfig {
} }
} }
#[derive(Debug)]
#[derive(Debug, Clone)]
pub enum StageAction { pub enum StageAction {
Back, Back,
None, None,
+5
View File
@@ -371,6 +371,11 @@ fn config_stuff(k_config: KiraConfig) -> Result<(), ExecCommandError> {
// hwclock --systohc // hwclock --systohc
kira_system::exec_cmd_chroot(MNT_DIR, "hwclock", &vec!["--systohc"])?; kira_system::exec_cmd_chroot(MNT_DIR, "hwclock", &vec!["--systohc"])?;
// set root password
log::info!("Setting root password...");
let sec_conf = k_config.res_security.as_ref().unwrap();
kira_system::set_root_passwd(MNT_DIR, &sec_conf.root_password)?;
Ok(()) Ok(())
} }
+87 -21
View File
@@ -19,8 +19,9 @@
*/ */
use crate::kira_scroll_list::{self, ListViewMessage}; use crate::kira_scroll_list::{self, ListViewMessage};
use crate::kira_system;
use crate::stage::{KiraConfig, StageAction}; use crate::stage::{KiraConfig, StageAction};
use iced::{Alignment, Length, widget}; use iced::{Alignment, Length, Task, widget};
use log; use log;
use rust_i18n::t; use rust_i18n::t;
use std::collections::HashMap; use std::collections::HashMap;
@@ -82,6 +83,19 @@ impl KeyboarLayout {
pub fn to_result(&self) -> String { pub fn to_result(&self) -> String {
format!("{}||{}", self.layout.layout, self.variant.variant) format!("{}||{}", self.layout.layout, self.variant.variant)
} }
pub fn xkb_layout(&self) -> String {
self.layout.layout.clone()
}
///
/// Returns string variant or empty string if variant is "default"
///
pub fn xkb_variant(&self) -> String {
if self.variant.variant == "default" {
"".into()
} else {
self.variant.variant.clone()
}
}
} }
#[derive(Debug, Clone, PartialEq, Eq)] #[derive(Debug, Clone, PartialEq, Eq)]
@@ -102,6 +116,9 @@ impl KeyboarModel {
description: v.1.trim().to_string(), description: v.1.trim().to_string(),
} }
} }
pub fn xkb_model(&self) -> String {
self.model.clone()
}
} }
impl std::fmt::Display for KeyboarLayout { impl std::fmt::Display for KeyboarLayout {
@@ -122,6 +139,7 @@ pub struct KeyboardStage {
keyboard_layout: Option<KeyboarLayout>, keyboard_layout: Option<KeyboarLayout>,
// selected_kbd_layout_id: Option<usize>, // selected_kbd_layout_id: Option<usize>,
k_config: KiraConfig, k_config: KiraConfig,
test_text: String,
} }
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq)]
@@ -157,22 +175,18 @@ impl KeyboardStageResult {
} }
pub fn xkb_model(&self) -> String { pub fn xkb_model(&self) -> String {
self.keyboard_model.model.clone() self.keyboard_model.xkb_model()
} }
pub fn xkb_layout(&self) -> String { pub fn xkb_layout(&self) -> String {
self.keyboard_layout.layout.layout.clone() self.keyboard_layout.xkb_layout()
} }
/// ///
/// Returns string variant or eppty string if variant is "default" /// Returns string variant or empty string if variant is "default"
/// ///
pub fn xkb_variant(&self) -> String { pub fn xkb_variant(&self) -> String {
if self.keyboard_layout.variant.variant == "default" { self.keyboard_layout.xkb_variant()
"".into()
} else {
self.keyboard_layout.variant.variant.clone()
}
} }
} }
@@ -191,6 +205,8 @@ pub enum Message {
SelectKeyboardModel(KeyboarModel), SelectKeyboardModel(KeyboarModel),
SelectLayout(kira_scroll_list::ListViewMessage), SelectLayout(kira_scroll_list::ListViewMessage),
SelectVariant(kira_scroll_list::ListViewMessage), SelectVariant(kira_scroll_list::ListViewMessage),
TestTextChange(String),
SysLayoutChanged,
// AddLayout(usize), // AddLayout(usize),
// RemoveLayout(usize), // RemoveLayout(usize),
@@ -199,6 +215,11 @@ pub enum Message {
Back, Back,
} }
pub enum Update {
StgAct(StageAction),
Task(Task<Message>),
}
const XKB_RULES_FILE_NAME: &str = "/usr/share/X11/xkb/rules/evdev.lst"; const XKB_RULES_FILE_NAME: &str = "/usr/share/X11/xkb/rules/evdev.lst";
/// Getting list of awailable keyboard layouts from from xkb/rules/evdev.lst file. /// Getting list of awailable keyboard layouts from from xkb/rules/evdev.lst file.
@@ -315,6 +336,7 @@ impl KeyboardStage {
variant: Some(0), variant: Some(0),
keyboard_layout: keyboard_layout, keyboard_layout: keyboard_layout,
k_config: k_config, k_config: k_config,
test_text: String::new(),
} }
} }
Err(ex) => { Err(ex) => {
@@ -332,11 +354,34 @@ impl KeyboardStage {
variant: None, variant: None,
keyboard_layout: None, keyboard_layout: None,
k_config: k_config, k_config: k_config,
test_text: String::new(),
} }
} }
} }
} }
fn set_input_method(&self) -> Task<Message> {
log::info!("Preparing task!");
let (layout, variant) = if let Some(kb_layout) = &self.keyboard_layout {
(kb_layout.xkb_layout(), kb_layout.xkb_variant())
} else {
(String::new(), String::new())
};
let model = if let Some(kb_model) = &self.model {
kb_model.xkb_model()
} else {
String::new()
};
log::info!("Task perform!");
Task::perform(
async move {
let a = kira_system::set_input_method(&layout, &model, &variant, "").await;
log::info!("Result: {:?}", a);
},
|_| Message::SysLayoutChanged,
)
}
fn gen_result(&mut self) -> KiraConfig { fn gen_result(&mut self) -> KiraConfig {
self.k_config.res_keyboard = Some(KeyboardStageResult { self.k_config.res_keyboard = Some(KeyboardStageResult {
keyboard_model: self.model.clone().expect("Keyboard model must be choosed!"), keyboard_model: self.model.clone().expect("Keyboard model must be choosed!"),
@@ -348,7 +393,7 @@ impl KeyboardStage {
self.k_config.clone() self.k_config.clone()
} }
pub fn update(&mut self, message: Message) -> StageAction { pub fn update(&mut self, message: Message) -> Update {
match message { match message {
Message::SelectLayout(ListViewMessage::Select(l_id)) => { Message::SelectLayout(ListViewMessage::Select(l_id)) => {
if let Some(current_l_id) = self.layout if let Some(current_l_id) = self.layout
@@ -358,12 +403,18 @@ impl KeyboardStage {
self.variants = self.variants_map[self.layouts[l_id].layout.as_str()].clone(); self.variants = self.variants_map[self.layouts[l_id].layout.as_str()].clone();
self.variant = Some(0); self.variant = Some(0);
let layout = self.layouts[l_id].clone();
let variant = self.variants[0].clone();
self.keyboard_layout = Some(KeyboarLayout { self.keyboard_layout = Some(KeyboarLayout {
layout: self.layouts[l_id].clone(), layout: layout,
variant: self.variants[0].clone(), variant: variant,
}); });
Update::Task(self.set_input_method())
} else {
Update::StgAct(StageAction::None)
} }
StageAction::None
} }
Message::SelectVariant(ListViewMessage::Select(v_id)) => { Message::SelectVariant(ListViewMessage::Select(v_id)) => {
self.variant = Some(v_id); self.variant = Some(v_id);
@@ -371,14 +422,21 @@ impl KeyboardStage {
layout: self.layouts[self.layout.unwrap()].clone(), layout: self.layouts[self.layout.unwrap()].clone(),
variant: self.variants[v_id].clone(), variant: self.variants[v_id].clone(),
}); });
StageAction::None Update::Task(self.set_input_method())
} }
Message::SelectKeyboardModel(k_m) => { Message::SelectKeyboardModel(k_m) => {
self.model = Some(k_m); self.model = Some(k_m);
StageAction::None Update::Task(self.set_input_method())
} }
Message::Next => StageAction::Next(self.gen_result()), Message::TestTextChange(test_text) => {
Message::Back => StageAction::Back, let mut res: String = test_text;
res.retain(|c: char| !c.is_control());
self.test_text = res;
Update::StgAct(StageAction::None)
}
Message::SysLayoutChanged => Update::StgAct(StageAction::None),
Message::Next => Update::StgAct(StageAction::Next(self.gen_result())),
Message::Back => Update::StgAct(StageAction::Back),
} }
} }
@@ -406,7 +464,7 @@ impl KeyboardStage {
crate::kira_scroll_list::list_view( crate::kira_scroll_list::list_view(
&self.layouts, &self.layouts,
self.layout, self.layout,
Length::Shrink Length::Fill
) )
.map(Message::SelectLayout) .map(Message::SelectLayout)
], ],
@@ -415,15 +473,23 @@ impl KeyboardStage {
crate::kira_scroll_list::list_view( crate::kira_scroll_list::list_view(
&self.variants, &self.variants,
self.variant, self.variant,
Length::FillPortion(1) Length::Fill
) )
.map(Message::SelectVariant) .map(Message::SelectVariant)
], ],
] ]
.spacing(10) .spacing(10)
.height(Length::Shrink), .height(Length::Fill),
widget::row![
widget::text("Test Keyboard:"),
widget::text_input("", &self.test_text).on_input(Message::TestTextChange),
]
.spacing(2)
.align_y(Alignment::Center)
.width(Length::Fill),
] ]
.spacing(10) .spacing(10)
.height(Length::Fill)
.align_x(Alignment::Center), .align_x(Alignment::Center),
) )
} else { } else {