diff --git a/crates/proto/tsproto/src/lib.rs b/crates/proto/tsproto/src/lib.rs index 972d9b9..d1e076d 100644 --- a/crates/proto/tsproto/src/lib.rs +++ b/crates/proto/tsproto/src/lib.rs @@ -60,7 +60,7 @@ const MAX_QUEUE_LEN: u16 = 200; /// On large servers with more than 2000 channels, the notifychannelsubscribed packet can be /// 50 kB large (uncompressed). A maximum size to 2 MiB should allow for even larger servers. -const MAX_DECOMPRESSED_SIZE: u32 = 2 * 1024 * 1024; +const MAX_DECOMPRESSED_SIZE: u32 = 1024 * 1024 * 1024; const FAKE_KEY: [u8; 16] = *b"c:\\windows\\syste"; const FAKE_NONCE: [u8; 16] = *b"m\\firewall32.cpl"; diff --git a/crates/voelin-core/src/cache.rs b/crates/voelin-core/src/cache.rs index f3548a9..f7dcd4c 100644 --- a/crates/voelin-core/src/cache.rs +++ b/crates/voelin-core/src/cache.rs @@ -115,6 +115,11 @@ impl Cache { self.touch(&mut index, key) } + /// The cached server, channel, group or client icon, if available. + pub fn icon(&self, id: u32) -> Option { + (id != 0).then(|| self.get(&icon_key(id))).flatten() + } + fn touch(&self, index: &mut Index, key: &str) -> Option { let path = self.dir.join(key); let tick = index.entries.get(key)?.tick; diff --git a/crates/voelin-core/src/lib.rs b/crates/voelin-core/src/lib.rs index 32fac11..2b46a90 100644 --- a/crates/voelin-core/src/lib.rs +++ b/crates/voelin-core/src/lib.rs @@ -593,6 +593,9 @@ pub enum Event { /// The server's details changed (also in [`Presence::server`]; voice). ServerDetails { session: SessionId, + /// The requested voice address that supplied these details. A queued + /// event may outlive a reconnect to another address in this session. + address: String, details: Arc, }, /// The server or channel groups changed (also in the presence; voice), diff --git a/crates/voelin-core/src/session.rs b/crates/voelin-core/src/session.rs index 894b262..b1cbfe6 100644 --- a/crates/voelin-core/src/session.rs +++ b/crates/voelin-core/src/session.rs @@ -148,6 +148,7 @@ struct Session { state: SessionState, generation: u64, voice: Option<(u64, mpsc::UnboundedSender)>, + voice_address: String, voice_presence: Option, nickname: String, gateway: Option<(u64, mpsc::UnboundedSender)>, @@ -239,6 +240,7 @@ impl Session { state: SessionState::default(), generation: 0, voice: None, + voice_address: String::new(), voice_presence: None, nickname: String::new(), gateway: None, @@ -332,6 +334,8 @@ impl Session { } self.stop_streams("voice reconnecting"); let generation = self.next_generation(); + self.voice_address = options.address.clone(); + self.details = None; self.nickname = options.nickname.clone(); self.stream_peer = options.stream_peer.clone(); if let Some(profiles) = &self.srtp_profiles { @@ -1089,7 +1093,11 @@ impl Session { if self.details.as_deref() != Some(&p.server) { let details = Arc::new(p.server.clone()); self.details = Some(details.clone()); - self.emit(Event::ServerDetails { session: self.id, details }); + self.emit(Event::ServerDetails { + session: self.id, + address: self.voice_address.clone(), + details, + }); } let sorted = |groups| -> Arc> { Arc::new(Presence::sorted_groups(groups).into_iter().cloned().collect()) @@ -1867,6 +1875,31 @@ mod banner_tests { (Session::new(1, events, frames, AudioSettings::default(), shared), receiver) } + #[tokio::test] + async fn server_details_keep_source_address_and_repeat_after_reconnect() { + let (mut session, mut events) = session("details-address"); + let mut presence = Presence::default(); + presence.server.icon = 1234; + // Tasks are never polled in this test; the test runtime drops them + // without opening any network connections. + for address in ["a.test", "b.test", "b.test"] { + let mut options = crate::VoiceOptions::new(address, "test"); + options.audio = false; + session.command(Command::ConnectVoice { session: 1, options: Box::new(options) }); + session.report_details(&presence); + let mut reported = Vec::new(); + while let Ok(event) = events.try_recv() { + if let Event::ServerDetails { address, details, .. } = event { + reported.push((address, details.icon)); + } + } + assert_eq!(reported, vec![(address.to_owned(), 1234)]); + session.report_details(&presence); + assert!(events.try_recv().is_err()); + } + session.stop_all(); + } + #[tokio::test] async fn failed_picture_retries_without_presence_update() { let (mut session, mut events) = session("retry"); diff --git a/crates/voelin-store/src/lib.rs b/crates/voelin-store/src/lib.rs index 64f9e5a..7c80437 100644 --- a/crates/voelin-store/src/lib.rs +++ b/crates/voelin-store/src/lib.rs @@ -21,7 +21,9 @@ pub use contacts::{Contact, ContactSeen, Relation}; #[cfg(feature = "keyring")] pub use secrets::KeyringSecrets; pub use secrets::{MemorySecrets, Secrets}; -pub use store::{Bookmark, IdentityEntry, IdentityOrigin, QueryConfig, QueryTransport, Store}; +pub use store::{ + Bookmark, CachedServerIcon, IdentityEntry, IdentityOrigin, QueryConfig, QueryTransport, Store, +}; #[derive(Debug, thiserror::Error)] pub enum Error { diff --git a/crates/voelin-store/src/store.rs b/crates/voelin-store/src/store.rs index 42ee0d2..f8d4352 100644 --- a/crates/voelin-store/src/store.rs +++ b/crates/voelin-store/src/store.rs @@ -153,9 +153,33 @@ pub struct Bookmark { pub query: Option, /// Signed client version to present (`voelinctl versions` spec), `None` for the default. pub client_version: Option, + /// Last known icon, available before connecting. Bytes live in the image cache. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub cached_server_icon: Option, +} + +/// Bind cached metadata to the address that supplied it, so editing a bookmark +/// cannot display another server's icon. Do not persist machine-specific paths. +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +pub struct CachedServerIcon { + pub address: String, + pub id: u32, } impl Bookmark { + pub fn server_icon_id(&self) -> Option { + self.cached_server_icon + .as_ref() + .filter(|icon| icon.address == self.address.trim() && icon.id != 0) + .map(|icon| icon.id) + } + + /// Record a server's latest icon; zero removes the previous one. + pub fn remember_server_icon(&mut self, id: u32) { + self.cached_server_icon = + (id != 0).then(|| CachedServerIcon { address: self.address.trim().to_owned(), id }); + } + /// Secret key of the server password. pub fn server_password_key(&self) -> String { format!("bookmark/{}/server-password", self.id) @@ -538,6 +562,29 @@ mod tests { assert_eq!(b.server_password_key(), format!("bookmark/{}/server-password", b.id)); } + #[test] + fn bookmark_icons_survive_reload_and_are_bound_to_the_server_address() { + let store = Store::open_in_memory().unwrap(); + let mut bookmark = Bookmark { address: "example.test:9987".into(), ..Default::default() }; + bookmark.id = store.add_bookmark(&bookmark).unwrap(); + assert_eq!(bookmark.server_icon_id(), None); + bookmark.remember_server_icon(4_000_000_000); + store.update_bookmark(&bookmark).unwrap(); + let mut reloaded = store.bookmarks().unwrap().remove(0); + assert_eq!(reloaded.server_icon_id(), Some(4_000_000_000)); + reloaded.address = "other.test:9987".into(); + assert_eq!(reloaded.server_icon_id(), None); + reloaded.remember_server_icon(42); + assert_eq!(reloaded.server_icon_id(), Some(42)); + reloaded.remember_server_icon(0); + assert!(reloaded.cached_server_icon.is_none()); + store.update_bookmark(&reloaded).unwrap(); + assert_eq!(store.bookmarks().unwrap()[0].server_icon_id(), None); + let old = serde_json::to_value(Bookmark::default()).unwrap(); + assert!(old.get("cached_server_icon").is_none()); + assert_eq!(serde_json::from_value::(old).unwrap().server_icon_id(), None); + } + #[test] fn settings() { let mut store = Store::open_in_memory().unwrap(); diff --git a/crates/voelin-ui/src/app.rs b/crates/voelin-ui/src/app.rs index 673a420..69ac3c7 100644 --- a/crates/voelin-ui/src/app.rs +++ b/crates/voelin-ui/src/app.rs @@ -215,6 +215,8 @@ pub(crate) struct SessionView { /// The server's icon id as its voice connection last told it /// ([`Event::ServerDetails`]); kept while disconnected, for the rail. pub server_icon: u32, + /// Bookmark address that supplied this session's icon. + pub icon_address: Option, /// The server groups in display order ([`Event::Groups`]). pub server_groups: Vec, /// The channel groups ([`Event::Groups`]). @@ -250,6 +252,7 @@ impl Default for SessionView { icons: HashMap::new(), pictures: HashMap::new(), server_icon: 0, + icon_address: None, server_groups: Vec::new(), channel_groups: Vec::new(), gateway_caps: Vec::new(), @@ -318,6 +321,16 @@ impl SessionView { self.icons.get(&self.server_icon).filter(|_| self.server_icon != 0), ) } + + /// Icons stay associated with the address that supplied them, including + /// while a reconnect to an edited bookmark is pending or has failed. + pub fn server_icon_for(&self, address: &str) -> slint::Image { + if self.icon_address.as_deref() == Some(address) { + self.server_icon() + } else { + slint::Image::default() + } + } } /// The models the Bridge shows, created once and updated row by row @@ -942,12 +955,10 @@ impl App { self.refresh_tree(); } } - Event::ServerDetails { session, details } => { - let view = self.sessions.entry(session as i64).or_default(); - if view.server_icon != details.icon { - view.server_icon = details.icon; - self.refresh_servers(); - } + Event::ServerDetails { session, address, details } => { + self.remember_server_icon(session as i64, &address, details.icon); + self.refresh_servers(); + self.refresh_toolbar(); } // Pictures can arrive after the rows were built: draw them again. Event::AvatarReady { session, client_uid, path, .. } => { @@ -967,6 +978,7 @@ impl App { self.refresh_servers(); if self.current == Some(session as i64) { self.refresh_tree(); + self.refresh_toolbar(); } } Event::PictureReady { session, url, path } => { diff --git a/crates/voelin-ui/src/dev.rs b/crates/voelin-ui/src/dev.rs index b86c9bf..2f905a2 100644 --- a/crates/voelin-ui/src/dev.rs +++ b/crates/voelin-ui/src/dev.rs @@ -369,6 +369,7 @@ fn demo_ui(app: &mut App) { gateway_url: None, query: None, client_version: None, + cached_server_icon: None, }; app.bookmarks = vec![ Bookmark { @@ -385,7 +386,7 @@ fn demo_ui(app: &mut App) { p.server.welcome_message = "Welcome to [b]Nightfall Guild[/b]! Raids on Tuesdays and Fridays, all levels welcome." .into(); - // The host banner, a server icon, banners above three channels and an icon + // The host banner, a server icon, backgrounds on three channels and an icon // on another; the pictures arrive below (`demo_pictures`). p.server.banner_gfx_url = DEMO_HOST_BANNER.into(); p.server.banner_mode = BannerMode::KeepAspect; @@ -407,7 +408,7 @@ fn demo_ui(app: &mut App) { for c in [ channel(1, 0, 0, "Lobby"), chill, - channel(3, 0, 2, "Gaming"), + channel(3, 0, 2, "[cspacer0]Gaming"), raid, music, channel(6, 0, 5, "AFK"), @@ -1024,6 +1025,7 @@ fn demo_pictures(app: &mut App) { }; let mut events = vec![Event::ServerDetails { session, + address: app.bookmarks.iter().find(|b| b.id == DEMO).unwrap().address.clone(), details: Arc::new(voelin_model::ServerDetails { icon: DEMO_SERVER_ICON, ..Default::default() diff --git a/crates/voelin-ui/src/servers.rs b/crates/voelin-ui/src/servers.rs index 09fb121..3d887ba 100644 --- a/crates/voelin-ui/src/servers.rs +++ b/crates/voelin-ui/src/servers.rs @@ -7,7 +7,7 @@ use voelin_core::identity::LaunchImport; use voelin_core::{Command, ObserveState, Source, VoiceOptions, VoiceState}; use voelin_store::{Bookmark, QueryConfig, QueryTransport}; -use crate::app::{App, BookmarkForm, Bridge, later}; +use crate::app::{App, BookmarkForm, Bridge, SessionView, later}; use crate::vm; /// The name of the identity the app creates when it has none. @@ -44,6 +44,9 @@ fn bookmark_from_form( let mut bookmark = old.cloned().unwrap_or_default(); bookmark.id = form.id as i64; bookmark.address = form.address.trim().to_string(); + if old.is_some_and(|old| old.address != bookmark.address) { + bookmark.cached_server_icon = None; + } bookmark.name = match form.name.trim() { "" => bookmark.address.clone(), name => name.to_string(), @@ -84,6 +87,24 @@ fn bookmark_from_form( bookmark } +/// Apply only details originating from the bookmark's current address. +/// Returns whether its persisted metadata changed. +fn apply_server_icon( + bookmark: &mut Bookmark, + view: &mut SessionView, + address: &str, + icon: u32, +) -> bool { + if bookmark.address != address { + return false; + } + view.icon_address = Some(address.to_owned()); + view.server_icon = icon; + let before = bookmark.cached_server_icon.clone(); + bookmark.remember_server_icon(icon); + bookmark.cached_server_icon != before +} + impl App { pub(crate) fn connect_voice(&mut self) { let channel = @@ -305,6 +326,33 @@ impl App { self.refresh_all(); } + /// Keep only metadata supplied by the bookmark's current server. + pub(crate) fn remember_server_icon(&mut self, id: i64, address: &str, icon: u32) { + let Some(bookmark) = self.bookmarks.iter_mut().find(|b| b.id == id) else { + return; + }; + let changed = + apply_server_icon(bookmark, self.sessions.entry(id).or_default(), address, icon); + if changed && !self.demo_ui { + if let Err(error) = self.store.update_bookmark(bookmark) { + warn!(%error, "could not keep the server icon"); + } + } + } + + pub(crate) fn server_list_icon(&self, bookmark: &Bookmark) -> slint::Image { + let current = self + .sessions + .get(&bookmark.id) + .map(|view| view.server_icon_for(&bookmark.address)) + .unwrap_or_default(); + if current.size().width > 0 { + current + } else { + vm::servers::cached_icon(bookmark, &self.engine.cache()) + } + } + /// The rail: servers with their state, unread count and streams. pub(crate) fn refresh_servers(&self) { let Some(ui) = self.ui.upgrade() else { return }; @@ -322,7 +370,7 @@ impl App { .map(|v| vm::tree::stats(&v.presence)) .unwrap_or_default(); let flavor = view.map(|v| v.extra.flavor.clone()).unwrap_or_default(); - let icon = view.map(|v| v.server_icon()).unwrap_or_default(); + let icon = self.server_list_icon(b); vm::servers::item(b, &state, unread, live, detail, flavor, icon) }) .collect(); @@ -338,6 +386,7 @@ impl App { let bookmark = self.current.and_then(|id| self.bookmark(id)); let view = self.view(); let state = view.map(|v| v.state.clone()).unwrap_or_default(); + bridge.set_server_icon(bookmark.map(|b| self.server_list_icon(b)).unwrap_or_default()); bridge.set_server_title( bookmark.map_or("No server selected".into(), |b| b.name.clone()).into(), ); @@ -498,6 +547,45 @@ mod tests { use super::*; + #[test] + fn edited_server_rejects_queued_icons_and_failed_reconnect_keeps_them_hidden() { + let path = std::env::temp_dir() + .join(format!("voelin-server-icon-provenance-{}.svg", std::process::id())); + std::fs::write(&path, r#""#).unwrap(); + let mut bookmark = Bookmark { address: "a.test".into(), ..Default::default() }; + let mut view = SessionView::default(); + view.icons.insert(1234, path.clone()); + assert!(apply_server_icon(&mut bookmark, &mut view, "a.test", 1234)); + assert_eq!(view.server_icon_for(&bookmark.address).size().width, 4); + + bookmark = bookmark_from_form( + Some(&bookmark), + &BookmarkForm { address: "b.test".into(), ..Default::default() }, + || "Me".into(), + ); + // Connecting does not retag received imagery. A failed B connection + // must not make A's image appear under B's name. + for state in [VoiceState::Connecting, VoiceState::Disconnected] { + view.state.voice = state; + assert_eq!(view.server_icon_for(&bookmark.address).size().width, 0); + } + assert!(!apply_server_icon(&mut bookmark, &mut view, "a.test", 4321)); + assert_eq!(view.server_icon, 1234); + assert_eq!(view.icon_address.as_deref(), Some("a.test")); + assert!(bookmark.server_icon_id().is_none()); + + // Equal icon IDs on the next server still need new provenance. + assert!(apply_server_icon(&mut bookmark, &mut view, "b.test", 1234)); + assert_eq!(bookmark.server_icon_id(), Some(1234)); + assert_eq!(view.server_icon_for(&bookmark.address).size().width, 4); + assert!(!apply_server_icon(&mut bookmark, &mut view, "a.test", 0)); + assert_eq!(bookmark.server_icon_id(), Some(1234)); + assert!(apply_server_icon(&mut bookmark, &mut view, "b.test", 0)); + assert!(bookmark.server_icon_id().is_none()); + assert_eq!(view.server_icon_for(&bookmark.address).size().width, 0); + std::fs::remove_file(path).unwrap(); + } + #[test] fn the_address_alone_makes_a_server() { let form = BookmarkForm { @@ -527,6 +615,10 @@ mod tests { gateway_url: Some("ws://gw.example.test:7788/v1".into()), query: Some(QueryConfig { server_port: Some(9988), ..Default::default() }), client_version: Some("linux".into()), + cached_server_icon: Some(voelin_store::CachedServerIcon { + address: "old.example.test".into(), + id: 1234, + }), }; let form = BookmarkForm { id: 7, @@ -543,6 +635,7 @@ mod tests { let b = bookmark_from_form(Some(&old), &form, || unreachable!("a nickname was given")); assert_eq!((b.id, b.name.as_str(), b.nickname.as_str()), (7, "Mine", "Other")); assert_eq!(b.address, "new.example.test:9988"); + assert!(b.cached_server_icon.is_none()); assert_eq!((b.identity, b.default_channel), (Some(2), Some("Lobby/Sub".into()))); assert_eq!(b.client_version.as_deref(), Some("linux")); assert_eq!(b.gateway_url, None); diff --git a/crates/voelin-ui/src/social.rs b/crates/voelin-ui/src/social.rs index 69b99b0..28957e3 100644 --- a/crates/voelin-ui/src/social.rs +++ b/crates/voelin-ui/src/social.rs @@ -958,11 +958,7 @@ impl App { subtitle: b.address.clone().into(), initials: vm::avatar::initials(&b.name).into(), tint: vm::avatar::tint(&b.name), - avatar: self - .sessions - .get(&b.id) - .map(|v| v.server_icon()) - .unwrap_or_default(), + avatar: self.server_list_icon(b), ..Default::default() }, Found::Server(b.id), diff --git a/crates/voelin-ui/src/vm/servers.rs b/crates/voelin-ui/src/vm/servers.rs index 7564f1b..a8ed7a7 100644 --- a/crates/voelin-ui/src/vm/servers.rs +++ b/crates/voelin-ui/src/vm/servers.rs @@ -6,6 +6,12 @@ use voelin_store::Bookmark; use crate::app::ServerItem; use crate::vm::avatar; +/// Restore a known server icon before any session exists. A missing/evicted +/// cache file falls back to initials; the bookmark stores no filesystem path. +pub fn cached_icon(bookmark: &Bookmark, cache: &voelin_core::Cache) -> slint::Image { + avatar::image(bookmark.server_icon_id().and_then(|id| cache.icon(id)).as_ref()) +} + /// "offline", "connecting", "observing" or "connected". pub fn status(state: &SessionState) -> &'static str { match (state.voice, state.observe) { @@ -92,6 +98,40 @@ pub fn invite_link(address: &str, path: &[&str]) -> String { mod tests { use super::*; + #[test] + fn server_icon_is_visible_before_connection_and_missing_files_fall_back() { + let dir = + std::env::temp_dir().join(format!("voelin-server-icon-model-{}", std::process::id())); + std::fs::create_dir_all(dir.join("icons")).unwrap(); + let path = dir.join("icons/1234"); + let mut bytes = Vec::new(); + let mut encoder = png::Encoder::new(&mut bytes, 4, 4); + encoder.set_color(png::ColorType::Rgba); + encoder.set_depth(png::BitDepth::Eight); + encoder.write_header().unwrap().write_image_data(&[200; 64]).unwrap(); + std::fs::write(&path, bytes).unwrap(); + let cache = voelin_core::Cache::new(&dir); + let mut bookmark = Bookmark { address: "example.test".into(), ..Default::default() }; + bookmark.remember_server_icon(1234); + let server = item( + &bookmark, + &SessionState::default(), + 0, + false, + String::new(), + String::new(), + cached_icon(&bookmark, &cache), + ); + assert_eq!(server.status.as_str(), "offline"); + assert_eq!(server.icon.size().width, 4); + bookmark.address = "different.test".into(); + assert_eq!(cached_icon(&bookmark, &cache).size().width, 0); + bookmark.address = "example.test".into(); + std::fs::remove_file(path).unwrap(); + assert_eq!(cached_icon(&bookmark, &cache).size().width, 0); + std::fs::remove_dir_all(dir).unwrap(); + } + #[test] fn invite_links() { assert_eq!( diff --git a/crates/voelin-ui/src/vm/tree.rs b/crates/voelin-ui/src/vm/tree.rs index 01e7c69..f8753ba 100644 --- a/crates/voelin-ui/src/vm/tree.rs +++ b/crates/voelin-ui/src/vm/tree.rs @@ -102,28 +102,43 @@ fn talking(input: &TreeInput, client: &ClientInfo) -> bool { input.talking.contains(&client.id) || client.talking == Some(true) } +/// Centered spacer prefixes are presentation metadata, not part of the title. +/// Leave other names untouched rather than guessing at the full spacer syntax. +fn channel_label(name: &str) -> (&str, bool) { + if let Some((suffix, label)) = name.strip_prefix("[cspacer").and_then(|s| s.split_once(']')) { + if suffix.bytes().all(|b| b.is_ascii_digit()) { + return (label, true); + } + } + (name, false) +} + /// The rows of the tree, channels with their clients below. pub fn rows(input: &TreeInput) -> Vec { let p = input.presence; let rows: Vec = tree_rows(p, &|cid| input.collapsed.contains(&cid)) .into_iter() .map(|row| match row { - TreeRow::Channel { depth, channel } => TreeItem { - is_channel: true, - depth: depth as i32, - id: channel.id as i32, - name: channel.name.clone().into(), - own: input.own_channel == Some(channel.id), - locked: channel.has_password, - collapsed: input.collapsed.contains(&channel.id), - local_volume: 100, - members: p.members(channel.id).count() as i32, - max_members: channel.max_clients.filter(|m| *m >= 0).unwrap_or(-1), - icon: input.icon(channel.icon).unwrap_or_default(), - banner: banner(input.pictures, channel.banner_gfx_url.as_deref()), - banner_mode: banner_mode(channel.banner_mode), - ..Default::default() - }, + TreeRow::Channel { depth, channel } => { + let (name, centered_spacer) = channel_label(&channel.name); + TreeItem { + centered_spacer, + is_channel: true, + depth: depth as i32, + id: channel.id as i32, + name: name.into(), + own: input.own_channel == Some(channel.id), + locked: channel.has_password, + collapsed: input.collapsed.contains(&channel.id), + local_volume: 100, + members: p.members(channel.id).count() as i32, + max_members: channel.max_clients.filter(|m| *m >= 0).unwrap_or(-1), + icon: input.icon(channel.icon).unwrap_or_default(), + banner: banner(input.pictures, channel.banner_gfx_url.as_deref()), + banner_mode: banner_mode(channel.banner_mode), + ..Default::default() + } + } TreeRow::Client { depth, client } => { let playback = client .uid @@ -480,6 +495,23 @@ mod tests { std::fs::remove_dir_all(dir).unwrap(); } + #[test] + fn centered_spacer_titles_keep_tree_identity_and_search() { + let mut p = presence(); + p.channels.get_mut(&2).unwrap().name = "[cspacer12]Гамесы".into(); + let (t, c, pb) = (HashSet::new(), HashSet::from([2]), ClientPlaybackMap::new()); + let e = Extras::default(); + let rows = rows(&input(&p, &t, &c, &pb, "Гамесы", &e)); + assert_eq!(rows.len(), 1); + assert_eq!(rows[0].name, "Гамесы"); + assert!(rows[0].centered_spacer && rows[0].collapsed); + assert_eq!(rows[0].id, 2); + assert_eq!(channel_label("[cspacer]Games"), ("Games", true)); + for name in ["[cspacerx]Games", "[cspacer2Games", "Games", "[spacer0]Games"] { + assert_eq!(channel_label(name), (name, false)); + } + } + #[test] fn tree_rows_and_counts() { let p = presence(); diff --git a/crates/voelin-ui/ui/app.slint b/crates/voelin-ui/ui/app.slint index f7ecd20..d3515f1 100644 --- a/crates/voelin-ui/ui/app.slint +++ b/crates/voelin-ui/ui/app.slint @@ -219,7 +219,6 @@ export component MainWindow inherits Window { && Bridge.current-tab >= 0 && Bridge.current-tab < Bridge.tabs.length && Bridge.tabs[Bridge.current-tab].kind == 1; banner: self.channel-chat ? Bridge.tabs[Bridge.current-tab].banner : @image-url(""); - banner-mode: self.channel-chat ? Bridge.tabs[Bridge.current-tab].banner-mode : 0; title: Nav.page == Page.settings ? @tr("Settings") : Nav.page == Page.friends ? @tr("Friends") : Nav.page == Page.messages ? @tr("Messages") diff --git a/crates/voelin-ui/ui/bridge.slint b/crates/voelin-ui/ui/bridge.slint index 8d3bc35..8c349f9 100644 --- a/crates/voelin-ui/ui/bridge.slint +++ b/crates/voelin-ui/ui/bridge.slint @@ -27,6 +27,8 @@ export struct ServerItem { export struct TreeItem { is-channel: bool, + // Recognized centred TeamSpeak spacer; name excludes its wire prefix. + centered-spacer: bool, depth: int, id: int, name: string, @@ -52,14 +54,14 @@ export struct TreeItem { // Channels: clients inside, and the limit (-1: none). members: int, max-members: int, - // Icons at the end of the row, empty where there is none: a channel's + // Leading channel icon or trailing client icons, empty where absent: a channel's // icon; a client's server group icons, its channel group's and its own, // in that order (the first three). icon: image, icon-2: image, icon-3: image, // A channel's banner picture (TeamSpeak 6), drawn behind the row; - // banner-mode: 0 as it is, 1 stretched, 2 scaled keeping its aspect. + // Wire sizing metadata; compact decorative backgrounds always cover. banner: image, banner-mode: int, } @@ -819,6 +821,7 @@ export global Bridge { in property server-stats; // The server's host banner, empty without one (the server card shows its // painted art then); mode as TreeItem.banner-mode. + in property server-icon; in property server-banner; in property server-banner-mode; // Our nickname on the current server, our avatar there (empty without diff --git a/crates/voelin-ui/ui/components/banner-picture.slint b/crates/voelin-ui/ui/components/banner-picture.slint index 965d878..8978698 100644 --- a/crates/voelin-ui/ui/components/banner-picture.slint +++ b/crates/voelin-ui/ui/components/banner-picture.slint @@ -1,29 +1,25 @@ import { Theme } from "../theme.slint"; -// Native artwork keeps its pixel size; resized artwork gets an aspect-aware -// area. Bound unusually tall pictures so navigation remains usable. -export global BannerLayout { - public pure function artwork-height(source: image, width: length, mode: int, limit: length) -> length { - return source.width <= 0 ? 0px : min(limit, max(32px, - mode == 0 ? source.height * 1px : width * source.height / source.width)); - } -} - -// Artwork has its own area: titles and controls use the solid surface below. -// Wire modes: 0 native (centred), 1 stretched, 2 aspect-preserving fit. +// Banners decorate their owning row/header; they never add layout height. +// Cover keeps artwork undistorted while cropping its centre to the surface. export component BannerPicture inherits Rectangle { in property source; - in property mode; clip: true; - background: Theme.surface-2; accessible-role: AccessibleRole.none; Image { width: 100%; height: 100%; source: root.source; - image-fit: root.mode == 1 ? ImageFit.fill : root.mode == 2 ? ImageFit.contain : ImageFit.preserve; + image-fit: cover; horizontal-alignment: center; vertical-alignment: center; accessible-role: AccessibleRole.none; } + // Even a white picture behind dark-theme text (or black behind light + // text) retains >4.5:1 contrast for Theme.text at the weakest stop. + Rectangle { + background: @linear-gradient(90deg, + Theme.surface.transparentize(0.26) 0%, + Theme.surface.transparentize(0.34) 100%); + } } diff --git a/crates/voelin-ui/ui/components/index.slint b/crates/voelin-ui/ui/components/index.slint index c14630a..b67248d 100644 --- a/crates/voelin-ui/ui/components/index.slint +++ b/crates/voelin-ui/ui/components/index.slint @@ -9,7 +9,7 @@ export { Toggle, ToggleRow, RadioRow } from "toggle.slint"; export { Slider } from "slider.slint"; export { SegmentedTabs, TabItem } from "tabs.slint"; export { Status, Avatar } from "avatar.slint"; -export { BannerPicture, BannerLayout } from "banner-picture.slint"; +export { BannerPicture } from "banner-picture.slint"; export { CountBadge, LiveBadge, Chip, Dot } from "badge.slint"; export { SectionHeader, Card, Divider, Banner } from "card.slint"; export { Meter, SpeakingBars } from "meter.slint"; diff --git a/crates/voelin-ui/ui/screens/channels.slint b/crates/voelin-ui/ui/screens/channels.slint index 0c58d8c..a73e034 100644 --- a/crates/voelin-ui/ui/screens/channels.slint +++ b/crates/voelin-ui/ui/screens/channels.slint @@ -5,88 +5,78 @@ import { Theme } from "../theme.slint"; import { Icons } from "../icons.slint"; import { Bridge, TreeItem } from "../bridge.slint"; import { Nav } from "../nav.slint"; -import { Icon, Button, ButtonKind, IconButton, Avatar, LiveBadge, Chip, SectionHeader, SpeakingBars, PopupMenu, MenuEntry, ListView, BannerPicture, BannerLayout } from "../components/index.slint"; +import { Icon, Button, ButtonKind, IconButton, Avatar, LiveBadge, Chip, SectionHeader, SpeakingBars, PopupMenu, MenuEntry, ListView, BannerPicture } from "../components/index.slint"; // The banner at the top of the sidebar: server name, counts, a menu. export component ServerHeader inherits Rectangle { - property artwork-height: Bridge.server-banner.width > 0 - ? BannerLayout.artwork-height(Bridge.server-banner, root.width, Bridge.server-banner-mode, 180px) : 64px; - height: root.artwork-height + 76px; + height: 76px * Theme.font-scale; border-radius: Theme.radius-lg; clip: true; background: Theme.surface-2; accessible-role: AccessibleRole.groupbox; accessible-label: Bridge.server-title; - // Keep the full host artwork separate from the server title and actions. if Bridge.server-banner.width > 0: BannerPicture { - y: 0; - height: root.artwork-height; source: Bridge.server-banner; - mode: Bridge.server-banner-mode; } - // Without one, a painted banner: a night sky gradient with a horizon - // glow. - if Bridge.server-banner.width == 0: Rectangle { - height: 72px; - y: 0; - background: @linear-gradient(180deg, #1a2d7a 0%, #3a2a8f 45%, #0b1330 100%); + HorizontalLayout { + padding: Theme.space-3; + spacing: Theme.space-3; Rectangle { - y: parent.height - 30px; - height: 30px; - background: @linear-gradient(180deg, transparent 0%, Theme.surface-2 100%); + width: 42px; + height: 42px; + y: (parent.height - self.height) / 2; + if Bridge.server-icon.width > 0: Image { + width: 100%; + height: 100%; + source: Bridge.server-icon; + image-fit: contain; + accessible-role: AccessibleRole.none; + } + if Bridge.server-icon.width == 0: Icon { + source: Icons.server; + size: 32px; + tint: Theme.text-secondary; + x: (parent.width - self.width) / 2; + y: (parent.height - self.height) / 2; + } } - for star[i] in [ - { x: 0.12, y: 0.2 }, { x: 0.3, y: 0.45 }, { x: 0.52, y: 0.15 }, { x: 0.7, y: 0.35 }, - { x: 0.86, y: 0.18 }, { x: 0.42, y: 0.62 }, { x: 0.93, y: 0.55 }, { x: 0.2, y: 0.7 }, - ]: Rectangle { - x: parent.width * star.x; - y: parent.height * star.y; - width: mod(i, 3) == 0 ? 3px : 2px; - height: self.width; - border-radius: self.width / 2; - background: #ffffffb0; - } - } - VerticalLayout { - padding: Theme.space-4; - padding-top: root.artwork-height + Theme.space-2; - spacing: 2px; - HorizontalLayout { - spacing: Theme.space-2; + VerticalLayout { + alignment: center; + horizontal-stretch: 1; + spacing: 3px; Text { text: Bridge.server-title; - font-size: Theme.font-lg; + font-size: Theme.font-md; font-weight: Theme.weight-semibold; color: Theme.text; - vertical-alignment: center; - horizontal-stretch: 1; overflow: elide; } - if Bridge.current-server >= 0: IconButton { - icon: Icons.chevron-down; - label: @tr("Server menu"); - size: 28px; - icon-size: Theme.icon-sm; - clicked => { menu.show(self.x + self.width - 220px, self.y + self.height + 4px); } + HorizontalLayout { + spacing: Theme.space-2; + Rectangle { + width: 7px; + height: 7px; + y: (parent.height - self.height) / 2; + border-radius: 4px; + background: Bridge.voice-connected ? Theme.success : Bridge.observing ? Theme.info : Bridge.voice-connecting ? Theme.warning : Theme.offline; + } + Text { + text: Bridge.server-stats != "" ? Bridge.server-stats + : Bridge.voice-connecting ? @tr("Connecting…") + : Bridge.current-server >= 0 ? @tr("Not connected") : @tr("Add a server to start"); + font-size: Theme.font-xs; + color: Bridge.server-banner.width > 0 ? Theme.text : Theme.text-secondary; + overflow: elide; + } } } - HorizontalLayout { - spacing: Theme.space-2; - Rectangle { - width: 8px; - height: 8px; - y: (parent.height - self.height) / 2; - border-radius: 4px; - background: Bridge.voice-connected ? Theme.success : Bridge.observing ? Theme.info : Bridge.voice-connecting ? Theme.warning : Theme.offline; - } - Text { - text: Bridge.server-stats != "" ? Bridge.server-stats - : Bridge.voice-connecting ? @tr("Connecting…") - : Bridge.current-server >= 0 ? @tr("Not connected") : @tr("Add a server to start"); - font-size: Theme.font-sm; - color: Theme.text-secondary; - overflow: elide; - } + if Bridge.current-server >= 0: IconButton { + icon: Icons.chevron-down; + label: @tr("Server menu"); + size: 24px; + icon-size: Theme.icon-sm; + y: (parent.height - self.height) / 2; + clicked => { menu.show(self.x + self.width - 220px, self.y + self.height + 4px); } } } menu := PopupMenu { @@ -127,8 +117,7 @@ export component ConnectActions inherits HorizontalLayout { } } -// A server's icon (channel, group, client) at the end of a tree row, in its -// own colours. +// A server-provided icon in its own colours. component RowIcon inherits VerticalLayout { in property source; alignment: center; @@ -146,9 +135,7 @@ component TreeRow inherits Rectangle { in property item; callback client-clicked(int); property indent: item.depth * 14px; - property artwork-height: item.is-channel - ? BannerLayout.artwork-height(item.banner, max(0px, root.width - root.indent), item.banner-mode, 112px) : 0px; - height: (item.is-channel ? 34px * Theme.font-scale : 30px * Theme.font-scale) + root.artwork-height; + height: item.is-channel ? 34px * Theme.font-scale : 30px * Theme.font-scale; clip: true; border-radius: Theme.radius-md; background: item.is-channel && item.own ? Theme.accent-soft : area.has-hover ? Theme.surface-3 : transparent; @@ -164,14 +151,12 @@ component TreeRow inherits Rectangle { client-clicked(item.id); } } - // Artwork above the title stays visible without reducing text contrast. + // Artwork is clipped behind the same compact row as its title. if item.is-channel && item.banner.width > 0: BannerPicture { x: root.indent; width: max(0px, root.width - root.indent); y: 0; - height: root.artwork-height; source: item.banner; - mode: item.banner-mode; } area := TouchArea { mouse-cursor: MouseCursor.pointer; @@ -189,33 +174,23 @@ component TreeRow inherits Rectangle { } } if item.is-channel: HorizontalLayout { - y: root.artwork-height; height: 34px * Theme.font-scale; padding-left: Theme.space-2 + root.indent; padding-right: Theme.space-3; spacing: Theme.space-2; - Rectangle { - width: 18px; - accessible-role: AccessibleRole.button; - accessible-label: item.collapsed ? @tr("Expand") : @tr("Collapse"); - accessible-action-default => { Bridge.toggle-collapse(item.id); } - Icon { - source: item.collapsed ? Icons.chevron-right : Icons.chevron-down; - size: 14px; - tint: Theme.text-muted; - } - TouchArea { - clicked => { Bridge.toggle-collapse(item.id); } - } + if item.centered-spacer: Rectangle { width: 18px; } + if !item.centered-spacer && item.icon.width > 0: RowIcon { + source: item.icon; } - Icon { + if !item.centered-spacer && item.icon.width == 0: Icon { source: item.locked ? Icons.lock : Icons.volume-2; size: 18px; - tint: item.own ? Theme.text : Theme.icon; + tint: item.banner.width > 0 || item.own ? Theme.text : Theme.icon; y: (parent.height - self.height) / 2; } Text { text: item.name; + horizontal-alignment: item.centered-spacer ? center : left; // Full contrast over a banner. color: item.own || item.banner.width > 0 ? Theme.text : Theme.text-secondary; font-weight: item.own || item.banner.width > 0 ? Theme.weight-semibold : Theme.weight-medium; @@ -223,10 +198,13 @@ component TreeRow inherits Rectangle { horizontal-stretch: 1; overflow: elide; } - if item.icon.width > 0: RowIcon { - source: item.icon; + if item.locked && item.icon.width > 0: Icon { + source: Icons.lock; + size: 14px; + tint: item.banner.width > 0 ? Theme.text : Theme.icon; + y: (parent.height - self.height) / 2; } - if item.members > 0 || item.max-members >= 0: HorizontalLayout { + if !item.centered-spacer && (item.members > 0 || item.max-members >= 0): HorizontalLayout { spacing: 3px; if item.own: Icon { source: Icons.users; @@ -236,11 +214,26 @@ component TreeRow inherits Rectangle { } Text { text: item.max-members >= 0 ? item.members + "/" + item.max-members : item.members; - color: item.own ? Theme.text : item.banner.width > 0 ? Theme.text-secondary : Theme.text-muted; + color: item.own || item.banner.width > 0 ? Theme.text : Theme.text-muted; font-size: Theme.font-sm; vertical-alignment: center; } } + Rectangle { + width: 18px; + accessible-role: AccessibleRole.button; + accessible-label: item.collapsed ? @tr("Expand") : @tr("Collapse"); + accessible-action-default => { Bridge.toggle-collapse(item.id); } + Icon { + source: item.collapsed ? Icons.chevron-right : Icons.chevron-down; + size: 14px; + tint: item.banner.width > 0 ? Theme.text : Theme.text-muted; + y: (parent.height - self.height) / 2; + } + TouchArea { + clicked => { Bridge.toggle-collapse(item.id); } + } + } } if !item.is-channel: HorizontalLayout { padding-left: Theme.space-2 + root.indent + 12px; diff --git a/crates/voelin-ui/ui/screens/chat.slint b/crates/voelin-ui/ui/screens/chat.slint index 572765b..37fac8a 100644 --- a/crates/voelin-ui/ui/screens/chat.slint +++ b/crates/voelin-ui/ui/screens/chat.slint @@ -6,15 +6,18 @@ import { Theme } from "../theme.slint"; import { Icons } from "../icons.slint"; import { Bridge, ChatLine, ReactionItem, FileItem, Images } from "../bridge.slint"; import { Nav } from "../nav.slint"; -import { Icon, IconButton, Avatar, Chip, TabItem, TextField, RichText, Banner, Button, ButtonKind, Spinner, Tooltip, ListView, BannerPicture, BannerLayout } from "../components/index.slint"; +import { Icon, IconButton, Avatar, Chip, TabItem, TextField, RichText, Banner, Button, ButtonKind, Spinner, Tooltip, ListView, BannerPicture } from "../components/index.slint"; -// The title, description and actions below a separate channel artwork area. +// A compact title and actions over the optional channel background. export component PageHeader inherits Rectangle { in property icon: Icons.hash; + in property banner; in property title; in property description; min-height: 60px; border-width: 0px; + clip: true; + if root.banner.width > 0: BannerPicture { source: root.banner; } HorizontalLayout { padding-left: Theme.space-6; padding-right: Theme.space-4; @@ -43,7 +46,7 @@ export component PageHeader inherits Rectangle { Text { text: root.description; font-size: Theme.font-sm; - color: Theme.text-muted; + color: root.banner.width > 0 ? Theme.text : Theme.text-muted; vertical-alignment: center; horizontal-stretch: 1; overflow: elide; @@ -583,14 +586,9 @@ export component ChatView inherits VerticalLayout { property tab-kind: Bridge.current-tab >= 0 && Bridge.current-tab < Bridge.tabs.length ? Bridge.tabs[Bridge.current-tab].kind : 0; property tab-topic: Bridge.current-tab >= 0 && Bridge.current-tab < Bridge.tabs.length ? Bridge.tabs[Bridge.current-tab].topic : ""; property tab-banner: Bridge.current-tab >= 0 && Bridge.current-tab < Bridge.tabs.length ? Bridge.tabs[Bridge.current-tab].banner : @image-url(""); - property tab-banner-mode: Bridge.current-tab >= 0 && Bridge.current-tab < Bridge.tabs.length ? Bridge.tabs[Bridge.current-tab].banner-mode : 0; - if root.header && root.tab-banner.width > 0: BannerPicture { - height: BannerLayout.artwork-height(root.tab-banner, self.width, root.tab-banner-mode, 160px); - source: root.tab-banner; - mode: root.tab-banner-mode; - } if root.header: PageHeader { + banner: root.tab-banner; icon: root.tab-kind == 1 ? Icons.hash : root.tab-kind == 2 ? Icons.at-sign : Icons.message-square; title: root.tab-name; description: root.tab-topic != "" ? root.tab-topic : Bridge.server-title; diff --git a/crates/voelin-ui/ui/screens/mobile-voice.slint b/crates/voelin-ui/ui/screens/mobile-voice.slint index f43743c..9e37500 100644 --- a/crates/voelin-ui/ui/screens/mobile-voice.slint +++ b/crates/voelin-ui/ui/screens/mobile-voice.slint @@ -7,7 +7,7 @@ import { Theme } from "../theme.slint"; import { Icons } from "../icons.slint"; import { Bridge, MemberItem, StreamItem } from "../bridge.slint"; import { Nav, MobileTab } from "../nav.slint"; -import { Icon, IconButton, Button, ButtonKind, Avatar, LiveBadge, Select, Slider, SpeakingBars, ScrollView, BannerPicture, BannerLayout } from "../components/index.slint"; +import { Icon, IconButton, Button, ButtonKind, Avatar, LiveBadge, Select, Slider, SpeakingBars, ScrollView, BannerPicture } from "../components/index.slint"; import { MessageList, Composer } from "chat.slint"; import { StudioBridge } from "../studio-bridge.slint"; @@ -21,18 +21,15 @@ export global PhoneVoice { } } -// The channel artwork above its name, topic, Back and Leave. +// Channel background behind its name, topic, Back and Leave. component ChannelBar inherits Rectangle { - property artwork-height: BannerLayout.artwork-height(Bridge.own-channel-banner, root.width, Bridge.own-channel-banner-mode, 120px); - height: 56px + root.artwork-height; + height: 56px; + clip: true; if Bridge.own-channel-banner.width > 0: BannerPicture { y: 0; - height: root.artwork-height; source: Bridge.own-channel-banner; - mode: Bridge.own-channel-banner-mode; } HorizontalLayout { - y: root.artwork-height; height: 56px; padding-left: Theme.space-3; padding-right: Theme.space-3; @@ -64,7 +61,7 @@ component ChannelBar inherits Rectangle { } if Bridge.own-channel-topic != "": Text { text: Bridge.own-channel-topic; - color: Theme.text-secondary; + color: Bridge.own-channel-banner.width > 0 ? Theme.text : Theme.text-secondary; font-size: Theme.font-sm; overflow: elide; } diff --git a/crates/voelin-ui/ui/screens/streams.slint b/crates/voelin-ui/ui/screens/streams.slint index 221323f..f0d23a5 100644 --- a/crates/voelin-ui/ui/screens/streams.slint +++ b/crates/voelin-ui/ui/screens/streams.slint @@ -5,7 +5,7 @@ import { Theme } from "../theme.slint"; import { Icons } from "../icons.slint"; import { Bridge, StreamItem, MemberItem } from "../bridge.slint"; import { Nav } from "../nav.slint"; -import { Icon, Button, ButtonKind, IconButton, Avatar, Status, LiveBadge, Chip, Select, SectionHeader, SpeakingBars, Slider, Spinner, TextField, TabItem, ListView, ScrollView, BannerPicture, BannerLayout } from "../components/index.slint"; +import { Icon, Button, ButtonKind, IconButton, Avatar, Status, LiveBadge, Chip, Select, SectionHeader, SpeakingBars, Slider, Spinner, TextField, TabItem, ListView, ScrollView } from "../components/index.slint"; import { MemberRow, GroupHeader } from "members.slint"; import { PageHeader, MessageList, Composer } from "chat.slint"; @@ -453,12 +453,8 @@ export component StreamViewer inherits Rectangle { compact: true; } if !root.alone: VerticalLayout { - if Bridge.own-channel-banner.width > 0: BannerPicture { - height: BannerLayout.artwork-height(Bridge.own-channel-banner, self.width, Bridge.own-channel-banner-mode, 160px); - source: Bridge.own-channel-banner; - mode: Bridge.own-channel-banner-mode; - } PageHeader { + banner: Bridge.own-channel-banner; icon: Icons.volume-2; title: Bridge.own-channel != "" ? Bridge.own-channel : Bridge.viewer-title; description: Bridge.own-channel-topic; diff --git a/crates/voelin-ui/ui/screens/voice.slint b/crates/voelin-ui/ui/screens/voice.slint index 5e6033d..a44ee55 100644 --- a/crates/voelin-ui/ui/screens/voice.slint +++ b/crates/voelin-ui/ui/screens/voice.slint @@ -5,7 +5,7 @@ import { Theme } from "../theme.slint"; import { Icons } from "../icons.slint"; import { Bridge, MemberItem, StreamItem } from "../bridge.slint"; import { Nav, SettingsSection } from "../nav.slint"; -import { Icon, IconButton, Button, ButtonKind, Avatar, LiveBadge, Chip, SpeakingBars, BannerPicture, BannerLayout } from "../components/index.slint"; +import { Icon, IconButton, Button, ButtonKind, Avatar, LiveBadge, Chip, SpeakingBars, BannerPicture } from "../components/index.slint"; import { MessageList, Composer } from "chat.slint"; // One person: a large avatar with a ring (green while talking, blue while @@ -212,14 +212,12 @@ component StreamCard inherits Rectangle { // The voice channel view (desktop): header, people, streams, chat. export component VoiceView inherits VerticalLayout { - // The title with the buttons beside it; the topic and the count below - // take the whole width. Artwork sits above the title on its own surface. - if Bridge.own-channel-banner.width > 0: BannerPicture { - height: BannerLayout.artwork-height(Bridge.own-channel-banner, self.width, Bridge.own-channel-banner-mode, 160px); - source: Bridge.own-channel-banner; - mode: Bridge.own-channel-banner-mode; - } + // Banner shares the header; it does not push people and streams down. Rectangle { + clip: true; + if Bridge.own-channel-banner.width > 0: BannerPicture { + source: Bridge.own-channel-banner; + } HorizontalLayout { padding-left: Theme.space-7; padding-right: Theme.space-5; @@ -271,7 +269,7 @@ export component VoiceView inherits VerticalLayout { } if Bridge.own-channel-topic != "": Text { text: Bridge.own-channel-topic; - color: Theme.text-secondary; + color: Bridge.own-channel-banner.width > 0 ? Theme.text : Theme.text-secondary; font-size: Theme.font-md; overflow: elide; } @@ -288,7 +286,7 @@ export component VoiceView inherits VerticalLayout { text: Bridge.own-channel-limit >= 0 ? @tr("{} in voice / {} total", Bridge.members.length, Bridge.own-channel-limit) : @tr("{} in voice", Bridge.members.length); - color: Theme.text-secondary; + color: Bridge.own-channel-banner.width > 0 ? Theme.text : Theme.text-secondary; font-size: Theme.font-body; } } diff --git a/crates/voelin-ui/ui/shells/mobile.slint b/crates/voelin-ui/ui/shells/mobile.slint index 7a74ac4..e46d89e 100644 --- a/crates/voelin-ui/ui/shells/mobile.slint +++ b/crates/voelin-ui/ui/shells/mobile.slint @@ -6,7 +6,7 @@ import { Theme } from "../theme.slint"; import { Icons } from "../icons.slint"; import { Bridge } from "../bridge.slint"; import { Nav, Page, MobileTab, SettingsSection } from "../nav.slint"; -import { Icon, IconButton, CountBadge, PopupMenu, MenuEntry, BannerPicture, BannerLayout } from "../components/index.slint"; +import { Icon, IconButton, CountBadge, PopupMenu, MenuEntry, BannerPicture } from "../components/index.slint"; import { PhoneVoice } from "../screens/mobile-voice.slint"; // One entry of the bottom navigation. @@ -107,7 +107,6 @@ export component MobileShell inherits Rectangle { in property title; in property subtitle; in property banner; - in property banner-mode; // Total unread messages (the Chat tab's badge). in property unread; // Show a back arrow (sub-pages such as the settings). @@ -121,15 +120,12 @@ export component MobileShell inherits Rectangle { callback go-back(); background: Theme.backdrop; VerticalLayout { - if root.banner.width > 0: BannerPicture { - height: BannerLayout.artwork-height(root.banner, self.width, root.banner-mode, 120px); - source: root.banner; - mode: root.banner-mode; - } // Top bar. Rectangle { height: 60px; accessible-role: AccessibleRole.banner; + clip: true; + if root.banner.width > 0: BannerPicture { source: root.banner; } HorizontalLayout { padding-left: Theme.space-4; padding-right: Theme.space-3; @@ -160,7 +156,7 @@ export component MobileShell inherits Rectangle { } if root.subtitle != "": Text { text: root.subtitle; - color: Theme.accent-text; + color: root.banner.width > 0 ? Theme.text : Theme.accent-text; font-size: Theme.font-sm; overflow: elide; } diff --git a/docs/screenshots/banners-desktop-dark.png b/docs/screenshots/banners-desktop-dark.png index 62d724e..915f2e7 100644 Binary files a/docs/screenshots/banners-desktop-dark.png and b/docs/screenshots/banners-desktop-dark.png differ diff --git a/docs/screenshots/banners-desktop-light.png b/docs/screenshots/banners-desktop-light.png index 7a7e685..6f99e88 100644 Binary files a/docs/screenshots/banners-desktop-light.png and b/docs/screenshots/banners-desktop-light.png differ diff --git a/docs/screenshots/banners-desktop-voice.png b/docs/screenshots/banners-desktop-voice.png index e13a634..4f6691b 100644 Binary files a/docs/screenshots/banners-desktop-voice.png and b/docs/screenshots/banners-desktop-voice.png differ diff --git a/docs/screenshots/banners-mobile-chat.png b/docs/screenshots/banners-mobile-chat.png index d12270e..a9ce79b 100644 Binary files a/docs/screenshots/banners-mobile-chat.png and b/docs/screenshots/banners-mobile-chat.png differ diff --git a/docs/screenshots/banners-mobile-servers.png b/docs/screenshots/banners-mobile-servers.png index dfcf3b7..864361b 100644 Binary files a/docs/screenshots/banners-mobile-servers.png and b/docs/screenshots/banners-mobile-servers.png differ diff --git a/docs/screenshots/banners-mobile-voice.png b/docs/screenshots/banners-mobile-voice.png index 529350d..4ab5d01 100644 Binary files a/docs/screenshots/banners-mobile-voice.png and b/docs/screenshots/banners-mobile-voice.png differ diff --git a/docs/ui.md b/docs/ui.md index 1f01ce7..8fb900b 100644 --- a/docs/ui.md +++ b/docs/ui.md @@ -424,15 +424,31 @@ the window's size so the pointer is not over the window, and passes ## Server and channel pictures -The server card shows the host banner. TeamSpeak 6 channel banners appear -above their tree rows, the desktop chat and voice headers, and the phone's -chat and voice headers. Artwork has a separate area from titles and controls, -so bright pictures remain visible without reducing text contrast. Areas follow -the picture's aspect ratio, capped at 180 pixels for the host, 112 for tree -rows, 160 for desktop headers and 120 for phone headers. The server's sizing -mode is preserved: 0 centres the original picture (clipped to the bounded -area), 1 stretches it, and 2 fits it while keeping its aspect ratio. -Missing or refused pictures leave the normal background in place. +The compact server card shows its icon over the host banner. TeamSpeak 6 +channel banners sit behind their titles in fixed-height tree rows (34 pixels), +and behind desktop and phone chat/voice headers. Artwork uses centred cover +cropping without distortion; it never adds height to navigation. Custom channel +icons lead the title, and recognized `[cspacerN]` labels are centred without +showing the prefix. A theme-aware surface gradient (74% to 66% opacity) keeps +primary text above 4.5:1 contrast even on all-white or all-black artwork, while +leaving the image visible. Missing pictures retain the normal background. + +Bookmarks remember the server icon ID and the address that supplied it. The +server list, search results and server header load its cached bytes before +connecting, including after restarting the app. Editing a server address +invalidates the association; queued details from the old address cannot replace +it. A missing or evicted image falls back to initials. This requires no +ServerQuery configuration and starts no background voice connection. + +First-visit icon downloads before login remain unverified. On a private TS6 +6.0.0-beta13.1 fixture, the native encrypted handshake completed without +`clientinit`, but pre-login `serverinfo`, `getserverinfo`, `servergetvariables`, +`ftinitdownload` and `ftgetchannelfilehttptoken scid=icons` probes each received +no response within three seconds. The installed official client's UI code +populates its bookmark icon cache from connected server properties. Its clean +profile requires account setup before the server list, so no fresh-profile +network capture was obtained. These observations do not establish that every +server or client version lacks a pre-login mechanism. The engine downloads HTTP(S) banners only while `cache.fetch_images` is enabled. Up to eight distinct banners download concurrently; duplicate URLs @@ -455,8 +471,10 @@ no extension. Raster pictures larger than 16,384 pixels on either axis or thread. SVG uses Slint's vector loader and the existing vector-cache cost. Avatars and server, channel, client and group icons use the same image cache. -The focused checks are the `voelin-core`, `voelin-model`, `voelin-observer` -and `voelin-ui` library tests. The live `ts6_banners` test checks disabled +The focused checks are the `voelin-core`, `voelin-model`, `voelin-observer`, +`voelin-store` and `voelin-ui` library tests. They cover offline icon restoration, +bookmark compatibility, cache misses and old-address event rejection. The live +`ts6_banners` test checks disabled fetching, recovery from HTTP 503 without another presence update, all three modes, channel URL replacement and removal, and a fresh host download after the 60-second interval. `ts6_avatars` uploads an avatar with one client and @@ -472,9 +490,11 @@ VOELIN_BANNER_QUERY_ADDR=127.0.0.1:20022 \ cargo test --locked -p voelin-core --test live ts6_banners -- --exact ``` -The 2026-10-04 check passed 176 focused library tests and both live scenarios -against a private TS6 6.0.0-beta13.1 instance, including its real reload -interval. These screenshots use sample data on Xvfb with Slint's software +The 2026-10-04 follow-up passed all 200 focused library tests. The download +checks passed both live scenarios against a private +TS6 6.0.0-beta13.1 instance, including its real reload interval. The compact +layout passed seven headless screenshot scenarios. These screenshots use +sample data on Xvfb with Slint's software renderer; the phone layouts are desktop renders, not Android device tests. | Desktop | Phone layout |