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
impl ThemeManager
Sourcepub fn init_global(config: &ThemeConfig) -> AppResult<()>
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)?;Sourcepub fn global() -> &'static Mutex<ThemeManager>
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
impl ThemeManager
pub fn text_primary() -> Color
Source§impl ThemeManager
impl ThemeManager
pub fn text_muted() -> Color
Source§impl ThemeManager
impl ThemeManager
pub fn primary_accent() -> Color
Source§impl ThemeManager
impl ThemeManager
pub fn title_accent() -> Color
Source§impl ThemeManager
impl ThemeManager
pub fn header_accent() -> Color
Source§impl ThemeManager
impl ThemeManager
pub fn selection_bg() -> Color
Source§impl ThemeManager
impl ThemeManager
pub fn selection_fg() -> Color
Source§impl ThemeManager
impl ThemeManager
pub fn message_sequence() -> Color
Source§impl ThemeManager
impl ThemeManager
pub fn message_id() -> Color
Source§impl ThemeManager
impl ThemeManager
pub fn message_timestamp() -> Color
Source§impl ThemeManager
impl ThemeManager
pub fn message_delivery_count() -> Color
Source§impl ThemeManager
impl ThemeManager
pub fn message_state_ready() -> Color
Source§impl ThemeManager
impl ThemeManager
pub fn message_state_deferred() -> Color
Source§impl ThemeManager
impl ThemeManager
pub fn message_state_outcome() -> Color
Source§impl ThemeManager
impl ThemeManager
pub fn message_state_failed() -> Color
Source§impl ThemeManager
impl ThemeManager
pub fn namespace_list_item() -> Color
Source§impl ThemeManager
impl ThemeManager
pub fn status_success() -> Color
Source§impl ThemeManager
impl ThemeManager
pub fn status_warning() -> Color
Source§impl ThemeManager
impl ThemeManager
pub fn status_error() -> Color
Source§impl ThemeManager
impl ThemeManager
pub fn status_info() -> Color
Source§impl ThemeManager
impl ThemeManager
pub fn status_loading() -> Color
Source§impl ThemeManager
impl ThemeManager
pub fn shortcut_key() -> Color
Source§impl ThemeManager
impl ThemeManager
pub fn shortcut_description() -> Color
Source§impl ThemeManager
impl ThemeManager
pub fn help_section_title() -> Color
Source§impl ThemeManager
impl ThemeManager
pub fn popup_text() -> Color
Source§impl ThemeManager
impl ThemeManager
Sourcepub fn switch_theme(
&mut self,
theme_name: &str,
flavor_name: &str,
) -> AppResult<()>
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")?;Sourcepub fn switch_theme_from_config(
&mut self,
config: &ThemeConfig,
) -> AppResult<()>
pub fn switch_theme_from_config( &mut self, config: &ThemeConfig, ) -> AppResult<()>
Sourcepub fn discover_themes_with_metadata(
&self,
) -> AppResult<ThemeCollectionWithMetadata>
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);
}
}Sourcepub fn global_discover_themes_with_metadata() -> AppResult<ThemeCollectionWithMetadata>
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§
impl Freeze for ThemeManager
impl RefUnwindSafe for ThemeManager
impl Send for ThemeManager
impl Sync for ThemeManager
impl Unpin for ThemeManager
impl UnwindSafe for ThemeManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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