Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f6e303bd0f | ||
|
|
d0f1b6c95a | ||
|
|
c6944041ea | ||
|
|
f03374b585 | ||
|
|
5bb42ba834 | ||
|
|
07214f1827 | ||
|
|
885ca01ff7 |
@@ -2,6 +2,49 @@
|
||||
|
||||
One section per version, newest first.
|
||||
|
||||
## v0.10.4 (2026-11-07)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
- The dock and taskbar show the remus icon for its window. The window now carries the app id me.anshorei.Fettleshed.Remus, which links it to the installed desktop file.
|
||||
|
||||
## v0.10.3 (2026-11-07)
|
||||
|
||||
### Features
|
||||
|
||||
- Settings has a Controls page listing every button and key, grouped by where it works, drawn for the controller in use or the keyboard.
|
||||
- The controls bar shows only the controls that depend on the selection or the screen. Back, Play / Pause, Sections, Now playing, Search, Skip, Seek, Volume and Mute, and Select where it only opens something, are on the Controls page instead. The login screen is unchanged.
|
||||
|
||||
## v0.10.2 (2026-11-06)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
- Leaving the last logged-in server while music plays, by logging out, forgetting it or a turned-down saved login, lets the screensaver run again on the login screen. Logging in after that starts with no leftover pause, position or restore state from the old queue.
|
||||
|
||||
## v0.10.1 (2026-11-06)
|
||||
|
||||
### Features
|
||||
|
||||
- Exit on the login screen is an X in the top right corner of the card instead of a button under Connect, which makes the card shorter. Up from the address field reaches it on a controller. When adding a server it cancels, as the button did.
|
||||
|
||||
## v0.10.0 (2026-11-06)
|
||||
|
||||
### Features
|
||||
|
||||
- A saved server in Settings can be logged out of or forgotten. The queue button opens a prompt naming the server, with Cancel selected. Log out drops the token or password and keeps the address and username. Forget removes the server, its saved queue and its cached covers. Both replace the double-press Remove.
|
||||
- The login screen lists the saved servers beside the form. Picking one fills in its address and username and moves to the password. Selecting a logged-out server in Settings opens the same prefilled form, and logging in again reuses its entry.
|
||||
- A saved login that the server turns down at startup is logged out, and the login screen opens prefilled with it instead of showing load errors.
|
||||
|
||||
### Bug fixes
|
||||
|
||||
- An http and an https login to the same host and user are labelled apart: the scheme is shown for http.
|
||||
|
||||
## v0.9.1 (2026-11-06)
|
||||
|
||||
### Features
|
||||
|
||||
- The dev script (REMUS_DEV_SCRIPT) has a fullscreen step that toggles fullscreen and a key:f11 step that presses F11. With RUST_LOG=remus=debug, each toggle logs whether the window was fullscreen and its size.
|
||||
|
||||
## v0.9.0 (2026-11-05)
|
||||
|
||||
### Features
|
||||
|
||||
Generated
+1
-1
@@ -4385,7 +4385,7 @@ checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4"
|
||||
|
||||
[[package]]
|
||||
name = "remus"
|
||||
version = "0.9.0"
|
||||
version = "0.10.4"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"directories",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "remus"
|
||||
version = "0.9.0"
|
||||
version = "0.10.4"
|
||||
edition = "2024"
|
||||
license = "MIT"
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ cargo run --release # fullscreen
|
||||
cargo run --release -- --windowed
|
||||
```
|
||||
|
||||
On first start remus asks for the server address, username and password. It stores the address, the username and an auth token (md5 of password + salt) in `~/.config/remus/config.toml`, mode 0600. The token is enough to log in to that server, so treat the file as a credential. Delete it to log in again.
|
||||
On first start remus asks for the server address, username and password. It stores the address, the username and an auth token (md5 of password + salt) in `~/.config/remus/config.toml`, mode 0600. The token is enough to log in to that server, so treat the file as a credential. To log in again, or to remove a server, select it under Settings and press the queue button (Y on a controller, Q on a keyboard). Log out drops the token and keeps the address and username, so the login screen lists the server and only asks for the password. Forget removes the server along with its saved queue and cached covers. If the server stops accepting the saved token, remus logs it out at startup and asks for the password.
|
||||
|
||||
Some servers refuse token logins (Subsonic error 41), Nextcloud Music among them. For those remus logs in with the password itself and stores that in `config.toml` instead of a token, still mode 0600. Nextcloud Music wants the API password generated in its Music settings, not the Nextcloud login password.
|
||||
|
||||
@@ -62,6 +62,8 @@ A bundle does not update itself. To update, install the next version's bundle th
|
||||
| | F11 | Toggle fullscreen |
|
||||
| | Ctrl+Q | Quit |
|
||||
|
||||
Settings has a Controls page with the same list, drawn with the buttons of the controller in use or the keyboard keys. The controls bar at the bottom shows only what depends on the selection, such as Add to queue on an album or Log out on a server. What works the same everywhere is left to the Controls page. The login screen shows all of its controls, since Settings cannot be reached from there.
|
||||
|
||||
With Steam running, remus listens only to Steam's virtual controller, so a pad Steam also exposes does not send every press twice. On a Deck, Steam + X opens the on-screen keyboard for the login and search fields.
|
||||
|
||||
## Development
|
||||
|
||||
@@ -8,3 +8,4 @@ Terminal=false
|
||||
Categories=AudioVideo;Audio;Player;
|
||||
Keywords=music;subsonic;navidrome;player;
|
||||
StartupNotify=true
|
||||
StartupWMClass=me.anshorei.Fettleshed.Remus
|
||||
|
||||
@@ -20,6 +20,12 @@
|
||||
</supports>
|
||||
<content_rating type="oars-1.1"/>
|
||||
<releases>
|
||||
<release version="0.10.4" date="2026-11-07"/>
|
||||
<release version="0.10.3" date="2026-11-07"/>
|
||||
<release version="0.10.2" date="2026-11-06"/>
|
||||
<release version="0.10.1" date="2026-11-06"/>
|
||||
<release version="0.10.0" date="2026-11-06"/>
|
||||
<release version="0.9.1" date="2026-11-06"/>
|
||||
<release version="0.9.0" date="2026-11-05"/>
|
||||
<release version="0.8.7" date="2026-11-04"/>
|
||||
<release version="0.8.6" date="2026-11-04"/>
|
||||
|
||||
+552
-80
@@ -25,7 +25,7 @@ use crate::prompts::{self, Control, Family, Prompts};
|
||||
use crate::saved_queue::{self, SavedQueue, SavedQueues};
|
||||
use crate::shuffle::{self, Library, Mode};
|
||||
use crate::subsonic::{self, Album, Artist, Client, Playlist, SearchResult, Song};
|
||||
use crate::{Action, AppWindow, Area, Header, Hint, Item, Screen, Theme};
|
||||
use crate::{Action, AppWindow, Area, Header, Hint, Item, KnownServer, Screen, Theme};
|
||||
|
||||
thread_local! {
|
||||
static APP: RefCell<Option<App>> = const { RefCell::new(None) };
|
||||
@@ -57,6 +57,8 @@ pub fn install(ui: &AppWindow, rt: Handle) {
|
||||
ui.on_search_accepted(|q| with_app(move |app| app.run_search(q.to_string())));
|
||||
ui.on_login_submit(|| with_app(|app| app.login_submit()));
|
||||
ui.on_login_field_clicked(|i| with_app(move |app| app.set_login_focus(i)));
|
||||
ui.on_login_known_clicked(|i| with_app(move |app| app.pick_known(i.max(0) as usize)));
|
||||
ui.on_confirm_clicked(|i| with_app(move |app| app.confirm_clicked(i.max(0) as usize)));
|
||||
ui.on_layout_changed(|| with_app(|app| app.sync_items(true)));
|
||||
|
||||
with_app(|app| app.start());
|
||||
@@ -129,6 +131,8 @@ enum Target {
|
||||
/// Starts library shuffle.
|
||||
ShuffleAll,
|
||||
Setting(Setting),
|
||||
/// A row of the Controls page, by index into `CONTROL_ROWS`.
|
||||
ControlRow(usize),
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
@@ -141,6 +145,147 @@ enum Setting {
|
||||
/// A saved login, by index into `Logins::servers`.
|
||||
Server(usize),
|
||||
AddServer,
|
||||
/// Opens the Controls page.
|
||||
Controls,
|
||||
}
|
||||
|
||||
/// What a row of the Controls page shows on its right.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
enum Keys {
|
||||
/// The control's icons, as the controls bar draws them.
|
||||
Icons(Control),
|
||||
/// Written out, for controls without icons: on a keyboard, then on a
|
||||
/// controller. Empty where there is none.
|
||||
Text(&'static str, &'static str),
|
||||
}
|
||||
|
||||
struct ControlRow {
|
||||
/// Where it works: the rows are listed in groups, in this order.
|
||||
group: &'static str,
|
||||
label: &'static str,
|
||||
keys: Keys,
|
||||
}
|
||||
|
||||
/// Every control, for the Controls page in Settings. The controls bar shows
|
||||
/// only what depends on the selection; the rest is learned here.
|
||||
const CONTROL_ROWS: &[ControlRow] = &[
|
||||
ControlRow {
|
||||
group: "Everywhere",
|
||||
label: "Move",
|
||||
keys: Keys::Text("Arrow keys", "D-pad or left stick"),
|
||||
},
|
||||
ControlRow {
|
||||
group: "Everywhere",
|
||||
label: "Select",
|
||||
keys: Keys::Icons(Control::Activate),
|
||||
},
|
||||
ControlRow {
|
||||
group: "Everywhere",
|
||||
label: "Back",
|
||||
keys: Keys::Icons(Control::Back),
|
||||
},
|
||||
ControlRow {
|
||||
group: "Everywhere",
|
||||
label: "Play / pause",
|
||||
keys: Keys::Icons(Control::PlayPause),
|
||||
},
|
||||
ControlRow {
|
||||
group: "Everywhere",
|
||||
label: "Skip track",
|
||||
keys: Keys::Icons(Control::Skip),
|
||||
},
|
||||
ControlRow {
|
||||
group: "Everywhere",
|
||||
label: "Seek 10 s",
|
||||
keys: Keys::Text(", / .", "Right stick left / right"),
|
||||
},
|
||||
ControlRow {
|
||||
group: "Everywhere",
|
||||
label: "Volume",
|
||||
keys: Keys::Icons(Control::Volume),
|
||||
},
|
||||
ControlRow {
|
||||
group: "Everywhere",
|
||||
label: "Mute",
|
||||
keys: Keys::Icons(Control::Mute),
|
||||
},
|
||||
ControlRow {
|
||||
group: "Everywhere",
|
||||
label: "Now playing",
|
||||
keys: Keys::Icons(Control::NowPlaying),
|
||||
},
|
||||
ControlRow {
|
||||
group: "Everywhere",
|
||||
label: "Search",
|
||||
keys: Keys::Icons(Control::Search),
|
||||
},
|
||||
ControlRow {
|
||||
group: "Browsing",
|
||||
label: "Sections",
|
||||
keys: Keys::Icons(Control::Sections),
|
||||
},
|
||||
ControlRow {
|
||||
group: "Browsing",
|
||||
label: "Add to queue",
|
||||
keys: Keys::Icons(Control::Queue),
|
||||
},
|
||||
ControlRow {
|
||||
group: "Browsing",
|
||||
label: "Shuffle play",
|
||||
keys: Keys::Icons(Control::ShufflePlay),
|
||||
},
|
||||
ControlRow {
|
||||
group: "Now playing",
|
||||
label: "Seek",
|
||||
keys: Keys::Icons(Control::Seek),
|
||||
},
|
||||
ControlRow {
|
||||
group: "Now playing",
|
||||
label: "Shuffle mode",
|
||||
keys: Keys::Icons(Control::Shuffle),
|
||||
},
|
||||
ControlRow {
|
||||
group: "Text fields",
|
||||
label: "Steam keyboard",
|
||||
keys: Keys::Icons(Control::OnScreenKeyboard),
|
||||
},
|
||||
ControlRow {
|
||||
group: "Window",
|
||||
label: "Fullscreen",
|
||||
keys: Keys::Text("F11", ""),
|
||||
},
|
||||
ControlRow {
|
||||
group: "Window",
|
||||
label: "Quit",
|
||||
keys: Keys::Text("Ctrl + Q", ""),
|
||||
},
|
||||
];
|
||||
|
||||
/// What the server prompt in Settings offers.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
enum Choice {
|
||||
Cancel,
|
||||
LogOut,
|
||||
Forget,
|
||||
}
|
||||
|
||||
impl Choice {
|
||||
fn label(self) -> &'static str {
|
||||
match self {
|
||||
Choice::Cancel => "Cancel",
|
||||
Choice::LogOut => "Log out",
|
||||
Choice::Forget => "Forget",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The prompt asking what to do with a saved server. Holds the server by
|
||||
/// address and username rather than index, in case the list changes under it.
|
||||
struct Confirm {
|
||||
url: String,
|
||||
username: String,
|
||||
choices: Vec<Choice>,
|
||||
sel: usize,
|
||||
}
|
||||
|
||||
/// How long the UI takes to change from one palette to the next.
|
||||
@@ -183,6 +328,8 @@ struct HeaderInfo {
|
||||
#[derive(Clone, Debug)]
|
||||
enum Source {
|
||||
Section(Section),
|
||||
/// The Controls page, opened from Settings.
|
||||
Controls,
|
||||
Album(String),
|
||||
Artist(String),
|
||||
Playlist(String),
|
||||
@@ -255,8 +402,11 @@ pub struct App {
|
||||
/// 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)>,
|
||||
/// The log out or forget prompt, while it is open.
|
||||
confirm: Option<Confirm>,
|
||||
/// No page has loaded since entering a saved login. A wrong-credentials
|
||||
/// error until then means the saved login stopped working.
|
||||
checking_login: bool,
|
||||
screen: Screen,
|
||||
area: Area,
|
||||
section: usize,
|
||||
@@ -361,7 +511,8 @@ impl App {
|
||||
mpris,
|
||||
logins: Logins::default(),
|
||||
player_epoch: Arc::default(),
|
||||
remove_armed: None,
|
||||
confirm: None,
|
||||
checking_login: false,
|
||||
screen: Screen::Login,
|
||||
area: Area::Content,
|
||||
section: 0,
|
||||
@@ -495,9 +646,40 @@ impl App {
|
||||
// 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);
|
||||
let known: Vec<KnownServer> = self
|
||||
.logins
|
||||
.servers
|
||||
.iter()
|
||||
.map(|c| KnownServer {
|
||||
label: c.label().into(),
|
||||
note: if c.logged_in() { "" } else { "Logged out" }.into(),
|
||||
})
|
||||
.collect();
|
||||
self.ui.set_login_known(ModelRc::new(VecModel::from(known)));
|
||||
self.set_login_focus(0);
|
||||
}
|
||||
|
||||
/// The login form filled in with a saved server, waiting for its password.
|
||||
fn login_to(&mut self, cfg: &Config) {
|
||||
self.ui.set_login_server(cfg.url.clone().into());
|
||||
self.ui.set_login_username(cfg.username.clone().into());
|
||||
self.ui.set_login_password("".into());
|
||||
self.ui.set_login_error("".into());
|
||||
self.show_login();
|
||||
self.set_login_focus(2);
|
||||
}
|
||||
|
||||
/// A saved server picked on the login screen.
|
||||
fn pick_known(&mut self, i: usize) {
|
||||
if let Some(cfg) = self.logins.servers.get(i).cloned() {
|
||||
self.ui.set_login_server(cfg.url.into());
|
||||
self.ui.set_login_username(cfg.username.into());
|
||||
self.ui.set_login_password("".into());
|
||||
self.ui.set_login_error("".into());
|
||||
self.set_login_focus(2);
|
||||
}
|
||||
}
|
||||
|
||||
/// The login form, empty, for one more server.
|
||||
fn add_server(&mut self) {
|
||||
self.ui.set_login_server("".into());
|
||||
@@ -520,9 +702,18 @@ impl App {
|
||||
self.set_area(area);
|
||||
}
|
||||
|
||||
/// Top to bottom: the saved servers in the card beside the form, from
|
||||
/// -n-1 to -2; the X in the form's corner at -1; the fields 0 to 2; and
|
||||
/// Connect at 3. So Up from the address field reaches the X, then the list.
|
||||
fn set_login_focus(&mut self, i: i32) {
|
||||
self.login_focus = i.clamp(0, 4);
|
||||
let known = self.logins.servers.len() as i32;
|
||||
self.login_focus = i.clamp(-known - 1, 3);
|
||||
self.ui.set_login_focus(self.login_focus);
|
||||
self.ui.set_login_known_selected(if self.login_focus < -1 {
|
||||
known + 1 + self.login_focus
|
||||
} else {
|
||||
-1
|
||||
});
|
||||
self.ui.invoke_focus_login(self.login_focus);
|
||||
self.render_hints();
|
||||
}
|
||||
@@ -531,9 +722,18 @@ impl App {
|
||||
match a {
|
||||
Action::Up | Action::SectionPrev => self.set_login_focus(self.login_focus - 1),
|
||||
Action::Down | Action::SectionNext => self.set_login_focus(self.login_focus + 1),
|
||||
// Across to the saved servers and back. A text field keeps Left
|
||||
// and Right on a keyboard for its cursor.
|
||||
Action::Left if self.login_focus >= -1 && !self.logins.servers.is_empty() => {
|
||||
self.set_login_focus(-(self.logins.servers.len() as i32) - 1)
|
||||
}
|
||||
Action::Right if self.login_focus < -1 => self.set_login_focus(0),
|
||||
Action::Activate if self.login_focus < -1 => {
|
||||
self.pick_known((self.logins.servers.len() as i32 + 1 + self.login_focus) as usize)
|
||||
}
|
||||
Action::Activate if self.login_focus == -1 && self.client.is_some() => self.cancel_login(),
|
||||
Action::Activate if self.login_focus == -1 => self.action(Action::Quit),
|
||||
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
|
||||
@@ -585,12 +785,9 @@ impl App {
|
||||
}
|
||||
|
||||
fn enter_browse(&mut self, client: Client) {
|
||||
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));
|
||||
.set_server_label(config::server_label(client.base(), client.user()).into());
|
||||
self.covers.dir = self.covers.root.as_ref().map(|r| r.join(cover_dir_name(&client)));
|
||||
if let Some(d) = &self.covers.dir
|
||||
&& let Err(e) = std::fs::create_dir_all(d)
|
||||
{
|
||||
@@ -598,6 +795,7 @@ impl App {
|
||||
self.covers.dir = None;
|
||||
}
|
||||
self.client = Some(client);
|
||||
self.checking_login = true;
|
||||
self.covers.generation += 1;
|
||||
self.covers.images.clear();
|
||||
self.covers.tones.clear();
|
||||
@@ -624,19 +822,7 @@ impl App {
|
||||
fn switch_server(&mut self, client: Client) {
|
||||
if self.client.is_some() {
|
||||
self.save_queue();
|
||||
self.stop_player();
|
||||
self.clear_queue();
|
||||
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);
|
||||
self.reset_playback();
|
||||
}
|
||||
log::info!("browsing {} on {}", client.user(), client.base());
|
||||
self.enter_browse(client);
|
||||
@@ -645,6 +831,30 @@ impl App {
|
||||
self.sync_inhibit();
|
||||
}
|
||||
|
||||
/// Stops the player and empties the queue with everything kept about it,
|
||||
/// so the next server starts clean. The player's own events would
|
||||
/// otherwise update the screen and the screensaver inhibit, but
|
||||
/// stop_player drops them, so both are done here.
|
||||
fn reset_playback(&mut self) {
|
||||
self.stop_player();
|
||||
self.clear_queue();
|
||||
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.art_waiting = false;
|
||||
self.flip_timer.stop();
|
||||
self.ui.set_np_flip_out(false);
|
||||
self.render_player();
|
||||
self.sync_queue(true);
|
||||
self.sync_inhibit();
|
||||
}
|
||||
|
||||
fn clear_queue(&mut self) {
|
||||
self.queue.clear();
|
||||
self.order.clear();
|
||||
@@ -669,54 +879,193 @@ impl App {
|
||||
}
|
||||
|
||||
fn select_server(&mut self, i: usize) {
|
||||
if i == self.logins.active {
|
||||
return;
|
||||
}
|
||||
let Some(cfg) = self.logins.servers.get(i).cloned() else {
|
||||
return;
|
||||
};
|
||||
if !cfg.logged_in() {
|
||||
self.login_to(&cfg);
|
||||
return;
|
||||
}
|
||||
if i == self.logins.active {
|
||||
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) {
|
||||
/// Asks whether to log out of a saved server or forget it.
|
||||
fn open_server_prompt(&mut self, i: usize) {
|
||||
let Some(cfg) = self.logins.servers.get(i) else {
|
||||
return;
|
||||
};
|
||||
let (title, message, choices) = if cfg.logged_in() {
|
||||
(
|
||||
format!("Log out of {}?", cfg.label()),
|
||||
"Logging out keeps the server, so logging in again only needs the password. \
|
||||
Forgetting removes it, with its saved queue and cached covers."
|
||||
.to_string(),
|
||||
vec![Choice::Cancel, Choice::LogOut, Choice::Forget],
|
||||
)
|
||||
} else {
|
||||
(
|
||||
format!("Forget {}?", cfg.label()),
|
||||
"Removes the server, with its saved queue and cached covers.".to_string(),
|
||||
vec![Choice::Cancel, Choice::Forget],
|
||||
)
|
||||
};
|
||||
let labels: Vec<SharedString> = choices.iter().map(|c| c.label().into()).collect();
|
||||
self.ui.set_confirm_title(title.into());
|
||||
self.ui.set_confirm_message(message.into());
|
||||
self.ui.set_confirm_choices(ModelRc::new(VecModel::from(labels)));
|
||||
self.confirm = Some(Confirm {
|
||||
url: cfg.url.clone(),
|
||||
username: cfg.username.clone(),
|
||||
choices,
|
||||
sel: 0,
|
||||
});
|
||||
self.render_confirm();
|
||||
}
|
||||
|
||||
fn render_confirm(&mut self) {
|
||||
self.ui.set_confirm_shown(self.confirm.is_some());
|
||||
if let Some(c) = &self.confirm {
|
||||
self.ui.set_confirm_selected(c.sel as i32);
|
||||
}
|
||||
self.render_hints();
|
||||
}
|
||||
|
||||
/// Keys and buttons while the prompt is open. Nothing else reacts.
|
||||
fn confirm_action(&mut self, a: Action) {
|
||||
let Some(c) = &mut self.confirm else { return };
|
||||
match a {
|
||||
Action::Left | Action::Up => c.sel = c.sel.saturating_sub(1),
|
||||
Action::Right | Action::Down => c.sel = (c.sel + 1).min(c.choices.len() - 1),
|
||||
Action::Activate => return self.choose(),
|
||||
Action::Back => self.confirm = None,
|
||||
_ => return,
|
||||
}
|
||||
self.render_confirm();
|
||||
}
|
||||
|
||||
fn confirm_clicked(&mut self, i: usize) {
|
||||
if let Some(c) = &mut self.confirm
|
||||
&& i < c.choices.len()
|
||||
{
|
||||
c.sel = i;
|
||||
self.choose();
|
||||
}
|
||||
}
|
||||
|
||||
fn choose(&mut self) {
|
||||
let Some(c) = self.confirm.take() else { return };
|
||||
self.render_confirm();
|
||||
let Some(i) = self.logins.find(&c.url, &c.username) else {
|
||||
return;
|
||||
};
|
||||
match c.choices[c.sel] {
|
||||
Choice::Cancel => {}
|
||||
Choice::LogOut => self.log_out_server(i),
|
||||
Choice::Forget => self.forget_server(i),
|
||||
}
|
||||
}
|
||||
|
||||
/// Drops a server's credentials and keeps its entry, queue and covers.
|
||||
fn log_out_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;
|
||||
let was_active = cfg.logged_in() && i == self.logins.active;
|
||||
self.logins.log_out(i);
|
||||
self.save_logins();
|
||||
self.toast(format!("Logged out of {}", cfg.label()));
|
||||
if was_active {
|
||||
self.leave_server(true);
|
||||
} else {
|
||||
self.refresh_settings();
|
||||
}
|
||||
self.remove_armed = None;
|
||||
let was_active = i == self.logins.active;
|
||||
}
|
||||
|
||||
/// Removes a server, with its saved queue and cover cache.
|
||||
fn forget_server(&mut self, i: usize) {
|
||||
let Some(cfg) = self.logins.servers.get(i).cloned() else {
|
||||
return;
|
||||
};
|
||||
let was_active = cfg.logged_in() && i == self.logins.active;
|
||||
self.logins.remove(i);
|
||||
self.save_logins();
|
||||
self.toast(format!("Removed {}", cfg.label()));
|
||||
if !was_active {
|
||||
if was_active {
|
||||
self.leave_server(false);
|
||||
} else {
|
||||
self.refresh_settings();
|
||||
return;
|
||||
}
|
||||
// After leaving, which saves the queue of the server it leaves.
|
||||
self.forget_server_data(&cfg);
|
||||
self.toast(format!("Forgot {}", cfg.label()));
|
||||
}
|
||||
|
||||
fn forget_server_data(&mut self, cfg: &Config) {
|
||||
let client = cfg.client();
|
||||
if self.saved.forget(client.base(), client.user())
|
||||
&& let Some(path) = &self.saved_path
|
||||
&& let Err(e) = saved_queue::save(path, &self.saved)
|
||||
{
|
||||
log::warn!("could not save the queue: {e:#}");
|
||||
}
|
||||
if let Some(root) = &self.covers.root {
|
||||
let dir = root.join(cover_dir_name(&client));
|
||||
match std::fs::remove_dir_all(&dir) {
|
||||
Ok(()) => log::info!("removed the cover cache {}", dir.display()),
|
||||
Err(e) if e.kind() == std::io::ErrorKind::NotFound => {}
|
||||
Err(e) => log::warn!("could not remove {}: {e}", dir.display()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The browsed server was logged out of or forgotten: browse the next
|
||||
/// logged-in one, or show the login screen when none is left.
|
||||
fn leave_server(&mut self, keep_queue: bool) {
|
||||
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.clear_queue();
|
||||
self.client = None;
|
||||
self.render_player();
|
||||
self.drop_client(keep_queue);
|
||||
self.add_server();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Stops browsing and playing, for the login screen.
|
||||
fn drop_client(&mut self, keep_queue: bool) {
|
||||
if keep_queue {
|
||||
self.save_queue();
|
||||
}
|
||||
self.reset_playback();
|
||||
self.client = None;
|
||||
self.checking_login = false;
|
||||
}
|
||||
|
||||
/// The server turned down the saved login of the browsed server: log it
|
||||
/// out and ask for its password, rather than showing load errors.
|
||||
fn login_rejected(&mut self) {
|
||||
let i = self.logins.active;
|
||||
let Some(cfg) = self.logins.active().cloned() else {
|
||||
return;
|
||||
};
|
||||
log::warn!("{} turned down the saved login, logging it out", cfg.label());
|
||||
self.logins.log_out(i);
|
||||
self.save_logins();
|
||||
self.drop_client(true);
|
||||
self.login_to(&cfg);
|
||||
self.ui.set_login_error(
|
||||
format!(
|
||||
"The server did not accept the saved login for {}. Enter the password to log in again.",
|
||||
cfg.label()
|
||||
)
|
||||
.into(),
|
||||
);
|
||||
}
|
||||
|
||||
/// 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 {
|
||||
@@ -768,6 +1117,13 @@ impl App {
|
||||
if prompts != self.prompts {
|
||||
self.prompts = prompts;
|
||||
self.render_hints();
|
||||
// Its rows show the buttons of the input in use.
|
||||
if self
|
||||
.current_page()
|
||||
.is_some_and(|p| matches!(p.source, Source::Controls))
|
||||
{
|
||||
self.sync_items(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -786,6 +1142,7 @@ impl App {
|
||||
}
|
||||
Action::ToggleFullscreen => {
|
||||
let w = self.ui.window();
|
||||
log::debug!("F11: fullscreen {} size {:?}", w.is_fullscreen(), w.size());
|
||||
w.set_fullscreen(!w.is_fullscreen());
|
||||
return;
|
||||
}
|
||||
@@ -801,6 +1158,9 @@ impl App {
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
if self.confirm.is_some() {
|
||||
return self.confirm_action(a);
|
||||
}
|
||||
match self.screen {
|
||||
Screen::Login => self.login_action(a),
|
||||
Screen::Browse => self.browse_action(a),
|
||||
@@ -881,7 +1241,7 @@ impl App {
|
||||
Action::Shuffle => self.shuffle_selected(),
|
||||
Action::Back => self.back(),
|
||||
Action::Queue => match self.selected_setting() {
|
||||
Some(Setting::Server(i)) => self.remove_server(i),
|
||||
Some(Setting::Server(i)) => self.open_server_prompt(i),
|
||||
_ => self.enqueue_selected(),
|
||||
},
|
||||
Action::SectionNext => self.select_section(self.section_step(1)),
|
||||
@@ -1171,6 +1531,7 @@ impl App {
|
||||
}
|
||||
Target::ShuffleAll => self.start_library_shuffle(),
|
||||
Target::Setting(s) => self.toggle_setting(s),
|
||||
Target::ControlRow(_) => {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1199,12 +1560,22 @@ impl App {
|
||||
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(),
|
||||
Setting::Controls => return self.open_controls(),
|
||||
// A range: left and right change it, confirm does nothing.
|
||||
Setting::CoverBackdrop | Setting::Version => return,
|
||||
}
|
||||
self.settings_changed();
|
||||
}
|
||||
|
||||
/// The Controls page, on top of Settings. No header: it is a list.
|
||||
fn open_controls(&mut self) {
|
||||
let page = self.new_page(Source::Controls, "Controls".to_string(), true, None);
|
||||
let id = page.id;
|
||||
self.stacks[self.section].push(page);
|
||||
self.load(id, Source::Controls);
|
||||
self.render_page();
|
||||
}
|
||||
|
||||
/// Moves a range setting one step up or down.
|
||||
fn adjust_setting(&mut self, setting: Setting, up: bool) {
|
||||
match setting {
|
||||
@@ -1219,7 +1590,8 @@ impl App {
|
||||
| Setting::ShowHintBar
|
||||
| Setting::Version
|
||||
| Setting::Server(_)
|
||||
| Setting::AddServer => return,
|
||||
| Setting::AddServer
|
||||
| Setting::Controls => return,
|
||||
}
|
||||
self.settings_changed();
|
||||
}
|
||||
@@ -1425,6 +1797,10 @@ impl App {
|
||||
self.page_loaded(page_id, Ok(data), true);
|
||||
return;
|
||||
}
|
||||
if matches!(source, Source::Controls) {
|
||||
self.page_loaded(page_id, Ok(controls_data()), true);
|
||||
return;
|
||||
}
|
||||
let Some(client) = self.client.clone() else { return };
|
||||
match source {
|
||||
Source::Section(Section::Recent) => self.spawn(
|
||||
@@ -1478,7 +1854,7 @@ impl App {
|
||||
async move { Ok(playlists_data(client.playlists().await?)) },
|
||||
move |app, r| app.page_loaded(page_id, r, true),
|
||||
),
|
||||
Source::Section(Section::Search | Section::Settings) => {}
|
||||
Source::Section(Section::Search | Section::Settings) | Source::Controls => {}
|
||||
Source::Search(q) => self.spawn(
|
||||
async move { Ok(search_data(client.search(&q).await?)) },
|
||||
move |app, r| app.page_loaded(page_id, r, true),
|
||||
@@ -1586,6 +1962,19 @@ impl App {
|
||||
|
||||
/// Appends a load result to the page. `done` is false while more batches follow.
|
||||
fn page_loaded(&mut self, page_id: u64, result: Result<PageData>, done: bool) {
|
||||
if self.find_page_mut(page_id).is_none() {
|
||||
return;
|
||||
}
|
||||
match &result {
|
||||
Ok(_) => self.checking_login = false,
|
||||
Err(e)
|
||||
if self.checking_login
|
||||
&& subsonic::api_error(e).is_some_and(|a| a.code == subsonic::WRONG_CREDENTIALS) =>
|
||||
{
|
||||
return self.login_rejected();
|
||||
}
|
||||
Err(_) => {}
|
||||
}
|
||||
let Some(page) = self.find_page_mut(page_id) else {
|
||||
return;
|
||||
};
|
||||
@@ -1764,13 +2153,17 @@ impl App {
|
||||
Target::Setting(Setting::CoverBackdrop) => Some(self.settings.cover_backdrop as f32 / 100.0),
|
||||
_ => None,
|
||||
};
|
||||
let (icons, detail) = match entry.target {
|
||||
Target::ControlRow(i) => self.control_keys(&CONTROL_ROWS[i]),
|
||||
_ => (Vec::new(), entry.detail),
|
||||
};
|
||||
Some(Item {
|
||||
index: index as i32,
|
||||
letter: initial(&entry.title).into(),
|
||||
tint: tint(&entry.title),
|
||||
title: entry.title.into(),
|
||||
subtitle: entry.subtitle.into(),
|
||||
detail: entry.detail.into(),
|
||||
detail: detail.into(),
|
||||
number: entry.number.into(),
|
||||
has_cover: cover.is_some(),
|
||||
cover: cover.unwrap_or_default(),
|
||||
@@ -1779,9 +2172,26 @@ impl App {
|
||||
playing,
|
||||
slider: level.is_some(),
|
||||
level: level.unwrap_or_default(),
|
||||
icons: ModelRc::new(VecModel::from(icons)),
|
||||
})
|
||||
}
|
||||
|
||||
/// A Controls row's icons for the input in use, or its keys written out,
|
||||
/// or which input it needs when this one has nothing for it.
|
||||
fn control_keys(&self, row: &ControlRow) -> (Vec<Image>, String) {
|
||||
let keyboard = self.prompts == Prompts::Keyboard;
|
||||
let (icons, text) = match row.keys {
|
||||
Keys::Icons(c) => (self.hint_icons(c), ""),
|
||||
Keys::Text(k, p) => (Vec::new(), if keyboard { k } else { p }),
|
||||
};
|
||||
let text = match text {
|
||||
"" if icons.is_empty() && keyboard => "Controller only",
|
||||
"" if icons.is_empty() => "Keyboard only",
|
||||
t => t,
|
||||
};
|
||||
(icons, text.to_string())
|
||||
}
|
||||
|
||||
fn render_shuffle(&self) {
|
||||
let label = match self.shuffle {
|
||||
_ if self.library.is_some() => "Shuffling the whole library",
|
||||
@@ -1806,12 +2216,17 @@ impl App {
|
||||
}
|
||||
};
|
||||
match self.screen {
|
||||
_ if self.confirm.is_some() => {
|
||||
h(Control::Activate, "Select");
|
||||
h(Control::Back, "Cancel");
|
||||
}
|
||||
Screen::Login => {
|
||||
let adding = self.client.is_some();
|
||||
let label = match self.login_focus {
|
||||
..-1 => "Use this server",
|
||||
-1 if adding => "Cancel",
|
||||
-1 => "Exit",
|
||||
0 | 1 => "Next",
|
||||
4 if adding => "Cancel",
|
||||
4 => "Exit",
|
||||
_ => "Connect",
|
||||
};
|
||||
h(Control::Activate, label);
|
||||
@@ -1819,20 +2234,18 @@ impl App {
|
||||
let shown = self.ui.get_login_password_shown();
|
||||
h(Control::Queue, if shown { "Hide password" } else { "Show password" });
|
||||
}
|
||||
if adding {
|
||||
// Already the activate hint while the X has focus.
|
||||
if adding && self.login_focus != -1 {
|
||||
h(Control::Back, "Cancel");
|
||||
}
|
||||
}
|
||||
Screen::Browse => match self.area {
|
||||
Area::Sidebar => {
|
||||
h(Control::Activate, "Open");
|
||||
h(Control::PlayPause, "Play / Pause");
|
||||
h(Control::Search, "Search");
|
||||
h(Control::NowPlaying, "Now playing");
|
||||
}
|
||||
// What works the same everywhere (Back, Play / Pause,
|
||||
// Sections, Now playing, Search, and Activate where it opens)
|
||||
// is on the Controls page in Settings instead.
|
||||
Area::Sidebar => {}
|
||||
Area::Search => {
|
||||
h(Control::Activate, "Search");
|
||||
h(Control::Back, "Back");
|
||||
h(Control::OnScreenKeyboard, "Keyboard");
|
||||
}
|
||||
_ => {
|
||||
@@ -1845,20 +2258,26 @@ impl App {
|
||||
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");
|
||||
let logged_in = self.logins.servers.get(*i).is_some_and(Config::logged_in);
|
||||
if !logged_in {
|
||||
h(Control::Activate, "Log in");
|
||||
h(Control::Queue, "Forget");
|
||||
} else {
|
||||
if *i != self.logins.active {
|
||||
h(Control::Activate, "Switch");
|
||||
}
|
||||
h(Control::Queue, "Log out or forget");
|
||||
}
|
||||
h(Control::Queue, "Remove");
|
||||
}
|
||||
Some(Target::Setting(Setting::AddServer)) => h(Control::Activate, "Add"),
|
||||
Some(Target::Setting(Setting::Controls)) => {}
|
||||
Some(Target::Setting(_)) => h(Control::Activate, "Change"),
|
||||
Some(_) => h(Control::Activate, "Open"),
|
||||
Some(_) => {}
|
||||
None if self.current_page().is_some_and(|p| p.error.is_some()) => {
|
||||
h(Control::Activate, "Try again")
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
h(Control::Back, "Back");
|
||||
if matches!(target, Some(Target::Song(_) | Target::Album(_) | Target::Playlist(_))) {
|
||||
h(Control::Queue, "Add to queue");
|
||||
}
|
||||
@@ -1874,16 +2293,10 @@ impl App {
|
||||
},
|
||||
);
|
||||
}
|
||||
h(Control::PlayPause, "Play / Pause");
|
||||
h(Control::Sections, "Sections");
|
||||
h(Control::NowPlaying, "Now playing");
|
||||
}
|
||||
},
|
||||
Screen::NowPlaying => {
|
||||
h(Control::Activate, "Play selected");
|
||||
h(Control::Back, "Back");
|
||||
h(Control::PlayPause, "Play / Pause");
|
||||
h(Control::Skip, "Skip");
|
||||
h(
|
||||
Control::Shuffle,
|
||||
match self.shuffle {
|
||||
@@ -1893,9 +2306,6 @@ impl App {
|
||||
Mode::Albums => "Shuffle: albums",
|
||||
},
|
||||
);
|
||||
h(Control::Seek, "Seek");
|
||||
h(Control::Volume, "Volume");
|
||||
h(Control::Mute, "Mute");
|
||||
}
|
||||
}
|
||||
self.ui.set_hints(ModelRc::new(VecModel::from(hints)));
|
||||
@@ -2202,7 +2612,7 @@ impl App {
|
||||
Ok(songs) => app.shuffle_play(songs),
|
||||
Err(e) => failed(app, e),
|
||||
}),
|
||||
Target::ShuffleAll | Target::Setting(_) => {}
|
||||
Target::ShuffleAll | Target::Setting(_) | Target::ControlRow(_) => {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2250,7 +2660,7 @@ impl App {
|
||||
)
|
||||
}
|
||||
Target::Artist(_) => self.toast("Open the artist to queue one of their albums".into()),
|
||||
Target::ShuffleAll | Target::Setting(_) => {}
|
||||
Target::ShuffleAll | Target::Setting(_) | Target::ControlRow(_) => {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2879,6 +3289,7 @@ impl App {
|
||||
playing: Some(index) == self.current,
|
||||
slider: false,
|
||||
level: 0.0,
|
||||
icons: ModelRc::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2972,12 +3383,14 @@ fn settings_data(s: &Settings, logins: &Logins) -> PageData {
|
||||
.enumerate()
|
||||
.map(|(i, cfg)| Entry {
|
||||
title: cfg.label(),
|
||||
subtitle: if i == logins.active {
|
||||
subtitle: if !cfg.logged_in() {
|
||||
"Logged out".to_string()
|
||||
} else if i == logins.active {
|
||||
"Browsing now".to_string()
|
||||
} else {
|
||||
"Saved login".to_string()
|
||||
},
|
||||
detail: if i == logins.active {
|
||||
detail: if cfg.logged_in() && i == logins.active {
|
||||
"Active".to_string()
|
||||
} else {
|
||||
String::new()
|
||||
@@ -3035,6 +3448,16 @@ fn settings_data(s: &Settings, logins: &Logins) -> PageData {
|
||||
show_art: false,
|
||||
target: Target::Setting(Setting::ShowHintBar),
|
||||
},
|
||||
Entry {
|
||||
title: "Controls".to_string(),
|
||||
subtitle: "Every button and key, for the controller in use or the keyboard".to_string(),
|
||||
detail: String::new(),
|
||||
number: String::new(),
|
||||
cover: None,
|
||||
round: false,
|
||||
show_art: false,
|
||||
target: Target::Setting(Setting::Controls),
|
||||
},
|
||||
],
|
||||
..Default::default()
|
||||
};
|
||||
@@ -3056,6 +3479,31 @@ fn settings_data(s: &Settings, logins: &Logins) -> PageData {
|
||||
data
|
||||
}
|
||||
|
||||
fn controls_data() -> PageData {
|
||||
PageData {
|
||||
entries: CONTROL_ROWS
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(i, row)| Entry {
|
||||
title: row.label.to_string(),
|
||||
// The one control that is a long press on a controller.
|
||||
subtitle: if row.keys == Keys::Icons(Control::ShufflePlay) {
|
||||
format!("{}, hold on a controller", row.group)
|
||||
} else {
|
||||
row.group.to_string()
|
||||
},
|
||||
detail: String::new(),
|
||||
number: String::new(),
|
||||
cover: None,
|
||||
round: false,
|
||||
show_art: false,
|
||||
target: Target::ControlRow(i),
|
||||
})
|
||||
.collect(),
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
/// One step of the volume, kept within 0 to 100.
|
||||
fn step_volume(v: u8, up: bool) -> u8 {
|
||||
let v = v.min(100);
|
||||
@@ -3176,6 +3624,12 @@ fn remove_unkeyed_covers(root: &Path) {
|
||||
}
|
||||
}
|
||||
|
||||
/// A server's directory under the cover cache root, keyed like the saved
|
||||
/// queue, by user and full address.
|
||||
fn cover_dir_name(client: &Client) -> String {
|
||||
sanitize(&format!("{}@{}", client.user(), client.base()))
|
||||
}
|
||||
|
||||
fn sanitize(id: &str) -> String {
|
||||
id.chars()
|
||||
.map(|c| {
|
||||
@@ -3338,6 +3792,24 @@ mod tests {
|
||||
assert!(has_version(false));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_controls_page_lists_every_control_in_groups() {
|
||||
for control in Control::ALL {
|
||||
assert!(
|
||||
CONTROL_ROWS.iter().any(|r| r.keys == Keys::Icons(control)),
|
||||
"{control:?} is missing"
|
||||
);
|
||||
}
|
||||
// Each group in one run, so the page reads as groups.
|
||||
let mut seen: Vec<&str> = Vec::new();
|
||||
for row in CONTROL_ROWS {
|
||||
if seen.last() != Some(&row.group) {
|
||||
assert!(!seen.contains(&row.group), "{} is split", row.group);
|
||||
seen.push(row.group);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn volume_steps_stay_in_range() {
|
||||
assert_eq!(step_volume(50, true), 55);
|
||||
|
||||
+138
-6
@@ -11,7 +11,8 @@ use crate::subsonic::{Auth, Client};
|
||||
|
||||
/// Server credentials, written 0600. Either a token, md5(password + salt),
|
||||
/// which is not the password but is enough to log in to this server; or, for
|
||||
/// a server that refuses tokens, the password itself.
|
||||
/// a server that refuses tokens, the password itself. Neither means logged
|
||||
/// out: the server and username are kept for logging in again.
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct Config {
|
||||
pub url: String,
|
||||
@@ -39,6 +40,17 @@ impl Config {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn logged_in(&self) -> bool {
|
||||
self.password.is_some() || !self.token.is_empty()
|
||||
}
|
||||
|
||||
/// Drops the credentials, keeping the server and username.
|
||||
pub fn log_out(&mut self) {
|
||||
self.salt.clear();
|
||||
self.token.clear();
|
||||
self.password = None;
|
||||
}
|
||||
|
||||
pub fn client(&self) -> Client {
|
||||
let auth = match &self.password {
|
||||
Some(p) => Auth::Password(p.clone()),
|
||||
@@ -72,8 +84,7 @@ pub fn state_dir() -> Option<PathBuf> {
|
||||
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('/'))
|
||||
server_label(&self.url, &self.username)
|
||||
}
|
||||
|
||||
fn same_login(&self, other: &Config) -> bool {
|
||||
@@ -81,10 +92,21 @@ impl Config {
|
||||
}
|
||||
}
|
||||
|
||||
/// "user on host". The scheme is left out for https only, so an http and an
|
||||
/// https login to the same host can be told apart.
|
||||
pub fn server_label(url: &str, username: &str) -> String {
|
||||
let host = match url.split_once("://") {
|
||||
Some(("https", rest)) => rest,
|
||||
_ => url,
|
||||
};
|
||||
format!("{} on {}", username, host.trim_end_matches('/'))
|
||||
}
|
||||
|
||||
/// Every saved login, and which one is browsed.
|
||||
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
|
||||
pub struct Logins {
|
||||
/// Index into `servers`.
|
||||
/// Index into `servers`. Points at a logged-in server whenever there is
|
||||
/// one.
|
||||
#[serde(default)]
|
||||
pub active: usize,
|
||||
/// `[[server]]` tables in the file.
|
||||
@@ -93,8 +115,22 @@ pub struct Logins {
|
||||
}
|
||||
|
||||
impl Logins {
|
||||
/// The server being browsed, or none when every saved one is logged out.
|
||||
pub fn active(&self) -> Option<&Config> {
|
||||
self.servers.get(self.active)
|
||||
self.servers.get(self.active).filter(|c| c.logged_in())
|
||||
}
|
||||
|
||||
/// Moves `active` off a server that is gone or logged out, to the first
|
||||
/// logged-in one.
|
||||
fn settle_active(&mut self) {
|
||||
if self.active().is_none() {
|
||||
self.active = self.servers.iter().position(Config::logged_in).unwrap_or(0);
|
||||
}
|
||||
}
|
||||
|
||||
/// The saved entry for this server and user, logged in or not.
|
||||
pub fn find(&self, url: &str, username: &str) -> Option<usize> {
|
||||
self.servers.iter().position(|s| s.url == url && s.username == username)
|
||||
}
|
||||
|
||||
/// Adds a login, or refreshes the saved one for the same server and user,
|
||||
@@ -113,7 +149,7 @@ impl Logins {
|
||||
}
|
||||
|
||||
/// Removes a login. The active one stays the same server where it can;
|
||||
/// removing it makes the first remaining login active.
|
||||
/// removing it makes the first remaining logged-in server active.
|
||||
pub fn remove(&mut self, i: usize) {
|
||||
if i >= self.servers.len() {
|
||||
return;
|
||||
@@ -124,6 +160,16 @@ impl Logins {
|
||||
} else if i == self.active {
|
||||
self.active = 0;
|
||||
}
|
||||
self.settle_active();
|
||||
}
|
||||
|
||||
/// Logs out of a server, keeping its entry. Logging out of the active one
|
||||
/// makes the first logged-in server active.
|
||||
pub fn log_out(&mut self, i: usize) {
|
||||
if let Some(s) = self.servers.get_mut(i) {
|
||||
s.log_out();
|
||||
self.settle_active();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,6 +189,7 @@ fn parse_logins(text: &str) -> Result<Logins> {
|
||||
if l.active >= l.servers.len() {
|
||||
l.active = 0;
|
||||
}
|
||||
l.settle_active();
|
||||
l
|
||||
}
|
||||
Stored::One(c) => Logins {
|
||||
@@ -362,6 +409,91 @@ mod tests {
|
||||
assert_eq!(parse_logins(text).unwrap().active, 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_logged_out_login_keeps_its_server_and_round_trips() {
|
||||
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())));
|
||||
l.log_out(0);
|
||||
l.log_out(1);
|
||||
let text = toml::to_string(&l).unwrap();
|
||||
assert!(
|
||||
!text.contains("salt") && !text.contains("token") && !text.contains("password"),
|
||||
"{text}"
|
||||
);
|
||||
let back = parse_logins(&text).unwrap();
|
||||
assert_eq!(back, l);
|
||||
assert_eq!(back.servers.len(), 2);
|
||||
assert!(back.servers.iter().all(|s| !s.logged_in()));
|
||||
assert_eq!(back.servers[1].url, "https://b");
|
||||
assert_eq!(back.servers[1].username, "v");
|
||||
assert!(back.active().is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_active_login_skips_logged_out_servers() {
|
||||
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 = 0;
|
||||
l.log_out(1);
|
||||
assert_eq!(l.active().unwrap().url, "https://a");
|
||||
l.log_out(0);
|
||||
assert_eq!(l.active().unwrap().url, "https://c");
|
||||
l.log_out(2);
|
||||
assert!(l.active().is_none());
|
||||
// Logging in again reuses the entry and makes it active.
|
||||
l.add(login("https://b", "u", Auth::Password("p".into())));
|
||||
assert_eq!(l.servers.len(), 3);
|
||||
assert_eq!(l.active().unwrap().url, "https://b");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_saved_active_index_on_a_logged_out_server_moves_to_a_logged_in_one() {
|
||||
let text = "active = 0\n[[server]]\nurl = \"https://a\"\nusername = \"u\"\n\
|
||||
[[server]]\nurl = \"https://b\"\nusername = \"u\"\npassword = \"p\"\n";
|
||||
let l = parse_logins(text).unwrap();
|
||||
assert_eq!(l.active, 1);
|
||||
assert_eq!(l.active().unwrap().url, "https://b");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn removing_the_active_login_skips_logged_out_servers() {
|
||||
let mut l = Logins::default();
|
||||
for host in ["https://a", "https://b", "https://c"] {
|
||||
l.add(login(host, "u", Auth::Password("p".into())));
|
||||
}
|
||||
l.log_out(0);
|
||||
l.active = 1;
|
||||
l.remove(1);
|
||||
assert_eq!(l.active().unwrap().url, "https://c");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_login_list_from_v0_8_0_loads_logged_in() {
|
||||
let text = "active = 1\n\
|
||||
[[server]]\nurl = \"https://a\"\nusername = \"u\"\nsalt = \"s\"\ntoken = \"t\"\n\
|
||||
[[server]]\nurl = \"https://b\"\nusername = \"v\"\npassword = \"p\"\n";
|
||||
let l = parse_logins(text).unwrap();
|
||||
assert_eq!(l.servers.len(), 2);
|
||||
assert!(l.servers.iter().all(Config::logged_in));
|
||||
assert_eq!(l.active().unwrap().url, "https://b");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn labels_tell_http_and_https_apart() {
|
||||
assert_eq!(server_label("https://h/", "u"), "u on h");
|
||||
assert_eq!(server_label("http://h", "u"), "u on http://h");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn settings_default_when_fields_are_missing() {
|
||||
let s: Settings = toml::from_str("").unwrap();
|
||||
|
||||
@@ -56,6 +56,13 @@ fn step(ui: slint::Weak<AppWindow>, steps: Vec<String>, i: usize) {
|
||||
Err(e) => log::error!("snapshot failed: {e}"),
|
||||
}
|
||||
}
|
||||
Some(("key", "f11")) => {
|
||||
use slint::platform::{Key, WindowEvent};
|
||||
let text: slint::SharedString = Key::F11.into();
|
||||
win.window()
|
||||
.dispatch_event(WindowEvent::KeyPressed { text: text.clone() });
|
||||
win.window().dispatch_event(WindowEvent::KeyReleased { text });
|
||||
}
|
||||
Some(("prompts", kind)) => {
|
||||
use crate::prompts::Family;
|
||||
let family = match kind {
|
||||
@@ -98,6 +105,7 @@ fn step(ui: slint::Weak<AppWindow>, steps: Vec<String>, i: usize) {
|
||||
"cycle-shuffle" => Action::CycleShuffle,
|
||||
"shuffle" => Action::Shuffle,
|
||||
"hold-activate" => Action::HoldActivate,
|
||||
"fullscreen" => Action::ToggleFullscreen,
|
||||
other => {
|
||||
log::warn!("unknown dev script step {other}");
|
||||
Action::None
|
||||
|
||||
@@ -15,6 +15,9 @@ mod subsonic;
|
||||
|
||||
use std::time::Duration;
|
||||
|
||||
/// The Flatpak app id, which is also the name of the desktop file.
|
||||
const APP_ID: &str = "me.anshorei.Fettleshed.Remus";
|
||||
|
||||
fn main() -> anyhow::Result<()> {
|
||||
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("remus=info")).init();
|
||||
|
||||
@@ -27,6 +30,10 @@ fn main() -> anyhow::Result<()> {
|
||||
.build()?;
|
||||
|
||||
let ui = AppWindow::new()?;
|
||||
// Docks match the window to the desktop file by this id, on Wayland as
|
||||
// the app id and on X11 as the WM_CLASS. It needs the platform that
|
||||
// AppWindow::new sets up, and has to be set before the window is shown.
|
||||
slint::set_xdg_app_id(APP_ID)?;
|
||||
ui.set_version(env!("CARGO_PKG_VERSION").into());
|
||||
app::install(&ui, rt.handle().clone());
|
||||
// The controller is read from the device, whichever window is in front, so
|
||||
|
||||
+24
-1
@@ -57,12 +57,22 @@ impl SavedQueues {
|
||||
pub fn set(&mut self, client: &Client, queue: SavedQueue) {
|
||||
self.servers.insert(key(client), queue);
|
||||
}
|
||||
|
||||
/// Drops the queue of a forgotten server, by its address as
|
||||
/// `Client::base` gives it. Returns whether there was one.
|
||||
pub fn forget(&mut self, base: &str, user: &str) -> bool {
|
||||
self.servers.remove(&key_of(base, user)).is_some()
|
||||
}
|
||||
}
|
||||
|
||||
/// Song ids are only unique within one server, and two users of a server
|
||||
/// have their own queues.
|
||||
fn key(client: &Client) -> String {
|
||||
format!("{}@{}", client.user(), client.base())
|
||||
key_of(client.base(), client.user())
|
||||
}
|
||||
|
||||
fn key_of(base: &str, user: &str) -> String {
|
||||
format!("{user}@{base}")
|
||||
}
|
||||
|
||||
pub fn path() -> Option<PathBuf> {
|
||||
@@ -156,6 +166,19 @@ mod tests {
|
||||
let _ = fs::remove_dir_all(path.parent().unwrap());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn forgetting_a_server_drops_only_its_queue() {
|
||||
let home = Client::new("https://home", "u", Auth::Password("p".into()));
|
||||
let other = Client::new("https://other", "u", Auth::Password("p".into()));
|
||||
let mut queues = SavedQueues::default();
|
||||
queues.set(&home, SavedQueue::default());
|
||||
queues.set(&other, SavedQueue::default());
|
||||
assert!(queues.forget(home.base(), home.user()));
|
||||
assert!(!queues.forget(home.base(), home.user()));
|
||||
assert!(queues.get(&home).is_none());
|
||||
assert!(queues.get(&other).is_some());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_queue_saved_before_shuffle_loads_unshuffled() {
|
||||
let path = temp("before-shuffle");
|
||||
|
||||
+265
-80
@@ -31,6 +31,8 @@ export struct Item {
|
||||
// A setting with a range: draws `level` (0 to 1) as a slider before `detail`.
|
||||
slider: bool,
|
||||
level: float,
|
||||
// Button or key icons after `detail`, on the Controls page.
|
||||
icons: [image],
|
||||
}
|
||||
|
||||
export struct Header {
|
||||
@@ -48,6 +50,9 @@ export struct Header {
|
||||
|
||||
export struct Hint { icons: [image], label: string }
|
||||
|
||||
// A saved server on the login screen: its label, and "Logged out" or nothing.
|
||||
export struct KnownServer { label: string, note: string }
|
||||
|
||||
export global Theme {
|
||||
in-out property <float> s: 1.0;
|
||||
// The brand palette: warm darks and cream text, from the logo's maroon
|
||||
@@ -277,6 +282,19 @@ component Row inherits Rectangle {
|
||||
horizontal-alignment: right;
|
||||
vertical-alignment: center;
|
||||
}
|
||||
|
||||
if root.item.icons.length > 0: HorizontalLayout {
|
||||
spacing: 4px * Theme.s;
|
||||
for icon in root.item.icons: VerticalLayout {
|
||||
alignment: center;
|
||||
Image {
|
||||
source: icon;
|
||||
height: 34px * Theme.s;
|
||||
// Keys such as Space are wider than a button.
|
||||
width: self.height * icon.width / max(1, icon.height);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TouchArea {
|
||||
@@ -619,6 +637,71 @@ component VolumeLevel inherits HorizontalLayout {
|
||||
}
|
||||
|
||||
// The level after a volume change, faded out again by the app after a moment.
|
||||
// Asks before doing something that cannot be undone from where it is asked.
|
||||
// The choices sit in a row; the app moves the selection and starts with the
|
||||
// first, which is Cancel.
|
||||
component ConfirmDialog inherits Rectangle {
|
||||
in property <string> title;
|
||||
in property <string> message;
|
||||
in property <[string]> choices;
|
||||
in property <int> selected;
|
||||
callback clicked(int);
|
||||
|
||||
background: #00000099;
|
||||
// Keeps clicks from reaching the page behind.
|
||||
TouchArea { }
|
||||
|
||||
Rectangle {
|
||||
width: min(620px * Theme.s, parent.width - 40px * Theme.s);
|
||||
height: col.preferred-height;
|
||||
border-radius: 18px * Theme.s;
|
||||
background: Theme.panel;
|
||||
border-width: 1px * Theme.s;
|
||||
border-color: Theme.line;
|
||||
drop-shadow-blur: 30px * Theme.s;
|
||||
drop-shadow-color: #00000080;
|
||||
|
||||
col := VerticalLayout {
|
||||
padding: 34px * Theme.s;
|
||||
spacing: 18px * Theme.s;
|
||||
Text {
|
||||
text: root.title;
|
||||
font-size: 24px * Theme.s;
|
||||
font-family: Theme.serif;
|
||||
font-weight: 600;
|
||||
color: Theme.text;
|
||||
wrap: word-wrap;
|
||||
}
|
||||
Text {
|
||||
text: root.message;
|
||||
font-size: 16px * Theme.s;
|
||||
color: Theme.muted;
|
||||
wrap: word-wrap;
|
||||
}
|
||||
HorizontalLayout {
|
||||
spacing: 12px * Theme.s;
|
||||
padding-top: 6px * Theme.s;
|
||||
for label[i] in root.choices: Rectangle {
|
||||
height: 50px * Theme.s;
|
||||
border-radius: 12px * Theme.s;
|
||||
background: i == root.selected ? Theme.accent : Theme.raised;
|
||||
border-width: 2px * Theme.s;
|
||||
border-color: i == root.selected ? Theme.focus : transparent;
|
||||
Text {
|
||||
text: label;
|
||||
font-size: 18px * Theme.s;
|
||||
font-weight: i == root.selected ? 700 : 500;
|
||||
color: i == root.selected ? Theme.on-accent : Theme.text;
|
||||
}
|
||||
TouchArea {
|
||||
clicked => { root.clicked(i); }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
component VolumeOverlay inherits Rectangle {
|
||||
in property <bool> shown;
|
||||
in property <int> level;
|
||||
@@ -893,9 +976,13 @@ component LoginView inherits Rectangle {
|
||||
in property <bool> busy;
|
||||
// Adding a server from inside the app: the bottom button goes back.
|
||||
in property <bool> can-cancel;
|
||||
// Saved servers above the form, and which one has focus, -1 for none.
|
||||
in property <[KnownServer]> known;
|
||||
in property <int> known-selected: -1;
|
||||
callback submit;
|
||||
callback exit;
|
||||
callback field-clicked(int);
|
||||
callback known-clicked(int);
|
||||
public function focus-field(i: int) {
|
||||
if (i == 0) {
|
||||
f0.focus-input();
|
||||
@@ -908,91 +995,166 @@ component LoginView inherits Rectangle {
|
||||
|
||||
background: @radial-gradient(circle, Theme.login-glow 0%, Theme.bg 70%);
|
||||
|
||||
Rectangle {
|
||||
width: min(560px * Theme.s, parent.width - 40px * Theme.s);
|
||||
height: col.preferred-height;
|
||||
border-radius: 18px * Theme.s;
|
||||
background: Theme.panel;
|
||||
// Saved servers in a card of their own beside the form, so the form is
|
||||
// as tall as without them and still fits an 800 px high screen.
|
||||
HorizontalLayout {
|
||||
alignment: center;
|
||||
spacing: 24px * Theme.s;
|
||||
padding: 20px * Theme.s;
|
||||
|
||||
col := VerticalLayout {
|
||||
padding: 40px * Theme.s;
|
||||
spacing: 20px * Theme.s;
|
||||
if root.known.length > 0: VerticalLayout {
|
||||
alignment: center;
|
||||
Rectangle {
|
||||
preferred-width: 400px * Theme.s;
|
||||
min-width: 240px * Theme.s;
|
||||
border-radius: 18px * Theme.s;
|
||||
background: Theme.panel;
|
||||
VerticalLayout {
|
||||
padding: 28px * Theme.s;
|
||||
spacing: 10px * Theme.s;
|
||||
Text {
|
||||
text: "Saved servers";
|
||||
font-size: 22px * Theme.s;
|
||||
font-family: Theme.serif;
|
||||
font-weight: 600;
|
||||
color: Theme.text;
|
||||
}
|
||||
Text {
|
||||
text: "Pick one to fill in its address and username.";
|
||||
font-size: 14px * Theme.s;
|
||||
color: Theme.muted;
|
||||
wrap: word-wrap;
|
||||
}
|
||||
for k[i] in root.known: Rectangle {
|
||||
height: 58px * Theme.s;
|
||||
border-radius: 10px * Theme.s;
|
||||
background: i == root.known-selected ? Theme.raised : transparent;
|
||||
border-width: 2px * Theme.s;
|
||||
border-color: i == root.known-selected ? Theme.focus : Theme.line;
|
||||
VerticalLayout {
|
||||
padding-left: 16px * Theme.s;
|
||||
padding-right: 16px * Theme.s;
|
||||
alignment: center;
|
||||
Text {
|
||||
text: k.label;
|
||||
font-size: 17px * Theme.s;
|
||||
color: Theme.text;
|
||||
overflow: elide;
|
||||
}
|
||||
if k.note != "": Text {
|
||||
text: k.note;
|
||||
font-size: 13px * Theme.s;
|
||||
color: Theme.faint;
|
||||
}
|
||||
}
|
||||
TouchArea {
|
||||
clicked => { root.known-clicked(i); }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HorizontalLayout {
|
||||
alignment: center;
|
||||
Image {
|
||||
source: @image-url("../branding/svg/remus-logo.svg");
|
||||
height: 68px * Theme.s;
|
||||
// The lockup's aspect ratio, so the image box hugs the logo.
|
||||
width: self.height * 2.93;
|
||||
}
|
||||
}
|
||||
Text {
|
||||
text: "Connect to your Subsonic server";
|
||||
font-size: 17px * Theme.s;
|
||||
color: Theme.muted;
|
||||
}
|
||||
f0 := Field {
|
||||
label: "Server address";
|
||||
text <=> root.server;
|
||||
highlighted: root.focus-index == 0;
|
||||
accepted => { root.field-clicked(1); }
|
||||
}
|
||||
f1 := Field {
|
||||
label: "Username";
|
||||
text <=> root.username;
|
||||
highlighted: root.focus-index == 1;
|
||||
accepted => { root.field-clicked(2); }
|
||||
}
|
||||
f2 := Field {
|
||||
label: "Password";
|
||||
text <=> root.password;
|
||||
password: true;
|
||||
shown <=> root.password-shown;
|
||||
highlighted: root.focus-index == 2;
|
||||
accepted => { root.submit(); }
|
||||
}
|
||||
VerticalLayout {
|
||||
alignment: center;
|
||||
Rectangle {
|
||||
height: 54px * Theme.s;
|
||||
border-radius: 12px * Theme.s;
|
||||
background: root.focus-index == 3 ? Theme.accent : Theme.raised;
|
||||
Text {
|
||||
text: root.busy ? "Connecting…" : "Connect";
|
||||
font-size: 19px * Theme.s;
|
||||
font-weight: 700;
|
||||
color: root.focus-index == 3 ? Theme.on-accent : Theme.text;
|
||||
preferred-width: 560px * Theme.s;
|
||||
min-width: 320px * Theme.s;
|
||||
height: col.preferred-height;
|
||||
border-radius: 18px * Theme.s;
|
||||
background: Theme.panel;
|
||||
|
||||
col := VerticalLayout {
|
||||
padding: 40px * Theme.s;
|
||||
spacing: 20px * Theme.s;
|
||||
|
||||
HorizontalLayout {
|
||||
alignment: center;
|
||||
Image {
|
||||
source: @image-url("../branding/svg/remus-logo.svg");
|
||||
height: 68px * Theme.s;
|
||||
// The lockup's aspect ratio, so the image box hugs the logo.
|
||||
width: self.height * 2.93;
|
||||
}
|
||||
}
|
||||
Text {
|
||||
text: "Connect to your Subsonic server";
|
||||
font-size: 17px * Theme.s;
|
||||
color: Theme.muted;
|
||||
}
|
||||
f0 := Field {
|
||||
label: "Server address";
|
||||
text <=> root.server;
|
||||
highlighted: root.focus-index == 0;
|
||||
accepted => { root.field-clicked(1); }
|
||||
}
|
||||
f1 := Field {
|
||||
label: "Username";
|
||||
text <=> root.username;
|
||||
highlighted: root.focus-index == 1;
|
||||
accepted => { root.field-clicked(2); }
|
||||
}
|
||||
f2 := Field {
|
||||
label: "Password";
|
||||
text <=> root.password;
|
||||
password: true;
|
||||
shown <=> root.password-shown;
|
||||
highlighted: root.focus-index == 2;
|
||||
accepted => { root.submit(); }
|
||||
}
|
||||
Rectangle {
|
||||
height: 54px * Theme.s;
|
||||
border-radius: 12px * Theme.s;
|
||||
background: root.focus-index == 3 ? Theme.accent : Theme.raised;
|
||||
Text {
|
||||
text: root.busy ? "Connecting…" : "Connect";
|
||||
font-size: 19px * Theme.s;
|
||||
font-weight: 700;
|
||||
color: root.focus-index == 3 ? Theme.on-accent : Theme.text;
|
||||
}
|
||||
TouchArea {
|
||||
clicked => { root.submit(); }
|
||||
}
|
||||
}
|
||||
if root.error != "": Text {
|
||||
text: root.error;
|
||||
font-size: 15px * Theme.s;
|
||||
color: Theme.error;
|
||||
wrap: word-wrap;
|
||||
}
|
||||
Text {
|
||||
text: "On a Steam Deck, press Steam + X to bring up the keyboard.";
|
||||
font-size: 13px * Theme.s;
|
||||
color: Theme.faint;
|
||||
wrap: word-wrap;
|
||||
}
|
||||
}
|
||||
TouchArea {
|
||||
clicked => { root.submit(); }
|
||||
|
||||
// Exit, or Cancel when adding a server from inside the app. A
|
||||
// corner button rather than a row, to keep the card short.
|
||||
Rectangle {
|
||||
x: parent.width - self.width - 14px * Theme.s;
|
||||
y: 14px * Theme.s;
|
||||
width: 44px * Theme.s;
|
||||
height: 44px * Theme.s;
|
||||
border-radius: self.width / 2;
|
||||
background: root.focus-index == -1 || x-area.has-hover ? Theme.raised : transparent;
|
||||
border-width: 2px * Theme.s;
|
||||
border-color: root.focus-index == -1 ? Theme.focus : transparent;
|
||||
Path {
|
||||
width: 18px * Theme.s;
|
||||
height: 18px * Theme.s;
|
||||
viewbox-width: 24;
|
||||
viewbox-height: 24;
|
||||
commands: "M 4 4 L 20 20 M 20 4 L 4 20";
|
||||
stroke: root.focus-index == -1 || x-area.has-hover ? Theme.text : Theme.muted;
|
||||
stroke-width: 2px * Theme.s;
|
||||
}
|
||||
x-area := TouchArea {
|
||||
clicked => { root.exit(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
// Secondary to Connect: outlined, no fill, and only lit when focused.
|
||||
Rectangle {
|
||||
height: 46px * Theme.s;
|
||||
border-radius: 12px * Theme.s;
|
||||
border-width: 2px * Theme.s;
|
||||
border-color: root.focus-index == 4 ? Theme.focus : Theme.line;
|
||||
Text {
|
||||
text: root.can-cancel ? "Cancel" : "Exit";
|
||||
font-size: 17px * Theme.s;
|
||||
color: root.focus-index == 4 ? Theme.text : Theme.muted;
|
||||
}
|
||||
TouchArea {
|
||||
clicked => { root.exit(); }
|
||||
}
|
||||
}
|
||||
if root.error != "": Text {
|
||||
text: root.error;
|
||||
font-size: 15px * Theme.s;
|
||||
color: Theme.error;
|
||||
wrap: word-wrap;
|
||||
}
|
||||
Text {
|
||||
text: "On a Steam Deck, press Steam + X to bring up the keyboard.";
|
||||
font-size: 13px * Theme.s;
|
||||
color: Theme.faint;
|
||||
wrap: word-wrap;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1200,6 +1362,8 @@ export component AppWindow inherits Window {
|
||||
callback search-accepted(string);
|
||||
callback login-submit();
|
||||
callback login-field-clicked(int);
|
||||
callback login-known-clicked(int);
|
||||
callback confirm-clicked(int);
|
||||
callback layout-changed();
|
||||
|
||||
in property <Screen> screen: Screen.login;
|
||||
@@ -1214,6 +1378,8 @@ export component AppWindow inherits Window {
|
||||
in property <bool> login-busy;
|
||||
in property <bool> login-can-cancel;
|
||||
in-out property <bool> login-password-shown;
|
||||
in property <[KnownServer]> login-known;
|
||||
in property <int> login-known-selected: -1;
|
||||
|
||||
// Browse
|
||||
in property <[string]> sections;
|
||||
@@ -1264,6 +1430,13 @@ export component AppWindow inherits Window {
|
||||
in property <string> version;
|
||||
in property <bool> show-hint-bar: true;
|
||||
|
||||
// The confirmation prompt, over everything else while shown.
|
||||
in property <bool> confirm-shown;
|
||||
in property <string> confirm-title;
|
||||
in property <string> confirm-message;
|
||||
in property <[string]> confirm-choices;
|
||||
in property <int> confirm-selected;
|
||||
|
||||
public function focus-main() {
|
||||
fs.focus();
|
||||
}
|
||||
@@ -1271,7 +1444,8 @@ export component AppWindow inherits Window {
|
||||
search.focus-input();
|
||||
}
|
||||
public function focus-login(i: int) {
|
||||
if (i >= 3) {
|
||||
// Below 0 is the X or a saved server, 3 is Connect: keys go to the scope.
|
||||
if (i >= 3 || i < 0) {
|
||||
fs.focus();
|
||||
} else {
|
||||
login.focus-field(i);
|
||||
@@ -1344,6 +1518,9 @@ export component AppWindow inherits Window {
|
||||
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); }
|
||||
known: root.login-known;
|
||||
known-selected: root.login-known-selected;
|
||||
known-clicked(i) => { root.login-known-clicked(i); }
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
@@ -1456,6 +1633,14 @@ export component AppWindow inherits Window {
|
||||
}
|
||||
}
|
||||
|
||||
if root.confirm-shown: ConfirmDialog {
|
||||
title: root.confirm-title;
|
||||
message: root.confirm-message;
|
||||
choices: root.confirm-choices;
|
||||
selected: root.confirm-selected;
|
||||
clicked(i) => { root.confirm-clicked(i); }
|
||||
}
|
||||
|
||||
VolumeOverlay {
|
||||
x: (parent.width - self.width) / 2;
|
||||
y: parent.height - self.height - 32px * Theme.s;
|
||||
|
||||
Reference in New Issue
Block a user