feat(power): only ask for user confirmation on destructive actions

This commit is contained in:
Ethan Brierley 2024-04-20 10:21:37 +01:00 committed by Ashley Wulber
parent 257250eb62
commit d097cb1c94

View file

@ -164,17 +164,22 @@ impl cosmic::Application for Power {
Command::none() Command::none()
} }
Message::Action(action) => { Message::Action(action) => {
let id = window::Id::unique(); // Ask for user confirmation of non-destructive actions only
self.action_to_confirm = Some((id, action, COUNTDOWN_LENGTH)); if matches!(action, PowerAction::Lock | PowerAction::Suspend) {
get_layer_surface(SctkLayerSurfaceSettings { action.perform()
id, } else {
keyboard_interactivity: KeyboardInteractivity::None, let id = window::Id::unique();
anchor: Anchor::all(), self.action_to_confirm = Some((id, action, COUNTDOWN_LENGTH));
namespace: "dialog".into(), get_layer_surface(SctkLayerSurfaceSettings {
size: Some((None, None)), id,
size_limits: Limits::NONE.min_width(1.0).min_height(1.0), keyboard_interactivity: KeyboardInteractivity::None,
..Default::default() anchor: Anchor::all(),
}) namespace: "dialog".into(),
size: Some((None, None)),
size_limits: Limits::NONE.min_width(1.0).min_height(1.0),
..Default::default()
})
}
} }
Message::Zbus(result) => { Message::Zbus(result) => {
if let Err(e) = result { if let Err(e) = result {