ThemeManager

Struct ThemeManager 

Source
pub struct ThemeManager { /* private fields */ }
Expand description

Central theme management system for the application.

ThemeManager provides thread-safe access to theme data and supports runtime theme switching. It maintains the current theme state and provides accessor methods for all color values used throughout the application.

§Thread Safety

The ThemeManager is designed to be used as a global singleton wrapped in a Mutex. All color accessor methods are thread-safe and include fallback mechanisms.

Implementations§

Source§

impl ThemeManager

Source

pub fn init_global(config: &ThemeConfig) -> AppResult<()>

Initializes the global theme manager singleton.

This method must be called once at application startup before any theme colors are accessed. It loads the initial theme from the provided configuration.

§Arguments
  • config - Theme configuration specifying the initial theme and flavor
§Returns

Ok(()) if initialization succeeds

§Errors

Returns an error if:

  • The theme manager is already initialized
  • The initial theme cannot be loaded
  • Theme files are invalid or missing
§Examples
use quetty::theme::{manager::ThemeManager, types::ThemeConfig};

let config = ThemeConfig {
    theme_name: "catppuccin".to_string(),
    flavor_name: "mocha".to_string(),
};
ThemeManager::init_global(&config)?;
Source

pub fn global() -> &'static Mutex<ThemeManager>

Gets a reference to the global theme manager instance.

§Returns

A reference to the Mutex-wrapped ThemeManager

§Panics

Panics if the theme manager has not been initialized with [init_global]

§Examples
use quetty::theme::manager::ThemeManager;

let manager = ThemeManager::global();
let mut theme_manager = manager.lock().unwrap();
theme_manager.switch_theme("nightfox", "carbonfox")?;
Source§

impl ThemeManager

Source§

impl ThemeManager

Source§

impl ThemeManager

Source

pub fn surface() -> Color

Source§

impl ThemeManager

Source§

impl ThemeManager

Source§

impl ThemeManager

Source§

impl ThemeManager

Source§

impl ThemeManager

Source§

impl ThemeManager

Source§

impl ThemeManager

Source§

impl ThemeManager

Source§

impl ThemeManager

Source§

impl ThemeManager

Source§

impl ThemeManager

Source§

impl ThemeManager

Source§

impl ThemeManager

Source§

impl ThemeManager

Source§

impl ThemeManager

Source§

impl ThemeManager

Source§

impl ThemeManager

Source§

impl ThemeManager

Source§

impl ThemeManager

Source§

impl ThemeManager

Source§

impl ThemeManager

Source§

impl ThemeManager

Source§

impl ThemeManager

Source§

impl ThemeManager

Source

pub fn switch_theme( &mut self, theme_name: &str, flavor_name: &str, ) -> AppResult<()>

Switches to a new theme by name and flavor.

This method loads and activates a new theme at runtime. All subsequent color accessor calls will use the new theme colors.

§Arguments
  • theme_name - Name of the theme (e.g., “catppuccin”, “nightfox”)
  • flavor_name - Name of the flavor (e.g., “mocha”, “carbonfox”)
§Returns

Ok(()) if the theme switch succeeds

§Errors

Returns an error if:

  • The theme or flavor does not exist
  • Theme files are invalid or corrupted
  • File system access fails
§Examples
use quetty::theme::manager::ThemeManager;

let mut manager = ThemeManager::global().lock().unwrap();
manager.switch_theme("catppuccin", "latte")?;
Source

pub fn switch_theme_from_config( &mut self, config: &ThemeConfig, ) -> AppResult<()>

Switches to a new theme using a ThemeConfig struct.

Convenience method for switching themes when you have a ThemeConfig.

§Arguments
  • config - Theme configuration containing theme and flavor names
§Returns

Ok(()) if the theme switch succeeds

§Errors

Returns the same errors as [switch_theme]

Source

pub fn discover_themes_with_metadata( &self, ) -> AppResult<ThemeCollectionWithMetadata>

Discovers all available themes with their metadata and icons.

This method scans the theme directories and loads metadata for all available themes and flavors. It includes display names, icons, and other theme information.

§Returns

ThemeCollectionWithMetadata containing all discovered themes with their metadata

§Errors

Returns an error if theme discovery or loading fails

§Examples
use quetty::theme::manager::ThemeManager;

let manager = ThemeManager::global().lock().unwrap();
let themes = manager.discover_themes_with_metadata()?;

for (theme_name, flavors) in themes {
    println!("Theme: {}", theme_name);
    for (flavor_name, theme_icon, flavor_icon) in flavors {
        println!("  {} {} {}", theme_icon, flavor_icon, flavor_name);
    }
}
Source

pub fn global_discover_themes_with_metadata() -> AppResult<ThemeCollectionWithMetadata>

Static method to discover themes using the global theme manager.

Convenience method that accesses the global theme manager and discovers available themes. This method is thread-safe and includes lock contention handling.

§Returns

ThemeCollectionWithMetadata containing all discovered themes

§Errors

Returns an error if:

  • Theme manager is not initialized
  • Lock cannot be acquired
  • Theme discovery fails
§Examples
use quetty::theme::manager::ThemeManager;

let themes = ThemeManager::global_discover_themes_with_metadata()?;

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> SendBound for T
where T: Send,