Reworked MODE switch
This commit is contained in:
@@ -225,6 +225,10 @@ command = "DeleteSelected"
|
||||
key_sequence = "v"
|
||||
command = "ToggleViewMode"
|
||||
|
||||
[[keymaps]]
|
||||
key_sequence = "m"
|
||||
command = "CycleSourceMode"
|
||||
|
||||
[[keymaps]]
|
||||
key_sequence = "f"
|
||||
command = "OpenLibraryFilters"
|
||||
|
||||
@@ -426,6 +426,21 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn default_source_mode_key_resolves_on_content_tabs() {
|
||||
let mut km = keymap_from(DEFAULT_KEYMAP);
|
||||
for context in [
|
||||
KeyContext::Library,
|
||||
KeyContext::Playlists,
|
||||
KeyContext::Queue,
|
||||
] {
|
||||
assert_eq!(
|
||||
km.resolve(key!(m), context),
|
||||
KeyResolution::Action(Action::CycleSourceMode)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn default_shift_n_is_unbound() {
|
||||
let mut km = keymap_from(DEFAULT_KEYMAP);
|
||||
|
||||
+8
-21
@@ -11,12 +11,6 @@ pub enum LibrarySourceMode {
|
||||
}
|
||||
|
||||
impl LibrarySourceMode {
|
||||
pub const ALL: [LibrarySourceMode; 3] = [
|
||||
LibrarySourceMode::Local,
|
||||
LibrarySourceMode::My,
|
||||
LibrarySourceMode::Global,
|
||||
];
|
||||
|
||||
pub fn label(self) -> &'static str {
|
||||
match self {
|
||||
LibrarySourceMode::Local => "Local",
|
||||
@@ -25,14 +19,6 @@ impl LibrarySourceMode {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn description(self) -> &'static str {
|
||||
match self {
|
||||
LibrarySourceMode::Local => "only this device",
|
||||
LibrarySourceMode::My => "this device + connected devices",
|
||||
LibrarySourceMode::Global => "my devices + known federation peers",
|
||||
}
|
||||
}
|
||||
|
||||
pub fn includes_network(self) -> bool {
|
||||
!matches!(self, LibrarySourceMode::Local)
|
||||
}
|
||||
@@ -40,6 +26,14 @@ impl LibrarySourceMode {
|
||||
pub fn includes_global_peers(self) -> bool {
|
||||
matches!(self, LibrarySourceMode::Global)
|
||||
}
|
||||
|
||||
pub fn next(self) -> Self {
|
||||
match self {
|
||||
LibrarySourceMode::Local => LibrarySourceMode::My,
|
||||
LibrarySourceMode::My => LibrarySourceMode::Global,
|
||||
LibrarySourceMode::Global => LibrarySourceMode::Local,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)]
|
||||
@@ -50,12 +44,6 @@ pub struct LibraryFilters {
|
||||
pub source_mode: LibrarySourceMode,
|
||||
}
|
||||
|
||||
impl LibraryFilters {
|
||||
pub fn is_active(&self) -> bool {
|
||||
self.hide_featured_only || self.source_mode != LibrarySourceMode::Local
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct AppSettings {
|
||||
#[serde(default = "default_volume")]
|
||||
@@ -140,7 +128,6 @@ hide_featured_only = true
|
||||
|
||||
assert_eq!(settings.volume, 100);
|
||||
assert!(settings.library.hide_featured_only);
|
||||
assert!(settings.library.is_active());
|
||||
assert_eq!(settings.library.source_mode, LibrarySourceMode::Local);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user