feat: display WPS hint only when WPS is available
This commit is contained in:
parent
a046692241
commit
82ca8bab37
2 changed files with 34 additions and 24 deletions
|
|
@ -981,30 +981,34 @@ impl cosmic::Application for CosmicNetworkApplet {
|
|||
.spacing(12),
|
||||
);
|
||||
content = content.push(id);
|
||||
let col = padded_control(
|
||||
column![
|
||||
text::body(fl!("enter-password")),
|
||||
text_input::secure_input(
|
||||
"",
|
||||
password,
|
||||
Some(Message::TogglePasswordVisibility),
|
||||
*password_hidden,
|
||||
)
|
||||
.on_input(Message::Password)
|
||||
.on_paste(Message::Password)
|
||||
.on_submit(Message::SubmitPassword),
|
||||
container(text::body(fl!("router-wps-button"))).padding(8),
|
||||
row![
|
||||
button::standard(fl!("cancel"))
|
||||
.on_press(Message::CancelNewConnection),
|
||||
button::suggested(fl!("connect")).on_press(Message::SubmitPassword)
|
||||
]
|
||||
.spacing(24)
|
||||
]
|
||||
.spacing(8)
|
||||
.align_x(Alignment::Center),
|
||||
let enter_password_col = column![
|
||||
text::body(fl!("enter-password")),
|
||||
text_input::secure_input(
|
||||
"",
|
||||
password,
|
||||
Some(Message::TogglePasswordVisibility),
|
||||
*password_hidden,
|
||||
)
|
||||
.on_input(Message::Password)
|
||||
.on_paste(Message::Password)
|
||||
.on_submit(Message::SubmitPassword)
|
||||
.password(),
|
||||
]
|
||||
.push_maybe(
|
||||
access_point
|
||||
.wps_push
|
||||
.then(|| container(text::body(fl!("router-wps-button"))).padding(8)),
|
||||
)
|
||||
.align_x(Alignment::Center);
|
||||
.push(
|
||||
row![
|
||||
button::standard(fl!("cancel")).on_press(Message::CancelNewConnection),
|
||||
button::suggested(fl!("connect")).on_press(Message::SubmitPassword)
|
||||
]
|
||||
.spacing(24),
|
||||
);
|
||||
let col =
|
||||
padded_control(enter_password_col.spacing(8).align_x(Alignment::Center))
|
||||
.align_x(Alignment::Center);
|
||||
content = content.push(col);
|
||||
}
|
||||
NewConnectionState::Waiting(access_point) => {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
use cosmic_dbus_networkmanager::{device::wireless::WirelessDevice, interface::enums::DeviceState};
|
||||
use cosmic_dbus_networkmanager::{
|
||||
device::wireless::WirelessDevice,
|
||||
interface::enums::{ApFlags, DeviceState},
|
||||
};
|
||||
|
||||
use futures_util::StreamExt;
|
||||
use itertools::Itertools;
|
||||
|
|
@ -33,6 +36,7 @@ pub async fn handle_wireless_device(
|
|||
let mut aps = HashMap::<String, AccessPoint>::new();
|
||||
for ap in access_points {
|
||||
let ssid = String::from_utf8_lossy(&ap.ssid().await?.clone()).into_owned();
|
||||
let wps_push = ap.flags().await?.contains(ApFlags::WPS_PBC);
|
||||
let strength = ap.strength().await?;
|
||||
if let Some(access_point) = aps.get(&ssid) {
|
||||
if access_point.strength > strength {
|
||||
|
|
@ -51,6 +55,7 @@ pub async fn handle_wireless_device(
|
|||
.as_ref()
|
||||
.and_then(|str_addr| HwAddress::from_str(str_addr))
|
||||
.unwrap_or_default(),
|
||||
wps_push,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
|
@ -69,4 +74,5 @@ pub struct AccessPoint {
|
|||
pub working: bool,
|
||||
pub path: ObjectPath<'static>,
|
||||
pub hw_address: HwAddress,
|
||||
pub wps_push: bool,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue