Add option to customize library tabs
New option is called `library_tabs`. By default all tabs are enabled. Fixes #798
This commit is contained in:
45
README.md
45
README.md
@@ -307,28 +307,29 @@ runtime use the command prompt by typing `:reload`.
|
||||
|
||||
Possible configuration values are:
|
||||
|
||||
| Name | Description | Possible values | Default |
|
||||
| :----------------------- | :------------------------------------------ |:--------------------------------------------------|:-----------:|
|
||||
| `command_key` | Key to open command line | Single character | `:` |
|
||||
| `initial_screen` | Screen to show after startup | `"library"`, `"search"`, `"queue"`, `"cover"`[^2] | `"library"` |
|
||||
| `use_nerdfont` | Turn nerdfont glyphs on/off | `true`, `false` | `false` |
|
||||
| `flip_status_indicators` | Reverse play/pause icon meaning[^1] | `true`, `false` | `false` |
|
||||
| `backend` | Audio backend to use | String [^3] | |
|
||||
| `backend_device` | Audio device to configure the backend | String | |
|
||||
| `audio_cache` | Enable caching of audio files | `true`, `false` | `true` |
|
||||
| `audio_cache_size` | Maximum size of audio cache in MiB | Number | |
|
||||
| `volnorm` | Enable volume normalization | `true`, `false` | `false` |
|
||||
| `volnorm_pregain` | Normalization pregain to apply (if enabled) | Number | 0 |
|
||||
| `default_keybindings` | Enable default keybindings | `true`, `false` | `false` |
|
||||
| `notify` | Enable desktop notifications | `true`, `false` | `false` |
|
||||
| `bitrate` | Audio bitrate to use for streaming | `96`, `160`, `320` | `320` |
|
||||
| `album_column` | Show album column for tracks | `true`, `false` | `true` |
|
||||
| `gapless` | Enable gapless playback | `true`, `false` | `true` |
|
||||
| `shuffle` | Set default shuffle state | `true`, `false` | `false` |
|
||||
| `repeat` | Set default repeat mode | `off`, `track`, `playlist` | `off` |
|
||||
| `playback_state` | Set default playback state | `"Stopped"`, `"Paused"`, `"Playing"`, `"Default"` | `"Paused"` |
|
||||
| `[theme]` | Custom theme | See [custom theme](#theming) | |
|
||||
| `[keybindings]` | Custom keybindings | See [custom keybindings](#custom-keybindings) | |
|
||||
| Name | Description | Possible values | Default |
|
||||
|--------------------------|---------------------------------------------|-----------------------------------------------------------------|-------------|
|
||||
| `command_key` | Key to open command line | Single character | `:` |
|
||||
| `initial_screen` | Screen to show after startup | `"library"`, `"search"`, `"queue"`, `"cover"`[^2] | `"library"` |
|
||||
| `use_nerdfont` | Turn nerdfont glyphs on/off | `true`, `false` | `false` |
|
||||
| `flip_status_indicators` | Reverse play/pause icon meaning[^1] | `true`, `false` | `false` |
|
||||
| `backend` | Audio backend to use | String [^3] | |
|
||||
| `backend_device` | Audio device to configure the backend | String | |
|
||||
| `audio_cache` | Enable caching of audio files | `true`, `false` | `true` |
|
||||
| `audio_cache_size` | Maximum size of audio cache in MiB | Number | |
|
||||
| `volnorm` | Enable volume normalization | `true`, `false` | `false` |
|
||||
| `volnorm_pregain` | Normalization pregain to apply (if enabled) | Number | `0` |
|
||||
| `default_keybindings` | Enable default keybindings | `true`, `false` | `false` |
|
||||
| `notify` | Enable desktop notifications | `true`, `false` | `false` |
|
||||
| `bitrate` | Audio bitrate to use for streaming | `96`, `160`, `320` | `320` |
|
||||
| `album_column` | Show album column for tracks | `true`, `false` | `true` |
|
||||
| `gapless` | Enable gapless playback | `true`, `false` | `true` |
|
||||
| `shuffle` | Set default shuffle state | `true`, `false` | `false` |
|
||||
| `repeat` | Set default repeat mode | `off`, `track`, `playlist` | `off` |
|
||||
| `playback_state` | Set default playback state | `"Stopped"`, `"Paused"`, `"Playing"`, `"Default"` | `"Paused"` |
|
||||
| `library_tabs` | Tabs to show in library screen | Array of `tracks`, `albums`, `artists`, `playlists`, `podcasts` | All tabs |
|
||||
| `[theme]` | Custom theme | See [custom theme](#theming) | |
|
||||
| `[keybindings]` | Custom keybindings | See [custom keybindings](#custom-keybindings) | |
|
||||
|
||||
[^1]:
|
||||
By default the statusbar will show a play icon when a track is playing and
|
||||
|
||||
@@ -23,6 +23,16 @@ pub enum PlaybackState {
|
||||
Default,
|
||||
}
|
||||
|
||||
#[derive(Clone, Serialize, Deserialize, Debug, Hash, strum::EnumIter)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum LibraryTab {
|
||||
Tracks,
|
||||
Albums,
|
||||
Artists,
|
||||
Playlists,
|
||||
Podcasts,
|
||||
}
|
||||
|
||||
#[derive(Clone, Serialize, Deserialize, Debug, Default)]
|
||||
pub struct ConfigValues {
|
||||
pub command_key: Option<char>,
|
||||
@@ -46,6 +56,7 @@ pub struct ConfigValues {
|
||||
pub repeat: Option<queue::RepeatSetting>,
|
||||
pub cover_max_scale: Option<f32>,
|
||||
pub playback_state: Option<PlaybackState>,
|
||||
pub library_tabs: Option<Vec<LibraryTab>>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Default, Clone)]
|
||||
|
||||
@@ -2,9 +2,11 @@ use std::sync::Arc;
|
||||
|
||||
use cursive::view::ViewWrapper;
|
||||
use cursive::Cursive;
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
use crate::command::Command;
|
||||
use crate::commands::CommandResult;
|
||||
use crate::config::LibraryTab;
|
||||
use crate::library::Library;
|
||||
use crate::queue::Queue;
|
||||
use crate::traits::ViewExt;
|
||||
@@ -19,35 +21,46 @@ pub struct LibraryView {
|
||||
|
||||
impl LibraryView {
|
||||
pub fn new(queue: Arc<Queue>, library: Arc<Library>) -> Self {
|
||||
let tabs = TabView::new()
|
||||
.tab(
|
||||
"tracks",
|
||||
"Tracks",
|
||||
ListView::new(library.tracks.clone(), queue.clone(), library.clone()),
|
||||
)
|
||||
.tab(
|
||||
"albums",
|
||||
"Albums",
|
||||
ListView::new(library.albums.clone(), queue.clone(), library.clone()),
|
||||
)
|
||||
.tab(
|
||||
"artists",
|
||||
"Artists",
|
||||
ListView::new(library.artists.clone(), queue.clone(), library.clone()),
|
||||
)
|
||||
.tab(
|
||||
"playlists",
|
||||
"Playlists",
|
||||
PlaylistsView::new(queue.clone(), library.clone()),
|
||||
)
|
||||
.tab(
|
||||
"podcasts",
|
||||
"Podcasts",
|
||||
ListView::new(library.shows.clone(), queue, library.clone()),
|
||||
);
|
||||
let mut tabview = TabView::new();
|
||||
let selected_tabs = library
|
||||
.cfg
|
||||
.values()
|
||||
.library_tabs
|
||||
.clone()
|
||||
.unwrap_or(Vec::from_iter(LibraryTab::iter()));
|
||||
|
||||
for tab in selected_tabs {
|
||||
match tab {
|
||||
LibraryTab::Tracks => tabview.add_tab(
|
||||
"tracks",
|
||||
"Tracks",
|
||||
ListView::new(library.tracks.clone(), queue.clone(), library.clone()),
|
||||
),
|
||||
LibraryTab::Albums => tabview.add_tab(
|
||||
"albums",
|
||||
"Albums",
|
||||
ListView::new(library.albums.clone(), queue.clone(), library.clone()),
|
||||
),
|
||||
LibraryTab::Artists => tabview.add_tab(
|
||||
"artists",
|
||||
"Artists",
|
||||
ListView::new(library.artists.clone(), queue.clone(), library.clone()),
|
||||
),
|
||||
LibraryTab::Playlists => tabview.add_tab(
|
||||
"playlists",
|
||||
"Playlists",
|
||||
PlaylistsView::new(queue.clone(), library.clone()),
|
||||
),
|
||||
LibraryTab::Podcasts => tabview.add_tab(
|
||||
"podcasts",
|
||||
"Podcasts",
|
||||
ListView::new(library.shows.clone(), queue.clone(), library.clone()),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
Self {
|
||||
tabs,
|
||||
tabs: tabview,
|
||||
display_name: library.display_name.clone(),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user