252 lines
6.5 KiB
Python
252 lines
6.5 KiB
Python
"""
|
|
EU-Utility - Icon Helper
|
|
|
|
Helper functions to replace emojis with SVG icons in UI components.
|
|
Use these functions instead of emojis for consistent theming.
|
|
"""
|
|
|
|
from PyQt6.QtWidgets import QLabel, QPushButton
|
|
from PyQt6.QtCore import Qt
|
|
from core.icon_manager import get_icon_manager
|
|
|
|
|
|
class IconHelper:
|
|
"""Helper class for consistent icon usage across the application."""
|
|
|
|
# Icon name mappings for common UI elements
|
|
ICONS = {
|
|
# Status indicators
|
|
'success': 'check',
|
|
'error': 'close',
|
|
'warning': 'warning',
|
|
'info': 'info',
|
|
|
|
# Actions
|
|
'search': 'search',
|
|
'copy': 'clipboard',
|
|
'delete': 'trash',
|
|
'settings': 'settings',
|
|
'close': 'close',
|
|
'minimize': 'minus',
|
|
|
|
# Navigation
|
|
'dashboard': 'grid',
|
|
'back': 'arrow-left',
|
|
'forward': 'arrow-right',
|
|
'up': 'arrow-up',
|
|
'down': 'arrow-down',
|
|
|
|
# Features
|
|
'stats': 'bar-chart',
|
|
'trending': 'trending-up',
|
|
'money': 'dollar-sign',
|
|
'target': 'target',
|
|
'chat': 'message-square',
|
|
'music': 'music',
|
|
'mission': 'map',
|
|
'combat': 'sword',
|
|
'inventory': 'package',
|
|
'ped': 'ped',
|
|
|
|
# Theme
|
|
'dark_mode': 'moon',
|
|
'light_mode': 'sun',
|
|
|
|
# Media controls
|
|
'play': 'play',
|
|
'pause': 'pause',
|
|
'skip_back': 'skip-back',
|
|
'skip_forward': 'skip-forward',
|
|
'previous': 'rewind',
|
|
'next': 'fast-forward',
|
|
}
|
|
|
|
def __init__(self):
|
|
self.icon_manager = get_icon_manager()
|
|
|
|
def get_icon_label(self, icon_name: str, size: int = 20, color: str = None) -> QLabel:
|
|
"""
|
|
Get a QLabel with an SVG icon.
|
|
|
|
Args:
|
|
icon_name: Name of the icon (from ICONS dict or assets/icons/)
|
|
size: Icon size in pixels
|
|
color: Optional color override (defaults to theme text color)
|
|
|
|
Returns:
|
|
QLabel configured with the icon pixmap
|
|
"""
|
|
label = QLabel()
|
|
pixmap = self.icon_manager.get_pixmap(icon_name, size=size)
|
|
label.setPixmap(pixmap)
|
|
label.setFixedSize(size, size)
|
|
|
|
if color:
|
|
label.setStyleSheet(f"color: {color};")
|
|
|
|
return label
|
|
|
|
def get_icon_button(self, icon_name: str, size: int = 20, tooltip: str = None) -> QPushButton:
|
|
"""
|
|
Get a QPushButton with an SVG icon.
|
|
|
|
Args:
|
|
icon_name: Name of the icon
|
|
size: Icon size in pixels
|
|
tooltip: Optional tooltip text
|
|
|
|
Returns:
|
|
QPushButton configured with the icon
|
|
"""
|
|
btn = QPushButton()
|
|
btn.setIcon(self.icon_manager.get_icon(icon_name))
|
|
btn.setIconSize(Qt.QSize(size, size))
|
|
btn.setFixedSize(size + 12, size + 12)
|
|
|
|
if tooltip:
|
|
btn.setToolTip(tooltip)
|
|
|
|
return btn
|
|
|
|
@classmethod
|
|
def get_icon_name(cls, key: str) -> str:
|
|
"""Get icon name from key."""
|
|
return cls.ICONS.get(key, key)
|
|
|
|
|
|
# Convenience functions for common icons
|
|
|
|
def icon_success(size: int = 16) -> QLabel:
|
|
"""Get success checkmark icon."""
|
|
helper = IconHelper()
|
|
return helper.get_icon_label('check', size)
|
|
|
|
|
|
def icon_error(size: int = 16) -> QLabel:
|
|
"""Get error X icon."""
|
|
helper = IconHelper()
|
|
return helper.get_icon_label('close', size)
|
|
|
|
|
|
def icon_warning(size: int = 16) -> QLabel:
|
|
"""Get warning triangle icon."""
|
|
helper = IconHelper()
|
|
return helper.get_icon_label('warning', size)
|
|
|
|
|
|
def icon_search(size: int = 20) -> QLabel:
|
|
"""Get search magnifying glass icon."""
|
|
helper = IconHelper()
|
|
return helper.get_icon_label('search', size)
|
|
|
|
|
|
def icon_stats(size: int = 20) -> QLabel:
|
|
"""Get bar chart stats icon."""
|
|
helper = IconHelper()
|
|
return helper.get_icon_label('bar-chart', size)
|
|
|
|
|
|
def icon_trending(size: int = 20) -> QLabel:
|
|
"""Get trending up icon."""
|
|
helper = IconHelper()
|
|
return helper.get_icon_label('trending-up', size)
|
|
|
|
|
|
def icon_money(size: int = 20) -> QLabel:
|
|
"""Get dollar sign/money icon."""
|
|
helper = IconHelper()
|
|
return helper.get_icon_label('dollar-sign', size)
|
|
|
|
|
|
def icon_target(size: int = 20) -> QLabel:
|
|
"""Get target/DPP icon."""
|
|
helper = IconHelper()
|
|
return helper.get_icon_label('target', size)
|
|
|
|
|
|
def icon_chat(size: int = 20) -> QLabel:
|
|
"""Get chat/message icon."""
|
|
helper = IconHelper()
|
|
return helper.get_icon_label('message-square', size)
|
|
|
|
|
|
def icon_moon(size: int = 20) -> QLabel:
|
|
"""Get moon/dark mode icon."""
|
|
helper = IconHelper()
|
|
return helper.get_icon_label('moon', size)
|
|
|
|
|
|
def icon_sun(size: int = 20) -> QLabel:
|
|
"""Get sun/light mode icon."""
|
|
helper = IconHelper()
|
|
return helper.get_icon_label('sun', size)
|
|
|
|
|
|
def icon_clipboard(size: int = 20) -> QLabel:
|
|
"""Get clipboard/copy icon."""
|
|
helper = IconHelper()
|
|
return helper.get_icon_label('clipboard', size)
|
|
|
|
|
|
def icon_sword(size: int = 20) -> QLabel:
|
|
"""Get sword/combat icon."""
|
|
helper = IconHelper()
|
|
return helper.get_icon_label('sword', size)
|
|
|
|
|
|
def icon_package(size: int = 20) -> QLabel:
|
|
"""Get package/inventory icon."""
|
|
helper = IconHelper()
|
|
return helper.get_icon_label('package', size)
|
|
|
|
|
|
def icon_music(size: int = 20) -> QLabel:
|
|
"""Get music icon."""
|
|
helper = IconHelper()
|
|
return helper.get_icon_label('music', size)
|
|
|
|
|
|
def icon_map(size: int = 20) -> QLabel:
|
|
"""Get map/mission icon."""
|
|
helper = IconHelper()
|
|
return helper.get_icon_label('map', size)
|
|
|
|
|
|
def icon_trash(size: int = 20) -> QLabel:
|
|
"""Get trash/delete icon."""
|
|
helper = IconHelper()
|
|
return helper.get_icon_label('trash', size)
|
|
|
|
|
|
def icon_close(size: int = 20) -> QLabel:
|
|
"""Get close X icon."""
|
|
helper = IconHelper()
|
|
return helper.get_icon_label('close', size)
|
|
|
|
|
|
def icon_minus(size: int = 20) -> QLabel:
|
|
"""Get minus/minimize icon."""
|
|
helper = IconHelper()
|
|
return helper.get_icon_label('minus', size)
|
|
|
|
|
|
# Text-based icon replacements (for when you just need text symbols)
|
|
# These are Unicode symbols, not emojis, and render consistently
|
|
|
|
TEXT_SYMBOLS = {
|
|
'bullet': '•',
|
|
'arrow_right': '→',
|
|
'arrow_left': '←',
|
|
'arrow_up': '↑',
|
|
'arrow_down': '↓',
|
|
'check': '✓',
|
|
'x': '✕',
|
|
'dash': '—',
|
|
'ellipsis': '…',
|
|
}
|
|
|
|
|
|
def get_text_symbol(key: str) -> str:
|
|
"""Get a text symbol (not emoji) for simple UI elements."""
|
|
return TEXT_SYMBOLS.get(key, '')
|