Add shortcut settings page

This commit is contained in:
2026-05-08 02:48:35 -04:00
parent 8b75b33761
commit f6e2b1b96b
9 changed files with 649 additions and 32 deletions
@@ -28,6 +28,7 @@ fn internal_page_title(url: &str) -> Option<&'static str> {
"ely://about" => Some("About ELY Browser"),
"ely://settings" => Some("Settings"),
"ely://settings/sidebar-tabs" => Some("Sidebar & Tabs Settings"),
"ely://settings/shortcuts" => Some("Shortcut Settings"),
"ely://settings/plugins" => Some("Plugin Settings"),
"ely://settings/profiles" => Some("Profile Settings"),
"ely://settings/sync" => Some("Sync Settings"),
@@ -137,6 +138,10 @@ pub(crate) fn settings_url() -> Result<UrlText, CoreError> {
internal_page_url("ely://settings")
}
pub(crate) fn shortcut_settings_url() -> Result<UrlText, CoreError> {
internal_page_url("ely://settings/shortcuts")
}
pub(crate) fn sync_status_url() -> Result<UrlText, CoreError> {
internal_page_url("ely://sync/status")
}
@@ -157,6 +162,9 @@ fn settings_page_route(query: &str) -> Option<&'static str> {
"sidebar" | "tabs" | "sidebar tabs" | "sidebar & tabs" => {
Some("ely://settings/sidebar-tabs")
}
"shortcut" | "shortcuts" | "keyboard" | "keyboard shortcuts" => {
Some("ely://settings/shortcuts")
}
"sync" | "sync settings" => Some("ely://settings/sync"),
"profile" | "profiles" | "profile settings" | "profiles settings" => {
Some("ely://settings/profiles")
@@ -8,7 +8,8 @@ use crate::{
about_url, archive_idle_days, archive_url, bookmarks_url, downloads_url, history_url,
move_tab_space_name, new_private_profile_name, new_profile_name, new_space_name,
plugin_detail_url, plugins_url, reading_list_url, search_url, settings_page_url,
settings_url, space_icon, switch_profile_name, sync_status_url, task_manager_url,
settings_url, shortcut_settings_url, space_icon, switch_profile_name, sync_status_url,
task_manager_url,
},
};
@@ -181,6 +182,10 @@ impl BrowserCore {
self.open_tab(settings_url()?);
Ok(true)
}
"shortcuts" | "open-shortcuts" | "open shortcuts" => {
self.open_tab(shortcut_settings_url()?);
Ok(true)
}
"sync" | "open-sync-status" | "open sync status" => {
self.open_tab(sync_status_url()?);
Ok(true)
+15
View File
@@ -141,6 +141,21 @@ fn open_settings_command_opens_settings_page() -> Result<(), Box<dyn Error>> {
Ok(())
}
#[test]
fn open_shortcuts_command_opens_shortcuts_page() -> Result<(), Box<dyn Error>> {
let mut core = BrowserCore::new(InitialBrowserConfig::ely_defaults()?)?;
core.set_command_query(">open-shortcuts");
let intent = core.submit_command()?;
let active_tab = core.active_tab()?;
assert_eq!(intent, Some(CommandIntent::Command("open-shortcuts".to_string())));
assert_eq!(active_tab.title(), "Shortcut Settings");
assert_eq!(active_tab.url().as_str(), "ely://settings/shortcuts");
assert_eq!(core.snapshot()?.command_query, "");
Ok(())
}
#[test]
fn open_sync_status_command_opens_sync_status_page() -> Result<(), Box<dyn Error>> {
let mut core = BrowserCore::new(InitialBrowserConfig::ely_defaults()?)?;
@@ -23,3 +23,24 @@ fn settings_scoped_search_opens_sidebar_tabs_page() -> Result<(), Box<dyn Error>
assert_eq!(core.snapshot()?.command_query, "");
Ok(())
}
#[test]
fn settings_scoped_search_opens_shortcuts_page() -> Result<(), Box<dyn Error>> {
let mut core = BrowserCore::new(InitialBrowserConfig::ely_defaults()?)?;
core.set_command_query("@settings shortcuts");
let intent = core.submit_command()?;
let active_tab = core.active_tab()?;
assert_eq!(
intent,
Some(CommandIntent::ScopedSearch {
scope: CommandScope::Settings,
query: "shortcuts".to_string(),
})
);
assert_eq!(active_tab.title(), "Shortcut Settings");
assert_eq!(active_tab.url().as_str(), "ely://settings/shortcuts");
assert_eq!(core.snapshot()?.command_query, "");
Ok(())
}