tweak(cosmic-theme): pretty write ini

This commit is contained in:
Adil Hanney 2026-02-18 20:42:34 +00:00 • committed by Jeremy Soller
parent 3ed5c173fd
commit 754b064bff
3 changed files with 12 additions and 4 deletions

View file

@ -1,3 +1,4 @@
use configparser::ini::WriteOptions;
use palette::{Srgba, rgb::Rgba}; use palette::{Srgba, rgb::Rgba};
use thiserror::Error; use thiserror::Error;
@ -78,3 +79,9 @@ pub fn to_rgba(c: Srgba) -> String {
c_u8.red, c_u8.green, c_u8.blue, c.alpha c_u8.red, c_u8.green, c_u8.blue, c.alpha
) )
} }
pub fn qt_settings_ini_style() -> WriteOptions {
let mut write_options = WriteOptions::default();
write_options.blank_lines_between_sections = 1;
write_options
}

View file

@ -5,7 +5,7 @@ use std::{
path::PathBuf, path::PathBuf,
}; };
use super::OutputError; use super::{OutputError, qt_settings_ini_style};
impl Theme { impl Theme {
/// The "version" of this theme. /// The "version" of this theme.
@ -86,7 +86,8 @@ impl Theme {
} }
} }
ini.write(path).map_err(OutputError::Io)?; ini.pretty_write(path, &qt_settings_ini_style())
.map_err(OutputError::Io)?;
Ok(()) Ok(())
} }

View file

@ -8,7 +8,7 @@ use std::{
path::{Path, PathBuf}, path::{Path, PathBuf},
}; };
use super::OutputError; use super::{OutputError, qt_settings_ini_style};
impl Theme { impl Theme {
/// Produces a color scheme ini file for Qt. /// Produces a color scheme ini file for Qt.
@ -258,7 +258,7 @@ widgetStyle=qt6ct-style
} }
kdeglobals_ini kdeglobals_ini
.write(kdeglobals_file) .pretty_write(kdeglobals_file, &qt_settings_ini_style())
.map_err(OutputError::Io)?; .map_err(OutputError::Io)?;
Ok(()) Ok(())
} }