merge: upstream/libcosmic a l'etat pinne par epoch-1.9.0 (08a09e3df)

# Conflicts:
#	Cargo.toml
#	i18n/th/libcosmic.ftl
#	iced
#	src/surface/action.rs
#	src/surface/mod.rs
This commit is contained in:
Lionel DARNIS 2026-09-24 20:45:53 +02:00
commit 97f42e565a
51 changed files with 1212 additions and 611 deletions

View file

@ -756,6 +756,7 @@ impl Theme {
}
/// Get the active theme based on the current theme mode.
#[allow(clippy::result_large_err)]
pub fn get_active() -> Result<Self, (Vec<cosmic_config::Error>, Self)> {
(|| {
(if ThemeMode::is_dark(&Config::new(Self::id(), Self::VERSION)?)? {
@ -768,7 +769,6 @@ impl Theme {
.and_then(|theme_config| Self::get_entry(&theme_config))
}
#[must_use]
/// Rebuild the current theme with the provided accent
pub fn with_accent(&self, c: Srgba) -> Self {
let mut oklcha: Oklcha = c.into_color();
@ -1103,7 +1103,7 @@ impl ThemeBuilder {
let container_alpha = alpha_map.blurred_alpha(frosted);
let actual_alpha =
if (frosted_windows || frosted_system_interface || frosted_panel || frosted_applets) {
if frosted_windows || frosted_system_interface || frosted_panel || frosted_applets {
container_alpha
} else {
1.0
@ -1173,9 +1173,14 @@ impl ThemeBuilder {
control_steps_array[0]
};
component_hovered_overlay.alpha = 0.1;
let mut background_pressed_overlay = component_hovered_overlay;
background_pressed_overlay.alpha = 0.2;
#[allow(unused_assignments)]
let mut component_pressed_overlay = component_hovered_overlay;
component_pressed_overlay.alpha = 0.2;
#[allow(unused_assignments)]
{
component_pressed_overlay.alpha = 0.2;
}
// Standard button background is neutral 7 with 25% opacity
let button_bg = control_steps_array[7].with_alpha(0.25);
@ -1210,7 +1215,7 @@ impl ThemeBuilder {
);
let primary = {
let mut container_bg = if let Some(primary_container_bg_color) = primary_container_bg {
let container_bg = if let Some(primary_container_bg_color) = primary_container_bg {
primary_container_bg_color
} else {
get_surface_color(bg_index, 5, &step_array, is_dark, &control_steps_array[1])
@ -1228,7 +1233,7 @@ impl ThemeBuilder {
};
component_hovered_overlay.alpha = 0.1;
component_pressed_overlay = component_hovered_overlay;
let mut component_pressed_overlay = component_hovered_overlay;
component_pressed_overlay.alpha = 0.2;
Container::new(
@ -1363,7 +1368,7 @@ impl ThemeBuilder {
accent,
on_bg_component,
component_hovered_overlay,
component_pressed_overlay,
background_pressed_overlay,
is_high_contrast,
control_steps_array[8],
),
@ -1659,7 +1664,7 @@ impl ThemeBuilder {
/// but this represents the strength of the blur effect.
#[allow(missing_docs)]
#[repr(u8)]
#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq)]
#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Default)]
pub enum BlurStrength {
ExtremelyLow,
ExtremelyLow2,
@ -1667,6 +1672,7 @@ pub enum BlurStrength {
VeryLow2,
Low,
Low2,
#[default]
Medium,
Medium2,
High,
@ -1677,12 +1683,6 @@ pub enum BlurStrength {
ExtremelyHigh2,
}
impl Default for BlurStrength {
fn default() -> Self {
Self::Medium
}
}
impl TryFrom<u8> for BlurStrength {
type Error = ();
@ -1707,6 +1707,7 @@ impl TryFrom<u8> for BlurStrength {
}
}
#[allow(missing_docs)]
#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq)]
pub struct AlphaMap {
pub extremely_low: f32,
@ -1725,6 +1726,7 @@ pub struct AlphaMap {
pub extremely_high_2: f32,
}
#[allow(missing_docs)]
impl AlphaMap {
pub fn blurred_alpha(&self, blur: BlurStrength) -> f32 {
match blur {

View file

@ -321,17 +321,15 @@ impl Theme {
return Ok(None);
}
if let Ok(metadata) = fs::symlink_metadata(path) {
if metadata.file_type().is_symlink() {
if let Ok(actual_cosmic_css) = fs::read_link(path) {
let canonical_target = fs::canonicalize(&actual_cosmic_css)?;
let canonical_base = fs::canonicalize(cosmic_css)?;
return Ok(Some(
canonical_target == canonical_base
|| canonical_target.starts_with(&canonical_base),
));
}
}
if let Ok(metadata) = fs::symlink_metadata(path)
&& metadata.file_type().is_symlink()
&& let Ok(actual_cosmic_css) = fs::read_link(path)
{
let canonical_target = fs::canonicalize(&actual_cosmic_css)?;
let canonical_base = fs::canonicalize(cosmic_css)?;
return Ok(Some(
canonical_target == canonical_base || canonical_target.starts_with(&canonical_base),
));
}
Ok(Some(false))
}

View file

@ -111,7 +111,6 @@ inactive_colors={}
qt6ct_res?;
Ok(())
}
#[must_use]
#[cold]
fn write_ct(&self, ct: &str, qpalette: &str) -> Result<(), OutputError> {
let file_path = Self::get_qpalette_path(ct, self.is_dark)?;
@ -139,7 +138,6 @@ inactive_colors={}
qt6ct_res?;
Ok(())
}
#[must_use]
#[cold]
fn apply_ct(ct: &str, is_dark: bool) -> Result<(), OutputError> {
let path = Self::get_conf_path(ct)?;
@ -213,7 +211,6 @@ inactive_colors={}
qt6ct_res?;
Ok(())
}
#[must_use]
#[cold]
fn reset_ct(ct: &str) -> Result<(), OutputError> {
let path = Self::get_conf_path(ct)?;
@ -249,7 +246,7 @@ inactive_colors={}
let Some(mut config_dir) = dirs::config_dir() else {
return Err(OutputError::MissingConfigDir);
};
config_dir.push(&ct);
config_dir.push(ct);
if !config_dir.exists() {
fs::create_dir_all(&config_dir).map_err(OutputError::Io)?;
}
@ -272,7 +269,7 @@ inactive_colors={}
let Some(mut config_dir) = dirs::config_dir() else {
return Err(OutputError::MissingConfigDir);
};
config_dir.push(&ct);
config_dir.push(ct);
config_dir.push("colors");
if !config_dir.exists() {
fs::create_dir_all(&config_dir).map_err(OutputError::Io)?;

View file

@ -275,6 +275,7 @@ impl Theme {
/// Returns an `OutputError` if the user config dir is missing, the
/// settings file cannot be read/written, or its JSON is invalid.
#[cold]
/// Applies the theme to VS Code's user settings.
pub fn apply_vs_code(self) -> Result<(), OutputError> {
let vs_theme = VsTheme::from(self);
let mut config_dir = dirs::config_dir().ok_or(OutputError::MissingConfigDir)?;
@ -307,6 +308,7 @@ impl Theme {
/// Returns an `OutputError` if the user config dir is missing, the
/// settings file cannot be read/written, or its JSON is invalid.
#[cold]
/// Removes COSMIC theme settings from VS Code's user settings.
pub fn reset_vs_code() -> Result<(), OutputError> {
let mut config_dir = dirs::config_dir().ok_or(OutputError::MissingConfigDir)?;
config_dir.extend(["Code", "User", "settings.json"]);