Added ctrl+shift+m to hide the windows
Moorly CI / windows-build (push) Successful in 3m5s
Moorly CI / linux-build (push) Successful in 4m5s

This commit is contained in:
Squid committed 2026-11-12 20:22:38 +01:00
1 parent 4dc4401871
commit b5713819fe
1 file changed
+375 -44
+375 -44
View File
@@ -285,6 +285,8 @@ fn subscription(state: &Moorly) -> Subscription<Message> {
state.saved_shortcuts.quit.clone(), state.saved_shortcuts.quit.clone(),
state.saved_shortcuts.quick_terminal.clone(), state.saved_shortcuts.quick_terminal.clone(),
state.saved_shortcuts.quick_ssh.clone(), state.saved_shortcuts.quick_ssh.clone(),
state.saved_shortcuts.close_tab.clone(),
state.saved_shortcuts.minimize_all.clone(),
state.shortcut_capture.is_some(), state.shortcut_capture.is_some(),
active_window, active_window,
)) ))
@@ -295,6 +297,8 @@ fn subscription(state: &Moorly) -> Subscription<Message> {
quit_shortcut, quit_shortcut,
quick_terminal_shortcut, quick_terminal_shortcut,
quick_ssh_shortcut, quick_ssh_shortcut,
close_tab_shortcut,
minimize_all_shortcut,
capturing, capturing,
window, window,
), ),
@@ -339,6 +343,18 @@ fn subscription(state: &Moorly) -> Subscription<Message> {
return window.map(Message::QuickSsh); return window.map(Message::QuickSsh);
} }
if let Some(shortcut) = &close_tab_shortcut
&& shortcut.matches(&key, modifiers)
{
return window.map(Message::CloseActiveTab);
}
if let Some(shortcut) = &minimize_all_shortcut
&& shortcut.matches(&key, modifiers)
{
return Some(Message::MinimizeAllWindows);
}
match key { match key {
keyboard::Key::Character(key) keyboard::Key::Character(key)
if cfg!(debug_assertions) if cfg!(debug_assertions)
@@ -348,13 +364,6 @@ fn subscription(state: &Moorly) -> Subscription<Message> {
{ {
Some(Message::ShowNotificationDemo) Some(Message::ShowNotificationDemo)
} }
keyboard::Key::Character(key)
if key.eq_ignore_ascii_case("w")
&& modifiers.control()
&& modifiers.shift() =>
{
window.map(Message::CloseActiveTab)
}
_ => None, _ => None,
} }
}, },
@@ -580,6 +589,10 @@ enum ShortcutAction {
CommandPalette, CommandPalette,
QuickTerminal, QuickTerminal,
QuickSsh, QuickSsh,
CloseTab,
MinimizeAll,
TerminalCopy,
TerminalPaste,
} }
impl ShortcutAction { impl ShortcutAction {
@@ -591,6 +604,10 @@ impl ShortcutAction {
Self::CommandPalette => "Command palette", Self::CommandPalette => "Command palette",
Self::QuickTerminal => "Quick terminal", Self::QuickTerminal => "Quick terminal",
Self::QuickSsh => "Quick SSH", Self::QuickSsh => "Quick SSH",
Self::CloseTab => "Close active tab",
Self::MinimizeAll => "Minimize all windows",
Self::TerminalCopy => "Copy terminal text",
Self::TerminalPaste => "Paste into terminal",
} }
} }
} }
@@ -603,6 +620,10 @@ struct Shortcuts {
command_palette: Option<Shortcut>, command_palette: Option<Shortcut>,
quick_terminal: Option<Shortcut>, quick_terminal: Option<Shortcut>,
quick_ssh: Option<Shortcut>, quick_ssh: Option<Shortcut>,
close_tab: Option<Shortcut>,
minimize_all: Option<Shortcut>,
terminal_copy: Option<Shortcut>,
terminal_paste: Option<Shortcut>,
} }
impl Default for Shortcuts { impl Default for Shortcuts {
@@ -614,6 +635,10 @@ impl Default for Shortcuts {
command_palette: Shortcut::parse("Ctrl+Shift+Space"), command_palette: Shortcut::parse("Ctrl+Shift+Space"),
quick_terminal: Shortcut::parse("Ctrl+Shift+T"), quick_terminal: Shortcut::parse("Ctrl+Shift+T"),
quick_ssh: Shortcut::parse("Ctrl+Shift+S"), quick_ssh: Shortcut::parse("Ctrl+Shift+S"),
close_tab: Shortcut::parse("Ctrl+Shift+W"),
minimize_all: Shortcut::parse("Ctrl+Shift+M"),
terminal_copy: Shortcut::parse("Ctrl+Shift+C"),
terminal_paste: Shortcut::parse("Ctrl+Shift+V"),
} }
} }
} }
@@ -627,6 +652,10 @@ impl Shortcuts {
ShortcutAction::CommandPalette => self.command_palette.as_ref(), ShortcutAction::CommandPalette => self.command_palette.as_ref(),
ShortcutAction::QuickTerminal => self.quick_terminal.as_ref(), ShortcutAction::QuickTerminal => self.quick_terminal.as_ref(),
ShortcutAction::QuickSsh => self.quick_ssh.as_ref(), ShortcutAction::QuickSsh => self.quick_ssh.as_ref(),
ShortcutAction::CloseTab => self.close_tab.as_ref(),
ShortcutAction::MinimizeAll => self.minimize_all.as_ref(),
ShortcutAction::TerminalCopy => self.terminal_copy.as_ref(),
ShortcutAction::TerminalPaste => self.terminal_paste.as_ref(),
} }
} }
@@ -638,6 +667,10 @@ impl Shortcuts {
ShortcutAction::CommandPalette => self.command_palette = shortcut, ShortcutAction::CommandPalette => self.command_palette = shortcut,
ShortcutAction::QuickTerminal => self.quick_terminal = shortcut, ShortcutAction::QuickTerminal => self.quick_terminal = shortcut,
ShortcutAction::QuickSsh => self.quick_ssh = shortcut, ShortcutAction::QuickSsh => self.quick_ssh = shortcut,
ShortcutAction::CloseTab => self.close_tab = shortcut,
ShortcutAction::MinimizeAll => self.minimize_all = shortcut,
ShortcutAction::TerminalCopy => self.terminal_copy = shortcut,
ShortcutAction::TerminalPaste => self.terminal_paste = shortcut,
} }
} }
@@ -651,20 +684,16 @@ impl Shortcuts {
(ShortcutAction::CommandPalette, &self.command_palette), (ShortcutAction::CommandPalette, &self.command_palette),
(ShortcutAction::QuickTerminal, &self.quick_terminal), (ShortcutAction::QuickTerminal, &self.quick_terminal),
(ShortcutAction::QuickSsh, &self.quick_ssh), (ShortcutAction::QuickSsh, &self.quick_ssh),
(ShortcutAction::CloseTab, &self.close_tab),
(ShortcutAction::MinimizeAll, &self.minimize_all),
(ShortcutAction::TerminalCopy, &self.terminal_copy),
(ShortcutAction::TerminalPaste, &self.terminal_paste),
]; ];
if let Some((action, _)) = configurable
configurable
.iter() .iter()
.find(|(action, shortcut)| *action != except && shortcut.as_ref() == Some(candidate)) .find(|(action, shortcut)| *action != except && shortcut.as_ref() == Some(candidate))
{ .map(|(action, _)| action.label())
return Some(action.label());
}
// Shortcuts that are fixed for now but still own their keys.
let reserved: &[(&str, &str)] = &[("Close Active Tab", "Ctrl+Shift+W")];
reserved.iter().find_map(|(name, text)| {
(Shortcut::parse(text).as_ref() == Some(candidate)).then_some(*name)
})
} }
} }
@@ -1535,7 +1564,7 @@ impl Command {
Self::Exit => ShortcutAction::Quit, Self::Exit => ShortcutAction::Quit,
Self::QuickTerminal => ShortcutAction::QuickTerminal, Self::QuickTerminal => ShortcutAction::QuickTerminal,
Self::QuickSsh => ShortcutAction::QuickSsh, Self::QuickSsh => ShortcutAction::QuickSsh,
Self::Close => return Some("Ctrl+Shift+W".to_owned()), Self::Close => ShortcutAction::CloseTab,
_ => return None, _ => return None,
}; };
@@ -1842,18 +1871,12 @@ enum TerminalClipboardAction {
fn terminal_clipboard_action( fn terminal_clipboard_action(
key: &keyboard::Key, key: &keyboard::Key,
modifiers: keyboard::Modifiers, modifiers: keyboard::Modifiers,
copy: Option<&Shortcut>,
paste: Option<&Shortcut>,
) -> Option<TerminalClipboardAction> { ) -> Option<TerminalClipboardAction> {
if !modifiers.command() || !modifiers.shift() { if copy.is_some_and(|shortcut| shortcut.matches(key, modifiers)) {
return None;
}
let keyboard::Key::Character(character) = key else {
return None;
};
if character.eq_ignore_ascii_case("c") {
Some(TerminalClipboardAction::Copy) Some(TerminalClipboardAction::Copy)
} else if character.eq_ignore_ascii_case("v") { } else if paste.is_some_and(|shortcut| shortcut.matches(key, modifiers)) {
Some(TerminalClipboardAction::Paste) Some(TerminalClipboardAction::Paste)
} else { } else {
None None
@@ -2997,6 +3020,14 @@ struct ShortcutConfig {
quick_terminal: String, quick_terminal: String,
#[serde(default = "default_quick_ssh_shortcut")] #[serde(default = "default_quick_ssh_shortcut")]
quick_ssh: String, quick_ssh: String,
#[serde(default = "default_close_tab_shortcut")]
close_tab: String,
#[serde(default = "default_minimize_all_shortcut")]
minimize_all: String,
#[serde(default = "default_terminal_copy_shortcut")]
terminal_copy: String,
#[serde(default = "default_terminal_paste_shortcut")]
terminal_paste: String,
} }
impl Default for ShortcutConfig { impl Default for ShortcutConfig {
@@ -3008,6 +3039,10 @@ impl Default for ShortcutConfig {
command_palette: default_command_palette_shortcut(), command_palette: default_command_palette_shortcut(),
quick_terminal: default_quick_terminal_shortcut(), quick_terminal: default_quick_terminal_shortcut(),
quick_ssh: default_quick_ssh_shortcut(), quick_ssh: default_quick_ssh_shortcut(),
close_tab: default_close_tab_shortcut(),
minimize_all: default_minimize_all_shortcut(),
terminal_copy: default_terminal_copy_shortcut(),
terminal_paste: default_terminal_paste_shortcut(),
} }
} }
} }
@@ -3074,6 +3109,34 @@ fn default_quick_ssh_shortcut() -> String {
.unwrap_or_default() .unwrap_or_default()
} }
fn default_close_tab_shortcut() -> String {
Shortcuts::default()
.close_tab
.map(|shortcut| shortcut.to_string())
.unwrap_or_default()
}
fn default_terminal_copy_shortcut() -> String {
Shortcuts::default()
.terminal_copy
.map(|shortcut| shortcut.to_string())
.unwrap_or_default()
}
fn default_minimize_all_shortcut() -> String {
Shortcuts::default()
.minimize_all
.map(|shortcut| shortcut.to_string())
.unwrap_or_default()
}
fn default_terminal_paste_shortcut() -> String {
Shortcuts::default()
.terminal_paste
.map(|shortcut| shortcut.to_string())
.unwrap_or_default()
}
fn color_to_hex(color: Color) -> String { fn color_to_hex(color: Color) -> String {
let r = (color.r * 255.0).round() as u8; let r = (color.r * 255.0).round() as u8;
let g = (color.g * 255.0).round() as u8; let g = (color.g * 255.0).round() as u8;
@@ -4911,6 +4974,30 @@ fn config_file(state: &Moorly) -> ConfigFile {
.as_ref() .as_ref()
.map(ToString::to_string) .map(ToString::to_string)
.unwrap_or_default(), .unwrap_or_default(),
close_tab: state
.saved_shortcuts
.close_tab
.as_ref()
.map(ToString::to_string)
.unwrap_or_default(),
minimize_all: state
.saved_shortcuts
.minimize_all
.as_ref()
.map(ToString::to_string)
.unwrap_or_default(),
terminal_copy: state
.saved_shortcuts
.terminal_copy
.as_ref()
.map(ToString::to_string)
.unwrap_or_default(),
terminal_paste: state
.saved_shortcuts
.terminal_paste
.as_ref()
.map(ToString::to_string)
.unwrap_or_default(),
}, },
command_palette: CommandPaletteConfig { command_palette: CommandPaletteConfig {
enabled: state.command_palette_enabled, enabled: state.command_palette_enabled,
@@ -4943,6 +5030,10 @@ impl Default for Moorly {
command_palette: Shortcut::parse(&config.shortcuts.command_palette), command_palette: Shortcut::parse(&config.shortcuts.command_palette),
quick_terminal: Shortcut::parse(&config.shortcuts.quick_terminal), quick_terminal: Shortcut::parse(&config.shortcuts.quick_terminal),
quick_ssh: Shortcut::parse(&config.shortcuts.quick_ssh), quick_ssh: Shortcut::parse(&config.shortcuts.quick_ssh),
close_tab: Shortcut::parse(&config.shortcuts.close_tab),
minimize_all: Shortcut::parse(&config.shortcuts.minimize_all),
terminal_copy: Shortcut::parse(&config.shortcuts.terminal_copy),
terminal_paste: Shortcut::parse(&config.shortcuts.terminal_paste),
}; };
let mut notifications = notifications::NotificationManager::default(); let mut notifications = notifications::NotificationManager::default();
@@ -5255,6 +5346,7 @@ enum Message {
Hotkey(hotkeys::Event), Hotkey(hotkeys::Event),
Tray(tray::Event), Tray(tray::Event),
SecondInstanceActivated, SecondInstanceActivated,
MinimizeAllWindows,
FinishToggleWindowVisibility(Option<bool>), FinishToggleWindowVisibility(Option<bool>),
FinishMinimizeToTray(window::Id, Option<bool>), FinishMinimizeToTray(window::Id, Option<bool>),
Quit, Quit,
@@ -5417,7 +5509,12 @@ fn update(state: &mut Moorly, message: Message) -> Task<Message> {
text, text,
modifiers, modifiers,
} => { } => {
match terminal_clipboard_action(&key, modifiers) { match terminal_clipboard_action(
&key,
modifiers,
state.shortcuts.get(ShortcutAction::TerminalCopy),
state.shortcuts.get(ShortcutAction::TerminalPaste),
) {
Some(TerminalClipboardAction::Copy) => { Some(TerminalClipboardAction::Copy) => {
return copy_terminal_selection(state, id); return copy_terminal_selection(state, id);
} }
@@ -6639,10 +6736,22 @@ fn update(state: &mut Moorly, message: Message) -> Task<Message> {
state.shortcut_capture = None; state.shortcut_capture = None;
} }
Message::DefaultShortcut(action) => { Message::DefaultShortcut(action) => {
state let default = Shortcuts::default().get(action).cloned();
.shortcuts
.set(action, Shortcuts::default().get(action).cloned()); let conflict = default
state.shortcut_capture = None; .as_ref()
.and_then(|shortcut| state.shortcuts.conflict(shortcut, action));
if let Some(name) = conflict {
state.shortcut_capture = Some(ShortcutCapture {
action,
candidate: default,
error: Some(format!("Already used by {name}.")),
});
} else {
state.shortcuts.set(action, default);
state.shortcut_capture = None;
}
} }
Message::ApplyShortcut => apply_shortcut(state), Message::ApplyShortcut => apply_shortcut(state),
Message::CaptureKey { key, modifiers } => match key { Message::CaptureKey { key, modifiers } => match key {
@@ -6688,6 +6797,22 @@ fn update(state: &mut Moorly, message: Message) -> Task<Message> {
Message::Hotkey(event) => return handle_hotkey_event(state, event), Message::Hotkey(event) => return handle_hotkey_event(state, event),
Message::Tray(event) => return handle_tray_event(state, event), Message::Tray(event) => return handle_tray_event(state, event),
Message::SecondInstanceActivated => return activate_main_window(state), Message::SecondInstanceActivated => return activate_main_window(state),
Message::MinimizeAllWindows => {
let windows = state.window_order.clone();
let to_tray =
state.minimize_to_tray && state.tray_available && !state.main_window_hidden;
let mut tasks = Vec::new();
for id in windows {
if to_tray && state.main_window == Some(id) {
tasks.push(hide_main_window(state));
} else {
tasks.push(window::minimize(id, true));
}
}
return Task::batch(tasks);
}
Message::FinishToggleWindowVisibility(minimized) => { Message::FinishToggleWindowVisibility(minimized) => {
return finish_toggle_window_visibility(state, minimized); return finish_toggle_window_visibility(state, minimized);
} }
@@ -8580,6 +8705,7 @@ fn color_swatch_row<'a>(
/// Shortcut bindings list. /// Shortcut bindings list.
fn shortcuts_panel(state: &Moorly) -> Element<'_, Message> { fn shortcuts_panel(state: &Moorly) -> Element<'_, Message> {
let mut panel = column![ let mut panel = column![
text("Press ... to change a shortcut.").size(12),
shortcut_row( shortcut_row(
&state.typography.h3, &state.typography.h3,
ShortcutAction::Settings, ShortcutAction::Settings,
@@ -8616,6 +8742,26 @@ fn shortcuts_panel(state: &Moorly) -> Element<'_, Message> {
&state.typography.h3, &state.typography.h3,
ShortcutAction::QuickSsh, ShortcutAction::QuickSsh,
state.shortcuts.get(ShortcutAction::QuickSsh), state.shortcuts.get(ShortcutAction::QuickSsh),
))
.push(shortcut_row(
&state.typography.h3,
ShortcutAction::CloseTab,
state.shortcuts.get(ShortcutAction::CloseTab),
))
.push(shortcut_row(
&state.typography.h3,
ShortcutAction::MinimizeAll,
state.shortcuts.get(ShortcutAction::MinimizeAll),
))
.push(shortcut_row(
&state.typography.h3,
ShortcutAction::TerminalCopy,
state.shortcuts.get(ShortcutAction::TerminalCopy),
))
.push(shortcut_row(
&state.typography.h3,
ShortcutAction::TerminalPaste,
state.shortcuts.get(ShortcutAction::TerminalPaste),
)); ));
if hotkeys::backend() == hotkeys::Backend::Portal { if hotkeys::backend() == hotkeys::Backend::Portal {
@@ -8624,11 +8770,8 @@ fn shortcuts_panel(state: &Moorly) -> Element<'_, Message> {
); );
} }
match &state.shortcut_capture { if let Some(capture) = &state.shortcut_capture {
Some(capture) => panel = panel.push(shortcut_capture_panel(capture)), panel = panel.push(shortcut_capture_panel(capture));
None => {
panel = panel.push(text("Press ... to change a shortcut.").size(12));
}
} }
panel.into() panel.into()
@@ -12611,14 +12754,26 @@ mod tests {
let key = |character: &str| keyboard::Key::Character(character.into()); let key = |character: &str| keyboard::Key::Character(character.into());
let ctrl = keyboard::Modifiers::CTRL; let ctrl = keyboard::Modifiers::CTRL;
let shift = keyboard::Modifiers::SHIFT; let shift = keyboard::Modifiers::SHIFT;
let defaults = super::Shortcuts::default();
let copy = defaults.get(super::ShortcutAction::TerminalCopy);
let paste = defaults.get(super::ShortcutAction::TerminalPaste);
assert_eq!(terminal_clipboard_action(&key("C"), ctrl | shift), Some(Copy)); assert_eq!(
assert_eq!(terminal_clipboard_action(&key("v"), ctrl | shift), Some(Paste)); terminal_clipboard_action(&key("C"), ctrl | shift, copy, paste),
Some(Copy)
);
assert_eq!(
terminal_clipboard_action(&key("v"), ctrl | shift, copy, paste),
Some(Paste)
);
// Plain Ctrl+C stays an interrupt and Ctrl+V stays normal input. // Plain Ctrl+C stays an interrupt and Ctrl+V stays normal input.
assert_eq!(terminal_clipboard_action(&key("c"), ctrl), None); assert_eq!(terminal_clipboard_action(&key("c"), ctrl, copy, paste), None);
assert_eq!(terminal_clipboard_action(&key("v"), ctrl), None); assert_eq!(terminal_clipboard_action(&key("v"), ctrl, copy, paste), None);
assert_eq!(terminal_clipboard_action(&key("x"), ctrl | shift), None); assert_eq!(
terminal_clipboard_action(&key("x"), ctrl | shift, copy, paste),
None
);
assert_eq!(terminal_right_click_action(true), Copy); assert_eq!(terminal_right_click_action(true), Copy);
assert_eq!(terminal_right_click_action(false), Paste); assert_eq!(terminal_right_click_action(false), Paste);
@@ -13025,6 +13180,22 @@ mod tests {
parsed["shortcuts"]["quick_ssh"].as_str(), parsed["shortcuts"]["quick_ssh"].as_str(),
Some("Ctrl+Shift+S") Some("Ctrl+Shift+S")
); );
assert_eq!(
parsed["shortcuts"]["close_tab"].as_str(),
Some("Ctrl+Shift+W")
);
assert_eq!(
parsed["shortcuts"]["terminal_copy"].as_str(),
Some("Ctrl+Shift+C")
);
assert_eq!(
parsed["shortcuts"]["minimize_all"].as_str(),
Some("Ctrl+Shift+M")
);
assert_eq!(
parsed["shortcuts"]["terminal_paste"].as_str(),
Some("Ctrl+Shift+V")
);
state.saved_theme_choice = super::ThemeChoice::Custom { state.saved_theme_choice = super::ThemeChoice::Custom {
id: "abc".to_owned(), id: "abc".to_owned(),
@@ -13962,6 +14133,141 @@ mod tests {
); );
} }
#[test]
fn close_tab_shortcut_is_configurable_and_checked() {
let mut state = state();
let _ = update(
&mut state,
Message::OpenShortcutCapture(super::ShortcutAction::CloseTab),
);
let _ = update(
&mut state,
press(
keyboard::Key::Character("k".into()),
keyboard::Modifiers::CTRL | keyboard::Modifiers::SHIFT,
),
);
let _ = update(&mut state, Message::ApplyShortcut);
assert_eq!(
state
.shortcuts
.close_tab
.as_ref()
.map(ToString::to_string),
Some("Ctrl+Shift+K".to_owned())
);
assert_eq!(
super::Command::Close.shortcut(&state),
Some("Ctrl+Shift+K".to_owned())
);
// Another action cannot take the key the tab close now owns.
let _ = update(
&mut state,
Message::OpenShortcutCapture(super::ShortcutAction::Settings),
);
let _ = update(
&mut state,
press(
keyboard::Key::Character("k".into()),
keyboard::Modifiers::CTRL | keyboard::Modifiers::SHIFT,
),
);
let _ = update(&mut state, Message::ApplyShortcut);
assert_eq!(
state.shortcuts.settings.as_ref().map(ToString::to_string),
Some("Ctrl+,".to_owned())
);
assert!(
state
.shortcut_capture
.as_ref()
.unwrap()
.error
.as_deref()
.is_some_and(|error| error.contains("Close active tab"))
);
}
#[test]
fn restoring_a_shortcut_default_does_not_steal_another_binding() {
let mut state = state();
let _ = update(
&mut state,
Message::ClearShortcut(super::ShortcutAction::CloseTab),
);
let _ = update(
&mut state,
Message::OpenShortcutCapture(super::ShortcutAction::Settings),
);
let _ = update(
&mut state,
press(
keyboard::Key::Character("w".into()),
keyboard::Modifiers::CTRL | keyboard::Modifiers::SHIFT,
),
);
let _ = update(&mut state, Message::ApplyShortcut);
assert_eq!(
state.shortcuts.settings.as_ref().map(ToString::to_string),
Some("Ctrl+Shift+W".to_owned())
);
let _ = update(
&mut state,
Message::DefaultShortcut(super::ShortcutAction::CloseTab),
);
assert!(state.shortcuts.close_tab.is_none());
assert!(
state
.shortcut_capture
.as_ref()
.unwrap()
.error
.as_deref()
.is_some_and(|error| error.contains("Settings"))
);
}
#[test]
fn terminal_clipboard_shortcuts_reserve_their_keys() {
let mut state = state();
for (key, owner) in [("c", "Copy terminal text"), ("v", "Paste into terminal")] {
let _ = update(
&mut state,
Message::OpenShortcutCapture(super::ShortcutAction::Settings),
);
let _ = update(
&mut state,
press(
keyboard::Key::Character(key.into()),
keyboard::Modifiers::CTRL | keyboard::Modifiers::SHIFT,
),
);
let _ = update(&mut state, Message::ApplyShortcut);
assert_eq!(
state.shortcuts.settings.as_ref().map(ToString::to_string),
Some("Ctrl+,".to_owned())
);
assert!(
state
.shortcut_capture
.as_ref()
.unwrap()
.error
.as_deref()
.is_some_and(|error| error.contains(owner))
);
}
}
#[test] #[test]
fn plain_keys_are_not_accepted_as_shortcuts() { fn plain_keys_are_not_accepted_as_shortcuts() {
let mut state = state(); let mut state = state();
@@ -14066,6 +14372,31 @@ mod tests {
state.shortcuts.quick_ssh.as_ref().map(ToString::to_string), state.shortcuts.quick_ssh.as_ref().map(ToString::to_string),
Some("Ctrl+Shift+S".to_owned()) Some("Ctrl+Shift+S".to_owned())
); );
assert_eq!(
state
.shortcuts
.minimize_all
.as_ref()
.map(ToString::to_string),
Some("Ctrl+Shift+M".to_owned())
);
}
#[test]
fn minimize_all_windows_follows_minimize_to_tray() {
let mut tray_state = state();
tray_state.minimize_to_tray = true;
tray_state.tray_available = true;
let _ = update(&mut tray_state, Message::MinimizeAllWindows);
assert!(tray_state.main_window_hidden);
let mut normal_state = state();
normal_state.minimize_to_tray = false;
let _ = update(&mut normal_state, Message::MinimizeAllWindows);
assert!(!normal_state.main_window_hidden);
assert!(normal_state.windows.contains_key(&test_window()));
} }
#[test] #[test]