Skip to content

Latest commit

 

History

History
217 lines (167 loc) · 6.61 KB

File metadata and controls

217 lines (167 loc) · 6.61 KB

HyprRice Theme System - Complete Overhaul

Overview

The HyprRice theme system has been completely redesigned to provide a unified, modern experience with proper system integration. The new system eliminates the previous issues with mixed light/dark elements and provides seamless theme switching.

Key Features

🎨 Unified Theme System

  • Three Themes: dark, light, and auto
  • System Integration: Automatically detects and matches system theme preferences
  • Consistent Styling: No more mixed light/dark elements
  • Modern Design: Clean, professional appearance

🌙 Modern Dark Theme

  • Background: Deep black (#0f0f0f) for modern look
  • Text: High contrast white (#ffffff) for accessibility
  • Accent: System accent color integration
  • Borders: Subtle but defined (#404040)
  • Shadows: Deep, modern shadows

☀️ Greyish Light Theme

  • Background: Light grey (#f5f5f5) instead of bright white
  • Text: Dark on light (#1a1a1a) for readability
  • Accent: System accent color integration
  • Borders: Light grey (#d4d4d4) for subtle definition
  • Shadows: Light, soft shadows

🔄 Auto Theme Detection

  • GNOME: Detects color-scheme via gsettings
  • KDE/Plasma: Reads kdeglobals configuration
  • GTK: Checks GTK_THEME environment variable
  • XFCE: Reads XFCE configuration files
  • Fallback: Defaults to dark theme for modern look

🎯 System Accent Color Detection

  • KDE/Plasma: Reads AccentColor from kdeglobals
  • GTK: Checks accent_color in GTK settings
  • GNOME: Uses gsettings for accent color
  • XFCE: Reads accent color from XFCE config
  • Environment: Supports HYPRRICE_ACCENT_COLOR override
  • Fallback: Modern indigo (#6366f1) as default

Implementation Details

Core Classes

ModernTheme

  • Location: src/hyprrice/gui/modern_theme.py
  • Purpose: Main theme management system
  • Features:
    • System accent color detection
    • Theme switching
    • QSS stylesheet generation
    • Color utilities (lighten/darken)

Key Methods

def _detect_system_accent_color(self) -> str
def _detect_system_theme(self) -> str
def _get_modern_dark_theme(self) -> Dict[str, str]
def _get_greyish_light_theme(self) -> Dict[str, str]
def set_theme(self, theme: str)
def get_qss(self) -> str

Color Utilities

  • _lighten_color(color, factor): Lightens hex colors
  • _darken_color(color, factor): Darkens hex colors
  • Automatic accent variations: Hover, pressed, light variants

QSS Generation

  • Comprehensive styling: All UI components styled
  • Modern design: Rounded corners, proper spacing
  • Accessibility: High contrast, proper focus indicators
  • Responsive: Adapts to different screen sizes

Usage

Theme Switching

# Set specific theme
theme.set_theme("dark")
theme.set_theme("light")

# Auto-detect system theme
theme.set_theme("auto")

# Apply to application
theme.apply_to_application(QApplication.instance())

Menu Integration

  • View → Theme → Dark: Switch to dark theme
  • View → Theme → Light: Switch to light theme
  • View → Theme → Auto: Auto-detect system theme

Configuration

gui:
  theme: "auto"  # auto, dark, or light

System Integration

Desktop Environment Support

  • GNOME: Full support via gsettings
  • KDE/Plasma: Full support via kdeglobals
  • XFCE: Full support via XFCE config
  • GTK: Basic support via environment variables
  • Generic: Fallback detection methods

Environment Variables

  • HYPRRICE_THEME: Override theme (dark/light)
  • HYPRRICE_ACCENT_COLOR: Override accent color

Benefits

Fixed Issues

  • No more mixed themes: Unified styling across all components
  • System integration: Matches user's desktop environment
  • Accessibility: High contrast, proper focus indicators
  • Modern appearance: Clean, professional design

Enhanced Features

  • Automatic detection: No manual configuration needed
  • Seamless switching: Instant theme changes
  • System consistency: Matches desktop environment
  • Future-proof: Extensible for new themes

Developer Experience

  • Clean API: Simple theme switching
  • Extensible: Easy to add new themes
  • Maintainable: Well-organized code structure
  • Testable: Comprehensive test coverage

Testing

Test Coverage

  • System detection: Accent color and theme detection
  • Theme switching: All three themes
  • Color utilities: Lighten/darken functions
  • QSS generation: Stylesheet compilation
  • GUI integration: Complete application testing

Test Results

🎨 Testing New Unified Theme System
==================================================

🔍 System Detection:
  System Accent Color: #b875dc
  Detected Theme: dark
  Available Themes: ['auto', 'dark', 'light']

🌙 Dark Theme Colors:
  Background: #0f0f0f
  Text: #ffffff
  Accent: #b875dc
  Border: #404040

☀️ Light Theme Colors:
  Background: #f5f5f5
  Text: #1a1a1a
  Accent: #b875dc
  Border: #d4d4d4

✅ Theme System Test Complete!

Migration Guide

From Old System

  1. Remove hardcoded themes: Old theme files are no longer needed
  2. Update configuration: Set gui.theme: "auto" for best experience
  3. Test system detection: Verify accent color and theme detection
  4. Customize if needed: Use environment variables for overrides

Configuration Changes

# Old
gui:
  theme: "dark"
  accent_color: "#6366f1"

# New
gui:
  theme: "auto"  # Auto-detect system theme
  # accent_color is now detected automatically

Future Enhancements

Planned Features

  • Custom themes: User-defined theme creation
  • Theme presets: Pre-built theme collections
  • Animation support: Smooth theme transitions
  • Accessibility modes: High contrast, large text options
  • Theme sharing: Export/import custom themes

Extensibility

  • Plugin support: Themes can be provided by plugins
  • API integration: External theme sources
  • Dynamic loading: Runtime theme switching
  • Configuration sync: Sync with system settings

Conclusion

The new HyprRice theme system provides a modern, unified experience that seamlessly integrates with the user's desktop environment. It eliminates the previous issues with mixed themes and provides a professional, accessible interface that adapts to user preferences automatically.

The system is designed to be extensible, maintainable, and user-friendly, providing a solid foundation for future enhancements while solving the immediate issues with theme consistency and system integration.