Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6997e7cd93 | ||
|
|
b5ef9fbb13 | ||
|
|
3518462dde | ||
|
|
d4de15acd8 | ||
|
|
0bcba21f1a | ||
|
|
ab42814302 | ||
|
|
a5d51cf044 |
@@ -2,6 +2,50 @@
|
||||
|
||||
One section per version, newest first.
|
||||
|
||||
## v0.8.3 (2026-11-04)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
- The now-playing cover, its background and the album art colours use the picture embedded in the playing track's file when it has one. Nextcloud Music gives every song of an album the album's cover, so tracks with their own art all showed the same one. Lists and the queue still show the server's cover.
|
||||
|
||||
## v0.8.2 (2026-11-04)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
- On the now-playing screen the play/pause icon and the volume bar sit exactly under the middle of the progress bar. Before, the icon moved with the widths of the two times and the volume bar sat left of centre.
|
||||
|
||||
## v0.8.1 (2026-11-04)
|
||||
|
||||
### Features
|
||||
|
||||
- The password field on the login screen has an eye to show what was typed, and the queue button does the same from a controller while the field is selected. It is hidden again whenever the login screen opens.
|
||||
|
||||
## v0.8.0 (2026-11-04)
|
||||
|
||||
### Features
|
||||
|
||||
- Remus keeps several logins and switches between them from Settings, where the servers are listed first. Add server opens the login form, and Cancel goes back. Each server keeps its own queue: switching away stops it, and switching back brings it back paused where it was. A server is removed by pressing the queue button twice on its row.
|
||||
- The shoulder triggers wrap around the sidebar, so Settings is one press back from Recently added.
|
||||
- An existing login is kept as the first of the list, with nothing to re-enter.
|
||||
|
||||
## v0.7.0 (2026-11-04)
|
||||
|
||||
### Features
|
||||
|
||||
- Remus is an MPRIS player, so media keys, headphone buttons and the desktop's media controls can play, pause and skip, and the desktop shows the track that is playing. Headphone buttons work wherever the system passes them to MPRIS, as KDE does in Desktop Mode.
|
||||
|
||||
## v0.6.8 (2026-11-04)
|
||||
|
||||
### Features
|
||||
|
||||
- Settings has a Show controls bar toggle. Turned off, the bar with the button hints and the version is hidden on the browse and now-playing screens, and Settings lists the version instead. The login screen always shows it.
|
||||
|
||||
## v0.6.7 (2026-11-04)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
- The volume level sits centred under the progress bar on the now-playing screen, and at the right of the bar at the bottom of the other screens, next to the time.
|
||||
|
||||
## v0.6.6 (2026-11-04)
|
||||
|
||||
### Features
|
||||
|
||||
Generated
+1
-1
@@ -4385,7 +4385,7 @@ checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4"
|
||||
|
||||
[[package]]
|
||||
name = "remus"
|
||||
version = "0.6.6"
|
||||
version = "0.8.3"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"directories",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "remus"
|
||||
version = "0.6.6"
|
||||
version = "0.8.3"
|
||||
edition = "2024"
|
||||
license = "MIT"
|
||||
|
||||
|
||||
@@ -20,6 +20,13 @@
|
||||
</supports>
|
||||
<content_rating type="oars-1.1"/>
|
||||
<releases>
|
||||
<release version="0.8.3" date="2026-11-04"/>
|
||||
<release version="0.8.2" date="2026-11-04"/>
|
||||
<release version="0.8.1" date="2026-11-04"/>
|
||||
<release version="0.8.0" date="2026-11-04"/>
|
||||
<release version="0.7.0" date="2026-11-04"/>
|
||||
<release version="0.6.8" date="2026-11-04"/>
|
||||
<release version="0.6.7" date="2026-11-04"/>
|
||||
<release version="0.6.6" date="2026-11-04"/>
|
||||
<release version="0.6.5" date="2026-11-04"/>
|
||||
<release version="0.6.4" date="2026-11-04"/>
|
||||
|
||||
@@ -18,6 +18,9 @@ finish-args:
|
||||
# Keeps the screensaver off while music plays, the way Chromium and
|
||||
# Electron apps do. The XDG portal route needs no permission.
|
||||
- --talk-name=org.freedesktop.ScreenSaver
|
||||
# MPRIS, through which the desktop's media keys and headphone buttons
|
||||
# reach the player.
|
||||
- --own-name=org.mpris.MediaPlayer2.remus
|
||||
|
||||
build-options:
|
||||
append-path: /usr/lib/sdk/rust-stable/bin
|
||||
|
||||
+494
-64
@@ -16,8 +16,9 @@ use slint::{Color, ComponentHandle, Image, ModelRc, Rgb8Pixel, SharedPixelBuffer
|
||||
use tokio::runtime::Handle;
|
||||
use tokio::sync::Semaphore;
|
||||
|
||||
use crate::config::{self, Config, Settings};
|
||||
use crate::config::{self, Config, Logins, Settings};
|
||||
use crate::inhibit::Inhibitor;
|
||||
use crate::mpris::{self, Mpris};
|
||||
use crate::palette::{Lab, Palette, Role, Tone};
|
||||
use crate::player::{Player, PlayerEvent};
|
||||
use crate::prompts::{self, Control, Family, Prompts};
|
||||
@@ -117,7 +118,7 @@ impl Section {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
enum Target {
|
||||
Album(String),
|
||||
Artist(String),
|
||||
@@ -131,6 +132,12 @@ enum Target {
|
||||
enum Setting {
|
||||
AlbumArtColours,
|
||||
CoverBackdrop,
|
||||
ShowHintBar,
|
||||
/// The version, listed while the hint bar that normally shows it is off.
|
||||
Version,
|
||||
/// A saved login, by index into `Logins::servers`.
|
||||
Server(usize),
|
||||
AddServer,
|
||||
}
|
||||
|
||||
/// How long the UI takes to change from one palette to the next.
|
||||
@@ -204,6 +211,10 @@ struct Page {
|
||||
|
||||
type CoverKey = (String, u32);
|
||||
|
||||
/// Prefix of the cover id for the picture embedded in a song's file, followed
|
||||
/// by the song id. Read from the stream, never asked of the server.
|
||||
const EMBEDDED: &str = "remus-embedded:";
|
||||
|
||||
struct Covers {
|
||||
images: LruCache<CoverKey, Image>,
|
||||
/// Per cover id, whatever size it was decoded at. None for a cover with
|
||||
@@ -213,8 +224,18 @@ struct Covers {
|
||||
prints: LruCache<CoverKey, u64>,
|
||||
pending: HashSet<CoverKey>,
|
||||
failed: HashSet<CoverKey>,
|
||||
/// Per song id, the picture embedded in its file as the player read it,
|
||||
/// None for a file without one. Some servers, such as Nextcloud Music,
|
||||
/// give every song the album's cover id, so this is the only place a
|
||||
/// track's own cover can come from.
|
||||
embedded: LruCache<String, Option<Arc<[u8]>>>,
|
||||
limit: Arc<Semaphore>,
|
||||
/// Per server, under `root`, since ids are only unique within a server.
|
||||
dir: Option<PathBuf>,
|
||||
root: Option<PathBuf>,
|
||||
/// Bumped on a server switch, so a load started for the old server is
|
||||
/// dropped when it lands instead of filling the new server's cache.
|
||||
generation: u64,
|
||||
}
|
||||
|
||||
pub struct App {
|
||||
@@ -224,6 +245,15 @@ pub struct App {
|
||||
player: Option<Player>,
|
||||
/// Keeps the screensaver off while music plays. Taken at shutdown.
|
||||
inhibitor: Option<Inhibitor>,
|
||||
/// Media keys, headphone buttons and the desktop's media controls.
|
||||
mpris: Mpris,
|
||||
/// Every saved login and the one being browsed.
|
||||
logins: Logins,
|
||||
/// Bumped when the player is stopped for a server switch; player events
|
||||
/// sent before that are dropped.
|
||||
player_epoch: Arc<std::sync::atomic::AtomicU64>,
|
||||
/// A server row whose remove button was pressed once, and when.
|
||||
remove_armed: Option<(usize, Instant)>,
|
||||
screen: Screen,
|
||||
area: Area,
|
||||
section: usize,
|
||||
@@ -265,6 +295,10 @@ pub struct App {
|
||||
fade: Fade,
|
||||
/// The now-playing art on screen, `None` when nothing is playing.
|
||||
art_shown: Option<ShownArt>,
|
||||
/// The playing track started and the player has not yet said whether its
|
||||
/// file has a picture: the art and palette wait, so they do not show the
|
||||
/// album cover and then change again.
|
||||
art_waiting: bool,
|
||||
/// Runs while the cover turns away; the new art goes up when it fires.
|
||||
flip_timer: Timer,
|
||||
}
|
||||
@@ -294,12 +328,19 @@ impl App {
|
||||
log::warn!("cover cache disabled, cannot create {}: {e}", d.display());
|
||||
}
|
||||
let inhibitor = Inhibitor::spawn(&rt);
|
||||
let mpris = Mpris::spawn(&rt, |c| {
|
||||
let _ = slint::invoke_from_event_loop(move || with_app(move |app| app.mpris_command(c)));
|
||||
});
|
||||
App {
|
||||
ui,
|
||||
rt,
|
||||
client: None,
|
||||
player: None,
|
||||
inhibitor: Some(inhibitor),
|
||||
mpris,
|
||||
logins: Logins::default(),
|
||||
player_epoch: Arc::default(),
|
||||
remove_armed: None,
|
||||
screen: Screen::Login,
|
||||
area: Area::Content,
|
||||
section: 0,
|
||||
@@ -315,8 +356,11 @@ impl App {
|
||||
prints: LruCache::new(NonZeroUsize::new(400).unwrap()),
|
||||
pending: HashSet::new(),
|
||||
failed: HashSet::new(),
|
||||
embedded: LruCache::new(NonZeroUsize::new(16).unwrap()),
|
||||
limit: Arc::new(Semaphore::new(6)),
|
||||
dir,
|
||||
dir: None,
|
||||
root: dir,
|
||||
generation: 0,
|
||||
},
|
||||
queue: Vec::new(),
|
||||
current: None,
|
||||
@@ -336,6 +380,7 @@ impl App {
|
||||
volume_timer: Timer::default(),
|
||||
volume_save_timer: Timer::default(),
|
||||
art_shown: None,
|
||||
art_waiting: false,
|
||||
flip_timer: Timer::default(),
|
||||
prompts: Prompts::Keyboard,
|
||||
icons: RefCell::default(),
|
||||
@@ -352,11 +397,22 @@ impl App {
|
||||
|
||||
fn start(&mut self) {
|
||||
self.render_backdrop();
|
||||
self.ui.set_show_hint_bar(self.settings.show_hint_bar);
|
||||
let labels: Vec<SharedString> = SECTIONS.iter().map(|s| s.label().into()).collect();
|
||||
self.ui.set_sections(ModelRc::new(VecModel::from(labels)));
|
||||
|
||||
match Player::spawn(|ev| {
|
||||
let _ = slint::invoke_from_event_loop(move || with_app(move |app| app.player_event(ev)));
|
||||
let epoch = self.player_epoch.clone();
|
||||
match Player::spawn(move |ev| {
|
||||
// Stamped when sent, so an event still on its way when the
|
||||
// server is switched is recognised as the old server's.
|
||||
let sent = epoch.load(std::sync::atomic::Ordering::Relaxed);
|
||||
let _ = slint::invoke_from_event_loop(move || {
|
||||
with_app(move |app| {
|
||||
if app.player_epoch.load(std::sync::atomic::Ordering::Relaxed) == sent {
|
||||
app.player_event(ev);
|
||||
}
|
||||
})
|
||||
});
|
||||
}) {
|
||||
Ok(p) => self.player = Some(p),
|
||||
Err(e) => {
|
||||
@@ -367,15 +423,20 @@ impl App {
|
||||
self.apply_volume();
|
||||
|
||||
match config::load() {
|
||||
Ok(Some(cfg)) => {
|
||||
log::info!("using saved login for {} on {}", cfg.username, cfg.url);
|
||||
self.ui.set_login_server(cfg.url.clone().into());
|
||||
self.ui.set_login_username(cfg.username.clone().into());
|
||||
self.enter_browse(cfg.client());
|
||||
}
|
||||
Ok(None) => {
|
||||
log::info!("no saved login, showing the login screen");
|
||||
self.show_login();
|
||||
Ok(logins) => {
|
||||
self.logins = logins;
|
||||
match self.logins.active().cloned() {
|
||||
Some(cfg) => {
|
||||
log::info!("using saved login for {} on {}", cfg.username, cfg.url);
|
||||
self.ui.set_login_server(cfg.url.clone().into());
|
||||
self.ui.set_login_username(cfg.username.clone().into());
|
||||
self.enter_browse(cfg.client());
|
||||
}
|
||||
None => {
|
||||
log::info!("no saved login, showing the login screen");
|
||||
self.show_login();
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
log::error!("could not read the saved login: {e:#}");
|
||||
@@ -403,9 +464,34 @@ impl App {
|
||||
fn show_login(&mut self) {
|
||||
self.screen = Screen::Login;
|
||||
self.ui.set_screen(Screen::Login);
|
||||
// Adding a server from inside the app: the bottom button goes back.
|
||||
self.ui.set_login_can_cancel(self.client.is_some());
|
||||
self.ui.set_login_password_shown(false);
|
||||
self.set_login_focus(0);
|
||||
}
|
||||
|
||||
/// The login form, empty, for one more server.
|
||||
fn add_server(&mut self) {
|
||||
self.ui.set_login_server("".into());
|
||||
self.ui.set_login_username("".into());
|
||||
self.ui.set_login_password("".into());
|
||||
self.ui.set_login_error("".into());
|
||||
self.show_login();
|
||||
}
|
||||
|
||||
/// Leaves the login form for the server that was being browsed.
|
||||
fn cancel_login(&mut self) {
|
||||
if self.client.is_none() {
|
||||
return;
|
||||
}
|
||||
self.ui.set_login_password("".into());
|
||||
self.ui.set_login_error("".into());
|
||||
self.screen = Screen::Browse;
|
||||
self.ui.set_screen(Screen::Browse);
|
||||
let area = self.area;
|
||||
self.set_area(area);
|
||||
}
|
||||
|
||||
fn set_login_focus(&mut self, i: i32) {
|
||||
self.login_focus = i.clamp(0, 4);
|
||||
self.ui.set_login_focus(self.login_focus);
|
||||
@@ -418,8 +504,16 @@ impl App {
|
||||
Action::Up | Action::SectionPrev => self.set_login_focus(self.login_focus - 1),
|
||||
Action::Down | Action::SectionNext => self.set_login_focus(self.login_focus + 1),
|
||||
Action::Activate if self.login_focus < 2 => self.set_login_focus(self.login_focus + 1),
|
||||
Action::Activate if self.login_focus == 4 && self.client.is_some() => self.cancel_login(),
|
||||
Action::Activate if self.login_focus == 4 => self.action(Action::Quit),
|
||||
Action::Activate => self.login_submit(),
|
||||
Action::Back => self.cancel_login(),
|
||||
// The face button that queues elsewhere; a keyboard types into
|
||||
// the field instead, and uses the eye.
|
||||
Action::Queue if self.login_focus == 2 => {
|
||||
self.ui.set_login_password_shown(!self.ui.get_login_password_shown());
|
||||
self.render_hints();
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
@@ -452,10 +546,9 @@ impl App {
|
||||
match r {
|
||||
Ok(client) => {
|
||||
app.ui.set_login_password("".into());
|
||||
if let Err(e) = config::save(&Config::from_client(&client)) {
|
||||
app.toast(format!("Could not save settings: {e:#}"));
|
||||
}
|
||||
app.enter_browse(client);
|
||||
app.logins.add(Config::from_client(&client));
|
||||
app.save_logins();
|
||||
app.switch_server(client);
|
||||
}
|
||||
Err(e) => app.ui.set_login_error(login_error(&e).into()),
|
||||
}
|
||||
@@ -467,11 +560,23 @@ impl App {
|
||||
let host = client.base().split("://").nth(1).unwrap_or(client.base()).to_string();
|
||||
self.ui
|
||||
.set_server_label(format!("{} on {}", client.user(), host).into());
|
||||
// Keyed like the saved queue, by user and full address.
|
||||
let key = sanitize(&format!("{}@{}", client.user(), client.base()));
|
||||
self.covers.dir = self.covers.root.as_ref().map(|r| r.join(key));
|
||||
if let Some(d) = &self.covers.dir
|
||||
&& let Err(e) = std::fs::create_dir_all(d)
|
||||
{
|
||||
log::warn!("cover cache disabled, cannot create {}: {e}", d.display());
|
||||
self.covers.dir = None;
|
||||
}
|
||||
self.client = Some(client);
|
||||
self.covers.generation += 1;
|
||||
self.covers.images.clear();
|
||||
self.covers.tones.clear();
|
||||
self.covers.prints.clear();
|
||||
self.covers.pending.clear();
|
||||
self.covers.failed.clear();
|
||||
self.covers.embedded.clear();
|
||||
for stack in &mut self.stacks {
|
||||
stack.clear();
|
||||
}
|
||||
@@ -485,6 +590,107 @@ impl App {
|
||||
}
|
||||
}
|
||||
|
||||
/// Browses `client`'s server. The server being left keeps its queue on
|
||||
/// disk and stops; the new one's saved queue comes back paused, so a
|
||||
/// switch never starts music by itself.
|
||||
fn switch_server(&mut self, client: Client) {
|
||||
if self.client.is_some() {
|
||||
self.save_queue();
|
||||
self.stop_player();
|
||||
self.queue.clear();
|
||||
self.current = None;
|
||||
self.queue_sel = 0;
|
||||
self.position = 0.0;
|
||||
self.duration = 0.0;
|
||||
self.paused = false;
|
||||
self.held = false;
|
||||
self.scrobbled = false;
|
||||
self.now_playing_due = false;
|
||||
self.restoring = None;
|
||||
self.art_shown = None;
|
||||
self.flip_timer.stop();
|
||||
self.ui.set_np_flip_out(false);
|
||||
}
|
||||
log::info!("browsing {} on {}", client.user(), client.base());
|
||||
self.enter_browse(client);
|
||||
self.render_player();
|
||||
self.sync_queue(true);
|
||||
self.sync_inhibit();
|
||||
}
|
||||
|
||||
/// Stops playback for good, dropping whatever the player still has on
|
||||
/// its way about the old queue.
|
||||
fn stop_player(&self) {
|
||||
if let Some(p) = &self.player {
|
||||
p.stop();
|
||||
}
|
||||
self.player_epoch.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
|
||||
}
|
||||
|
||||
fn save_logins(&mut self) {
|
||||
if let Err(e) = config::save(&self.logins) {
|
||||
self.toast(format!("Could not save the logins: {e:#}"));
|
||||
}
|
||||
}
|
||||
|
||||
fn select_server(&mut self, i: usize) {
|
||||
if i == self.logins.active {
|
||||
return;
|
||||
}
|
||||
let Some(cfg) = self.logins.servers.get(i).cloned() else {
|
||||
return;
|
||||
};
|
||||
self.logins.active = i;
|
||||
self.save_logins();
|
||||
self.switch_server(cfg.client());
|
||||
self.toast(format!("Switched to {}", cfg.label()));
|
||||
}
|
||||
|
||||
/// The first press arms, a second within a few seconds removes.
|
||||
fn remove_server(&mut self, i: usize) {
|
||||
let Some(cfg) = self.logins.servers.get(i).cloned() else {
|
||||
return;
|
||||
};
|
||||
let armed = self
|
||||
.remove_armed
|
||||
.is_some_and(|(j, at)| j == i && at.elapsed() < Duration::from_secs(4));
|
||||
if !armed {
|
||||
self.remove_armed = Some((i, Instant::now()));
|
||||
self.toast(format!("Press again to remove {}", cfg.label()));
|
||||
return;
|
||||
}
|
||||
self.remove_armed = None;
|
||||
let was_active = i == self.logins.active;
|
||||
self.logins.remove(i);
|
||||
self.save_logins();
|
||||
self.toast(format!("Removed {}", cfg.label()));
|
||||
if !was_active {
|
||||
self.refresh_settings();
|
||||
return;
|
||||
}
|
||||
match self.logins.active().cloned() {
|
||||
Some(next) => self.switch_server(next.client()),
|
||||
None => {
|
||||
// Nothing left to browse: stop, keep the queue on disk.
|
||||
self.save_queue();
|
||||
self.stop_player();
|
||||
self.queue.clear();
|
||||
self.current = None;
|
||||
self.client = None;
|
||||
self.render_player();
|
||||
self.add_server();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The section that `delta` steps away, wrapping around, so Settings is
|
||||
/// one press back from the first section.
|
||||
fn section_step(&self, delta: isize) -> usize {
|
||||
let n = SECTIONS.len() as isize;
|
||||
let from = self.section.min(SECTIONS.len() - 1) as isize;
|
||||
(from + delta).rem_euclid(n) as usize
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- input
|
||||
|
||||
/// A key pressed in the window.
|
||||
@@ -591,8 +797,10 @@ impl App {
|
||||
}
|
||||
match self.area {
|
||||
Area::Sidebar => match a {
|
||||
Action::Up | Action::SectionPrev => self.select_section(self.section.saturating_sub(1)),
|
||||
Action::Down | Action::SectionNext => self.select_section((self.section + 1).min(SECTIONS.len() - 1)),
|
||||
Action::Up => self.select_section(self.section.saturating_sub(1)),
|
||||
Action::Down => self.select_section((self.section + 1).min(SECTIONS.len() - 1)),
|
||||
Action::SectionPrev => self.select_section(self.section_step(-1)),
|
||||
Action::SectionNext => self.select_section(self.section_step(1)),
|
||||
Action::Activate if SECTIONS[self.section] == Section::Random => {
|
||||
self.reload_root();
|
||||
self.enter_content();
|
||||
@@ -609,9 +817,12 @@ impl App {
|
||||
}
|
||||
Action::Activate => self.activate(),
|
||||
Action::Back => self.back(),
|
||||
Action::Queue => self.enqueue_selected(),
|
||||
Action::SectionNext => self.select_section((self.section + 1).min(SECTIONS.len() - 1)),
|
||||
Action::SectionPrev => self.select_section(self.section.saturating_sub(1)),
|
||||
Action::Queue => match self.selected_setting() {
|
||||
Some(Setting::Server(i)) => self.remove_server(i),
|
||||
_ => self.enqueue_selected(),
|
||||
},
|
||||
Action::SectionNext => self.select_section(self.section_step(1)),
|
||||
Action::SectionPrev => self.select_section(self.section_step(-1)),
|
||||
_ => {}
|
||||
},
|
||||
Area::Search => match a {
|
||||
@@ -625,8 +836,8 @@ impl App {
|
||||
self.run_search(q);
|
||||
}
|
||||
Action::Back | Action::Left => self.set_area(Area::Sidebar),
|
||||
Action::SectionNext => self.select_section((self.section + 1).min(SECTIONS.len() - 1)),
|
||||
Action::SectionPrev => self.select_section(self.section.saturating_sub(1)),
|
||||
Action::SectionNext => self.select_section(self.section_step(1)),
|
||||
Action::SectionPrev => self.select_section(self.section_step(-1)),
|
||||
_ => {}
|
||||
},
|
||||
}
|
||||
@@ -899,6 +1110,14 @@ impl App {
|
||||
}
|
||||
}
|
||||
|
||||
fn selected_setting(&self) -> Option<Setting> {
|
||||
let page = self.current_page()?;
|
||||
match page.entries.get(page.sel)?.target {
|
||||
Target::Setting(s) => Some(s),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// The range setting under the selection, which left and right adjust.
|
||||
fn selected_range_setting(&self) -> Option<Setting> {
|
||||
let page = self.current_page()?;
|
||||
@@ -913,8 +1132,11 @@ impl App {
|
||||
fn toggle_setting(&mut self, setting: Setting) {
|
||||
match setting {
|
||||
Setting::AlbumArtColours => self.settings.album_art_colours = !self.settings.album_art_colours,
|
||||
Setting::ShowHintBar => self.settings.show_hint_bar = !self.settings.show_hint_bar,
|
||||
Setting::Server(i) => return self.select_server(i),
|
||||
Setting::AddServer => return self.add_server(),
|
||||
// A range: left and right change it, confirm does nothing.
|
||||
Setting::CoverBackdrop => return,
|
||||
Setting::CoverBackdrop | Setting::Version => return,
|
||||
}
|
||||
self.settings_changed();
|
||||
}
|
||||
@@ -929,7 +1151,11 @@ impl App {
|
||||
}
|
||||
self.settings.cover_backdrop = v;
|
||||
}
|
||||
Setting::AlbumArtColours => return,
|
||||
Setting::AlbumArtColours
|
||||
| Setting::ShowHintBar
|
||||
| Setting::Version
|
||||
| Setting::Server(_)
|
||||
| Setting::AddServer => return,
|
||||
}
|
||||
self.settings_changed();
|
||||
}
|
||||
@@ -939,16 +1165,26 @@ impl App {
|
||||
if let Err(e) = config::save_settings(&self.settings) {
|
||||
self.toast(format!("Could not save settings: {e:#}"));
|
||||
}
|
||||
let entries = settings_data(&self.settings).entries;
|
||||
self.refresh_settings();
|
||||
self.render_backdrop();
|
||||
self.ui.set_show_hint_bar(self.settings.show_hint_bar);
|
||||
self.update_theme();
|
||||
}
|
||||
|
||||
/// Redraws the Settings rows, keeping the selection in range.
|
||||
fn refresh_settings(&mut self) {
|
||||
let entries = settings_data(&self.settings, &self.logins).entries;
|
||||
let index = SECTIONS.iter().position(|s| *s == Section::Settings).unwrap_or(0);
|
||||
if let Some(page) = self.stacks[index].first_mut() {
|
||||
page.sel = page.sel.min(entries.len().saturating_sub(1));
|
||||
page.entries = entries;
|
||||
if self.section == index {
|
||||
let sel = page.sel;
|
||||
self.ui.set_selected(sel as i32);
|
||||
self.sync_items(true);
|
||||
self.render_hints();
|
||||
}
|
||||
}
|
||||
self.render_backdrop();
|
||||
self.update_theme();
|
||||
}
|
||||
|
||||
fn render_backdrop(&self) {
|
||||
@@ -995,6 +1231,7 @@ impl App {
|
||||
}
|
||||
self.ui.set_volume(self.settings.volume as i32);
|
||||
self.ui.set_muted(self.settings.muted);
|
||||
self.sync_mpris();
|
||||
}
|
||||
|
||||
fn show_volume(&mut self) {
|
||||
@@ -1014,11 +1251,10 @@ impl App {
|
||||
if !self.settings.album_art_colours {
|
||||
return Some(Palette::brand());
|
||||
}
|
||||
let Some(id) = self
|
||||
.current
|
||||
.and_then(|i| self.queue.get(i))
|
||||
.and_then(|s| s.cover_art.clone())
|
||||
else {
|
||||
if self.art_waiting {
|
||||
return None;
|
||||
}
|
||||
let Some(id) = self.playing_cover_id() else {
|
||||
return Some(Palette::brand());
|
||||
};
|
||||
match self.covers.tones.get(&id) {
|
||||
@@ -1121,7 +1357,7 @@ impl App {
|
||||
|
||||
fn load(&mut self, page_id: u64, source: Source) {
|
||||
if matches!(source, Source::Section(Section::Settings)) {
|
||||
let data = settings_data(&self.settings);
|
||||
let data = settings_data(&self.settings, &self.logins);
|
||||
self.page_loaded(page_id, Ok(data), true);
|
||||
return;
|
||||
}
|
||||
@@ -1449,12 +1685,21 @@ impl App {
|
||||
};
|
||||
match self.screen {
|
||||
Screen::Login => {
|
||||
let adding = self.client.is_some();
|
||||
let label = match self.login_focus {
|
||||
0 | 1 => "Next",
|
||||
4 if adding => "Cancel",
|
||||
4 => "Exit",
|
||||
_ => "Connect",
|
||||
};
|
||||
h(Control::Activate, label);
|
||||
if self.login_focus == 2 && matches!(self.prompts, Prompts::Pad(_)) {
|
||||
let shown = self.ui.get_login_password_shown();
|
||||
h(Control::Queue, if shown { "Hide password" } else { "Show password" });
|
||||
}
|
||||
if adding {
|
||||
h(Control::Back, "Cancel");
|
||||
}
|
||||
}
|
||||
Screen::Browse => match self.area {
|
||||
Area::Sidebar => {
|
||||
@@ -1476,6 +1721,14 @@ impl App {
|
||||
match target {
|
||||
Some(Target::Song(_)) => h(Control::Activate, "Play"),
|
||||
Some(Target::Setting(Setting::CoverBackdrop)) => h(Control::Seek, "Adjust"),
|
||||
Some(Target::Setting(Setting::Version)) => {}
|
||||
Some(Target::Setting(Setting::Server(i))) => {
|
||||
if *i != self.logins.active {
|
||||
h(Control::Activate, "Switch");
|
||||
}
|
||||
h(Control::Queue, "Remove");
|
||||
}
|
||||
Some(Target::Setting(Setting::AddServer)) => h(Control::Activate, "Add"),
|
||||
Some(Target::Setting(_)) => h(Control::Activate, "Change"),
|
||||
Some(_) => h(Control::Activate, "Open"),
|
||||
None if self.current_page().is_some_and(|p| p.error.is_some()) => {
|
||||
@@ -1563,6 +1816,20 @@ impl App {
|
||||
if self.covers.pending.contains(&key) || self.covers.failed.contains(&key) {
|
||||
return None;
|
||||
}
|
||||
let generation = self.covers.generation;
|
||||
if let Some(song) = id.strip_prefix(EMBEDDED) {
|
||||
let bytes = self.covers.embedded.get(song).cloned().flatten()?;
|
||||
self.covers.pending.insert(key.clone());
|
||||
self.spawn(
|
||||
async move { tokio::task::spawn_blocking(move || decode_cover(&bytes, px)).await? },
|
||||
move |app, r| {
|
||||
if app.covers.generation == generation {
|
||||
app.cover_loaded(key, r);
|
||||
}
|
||||
},
|
||||
);
|
||||
return None;
|
||||
}
|
||||
let client = self.client.clone()?;
|
||||
self.covers.pending.insert(key.clone());
|
||||
let limit = self.covers.limit.clone();
|
||||
@@ -1589,7 +1856,11 @@ impl App {
|
||||
let decoded = tokio::task::spawn_blocking(move || decode_cover(&bytes, px)).await??;
|
||||
Ok(decoded)
|
||||
},
|
||||
move |app, r| app.cover_loaded(key, r),
|
||||
move |app, r| {
|
||||
if app.covers.generation == generation {
|
||||
app.cover_loaded(key, r);
|
||||
}
|
||||
},
|
||||
);
|
||||
None
|
||||
}
|
||||
@@ -1610,11 +1881,11 @@ impl App {
|
||||
Err(e) => {
|
||||
log::debug!("cover {} failed: {e:#}", key.0);
|
||||
// The playing track's art may be waiting on this to flip.
|
||||
let playing = self
|
||||
.current
|
||||
.and_then(|i| self.queue.get(i))
|
||||
.and_then(|s| s.cover_art.as_deref())
|
||||
== Some(key.0.as_str());
|
||||
let playing = self.playing_cover_id().as_deref() == Some(key.0.as_str());
|
||||
// A picture in the file that will not decode: the album cover then.
|
||||
if let Some(song) = key.0.strip_prefix(EMBEDDED) {
|
||||
self.covers.embedded.put(song.to_string(), None);
|
||||
}
|
||||
self.covers.failed.insert(key);
|
||||
if playing {
|
||||
self.render_player();
|
||||
@@ -1654,12 +1925,7 @@ impl App {
|
||||
{
|
||||
self.render_page_header();
|
||||
}
|
||||
if self
|
||||
.current
|
||||
.and_then(|i| self.queue.get(i))
|
||||
.and_then(|s| s.cover_art.as_deref())
|
||||
== Some(id)
|
||||
{
|
||||
if self.playing_cover_id().as_deref() == Some(id) {
|
||||
self.render_player();
|
||||
}
|
||||
let (qlo, qhi) = self.queue_range;
|
||||
@@ -1789,6 +2055,8 @@ impl App {
|
||||
// new play: another queue started there, or the track replayed.
|
||||
let t = t.filter(|&i| i < self.queue.len());
|
||||
self.current = t;
|
||||
// A file already read needs no wait: replayed, or skipped back to.
|
||||
self.art_waiting = t.is_some_and(|i| !self.covers.embedded.contains(&self.queue[i].id));
|
||||
self.position = 0.0;
|
||||
self.scrobbled = false;
|
||||
if let Some((i, _)) = self.restoring.take()
|
||||
@@ -1812,8 +2080,79 @@ impl App {
|
||||
self.sync_queue(true);
|
||||
self.save_queue();
|
||||
}
|
||||
PlayerEvent::Art(i, bytes) => {
|
||||
if self.current != Some(i) {
|
||||
return;
|
||||
}
|
||||
let Some(song) = self.queue.get(i).map(|s| s.id.clone()) else {
|
||||
return;
|
||||
};
|
||||
log::debug!(
|
||||
"track {song}: {}",
|
||||
if bytes.is_some() {
|
||||
"picture in the file"
|
||||
} else {
|
||||
"no picture in the file"
|
||||
}
|
||||
);
|
||||
// A late picture does not undo one already read.
|
||||
if bytes.is_some() || !self.covers.embedded.contains(&song) {
|
||||
self.covers.embedded.put(song, bytes.map(Arc::from));
|
||||
}
|
||||
self.art_waiting = false;
|
||||
self.render_player();
|
||||
return;
|
||||
}
|
||||
}
|
||||
self.sync_inhibit();
|
||||
self.sync_mpris();
|
||||
}
|
||||
|
||||
/// Tells MPRIS clients what is playing.
|
||||
fn sync_mpris(&self) {
|
||||
let track = self.current.and_then(|i| self.queue.get(i).map(|s| (i, s)));
|
||||
let status = match track {
|
||||
None => mpris::Status::Stopped,
|
||||
Some(_) if self.paused || self.held => mpris::Status::Paused,
|
||||
Some(_) => mpris::Status::Playing,
|
||||
};
|
||||
let volume = if self.settings.muted {
|
||||
0.0
|
||||
} else {
|
||||
self.settings.volume as f64 / 100.0
|
||||
};
|
||||
self.mpris.update(mpris::NowPlaying {
|
||||
status,
|
||||
track: track.map(|(index, s)| mpris::Track {
|
||||
index,
|
||||
title: s.title.clone(),
|
||||
artist: s.artist.clone(),
|
||||
album: s.album.clone(),
|
||||
seconds: s.duration,
|
||||
}),
|
||||
volume,
|
||||
});
|
||||
}
|
||||
|
||||
/// A media key, headphone button or desktop control, through MPRIS.
|
||||
fn mpris_command(&mut self, c: mpris::Command) {
|
||||
let playing = self.current.is_some() && !self.paused && !self.held;
|
||||
let action = match c {
|
||||
mpris::Command::PlayPause => Action::PlayPause,
|
||||
mpris::Command::Play if !playing => Action::PlayPause,
|
||||
mpris::Command::Pause | mpris::Command::Stop if playing => Action::PlayPause,
|
||||
mpris::Command::Next => Action::Next,
|
||||
mpris::Command::Previous => Action::Prev,
|
||||
mpris::Command::Quit => Action::Quit,
|
||||
_ => return,
|
||||
};
|
||||
log::debug!("MPRIS {c:?}");
|
||||
// Not on the login screen: nothing is loaded there.
|
||||
if action == Action::Quit {
|
||||
self.action(action);
|
||||
} else if self.screen != Screen::Login {
|
||||
self.global_action(action);
|
||||
}
|
||||
}
|
||||
|
||||
/// Inhibits only while sound is coming out: a restored queue is loaded
|
||||
@@ -1920,6 +2259,7 @@ impl App {
|
||||
self.ui.set_np_progress(progress as f32);
|
||||
self.ui.set_np_position(fmt_time(self.position).into());
|
||||
self.ui.set_np_duration(fmt_time(self.duration).into());
|
||||
self.mpris.set_position(self.position);
|
||||
}
|
||||
|
||||
fn render_player(&mut self) {
|
||||
@@ -1947,6 +2287,7 @@ impl App {
|
||||
}
|
||||
}
|
||||
self.render_progress();
|
||||
self.sync_mpris();
|
||||
self.update_theme();
|
||||
}
|
||||
|
||||
@@ -1954,8 +2295,9 @@ impl App {
|
||||
/// from the one on screen. While a changed track's cover loads, the old one
|
||||
/// stays up: the load ends in a render either way, and decides then.
|
||||
fn update_art(&mut self, s: &Song) {
|
||||
if self.flip_timer.running() {
|
||||
// Mid-turn: the midpoint puts up whatever is current then.
|
||||
if self.flip_timer.running() || self.art_waiting {
|
||||
// Mid-turn: the midpoint puts up whatever is current then. Waiting
|
||||
// on the player: its answer ends in a render.
|
||||
return;
|
||||
}
|
||||
let Some(shown) = &self.art_shown else {
|
||||
@@ -1963,7 +2305,7 @@ impl App {
|
||||
self.render_art(s);
|
||||
return;
|
||||
};
|
||||
if shown.id == s.cover_art || self.screen != Screen::NowPlaying {
|
||||
if shown.id == self.cover_id(s) || self.screen != Screen::NowPlaying {
|
||||
self.render_art(s);
|
||||
return;
|
||||
}
|
||||
@@ -1982,10 +2324,10 @@ impl App {
|
||||
/// The picture the song's art will show: `Some(None)` for the placeholder,
|
||||
/// `None` while its cover is still loading.
|
||||
fn art_print(&mut self, s: &Song) -> Option<Option<u64>> {
|
||||
let Some(id) = s.cover_art.as_deref() else {
|
||||
let Some(id) = self.cover_id(s) else {
|
||||
return Some(None);
|
||||
};
|
||||
let key: CoverKey = (id.to_string(), self.now_playing_px());
|
||||
let key: CoverKey = (id, self.now_playing_px());
|
||||
if let Some(p) = self.covers.prints.get(&key) {
|
||||
return Some(Some(*p));
|
||||
}
|
||||
@@ -1993,7 +2335,7 @@ impl App {
|
||||
return Some(None);
|
||||
}
|
||||
// Starts the load if it is not under way.
|
||||
self.cover(id, key.1);
|
||||
self.cover(&key.0, key.1);
|
||||
None
|
||||
}
|
||||
|
||||
@@ -2004,7 +2346,7 @@ impl App {
|
||||
return;
|
||||
}
|
||||
let next = self.current.and_then(|i| self.queue.get(i + 1));
|
||||
if let Some(id) = next.and_then(|s| s.cover_art.clone()) {
|
||||
if let Some(id) = next.and_then(|s| self.cover_id(s)) {
|
||||
let px = self.now_playing_px();
|
||||
self.cover(&id, px);
|
||||
}
|
||||
@@ -2013,9 +2355,9 @@ impl App {
|
||||
/// Puts the song's cover, or its letter placeholder, on screen.
|
||||
fn render_art(&mut self, s: &Song) {
|
||||
let px = self.now_playing_px();
|
||||
let cover = s.cover_art.as_deref().and_then(|id| self.cover(id, px));
|
||||
let print = s
|
||||
.cover_art
|
||||
let id = self.cover_id(s);
|
||||
let cover = id.as_deref().and_then(|id| self.cover(id, px));
|
||||
let print = id
|
||||
.as_ref()
|
||||
.and_then(|id| self.covers.prints.get(&(id.clone(), px)).copied())
|
||||
.filter(|_| cover.is_some());
|
||||
@@ -2024,10 +2366,23 @@ impl App {
|
||||
self.ui.set_np_tint(tint(name));
|
||||
self.ui.set_np_has_cover(cover.is_some());
|
||||
self.ui.set_np_cover(cover.unwrap_or_default());
|
||||
self.art_shown = Some(ShownArt {
|
||||
id: s.cover_art.clone(),
|
||||
print,
|
||||
});
|
||||
self.art_shown = Some(ShownArt { id, print });
|
||||
}
|
||||
|
||||
/// The cover id the now-playing art, backdrop and palette use for `s`:
|
||||
/// the picture in its file once the player has read one, else the
|
||||
/// server's cover. Lists keep the server's cover.
|
||||
fn cover_id(&self, s: &Song) -> Option<String> {
|
||||
match self.covers.embedded.peek(&s.id) {
|
||||
Some(Some(_)) => Some(format!("{EMBEDDED}{}", s.id)),
|
||||
_ => s.cover_art.clone(),
|
||||
}
|
||||
}
|
||||
|
||||
fn playing_cover_id(&self) -> Option<String> {
|
||||
self.current
|
||||
.and_then(|i| self.queue.get(i))
|
||||
.and_then(|s| self.cover_id(s))
|
||||
}
|
||||
|
||||
/// The cover is edge-on: swap in the current track's art and turn it back.
|
||||
@@ -2220,9 +2575,42 @@ fn song_entry(s: &Song, index: usize) -> Entry {
|
||||
}
|
||||
}
|
||||
|
||||
fn settings_data(s: &Settings) -> PageData {
|
||||
fn settings_data(s: &Settings, logins: &Logins) -> PageData {
|
||||
let on_off = |on: bool| if on { "On" } else { "Off" }.to_string();
|
||||
PageData {
|
||||
let mut servers: Vec<Entry> = logins
|
||||
.servers
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(i, cfg)| Entry {
|
||||
title: cfg.label(),
|
||||
subtitle: if i == logins.active {
|
||||
"Browsing now".to_string()
|
||||
} else {
|
||||
"Saved login".to_string()
|
||||
},
|
||||
detail: if i == logins.active {
|
||||
"Active".to_string()
|
||||
} else {
|
||||
String::new()
|
||||
},
|
||||
number: String::new(),
|
||||
cover: None,
|
||||
round: false,
|
||||
show_art: false,
|
||||
target: Target::Setting(Setting::Server(i)),
|
||||
})
|
||||
.collect();
|
||||
servers.push(Entry {
|
||||
title: "Add server".to_string(),
|
||||
subtitle: "Log in to another Subsonic server, keeping this one".to_string(),
|
||||
detail: String::new(),
|
||||
number: String::new(),
|
||||
cover: None,
|
||||
round: false,
|
||||
show_art: false,
|
||||
target: Target::Setting(Setting::AddServer),
|
||||
});
|
||||
let mut data = PageData {
|
||||
entries: vec![
|
||||
Entry {
|
||||
title: "Colours from album art".to_string(),
|
||||
@@ -2248,9 +2636,35 @@ fn settings_data(s: &Settings) -> PageData {
|
||||
show_art: false,
|
||||
target: Target::Setting(Setting::CoverBackdrop),
|
||||
},
|
||||
Entry {
|
||||
title: "Show controls bar".to_string(),
|
||||
subtitle: "The buttons for each screen and the version, at the bottom".to_string(),
|
||||
detail: on_off(s.show_hint_bar),
|
||||
number: String::new(),
|
||||
cover: None,
|
||||
round: false,
|
||||
show_art: false,
|
||||
target: Target::Setting(Setting::ShowHintBar),
|
||||
},
|
||||
],
|
||||
..Default::default()
|
||||
};
|
||||
// Servers first, so switching is the shortest reach in Settings.
|
||||
data.entries.splice(0..0, servers);
|
||||
// The bar is where the version normally shows.
|
||||
if !s.show_hint_bar {
|
||||
data.entries.push(Entry {
|
||||
title: "Version".to_string(),
|
||||
subtitle: String::new(),
|
||||
detail: concat!("remus ", env!("CARGO_PKG_VERSION")).to_string(),
|
||||
number: String::new(),
|
||||
cover: None,
|
||||
round: false,
|
||||
show_art: false,
|
||||
target: Target::Setting(Setting::Version),
|
||||
});
|
||||
}
|
||||
data
|
||||
}
|
||||
|
||||
/// One step of the volume, kept within 0 to 100.
|
||||
@@ -2474,6 +2888,22 @@ mod tests {
|
||||
assert_ne!(a, c);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn version_is_listed_in_settings_only_while_the_bar_is_hidden() {
|
||||
let has_version = |show_hint_bar: bool| {
|
||||
let s = Settings {
|
||||
show_hint_bar,
|
||||
..Settings::default()
|
||||
};
|
||||
settings_data(&s, &Logins::default())
|
||||
.entries
|
||||
.iter()
|
||||
.any(|e| e.target == Target::Setting(Setting::Version))
|
||||
};
|
||||
assert!(!has_version(true));
|
||||
assert!(has_version(false));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn volume_steps_stay_in_range() {
|
||||
assert_eq!(step_volume(50, true), 55);
|
||||
|
||||
+166
-9
@@ -69,21 +69,104 @@ pub fn state_dir() -> Option<PathBuf> {
|
||||
dirs().map(|d| d.state_dir().unwrap_or(d.data_dir()).to_path_buf())
|
||||
}
|
||||
|
||||
pub fn load() -> Result<Option<Config>> {
|
||||
let Some(path) = config_path() else { return Ok(None) };
|
||||
impl Config {
|
||||
/// Names the server and user, as the sidebar shows them.
|
||||
pub fn label(&self) -> String {
|
||||
let host = self.url.split("://").nth(1).unwrap_or(&self.url);
|
||||
format!("{} on {}", self.username, host.trim_end_matches('/'))
|
||||
}
|
||||
|
||||
fn same_login(&self, other: &Config) -> bool {
|
||||
self.url == other.url && self.username == other.username
|
||||
}
|
||||
}
|
||||
|
||||
/// Every saved login, and which one is browsed.
|
||||
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
|
||||
pub struct Logins {
|
||||
/// Index into `servers`.
|
||||
#[serde(default)]
|
||||
pub active: usize,
|
||||
/// `[[server]]` tables in the file.
|
||||
#[serde(rename = "server", default)]
|
||||
pub servers: Vec<Config>,
|
||||
}
|
||||
|
||||
impl Logins {
|
||||
pub fn active(&self) -> Option<&Config> {
|
||||
self.servers.get(self.active)
|
||||
}
|
||||
|
||||
/// Adds a login, or refreshes the saved one for the same server and user,
|
||||
/// and makes it the active one.
|
||||
pub fn add(&mut self, cfg: Config) {
|
||||
match self.servers.iter().position(|s| s.same_login(&cfg)) {
|
||||
Some(i) => {
|
||||
self.servers[i] = cfg;
|
||||
self.active = i;
|
||||
}
|
||||
None => {
|
||||
self.servers.push(cfg);
|
||||
self.active = self.servers.len() - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Removes a login. The active one stays the same server where it can;
|
||||
/// removing it makes the first remaining login active.
|
||||
pub fn remove(&mut self, i: usize) {
|
||||
if i >= self.servers.len() {
|
||||
return;
|
||||
}
|
||||
self.servers.remove(i);
|
||||
if i < self.active {
|
||||
self.active -= 1;
|
||||
} else if i == self.active {
|
||||
self.active = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The single login of earlier versions, or the list. Tried in that order:
|
||||
/// every field of the list has a default, so it would take an old file as an
|
||||
/// empty list, while the old shape needs `url` and `username` at the top.
|
||||
#[derive(Deserialize)]
|
||||
#[serde(untagged)]
|
||||
enum Stored {
|
||||
One(Config),
|
||||
List(Logins),
|
||||
}
|
||||
|
||||
fn parse_logins(text: &str) -> Result<Logins> {
|
||||
Ok(match toml::from_str::<Stored>(text)? {
|
||||
Stored::List(mut l) => {
|
||||
if l.active >= l.servers.len() {
|
||||
l.active = 0;
|
||||
}
|
||||
l
|
||||
}
|
||||
Stored::One(c) => Logins {
|
||||
active: 0,
|
||||
servers: vec![c],
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
pub fn load() -> Result<Logins> {
|
||||
let Some(path) = config_path() else {
|
||||
return Ok(Logins::default());
|
||||
};
|
||||
match fs::read_to_string(&path) {
|
||||
Ok(text) => Ok(Some(
|
||||
toml::from_str(&text).with_context(|| format!("parsing {}", path.display()))?,
|
||||
)),
|
||||
Err(e) if e.kind() == std::io::ErrorKind::NotFound => Ok(None),
|
||||
Ok(text) => parse_logins(&text).with_context(|| format!("parsing {}", path.display())),
|
||||
Err(e) if e.kind() == std::io::ErrorKind::NotFound => Ok(Logins::default()),
|
||||
Err(e) => Err(e).with_context(|| format!("reading {}", path.display())),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn save(cfg: &Config) -> Result<()> {
|
||||
pub fn save(logins: &Logins) -> Result<()> {
|
||||
let path = config_path().context("no config directory")?;
|
||||
write_atomic(&path, &toml::to_string(cfg)?)?;
|
||||
log::info!("saved login to {}", path.display());
|
||||
write_atomic(&path, &toml::to_string(logins)?)?;
|
||||
log::info!("saved {} login(s) to {}", logins.servers.len(), path.display());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -99,6 +182,9 @@ pub struct Settings {
|
||||
pub volume: u8,
|
||||
/// Muted, keeping `volume` for when it is unmuted.
|
||||
pub muted: bool,
|
||||
/// The bar with the button hints and the version. The login screen shows
|
||||
/// it regardless.
|
||||
pub show_hint_bar: bool,
|
||||
}
|
||||
|
||||
/// The cover backdrop strength that looks like it did before it was a setting.
|
||||
@@ -111,6 +197,7 @@ impl Default for Settings {
|
||||
cover_backdrop: COVER_BACKDROP_DEFAULT,
|
||||
volume: 100,
|
||||
muted: false,
|
||||
show_hint_bar: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -208,6 +295,73 @@ mod tests {
|
||||
assert!(!text.contains("salt") && !text.contains("token"), "{text}");
|
||||
}
|
||||
|
||||
fn login(url: &str, user: &str, auth: Auth) -> Config {
|
||||
Config::from_client(&Client::new(url, user, auth))
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_single_login_file_loads_as_the_only_login() {
|
||||
let old = "url = \"https://h\"\nusername = \"u\"\nsalt = \"s\"\ntoken = \"t\"\n";
|
||||
let l = parse_logins(old).unwrap();
|
||||
assert_eq!(l.servers.len(), 1);
|
||||
assert_eq!(l.active, 0);
|
||||
assert_eq!(l.active().unwrap().username, "u");
|
||||
let old = "url = \"https://h\"\nusername = \"u\"\npassword = \"p\"\n";
|
||||
let l = parse_logins(old).unwrap();
|
||||
assert_eq!(*l.active().unwrap().client().auth(), Auth::Password("p".into()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_login_list_round_trips_with_both_auth_methods() {
|
||||
let mut l = Logins::default();
|
||||
l.add(login(
|
||||
"https://a",
|
||||
"u",
|
||||
Auth::Token {
|
||||
salt: "s".into(),
|
||||
token: "t".into(),
|
||||
},
|
||||
));
|
||||
l.add(login("https://b", "v", Auth::Password("p".into())));
|
||||
let text = toml::to_string(&l).unwrap();
|
||||
assert!(text.contains("[[server]]"), "{text}");
|
||||
let back = parse_logins(&text).unwrap();
|
||||
assert_eq!(back, l);
|
||||
assert_eq!(back.active, 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn adding_the_same_login_again_replaces_it() {
|
||||
let mut l = Logins::default();
|
||||
l.add(login("https://a", "u", Auth::Password("old".into())));
|
||||
l.add(login("https://b", "u", Auth::Password("p".into())));
|
||||
l.add(login("https://a", "u", Auth::Password("new".into())));
|
||||
assert_eq!(l.servers.len(), 2);
|
||||
assert_eq!(l.active, 0);
|
||||
assert_eq!(*l.servers[0].client().auth(), Auth::Password("new".into()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn removing_keeps_the_active_server_where_it_can() {
|
||||
let mut l = Logins::default();
|
||||
for host in ["https://a", "https://b", "https://c"] {
|
||||
l.add(login(host, "u", Auth::Password("p".into())));
|
||||
}
|
||||
l.active = 2;
|
||||
l.remove(0);
|
||||
assert_eq!(l.active().unwrap().url, "https://c");
|
||||
l.remove(1);
|
||||
assert_eq!(l.active().unwrap().url, "https://b");
|
||||
l.remove(0);
|
||||
assert!(l.active().is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_out_of_range_active_index_falls_back_to_the_first() {
|
||||
let text = "active = 5\n[[server]]\nurl = \"https://a\"\nusername = \"u\"\npassword = \"p\"\n";
|
||||
assert_eq!(parse_logins(text).unwrap().active, 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn settings_default_when_fields_are_missing() {
|
||||
let s: Settings = toml::from_str("").unwrap();
|
||||
@@ -216,6 +370,7 @@ mod tests {
|
||||
assert_eq!(s.cover_backdrop, COVER_BACKDROP_DEFAULT);
|
||||
assert_eq!(s.volume, 100);
|
||||
assert!(!s.muted);
|
||||
assert!(s.show_hint_bar);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -223,6 +378,7 @@ mod tests {
|
||||
let s: Settings = toml::from_str("album_art_colours = true\n").unwrap();
|
||||
assert!(s.album_art_colours);
|
||||
assert_eq!(s.cover_backdrop, COVER_BACKDROP_DEFAULT);
|
||||
assert!(s.show_hint_bar);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -232,6 +388,7 @@ mod tests {
|
||||
cover_backdrop: 70,
|
||||
volume: 35,
|
||||
muted: true,
|
||||
show_hint_bar: false,
|
||||
};
|
||||
let back: Settings = toml::from_str(&toml::to_string(&s).unwrap()).unwrap();
|
||||
assert_eq!(back, s);
|
||||
|
||||
@@ -88,6 +88,7 @@ fn step(ui: slint::Weak<AppWindow>, steps: Vec<String>, i: usize) {
|
||||
"next" => Action::Next,
|
||||
"play-pause" => Action::PlayPause,
|
||||
"section-next" => Action::SectionNext,
|
||||
"section-prev" => Action::SectionPrev,
|
||||
"now-playing" => Action::NowPlaying,
|
||||
"search" => Action::Search,
|
||||
"quit" => Action::Quit,
|
||||
|
||||
@@ -5,6 +5,7 @@ mod config;
|
||||
mod devscript;
|
||||
mod inhibit;
|
||||
mod input;
|
||||
mod mpris;
|
||||
mod palette;
|
||||
mod player;
|
||||
mod prompts;
|
||||
|
||||
+368
@@ -0,0 +1,368 @@
|
||||
//! MPRIS on the session bus, so the desktop's media controls and media keys
|
||||
//! can drive playback. Headphone buttons arrive this way too: the desktop
|
||||
//! turns the key events of a headset or a Bluetooth AVRCP device into calls
|
||||
//! on the active MPRIS player. Reading those devices directly is not an
|
||||
//! option, since keyboard-like input devices are root:input and only
|
||||
//! gamepads are opened up to the logged-in user.
|
||||
//!
|
||||
//! A bus that cannot be reached, or a name already taken by another remus,
|
||||
//! is logged once and otherwise ignored.
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::{AtomicI64, Ordering};
|
||||
|
||||
use anyhow::Result;
|
||||
use tokio::runtime::Handle;
|
||||
use tokio::sync::watch;
|
||||
use zbus::interface;
|
||||
use zbus::zvariant::{ObjectPath, OwnedValue, Value};
|
||||
|
||||
const BUS_NAME: &str = "org.mpris.MediaPlayer2.remus";
|
||||
const PATH: &str = "/org/mpris/MediaPlayer2";
|
||||
const DESKTOP_ENTRY: &str = "me.anshorei.Fettleshed.Remus";
|
||||
|
||||
/// What a client asked for.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum Command {
|
||||
PlayPause,
|
||||
Play,
|
||||
Pause,
|
||||
Stop,
|
||||
Next,
|
||||
Previous,
|
||||
Quit,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
|
||||
pub enum Status {
|
||||
#[default]
|
||||
Stopped,
|
||||
Paused,
|
||||
Playing,
|
||||
}
|
||||
|
||||
impl Status {
|
||||
fn as_str(self) -> &'static str {
|
||||
match self {
|
||||
Status::Stopped => "Stopped",
|
||||
Status::Paused => "Paused",
|
||||
Status::Playing => "Playing",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, PartialEq)]
|
||||
pub struct Track {
|
||||
/// Position in the queue, which makes the track id.
|
||||
pub index: usize,
|
||||
pub title: String,
|
||||
pub artist: Option<String>,
|
||||
pub album: Option<String>,
|
||||
pub seconds: Option<u32>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, PartialEq)]
|
||||
pub struct NowPlaying {
|
||||
pub status: Status,
|
||||
pub track: Option<Track>,
|
||||
/// 0 to 1, already muted to 0.
|
||||
pub volume: f64,
|
||||
}
|
||||
|
||||
pub struct Mpris {
|
||||
state: watch::Sender<NowPlaying>,
|
||||
position: Arc<AtomicI64>,
|
||||
}
|
||||
|
||||
impl Mpris {
|
||||
pub fn spawn(rt: &Handle, on_command: impl Fn(Command) + Send + Sync + 'static) -> Mpris {
|
||||
let (state, rx) = watch::channel(NowPlaying::default());
|
||||
let position = Arc::new(AtomicI64::new(0));
|
||||
let pos = position.clone();
|
||||
let on_command: Arc<dyn Fn(Command) + Send + Sync> = Arc::new(on_command);
|
||||
rt.spawn(async move {
|
||||
if let Err(e) = run(rx, pos, on_command).await {
|
||||
log::warn!("MPRIS unavailable, media keys will not reach remus: {e:#}");
|
||||
}
|
||||
});
|
||||
Mpris { state, position }
|
||||
}
|
||||
|
||||
/// Publishes what is playing. Clients hear only about what changed.
|
||||
pub fn update(&self, now: NowPlaying) {
|
||||
self.state.send_if_modified(|s| {
|
||||
let changed = *s != now;
|
||||
*s = now;
|
||||
changed
|
||||
});
|
||||
}
|
||||
|
||||
/// Clients read the position when they want it; it sends no signal.
|
||||
pub fn set_position(&self, seconds: f64) {
|
||||
self.position.store((seconds * 1e6) as i64, Ordering::Relaxed);
|
||||
}
|
||||
}
|
||||
|
||||
async fn run(
|
||||
mut rx: watch::Receiver<NowPlaying>,
|
||||
position: Arc<AtomicI64>,
|
||||
on_command: Arc<dyn Fn(Command) + Send + Sync>,
|
||||
) -> Result<()> {
|
||||
let player = Player {
|
||||
now: rx.borrow().clone(),
|
||||
position,
|
||||
on_command: on_command.clone(),
|
||||
};
|
||||
let conn = zbus::connection::Builder::session()?
|
||||
.name(BUS_NAME)?
|
||||
.serve_at(PATH, Root { on_command })?
|
||||
.serve_at(PATH, player)?
|
||||
.build()
|
||||
.await?;
|
||||
log::info!("MPRIS player registered as {BUS_NAME}");
|
||||
let iface = conn.object_server().interface::<_, Player>(PATH).await?;
|
||||
while rx.changed().await.is_ok() {
|
||||
let now = rx.borrow_and_update().clone();
|
||||
let mut p = iface.get_mut().await;
|
||||
let status = p.now.status != now.status;
|
||||
let track = p.now.track != now.track;
|
||||
let volume = p.now.volume != now.volume;
|
||||
p.now = now;
|
||||
let emitter = iface.signal_emitter();
|
||||
if status {
|
||||
p.playback_status_changed(emitter).await?;
|
||||
}
|
||||
if track {
|
||||
p.metadata_changed(emitter).await?;
|
||||
p.can_play_changed(emitter).await?;
|
||||
p.can_pause_changed(emitter).await?;
|
||||
p.can_go_next_changed(emitter).await?;
|
||||
p.can_go_previous_changed(emitter).await?;
|
||||
}
|
||||
if volume {
|
||||
p.volume_changed(emitter).await?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
struct Root {
|
||||
on_command: Arc<dyn Fn(Command) + Send + Sync>,
|
||||
}
|
||||
|
||||
#[interface(name = "org.mpris.MediaPlayer2")]
|
||||
impl Root {
|
||||
fn raise(&self) {}
|
||||
|
||||
fn quit(&self) {
|
||||
(self.on_command)(Command::Quit);
|
||||
}
|
||||
|
||||
#[zbus(property)]
|
||||
fn can_quit(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
#[zbus(property)]
|
||||
fn can_raise(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
#[zbus(property)]
|
||||
fn has_track_list(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
#[zbus(property)]
|
||||
fn identity(&self) -> &str {
|
||||
"Remus"
|
||||
}
|
||||
|
||||
#[zbus(property)]
|
||||
fn desktop_entry(&self) -> &str {
|
||||
DESKTOP_ENTRY
|
||||
}
|
||||
|
||||
#[zbus(property)]
|
||||
fn supported_uri_schemes(&self) -> Vec<String> {
|
||||
Vec::new()
|
||||
}
|
||||
|
||||
#[zbus(property)]
|
||||
fn supported_mime_types(&self) -> Vec<String> {
|
||||
Vec::new()
|
||||
}
|
||||
}
|
||||
|
||||
struct Player {
|
||||
now: NowPlaying,
|
||||
position: Arc<AtomicI64>,
|
||||
on_command: Arc<dyn Fn(Command) + Send + Sync>,
|
||||
}
|
||||
|
||||
#[interface(name = "org.mpris.MediaPlayer2.Player")]
|
||||
impl Player {
|
||||
fn play_pause(&self) {
|
||||
(self.on_command)(Command::PlayPause);
|
||||
}
|
||||
|
||||
fn play(&self) {
|
||||
(self.on_command)(Command::Play);
|
||||
}
|
||||
|
||||
fn pause(&self) {
|
||||
(self.on_command)(Command::Pause);
|
||||
}
|
||||
|
||||
fn stop(&self) {
|
||||
(self.on_command)(Command::Stop);
|
||||
}
|
||||
|
||||
fn next(&self) {
|
||||
(self.on_command)(Command::Next);
|
||||
}
|
||||
|
||||
fn previous(&self) {
|
||||
(self.on_command)(Command::Previous);
|
||||
}
|
||||
|
||||
// CanSeek is false, so clients do not call these; they are part of the
|
||||
// interface all the same.
|
||||
fn seek(&self, _offset: i64) {}
|
||||
|
||||
fn set_position(&self, _track_id: ObjectPath<'_>, _position: i64) {}
|
||||
|
||||
fn open_uri(&self, _uri: &str) {}
|
||||
|
||||
#[zbus(property)]
|
||||
fn playback_status(&self) -> &str {
|
||||
self.now.status.as_str()
|
||||
}
|
||||
|
||||
#[zbus(property)]
|
||||
fn rate(&self) -> f64 {
|
||||
1.0
|
||||
}
|
||||
|
||||
#[zbus(property)]
|
||||
fn minimum_rate(&self) -> f64 {
|
||||
1.0
|
||||
}
|
||||
|
||||
#[zbus(property)]
|
||||
fn maximum_rate(&self) -> f64 {
|
||||
1.0
|
||||
}
|
||||
|
||||
#[zbus(property)]
|
||||
fn metadata(&self) -> HashMap<String, OwnedValue> {
|
||||
metadata(self.now.track.as_ref())
|
||||
}
|
||||
|
||||
#[zbus(property)]
|
||||
fn volume(&self) -> f64 {
|
||||
self.now.volume
|
||||
}
|
||||
|
||||
#[zbus(property(emits_changed_signal = "false"))]
|
||||
fn position(&self) -> i64 {
|
||||
self.position.load(Ordering::Relaxed)
|
||||
}
|
||||
|
||||
#[zbus(property)]
|
||||
fn can_go_next(&self) -> bool {
|
||||
self.now.track.is_some()
|
||||
}
|
||||
|
||||
#[zbus(property)]
|
||||
fn can_go_previous(&self) -> bool {
|
||||
self.now.track.is_some()
|
||||
}
|
||||
|
||||
#[zbus(property)]
|
||||
fn can_play(&self) -> bool {
|
||||
self.now.track.is_some()
|
||||
}
|
||||
|
||||
#[zbus(property)]
|
||||
fn can_pause(&self) -> bool {
|
||||
self.now.track.is_some()
|
||||
}
|
||||
|
||||
#[zbus(property)]
|
||||
fn can_seek(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
#[zbus(property(emits_changed_signal = "const"))]
|
||||
fn can_control(&self) -> bool {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
/// The MPRIS metadata map for a track, empty when nothing is loaded.
|
||||
fn metadata(track: Option<&Track>) -> HashMap<String, OwnedValue> {
|
||||
let mut m = HashMap::new();
|
||||
let Some(t) = track else {
|
||||
let none = ObjectPath::from_static_str_unchecked("/org/mpris/MediaPlayer2/TrackList/NoTrack");
|
||||
insert(&mut m, "mpris:trackid", Value::from(none));
|
||||
return m;
|
||||
};
|
||||
// Outside /org/mpris, which the spec reserves.
|
||||
let id = format!("/me/anshorei/Fettleshed/Remus/track/{}", t.index);
|
||||
if let Ok(path) = ObjectPath::try_from(id) {
|
||||
insert(&mut m, "mpris:trackid", Value::from(path));
|
||||
}
|
||||
insert(&mut m, "xesam:title", Value::from(t.title.clone()));
|
||||
if let Some(a) = &t.artist {
|
||||
insert(&mut m, "xesam:artist", Value::from(vec![a.clone()]));
|
||||
}
|
||||
if let Some(a) = &t.album {
|
||||
insert(&mut m, "xesam:album", Value::from(a.clone()));
|
||||
}
|
||||
if let Some(s) = t.seconds {
|
||||
insert(&mut m, "mpris:length", Value::from(s as i64 * 1_000_000));
|
||||
}
|
||||
m
|
||||
}
|
||||
|
||||
fn insert(m: &mut HashMap<String, OwnedValue>, key: &str, value: Value<'_>) {
|
||||
if let Ok(v) = OwnedValue::try_from(value) {
|
||||
m.insert(key.to_string(), v);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn metadata_without_a_track_says_so() {
|
||||
let m = metadata(None);
|
||||
assert_eq!(m.len(), 1);
|
||||
let id: ObjectPath = m["mpris:trackid"].clone().try_into().unwrap();
|
||||
assert_eq!(id.as_str(), "/org/mpris/MediaPlayer2/TrackList/NoTrack");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn metadata_carries_the_track() {
|
||||
let t = Track {
|
||||
index: 3,
|
||||
title: "Feijão".into(),
|
||||
artist: Some("Dr. Quandary".into()),
|
||||
album: None,
|
||||
seconds: Some(218),
|
||||
};
|
||||
let m = metadata(Some(&t));
|
||||
let title: String = m["xesam:title"].clone().try_into().unwrap();
|
||||
assert_eq!(title, "Feijão");
|
||||
let artists: Vec<String> = m["xesam:artist"].clone().try_into().unwrap();
|
||||
assert_eq!(artists, ["Dr. Quandary"]);
|
||||
let length: i64 = m["mpris:length"].clone().try_into().unwrap();
|
||||
assert_eq!(length, 218_000_000);
|
||||
assert!(!m.contains_key("xesam:album"));
|
||||
let id: ObjectPath = m["mpris:trackid"].clone().try_into().unwrap();
|
||||
assert_eq!(id.as_str(), "/me/anshorei/Fettleshed/Remus/track/3");
|
||||
}
|
||||
}
|
||||
+183
-7
@@ -2,6 +2,7 @@
|
||||
//! track can be handed to playbin in `about-to-finish`, which keeps playback
|
||||
//! gapless.
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::sync::{Arc, Mutex, MutexGuard};
|
||||
use std::thread::JoinHandle;
|
||||
@@ -11,13 +12,17 @@ use anyhow::{Context, Result};
|
||||
use gstreamer as gst;
|
||||
use gstreamer::prelude::*;
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum PlayerEvent {
|
||||
Position(f64),
|
||||
Duration(f64),
|
||||
Paused(bool),
|
||||
/// Index into the queue, None when playback has stopped.
|
||||
Track(Option<usize>),
|
||||
/// The picture embedded in a track's file, or None once it is clear the
|
||||
/// file has none. Sent once per track started, after its `Track`. A
|
||||
/// picture that turns up late is still sent, after the None.
|
||||
Art(usize, Option<Vec<u8>>),
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
@@ -33,14 +38,21 @@ struct Queue {
|
||||
seek_to: Option<f64>,
|
||||
}
|
||||
|
||||
/// Pictures found in the files being decoded, by URI.
|
||||
type Pictures = Arc<Mutex<HashMap<String, Vec<u8>>>>;
|
||||
|
||||
pub struct Player {
|
||||
playbin: gst::Element,
|
||||
queue: Arc<Mutex<Queue>>,
|
||||
pictures: Pictures,
|
||||
stop: Arc<AtomicBool>,
|
||||
bus_thread: Option<JoinHandle<()>>,
|
||||
}
|
||||
|
||||
const TICK: Duration = Duration::from_millis(250);
|
||||
/// How long after a track starts its tags can still bring a picture. Tags
|
||||
/// come ahead of the audio, so this is mostly a slow server's margin.
|
||||
const ART_WAIT: Duration = Duration::from_millis(600);
|
||||
|
||||
impl Player {
|
||||
pub fn spawn(on_event: impl Fn(PlayerEvent) + Send + 'static) -> Result<Player> {
|
||||
@@ -71,15 +83,19 @@ impl Player {
|
||||
None
|
||||
});
|
||||
|
||||
let pictures = Pictures::default();
|
||||
watch_pictures(&playbin, &pictures);
|
||||
|
||||
let stop = Arc::new(AtomicBool::new(false));
|
||||
let bus_thread = std::thread::Builder::new().name("gst-bus".into()).spawn({
|
||||
let (playbin, queue, stop) = (playbin.clone(), queue.clone(), stop.clone());
|
||||
move || watch_bus(&playbin, &queue, &stop, &on_event)
|
||||
let (playbin, queue, pictures, stop) = (playbin.clone(), queue.clone(), pictures.clone(), stop.clone());
|
||||
move || watch_bus(&playbin, &queue, &pictures, &stop, &on_event)
|
||||
})?;
|
||||
|
||||
Ok(Player {
|
||||
playbin,
|
||||
queue,
|
||||
pictures,
|
||||
stop,
|
||||
bus_thread: Some(bus_thread),
|
||||
})
|
||||
@@ -143,6 +159,14 @@ impl Player {
|
||||
start(&self.playbin, &url);
|
||||
}
|
||||
|
||||
/// Stops playback and forgets the queue, as when switching server. Going
|
||||
/// to Null flushes the bus, so nothing from the old track reports later.
|
||||
pub fn stop(&self) {
|
||||
*lock(&self.queue) = Queue::default();
|
||||
lock(&self.pictures).clear();
|
||||
let _ = self.playbin.set_state(gst::State::Null);
|
||||
}
|
||||
|
||||
pub fn toggle_pause(&self) {
|
||||
// Toggles where the pipeline is heading, so play pressed while a
|
||||
// paused track is still loading is not lost.
|
||||
@@ -206,8 +230,53 @@ impl Drop for Player {
|
||||
}
|
||||
}
|
||||
|
||||
fn lock(q: &Mutex<Queue>) -> MutexGuard<'_, Queue> {
|
||||
q.lock().unwrap_or_else(|e| e.into_inner())
|
||||
fn lock<T>(m: &Mutex<T>) -> MutexGuard<'_, T> {
|
||||
m.lock().unwrap_or_else(|e| e.into_inner())
|
||||
}
|
||||
|
||||
/// Records the picture in each file playbin decodes, keyed by its URI. Read
|
||||
/// where each file's decoder hands on its stream, because further down the
|
||||
/// tags of a file without a picture still carry the previous file's, once
|
||||
/// playback moves on gaplessly.
|
||||
fn watch_pictures(playbin: &gst::Element, pictures: &Pictures) {
|
||||
let Some(bin) = playbin.downcast_ref::<gst::Bin>() else {
|
||||
return;
|
||||
};
|
||||
let pictures = pictures.clone();
|
||||
bin.connect_deep_element_added(move |_, _, element| {
|
||||
let decoder = element
|
||||
.factory()
|
||||
.is_some_and(|f| matches!(f.name().as_str(), "uridecodebin" | "uridecodebin3"));
|
||||
// playbin adds the same decoder again for later tracks.
|
||||
// SAFETY: the key is only ever set to a bool, here.
|
||||
if !decoder || unsafe { element.data::<bool>("remus-pictures") }.is_some() {
|
||||
return;
|
||||
}
|
||||
unsafe { element.set_data("remus-pictures", true) };
|
||||
let pictures = pictures.clone();
|
||||
element.connect_pad_added(move |decoder, pad| {
|
||||
let decoder = decoder.downgrade();
|
||||
let pictures = pictures.clone();
|
||||
pad.add_probe(gst::PadProbeType::EVENT_DOWNSTREAM, move |_, info| {
|
||||
if let Some(gst::PadProbeData::Event(ev)) = &info.data
|
||||
&& let gst::EventView::Tag(t) = ev.view()
|
||||
&& let Some(bytes) = embedded_picture(t.tag())
|
||||
&& let Some(uri) = decoder.upgrade().and_then(|d| d.property::<Option<String>>("uri"))
|
||||
{
|
||||
lock(&pictures).entry(uri).or_insert(bytes);
|
||||
}
|
||||
gst::PadProbeReturn::Ok
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/// The track whose picture is still being looked for.
|
||||
struct ArtWait {
|
||||
index: usize,
|
||||
since: Instant,
|
||||
/// Already reported as without a picture; one turning up later is still sent.
|
||||
told_none: bool,
|
||||
}
|
||||
|
||||
fn start(playbin: &gst::Element, url: &str) {
|
||||
@@ -239,7 +308,13 @@ fn seek_to(playbin: &gst::Element, seconds: f64) {
|
||||
}
|
||||
}
|
||||
|
||||
fn watch_bus(playbin: &gst::Element, queue: &Mutex<Queue>, stop: &AtomicBool, emit: &dyn Fn(PlayerEvent)) {
|
||||
fn watch_bus(
|
||||
playbin: &gst::Element,
|
||||
queue: &Mutex<Queue>,
|
||||
pictures: &Pictures,
|
||||
stop: &AtomicBool,
|
||||
emit: &dyn Fn(PlayerEvent),
|
||||
) {
|
||||
let Some(bus) = playbin.bus() else { return };
|
||||
let mut last_tick = Instant::now();
|
||||
let mut duration = 0.0;
|
||||
@@ -252,8 +327,12 @@ fn watch_bus(playbin: &gst::Element, queue: &Mutex<Queue>, stop: &AtomicBool, em
|
||||
last_track = Some(t);
|
||||
emit(PlayerEvent::Track(t));
|
||||
emit(PlayerEvent::Position(0.0));
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
};
|
||||
let mut art_wait: Option<ArtWait> = None;
|
||||
while !stop.load(Ordering::Relaxed) {
|
||||
if let Some(msg) = bus.timed_pop(gst::ClockTime::from_mseconds(TICK.as_millis() as u64)) {
|
||||
use gst::MessageView;
|
||||
@@ -271,7 +350,24 @@ fn watch_bus(playbin: &gst::Element, queue: &Mutex<Queue>, stop: &AtomicBool, em
|
||||
(q.current, started)
|
||||
};
|
||||
duration = 0.0;
|
||||
report_track(current, started);
|
||||
if report_track(current, started) {
|
||||
art_wait = current.map(|index| ArtWait {
|
||||
index,
|
||||
since: Instant::now(),
|
||||
told_none: false,
|
||||
});
|
||||
// Keep only what this track and the next may still need.
|
||||
let keep: Vec<String> = {
|
||||
let q = lock(queue);
|
||||
current
|
||||
.into_iter()
|
||||
.flat_map(|i| q.urls.get(i..=i + 1))
|
||||
.flatten()
|
||||
.cloned()
|
||||
.collect()
|
||||
};
|
||||
lock(pictures).retain(|uri, _| keep.contains(uri));
|
||||
}
|
||||
}
|
||||
MessageView::StateChanged(s) if s.src() == Some(playbin.upcast_ref()) => match s.current() {
|
||||
gst::State::Playing => emit(PlayerEvent::Paused(false)),
|
||||
@@ -296,6 +392,7 @@ fn watch_bus(playbin: &gst::Element, queue: &Mutex<Queue>, stop: &AtomicBool, em
|
||||
}
|
||||
let _ = playbin.set_state(gst::State::Ready);
|
||||
report_track(None, false);
|
||||
art_wait = None;
|
||||
}
|
||||
// A failing source posts several errors. Once the first has moved
|
||||
// on to the next track, the source is out of playbin and the rest
|
||||
@@ -329,11 +426,23 @@ fn watch_bus(playbin: &gst::Element, queue: &Mutex<Queue>, stop: &AtomicBool, em
|
||||
} else {
|
||||
let _ = playbin.set_state(gst::State::Ready);
|
||||
report_track(None, false);
|
||||
art_wait = None;
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
if let Some(w) = &mut art_wait {
|
||||
let url = lock(queue).urls.get(w.index).cloned();
|
||||
let picture = url.and_then(|u| lock(pictures).get(&u).cloned());
|
||||
if picture.is_some() {
|
||||
emit(PlayerEvent::Art(w.index, picture));
|
||||
art_wait = None;
|
||||
} else if !w.told_none && w.since.elapsed() >= ART_WAIT {
|
||||
w.told_none = true;
|
||||
emit(PlayerEvent::Art(w.index, None));
|
||||
}
|
||||
}
|
||||
if last_tick.elapsed() >= TICK {
|
||||
last_tick = Instant::now();
|
||||
if playbin.current_state() == gst::State::Playing {
|
||||
@@ -351,6 +460,22 @@ fn watch_bus(playbin: &gst::Element, queue: &Mutex<Queue>, stop: &AtomicBool, em
|
||||
}
|
||||
}
|
||||
|
||||
/// The front cover among the pictures in `tags`, else the first picture.
|
||||
fn embedded_picture(tags: &gst::TagListRef) -> Option<Vec<u8>> {
|
||||
// GST_TAG_IMAGE_TYPE_FRONT_COVER in gst-tag's GstTagImageType.
|
||||
const FRONT_COVER: i32 = 1;
|
||||
let is_front = |s: &gst::Sample| {
|
||||
s.info()
|
||||
.and_then(|i| i.value("image-type").ok())
|
||||
.and_then(|v| gst::glib::EnumValue::from_value(v))
|
||||
.is_some_and(|(_, v)| v.value() == FRONT_COVER)
|
||||
};
|
||||
let pictures: Vec<gst::Sample> = tags.iter_tag::<gst::tags::Image>().map(|v| v.get()).collect();
|
||||
let sample = pictures.iter().find(|s| is_front(s)).or(pictures.first())?;
|
||||
let map = sample.buffer()?.map_readable().ok()?;
|
||||
Some(map.as_slice().to_vec())
|
||||
}
|
||||
|
||||
/// Removes the query string from any URL in `text`. Stream URLs carry the
|
||||
/// Subsonic auth token, and GStreamer's HTTP errors quote the URL.
|
||||
fn strip_queries(text: &str) -> String {
|
||||
@@ -418,6 +543,57 @@ mod tests {
|
||||
format!("file://{}", path.display())
|
||||
}
|
||||
|
||||
/// Puts an ID3v2.3 tag holding `picture` as the front cover before the
|
||||
/// file at `uri`, as a tagged MP3 would carry it.
|
||||
fn with_id3_picture(uri: &str, picture: &[u8]) {
|
||||
let path = uri.strip_prefix("file://").unwrap();
|
||||
let mut body = vec![0u8]; // Latin-1 text
|
||||
body.extend_from_slice(b"image/png\0");
|
||||
body.push(3); // front cover
|
||||
body.push(0); // empty description
|
||||
body.extend_from_slice(picture);
|
||||
let mut frame = b"APIC".to_vec();
|
||||
frame.extend_from_slice(&(body.len() as u32).to_be_bytes());
|
||||
frame.extend_from_slice(&[0, 0]);
|
||||
frame.extend_from_slice(&body);
|
||||
let n = frame.len() as u32;
|
||||
let syncsafe = [(n >> 21) & 0x7f, (n >> 14) & 0x7f, (n >> 7) & 0x7f, n & 0x7f].map(|b| b as u8);
|
||||
let mut tagged = b"ID3\x03\x00\x00".to_vec();
|
||||
tagged.extend_from_slice(&syncsafe);
|
||||
tagged.extend_from_slice(&frame);
|
||||
tagged.extend_from_slice(&std::fs::read(path).unwrap());
|
||||
std::fs::write(path, tagged).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn reports_the_picture_in_each_file() {
|
||||
// SAFETY: set before any thread reads the environment in this test.
|
||||
unsafe { std::env::set_var("REMUS_AUDIO_SINK", "fakesink") };
|
||||
let dir = std::env::temp_dir().join(format!("remus-player-art-{}", std::process::id()));
|
||||
std::fs::create_dir_all(&dir).unwrap();
|
||||
let urls = vec![silent_wav(&dir, "a.wav", 1.0), silent_wav(&dir, "b.wav", 1.0)];
|
||||
let mut png = Vec::new();
|
||||
image::RgbImage::from_pixel(4, 4, image::Rgb([200, 30, 30]))
|
||||
.write_to(&mut std::io::Cursor::new(&mut png), image::ImageFormat::Png)
|
||||
.unwrap();
|
||||
with_id3_picture(&urls[0], &png);
|
||||
|
||||
let (tx, rx) = mpsc::channel();
|
||||
let player = Player::spawn(move |ev| {
|
||||
if let PlayerEvent::Art(i, bytes) = ev {
|
||||
let _ = tx.send((i, bytes));
|
||||
}
|
||||
})
|
||||
.unwrap();
|
||||
player.play_list(&urls, 0);
|
||||
let first = rx.recv_timeout(Duration::from_secs(5));
|
||||
let second = rx.recv_timeout(Duration::from_secs(5));
|
||||
drop(player);
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
assert_eq!(first, Ok((0, Some(png))), "the tagged file's picture");
|
||||
assert_eq!(second, Ok((1, None)), "the plain file has none");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn plays_a_queue_through_to_the_end() {
|
||||
// SAFETY: set before any thread reads the environment in this test.
|
||||
|
||||
+136
-48
@@ -567,6 +567,55 @@ component Speaker {
|
||||
}
|
||||
}
|
||||
|
||||
// A quiet speaker, bar and number for the current volume.
|
||||
component VolumeLevel inherits HorizontalLayout {
|
||||
in property <int> level;
|
||||
in property <bool> muted;
|
||||
in property <length> font-size: 13px * Theme.s;
|
||||
// The speaker gets a box as wide as the number, so the bar is the middle
|
||||
// of the whole and centring the row centres the bar.
|
||||
in property <bool> balanced;
|
||||
// Fixed, so the bar does not shift as the number changes, and wide enough
|
||||
// for "Muted".
|
||||
property <length> label-width: 4.2 * root.font-size;
|
||||
spacing: 10px * Theme.s;
|
||||
// Its own width only, so a stretching row does not hand it the slack.
|
||||
horizontal-stretch: 0;
|
||||
|
||||
HorizontalLayout {
|
||||
width: root.balanced ? root.label-width : 14px * Theme.s;
|
||||
alignment: end;
|
||||
Speaker {
|
||||
muted: root.muted || root.level == 0;
|
||||
tint: Theme.muted;
|
||||
size: 14px * Theme.s;
|
||||
y: (parent.height - self.height) / 2;
|
||||
}
|
||||
}
|
||||
VerticalLayout {
|
||||
alignment: center;
|
||||
Rectangle {
|
||||
width: 90px * Theme.s;
|
||||
height: 4px * Theme.s;
|
||||
border-radius: 2px * Theme.s;
|
||||
background: Theme.raised;
|
||||
Rectangle {
|
||||
x: 0;
|
||||
width: parent.width * (root.muted ? 0 : root.level / 100);
|
||||
border-radius: 2px * Theme.s;
|
||||
background: Theme.muted;
|
||||
}
|
||||
}
|
||||
}
|
||||
Text {
|
||||
width: root.label-width;
|
||||
text: root.muted ? "Muted" : root.level;
|
||||
font-size: root.font-size;
|
||||
color: Theme.muted;
|
||||
vertical-alignment: center;
|
||||
}
|
||||
}
|
||||
|
||||
// The level after a volume change, faded out again by the app after a moment.
|
||||
component VolumeOverlay inherits Rectangle {
|
||||
in property <bool> shown;
|
||||
@@ -633,6 +682,8 @@ component NowBar inherits Rectangle {
|
||||
in property <float> progress;
|
||||
in property <string> time;
|
||||
in property <bool> paused;
|
||||
in property <int> volume;
|
||||
in property <bool> muted;
|
||||
|
||||
background: Theme.panel;
|
||||
|
||||
@@ -699,6 +750,12 @@ component NowBar inherits Rectangle {
|
||||
size: 15px * Theme.s;
|
||||
}
|
||||
}
|
||||
if root.has-track: Rectangle { width: 6px * Theme.s; }
|
||||
if root.has-track: VolumeLevel {
|
||||
level: root.volume;
|
||||
muted: root.muted;
|
||||
font-size: 15px * Theme.s;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -750,6 +807,8 @@ component Field inherits VerticalLayout {
|
||||
in property <string> label;
|
||||
in-out property <string> text;
|
||||
in property <bool> password;
|
||||
// A password field shows its text while this is set, toggled by the eye.
|
||||
in-out property <bool> shown;
|
||||
in property <bool> highlighted;
|
||||
callback accepted;
|
||||
public function focus-input() {
|
||||
@@ -770,16 +829,55 @@ component Field inherits VerticalLayout {
|
||||
border-color: input.has-focus || root.highlighted ? Theme.focus : Theme.line;
|
||||
input := TextInput {
|
||||
x: 16px * Theme.s;
|
||||
width: parent.width - 32px * Theme.s;
|
||||
// Leaves room for the eye on a password field.
|
||||
width: parent.width - (root.password ? 64px : 32px) * Theme.s;
|
||||
height: parent.height;
|
||||
text <=> root.text;
|
||||
font-size: 19px * Theme.s;
|
||||
color: Theme.text;
|
||||
vertical-alignment: center;
|
||||
single-line: true;
|
||||
input-type: root.password ? InputType.password : InputType.text;
|
||||
input-type: root.password && !root.shown ? InputType.password : InputType.text;
|
||||
accepted => { root.accepted(); }
|
||||
}
|
||||
if root.password: Rectangle {
|
||||
x: parent.width - self.width - 8px * Theme.s;
|
||||
width: 40px * Theme.s;
|
||||
height: parent.height;
|
||||
// An eye to show the password, struck through to hide it again.
|
||||
Path {
|
||||
width: 22px * Theme.s;
|
||||
height: 22px * Theme.s;
|
||||
viewbox-width: 24;
|
||||
viewbox-height: 24;
|
||||
commands: "M 1.5 12 C 4.5 6.5 8 4.5 12 4.5 C 16 4.5 19.5 6.5 22.5 12 C 19.5 17.5 16 19.5 12 19.5 C 8 19.5 4.5 17.5 1.5 12 Z";
|
||||
stroke: eye-area.has-hover ? Theme.text : Theme.muted;
|
||||
stroke-width: 1.6px * Theme.s;
|
||||
}
|
||||
Path {
|
||||
width: 22px * Theme.s;
|
||||
height: 22px * Theme.s;
|
||||
viewbox-width: 24;
|
||||
viewbox-height: 24;
|
||||
commands: "M 12 8.5 A 3.5 3.5 0 1 1 11.99 8.5 Z";
|
||||
fill: eye-area.has-hover ? Theme.text : Theme.muted;
|
||||
}
|
||||
if root.shown: Path {
|
||||
width: 22px * Theme.s;
|
||||
height: 22px * Theme.s;
|
||||
viewbox-width: 24;
|
||||
viewbox-height: 24;
|
||||
commands: "M 3 21 L 21 3";
|
||||
stroke: eye-area.has-hover ? Theme.text : Theme.muted;
|
||||
stroke-width: 1.8px * Theme.s;
|
||||
}
|
||||
eye-area := TouchArea {
|
||||
clicked => {
|
||||
root.shown = !root.shown;
|
||||
input.focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -787,9 +885,12 @@ component LoginView inherits Rectangle {
|
||||
in-out property <string> server;
|
||||
in-out property <string> username;
|
||||
in-out property <string> password;
|
||||
in-out property <bool> password-shown;
|
||||
in property <int> focus-index;
|
||||
in property <string> error;
|
||||
in property <bool> busy;
|
||||
// Adding a server from inside the app: the bottom button goes back.
|
||||
in property <bool> can-cancel;
|
||||
callback submit;
|
||||
callback exit;
|
||||
callback field-clicked(int);
|
||||
@@ -845,6 +946,7 @@ component LoginView inherits Rectangle {
|
||||
label: "Password";
|
||||
text <=> root.password;
|
||||
password: true;
|
||||
shown <=> root.password-shown;
|
||||
highlighted: root.focus-index == 2;
|
||||
accepted => { root.submit(); }
|
||||
}
|
||||
@@ -869,7 +971,7 @@ component LoginView inherits Rectangle {
|
||||
border-width: 2px * Theme.s;
|
||||
border-color: root.focus-index == 4 ? Theme.focus : Theme.line;
|
||||
Text {
|
||||
text: "Exit";
|
||||
text: root.can-cancel ? "Cancel" : "Exit";
|
||||
font-size: 17px * Theme.s;
|
||||
color: root.focus-index == 4 ? Theme.text : Theme.muted;
|
||||
}
|
||||
@@ -992,60 +1094,37 @@ component NowPlayingView inherits Rectangle {
|
||||
background: Theme.highlight;
|
||||
}
|
||||
}
|
||||
HorizontalLayout {
|
||||
Text {
|
||||
// Placed by hand: the icon on the bar's midpoint whatever the
|
||||
// widths of the two times, which a layout would share out.
|
||||
Rectangle {
|
||||
height: position-text.preferred-height;
|
||||
position-text := Text {
|
||||
x: 0;
|
||||
width: self.preferred-width;
|
||||
text: root.position;
|
||||
font-size: 14px * Theme.s;
|
||||
color: Theme.muted;
|
||||
}
|
||||
// Sized below the time text, so the row keeps the text's height.
|
||||
HorizontalLayout {
|
||||
horizontal-stretch: 1;
|
||||
alignment: center;
|
||||
if root.has-track: VerticalLayout {
|
||||
alignment: center;
|
||||
PlayState {
|
||||
paused: root.paused;
|
||||
size: 11px * Theme.s;
|
||||
}
|
||||
}
|
||||
}
|
||||
Text {
|
||||
x: parent.width - self.width;
|
||||
width: self.preferred-width;
|
||||
text: root.duration;
|
||||
font-size: 14px * Theme.s;
|
||||
color: Theme.muted;
|
||||
}
|
||||
if root.has-track: PlayState {
|
||||
x: (parent.width - self.width) / 2;
|
||||
y: (parent.height - self.height) / 2;
|
||||
paused: root.paused;
|
||||
size: 11px * Theme.s;
|
||||
}
|
||||
}
|
||||
HorizontalLayout {
|
||||
spacing: 10px * Theme.s;
|
||||
alignment: start;
|
||||
VerticalLayout {
|
||||
alignment: center;
|
||||
Speaker {
|
||||
muted: root.muted || root.volume == 0;
|
||||
tint: Theme.muted;
|
||||
size: 14px * Theme.s;
|
||||
}
|
||||
}
|
||||
VerticalLayout {
|
||||
alignment: center;
|
||||
Rectangle {
|
||||
width: 90px * Theme.s;
|
||||
height: 4px * Theme.s;
|
||||
border-radius: 2px * Theme.s;
|
||||
background: Theme.raised;
|
||||
Rectangle {
|
||||
x: 0;
|
||||
width: parent.width * (root.muted ? 0 : root.volume / 100);
|
||||
border-radius: 2px * Theme.s;
|
||||
background: Theme.muted;
|
||||
}
|
||||
}
|
||||
}
|
||||
Text {
|
||||
text: root.muted ? "Muted" : root.volume;
|
||||
font-size: 13px * Theme.s;
|
||||
color: Theme.muted;
|
||||
alignment: center;
|
||||
VolumeLevel {
|
||||
level: root.volume;
|
||||
muted: root.muted;
|
||||
balanced: true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1118,6 +1197,8 @@ export component AppWindow inherits Window {
|
||||
in property <int> login-focus;
|
||||
in property <string> login-error;
|
||||
in property <bool> login-busy;
|
||||
in property <bool> login-can-cancel;
|
||||
in-out property <bool> login-password-shown;
|
||||
|
||||
// Browse
|
||||
in property <[string]> sections;
|
||||
@@ -1165,6 +1246,7 @@ export component AppWindow inherits Window {
|
||||
in property <int> volume;
|
||||
in property <bool> muted;
|
||||
in property <string> version;
|
||||
in property <bool> show-hint-bar: true;
|
||||
|
||||
public function focus-main() {
|
||||
fs.focus();
|
||||
@@ -1236,11 +1318,13 @@ export component AppWindow inherits Window {
|
||||
server <=> root.login-server;
|
||||
username <=> root.login-username;
|
||||
password <=> root.login-password;
|
||||
password-shown <=> root.login-password-shown;
|
||||
focus-index: root.login-focus;
|
||||
error: root.login-error;
|
||||
busy: root.login-busy;
|
||||
submit => { root.login-submit(); }
|
||||
exit => { root.action(Action.quit); }
|
||||
can-cancel: root.login-can-cancel;
|
||||
exit => { root.action(root.login-can-cancel ? Action.back : Action.quit); }
|
||||
field-clicked(i) => { root.login-field-clicked(i); }
|
||||
}
|
||||
|
||||
@@ -1374,9 +1458,13 @@ export component AppWindow inherits Window {
|
||||
progress: root.np-progress;
|
||||
time: root.np-position + " / " + root.np-duration;
|
||||
paused: root.np-paused;
|
||||
volume: root.volume;
|
||||
muted: root.muted;
|
||||
}
|
||||
|
||||
HintBar {
|
||||
// Optional, except on the login screen, where the controls are
|
||||
// not known yet and Settings cannot be reached.
|
||||
if root.show-hint-bar || root.screen == Screen.login: HintBar {
|
||||
height: 46px * Theme.s;
|
||||
hints: root.hints;
|
||||
version: root.version;
|
||||
|
||||
Reference in New Issue
Block a user