feat(client): redesign native UI, themes, settings and avatars
Separate conversation drafts and voice view state, add native settings and restricted CSS themes, implement validated avatar cropping, and refresh dependencies with documented desktop compatibility backports.
This commit is contained in:
parent
44d284a568
commit
8e5ab56611
276 changed files with 53546 additions and 3399 deletions
81
patches/i-slint-backend-winit/tests/hide_from_window_event.rs
vendored
Normal file
81
patches/i-slint-backend-winit/tests/hide_from_window_event.rs
vendored
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
// Copyright © SixtyFPS GmbH <info@slint.dev>
|
||||
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
|
||||
|
||||
//! Hiding a window from one of its own event handlers must not report that the window
|
||||
//! is kept alive: the event loop holds a reference to it while dispatching the event.
|
||||
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::rc::Rc;
|
||||
|
||||
use slint::winit_030::{CustomApplicationHandler, EventResult, winit};
|
||||
|
||||
/// Part of the message the backend logs about a window kept alive after being hidden.
|
||||
const REPORT: &str = "references to it still exist";
|
||||
|
||||
slint::slint! {
|
||||
export component App inherits Window {
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
}
|
||||
}
|
||||
|
||||
/// Hides the window from a winit event, like an application does on a click on the close button.
|
||||
struct HideOnRedraw {
|
||||
hidden: Rc<Cell<bool>>,
|
||||
}
|
||||
|
||||
impl CustomApplicationHandler for HideOnRedraw {
|
||||
fn window_event(
|
||||
&mut self,
|
||||
_event_loop: &winit::event_loop::ActiveEventLoop,
|
||||
_window_id: winit::window::WindowId,
|
||||
_winit_window: Option<&winit::window::Window>,
|
||||
slint_window: Option<&slint::Window>,
|
||||
event: &winit::event::WindowEvent,
|
||||
) -> EventResult {
|
||||
// Every platform delivers a redraw for a window that was just shown.
|
||||
if !self.hidden.get()
|
||||
&& matches!(event, winit::event::WindowEvent::RedrawRequested)
|
||||
&& let Some(slint_window) = slint_window
|
||||
{
|
||||
self.hidden.set(true);
|
||||
slint_window.hide().unwrap();
|
||||
}
|
||||
EventResult::Propagate
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// Only Wayland destroys the window when it is hidden, and only then is there
|
||||
// something that could be kept alive. Take that path on every platform.
|
||||
unsafe { std::env::set_var("SLINT_DESTROY_WINDOW_ON_HIDE", "1") };
|
||||
|
||||
let hidden = Rc::new(Cell::new(false));
|
||||
slint::BackendSelector::new()
|
||||
.backend_name("winit".into())
|
||||
.with_winit_custom_application_handler(HideOnRedraw { hidden: hidden.clone() })
|
||||
.select()
|
||||
.unwrap();
|
||||
|
||||
let messages = Rc::new(RefCell::new(Vec::new()));
|
||||
let collect = messages.clone();
|
||||
i_slint_core::with_global_context(
|
||||
|| unreachable!("the backend selector set the platform"),
|
||||
|ctx| {
|
||||
ctx.set_log_message_handler(Some(Box::new(move |message| {
|
||||
collect.borrow_mut().push(message.message_arguments().to_string());
|
||||
})))
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let app = App::new().unwrap();
|
||||
app.show().unwrap();
|
||||
// The window is the only one, so the event loop returns once it is hidden.
|
||||
slint::run_event_loop().unwrap();
|
||||
|
||||
assert!(hidden.get(), "the window was never hidden");
|
||||
let reports: Vec<_> =
|
||||
messages.take().into_iter().filter(|message| message.contains(REPORT)).collect();
|
||||
assert!(reports.is_empty(), "the window was reported as kept alive: {reports:?}");
|
||||
}
|
||||
63
patches/i-slint-backend-winit/tests/hide_with_external_reference.rs
vendored
Normal file
63
patches/i-slint-backend-winit/tests/hide_with_external_reference.rs
vendored
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
// Copyright © SixtyFPS GmbH <info@slint.dev>
|
||||
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
|
||||
|
||||
//! An application that keeps the winit window of a hidden window alive is told about it.
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
|
||||
use slint::winit_030::WinitWindowAccessor;
|
||||
|
||||
/// Part of the message the backend logs about a window kept alive after being hidden.
|
||||
const REPORT: &str = "references to it still exist";
|
||||
|
||||
slint::slint! {
|
||||
export component App inherits Window {
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// Only Wayland destroys the window when it is hidden, and only then is there
|
||||
// something that could be kept alive. Take that path on every platform.
|
||||
unsafe { std::env::set_var("SLINT_DESTROY_WINDOW_ON_HIDE", "1") };
|
||||
|
||||
slint::BackendSelector::new().backend_name("winit".into()).select().unwrap();
|
||||
|
||||
let messages = Rc::new(RefCell::new(Vec::new()));
|
||||
let collect = messages.clone();
|
||||
i_slint_core::with_global_context(
|
||||
|| unreachable!("the backend selector set the platform"),
|
||||
|ctx| {
|
||||
ctx.set_log_message_handler(Some(Box::new(move |message| {
|
||||
collect.borrow_mut().push(message.message_arguments().to_string());
|
||||
})))
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let reported = messages.clone();
|
||||
slint::spawn_local(async move {
|
||||
let app = App::new().unwrap();
|
||||
app.show().unwrap();
|
||||
let kept_alive = app.window().winit_window().await.unwrap();
|
||||
|
||||
app.window().hide().unwrap();
|
||||
|
||||
// The report comes once the event loop is done with what hid the window, so read it
|
||||
// on the next iteration.
|
||||
slint::Timer::single_shot(std::time::Duration::default(), move || {
|
||||
let reports: Vec<_> =
|
||||
reported.take().into_iter().filter(|message| message.contains(REPORT)).collect();
|
||||
assert_eq!(reports.len(), 1, "expected one report, got {reports:?}");
|
||||
|
||||
// Let go of the window while the event loop is still there to destroy it.
|
||||
drop(kept_alive);
|
||||
slint::quit_event_loop().unwrap();
|
||||
});
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
slint::run_event_loop_until_quit().unwrap();
|
||||
}
|
||||
38
patches/i-slint-backend-winit/tests/menubar_borrow.rs
vendored
Normal file
38
patches/i-slint-backend-winit/tests/menubar_borrow.rs
vendored
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
// Copyright © SixtyFPS GmbH <info@slint.dev>
|
||||
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
|
||||
|
||||
fn main() {
|
||||
slint::slint! {
|
||||
import { Palette } from "std-widgets.slint";
|
||||
export component App inherits Window {
|
||||
property <bool> dark-mode: Palette.color-scheme == ColorScheme.dark;
|
||||
MenuBar {
|
||||
Menu {
|
||||
title: @tr("Settings");
|
||||
MenuItem {
|
||||
title: @tr("Toggle dark mode");
|
||||
checkable: true;
|
||||
checked: { Palette.color-scheme == ColorScheme.dark } // Result in panic "RefCell already mutably borrowed"
|
||||
activated => {
|
||||
Palette.color-scheme = root.dark-mode ? ColorScheme.light : ColorScheme.dark;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
use slint::winit_030::WinitWindowAccessor;
|
||||
slint::BackendSelector::new().backend_name("winit".into()).select().unwrap();
|
||||
slint::spawn_local(async move {
|
||||
let app = App::new().unwrap();
|
||||
let slint_window = app.window();
|
||||
|
||||
app.show().unwrap();
|
||||
let result = slint_window.winit_window().await;
|
||||
assert!(result.is_ok(), "Failed to get winit window: {:?}", result.err());
|
||||
slint::quit_event_loop().unwrap();
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
slint::run_event_loop().unwrap();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue