chore: resolve cargo fmt and clippy findings
This commit is contained in:
parent
d77e99fb15
commit
d9431dc367
6 changed files with 30 additions and 32 deletions
|
|
@ -1,6 +1,5 @@
|
|||
use proc_macro::TokenStream;
|
||||
use quote::quote;
|
||||
use syn;
|
||||
|
||||
#[proc_macro_derive(CosmicConfigEntry, attributes(version, id, cosmic_config_entry))]
|
||||
pub fn cosmic_config_entry_derive(input: TokenStream) -> TokenStream {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use iced_futures::futures::SinkExt;
|
||||
use iced_futures::futures::channel::mpsc;
|
||||
use iced_futures::futures::{SinkExt, Stream};
|
||||
use iced_futures::stream;
|
||||
use notify::RecommendedWatcher;
|
||||
use std::borrow::Cow;
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
@ -1097,7 +1097,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
|
||||
|
|
@ -1167,9 +1167,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);
|
||||
|
|
@ -1204,7 +1209,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])
|
||||
|
|
@ -1222,7 +1227,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(
|
||||
|
|
@ -1357,7 +1362,7 @@ impl ThemeBuilder {
|
|||
accent,
|
||||
on_bg_component,
|
||||
component_hovered_overlay,
|
||||
component_pressed_overlay,
|
||||
background_pressed_overlay,
|
||||
is_high_contrast,
|
||||
control_steps_array[8],
|
||||
),
|
||||
|
|
@ -1653,7 +1658,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,
|
||||
|
|
@ -1661,6 +1666,7 @@ pub enum BlurStrength {
|
|||
VeryLow2,
|
||||
Low,
|
||||
Low2,
|
||||
#[default]
|
||||
Medium,
|
||||
Medium2,
|
||||
High,
|
||||
|
|
@ -1671,12 +1677,6 @@ pub enum BlurStrength {
|
|||
ExtremelyHigh2,
|
||||
}
|
||||
|
||||
impl Default for BlurStrength {
|
||||
fn default() -> Self {
|
||||
Self::Medium
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<u8> for BlurStrength {
|
||||
type Error = ();
|
||||
|
||||
|
|
@ -1701,6 +1701,7 @@ impl TryFrom<u8> for BlurStrength {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(missing_docs)]
|
||||
#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq)]
|
||||
pub struct AlphaMap {
|
||||
pub extremely_low: f32,
|
||||
|
|
@ -1719,6 +1720,7 @@ pub struct AlphaMap {
|
|||
pub extremely_high_2: f32,
|
||||
}
|
||||
|
||||
#[allow(missing_docs)]
|
||||
impl AlphaMap {
|
||||
pub fn blurred_alpha(&self, blur: BlurStrength) -> f32 {
|
||||
match blur {
|
||||
|
|
|
|||
|
|
@ -262,17 +262,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))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)?;
|
||||
|
|
|
|||
|
|
@ -267,6 +267,7 @@ impl From<Theme> for VsTheme {
|
|||
|
||||
impl Theme {
|
||||
#[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)?;
|
||||
|
|
@ -292,6 +293,7 @@ impl Theme {
|
|||
}
|
||||
|
||||
#[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"]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue