The server page had one layout: a channel tree, a chat and a panel of members and streams. The design asks for more of it at once, so the same page now carries the pieces it was missing. The chat shows reactions, a pin marker, file cards and older messages, and every message can be reacted to, pinned or made into a topic where the gateway offers it. A compact voice bar sits over it with the connected channel, who is talking and the voice controls, so the sidebar card is no longer the only way to leave or mute. The members panel groups people by server group with the group's icon, shows the badges and talk power a TeamSpeak client expects, and opens a card with the person's description, groups, private chat, poke, contact and volume. Its width is the setting `ui.members_width`, so dragging the handle keeps it. Pins and topics are drawers over the chat, the voice channel can be seen as a grid of tiles with the streams in it, and the stream viewer gained the elapsed time, the viewer count, a quality picker, a mute button, the chat beside the player and a pop-out that hides the shell. The quality picker stays hidden for now: the engine tells a viewer neither which simulcast layers a streamer offers nor lets it ask for one, so there is nothing to choose between. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
74 lines
2.6 KiB
Rust
74 lines
2.6 KiB
Rust
//! Appearance settings (`ui.theme`, `ui.font_scale`, `ui.narrow_breakpoint`,
|
|
//! `ui.image_cache_mb`): applied to the Theme and Nav globals and the image
|
|
//! cache whenever they change, from the settings page or elsewhere.
|
|
|
|
use slint::ComponentHandle;
|
|
use tracing::warn;
|
|
|
|
use crate::app::{App, AppearanceForm, Bridge, Nav, Theme};
|
|
use crate::images;
|
|
use crate::settings::{
|
|
ThemeChoice, UI_FONT_SCALE, UI_IMAGE_CACHE_MB, UI_MEMBERS_WIDTH, UI_NARROW_BREAKPOINT, UI_THEME,
|
|
};
|
|
|
|
impl App {
|
|
/// Show the current values of the appearance keys.
|
|
pub(crate) fn apply_appearance(&self) {
|
|
let theme = self.prefs.get(&UI_THEME);
|
|
let scale = self.prefs.get(&UI_FONT_SCALE);
|
|
let breakpoint = self.prefs.get(&UI_NARROW_BREAKPOINT);
|
|
let cache_mb = self.prefs.get(&UI_IMAGE_CACHE_MB);
|
|
images::set_budget_mb(cache_mb);
|
|
let Some(ui) = self.ui.upgrade() else { return };
|
|
let t = ui.global::<Theme>();
|
|
t.set_mode(theme.as_str().into());
|
|
t.set_font_scale(scale);
|
|
let nav = ui.global::<Nav>();
|
|
nav.set_narrow_breakpoint(breakpoint as f32);
|
|
let width = self.prefs.get(&UI_MEMBERS_WIDTH) as f32;
|
|
if nav.get_right_panel_width() != width {
|
|
nav.set_right_panel_width(width);
|
|
}
|
|
let bridge = ui.global::<Bridge>();
|
|
bridge.set_appearance(AppearanceForm {
|
|
theme: theme.as_str().into(),
|
|
font_scale: scale,
|
|
narrow_breakpoint: breakpoint as f32,
|
|
image_cache_mb: cache_mb as f32,
|
|
});
|
|
bridge.set_image_cache_usage(images::usage_text().into());
|
|
}
|
|
|
|
/// The settings page changed the form: store the keys (they apply
|
|
/// through the change events).
|
|
pub(crate) fn appearance_changed(&mut self, form: &AppearanceForm) {
|
|
let results = [
|
|
self.prefs.set(&UI_THEME, ThemeChoice::parse(&form.theme)),
|
|
self.prefs.set(&UI_FONT_SCALE, form.font_scale),
|
|
self.prefs.set(&UI_NARROW_BREAKPOINT, form.narrow_breakpoint.max(0.0).round() as u32),
|
|
self.prefs.set(&UI_IMAGE_CACHE_MB, form.image_cache_mb.max(0.0).round() as u32),
|
|
];
|
|
for result in results {
|
|
if let Err(e) = result {
|
|
warn!(%e, "appearance setting rejected");
|
|
self.set_status(e.to_string());
|
|
}
|
|
}
|
|
// Applied now too: change events come through the engine, which
|
|
// may not run the settings service (tests, a hosted engine).
|
|
self.apply_appearance();
|
|
}
|
|
|
|
/// The members panel was dragged to another width: store it, so it
|
|
/// comes back the same and `--set ui.members_width` can change it.
|
|
pub(crate) fn panel_resized(&mut self, width: f32) {
|
|
let width = width.max(0.0).round() as u32;
|
|
if self.prefs.get(&UI_MEMBERS_WIDTH) == width {
|
|
return;
|
|
}
|
|
if let Err(e) = self.prefs.set(&UI_MEMBERS_WIDTH, width) {
|
|
warn!(%e, "could not store the panel width");
|
|
}
|
|
}
|
|
}
|