fix(network): focus password input in authentication dialog
This commit is contained in:
parent
eb8784be40
commit
6e74e90ea2
2 changed files with 31 additions and 26 deletions
|
|
@ -34,7 +34,7 @@ use cosmic::{
|
||||||
iced_runtime::core::window,
|
iced_runtime::core::window,
|
||||||
surface, theme,
|
surface, theme,
|
||||||
widget::{
|
widget::{
|
||||||
Column, Row, button, container, divider,
|
Column, Id, Row, button, container, divider,
|
||||||
icon::{self, from_name},
|
icon::{self, from_name},
|
||||||
scrollable, secure_input, text, text_input,
|
scrollable, secure_input, text, text_input,
|
||||||
},
|
},
|
||||||
|
|
@ -99,6 +99,8 @@ impl From<NewConnectionState> for AccessPoint {
|
||||||
static WIFI: LazyLock<id::Toggler> = LazyLock::new(id::Toggler::unique);
|
static WIFI: LazyLock<id::Toggler> = LazyLock::new(id::Toggler::unique);
|
||||||
static AIRPLANE_MODE: LazyLock<id::Toggler> = LazyLock::new(id::Toggler::unique);
|
static AIRPLANE_MODE: LazyLock<id::Toggler> = LazyLock::new(id::Toggler::unique);
|
||||||
|
|
||||||
|
pub static SECURE_INPUT_WIFI: LazyLock<Id> = LazyLock::new(Id::unique);
|
||||||
|
|
||||||
#[derive(Default, Debug, Clone)]
|
#[derive(Default, Debug, Clone)]
|
||||||
pub struct MyNetworkState {
|
pub struct MyNetworkState {
|
||||||
pub known_vpns: IndexMap<UUID, ConnectionSettings>,
|
pub known_vpns: IndexMap<UUID, ConnectionSettings>,
|
||||||
|
|
@ -466,6 +468,8 @@ pub(crate) enum Message {
|
||||||
OpenSettings,
|
OpenSettings,
|
||||||
ResetFailedKnownSsid(String, HwAddress),
|
ResetFailedKnownSsid(String, HwAddress),
|
||||||
TogglePasswordVisibility,
|
TogglePasswordVisibility,
|
||||||
|
FocusSecureInput,
|
||||||
|
NoOp,
|
||||||
Surface(surface::Action),
|
Surface(surface::Action),
|
||||||
ActivateVpn(Arc<str>), // UUID of VPN to activate
|
ActivateVpn(Arc<str>), // UUID of VPN to activate
|
||||||
DeactivateVpn(Arc<str>), // UUID of VPN to deactivate
|
DeactivateVpn(Arc<str>), // UUID of VPN to deactivate
|
||||||
|
|
@ -893,6 +897,7 @@ impl cosmic::Application for CosmicNetworkApplet {
|
||||||
password: String::new().into(),
|
password: String::new().into(),
|
||||||
password_hidden: true,
|
password_hidden: true,
|
||||||
});
|
});
|
||||||
|
return cosmic::task::message(cosmic::Action::App(Message::FocusSecureInput));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Message::ToggleVisibleNetworks => {
|
Message::ToggleVisibleNetworks => {
|
||||||
|
|
@ -907,6 +912,11 @@ impl cosmic::Application for CosmicNetworkApplet {
|
||||||
*password_hidden = !*password_hidden;
|
*password_hidden = !*password_hidden;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Message::FocusSecureInput => {
|
||||||
|
return text_input::focus(SECURE_INPUT_WIFI.clone())
|
||||||
|
.map(|_: ()| cosmic::Action::App(Message::NoOp));
|
||||||
|
}
|
||||||
|
Message::NoOp => {}
|
||||||
Message::CancelNewConnection => {
|
Message::CancelNewConnection => {
|
||||||
self.new_connection = None;
|
self.new_connection = None;
|
||||||
}
|
}
|
||||||
|
|
@ -1866,6 +1876,7 @@ impl cosmic::Application for CosmicNetworkApplet {
|
||||||
Some(Message::TogglePasswordVisibility),
|
Some(Message::TogglePasswordVisibility),
|
||||||
*password_hidden,
|
*password_hidden,
|
||||||
)
|
)
|
||||||
|
.id(SECURE_INPUT_WIFI.clone())
|
||||||
.on_input(|s| Message::PasswordUpdate(SecureString::from(s)))
|
.on_input(|s| Message::PasswordUpdate(SecureString::from(s)))
|
||||||
.on_paste(|s| Message::PasswordUpdate(SecureString::from(s)))
|
.on_paste(|s| Message::PasswordUpdate(SecureString::from(s)))
|
||||||
.on_submit(|_| Message::ConnectWithPassword),
|
.on_submit(|_| Message::ConnectWithPassword),
|
||||||
|
|
|
||||||
|
|
@ -147,33 +147,27 @@ impl cosmic::Application for Power {
|
||||||
tracing::error!("Wayland tx is None");
|
tracing::error!("Wayland tx is None");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Message::Action(action) => {
|
Message::Action(action) => match action {
|
||||||
match action {
|
PowerAction::LogOut => {
|
||||||
PowerAction::LogOut => {
|
if let Err(err) = process::Command::new("cosmic-osd").arg("log-out").spawn() {
|
||||||
if let Err(err) = process::Command::new("cosmic-osd").arg("log-out").spawn()
|
tracing::error!("Failed to spawn cosmic-osd. {err:?}");
|
||||||
{
|
return PowerAction::LogOut.perform();
|
||||||
tracing::error!("Failed to spawn cosmic-osd. {err:?}");
|
|
||||||
return PowerAction::LogOut.perform();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
PowerAction::Restart => {
|
|
||||||
if let Err(err) = process::Command::new("cosmic-osd").arg("restart").spawn()
|
|
||||||
{
|
|
||||||
tracing::error!("Failed to spawn cosmic-osd. {err:?}");
|
|
||||||
return PowerAction::Restart.perform();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
PowerAction::Shutdown => {
|
|
||||||
if let Err(err) =
|
|
||||||
process::Command::new("cosmic-osd").arg("shutdown").spawn()
|
|
||||||
{
|
|
||||||
tracing::error!("Failed to spawn cosmic-osd. {err:?}");
|
|
||||||
return PowerAction::Shutdown.perform();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
a => return a.perform(),
|
|
||||||
}
|
}
|
||||||
}
|
PowerAction::Restart => {
|
||||||
|
if let Err(err) = process::Command::new("cosmic-osd").arg("restart").spawn() {
|
||||||
|
tracing::error!("Failed to spawn cosmic-osd. {err:?}");
|
||||||
|
return PowerAction::Restart.perform();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PowerAction::Shutdown => {
|
||||||
|
if let Err(err) = process::Command::new("cosmic-osd").arg("shutdown").spawn() {
|
||||||
|
tracing::error!("Failed to spawn cosmic-osd. {err:?}");
|
||||||
|
return PowerAction::Shutdown.perform();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
a => return a.perform(),
|
||||||
|
},
|
||||||
Message::Zbus(result) => {
|
Message::Zbus(result) => {
|
||||||
if let Err(e) = result {
|
if let Err(e) = result {
|
||||||
eprintln!("cosmic-applet-power ERROR: '{e}'");
|
eprintln!("cosmic-applet-power ERROR: '{e}'");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue