""" Emoji/Unicode icon helpers — no external icon pack dependency. All icons are rendered from Unicode characters by Qt. """ from PyQt6.QtGui import QIcon, QPixmap, QPainter, QFont, QColor from PyQt6.QtCore import Qt, QSize # ── Unicode glyph map ───────────────────────────────────────────────────────── ICONS = { # Connections "connection": "🔌", "connected": "🟢", "disconnected": "🔴", # Schema tree "database": "🗄️", "table": "📋", "view": "👁️", "column": "📊", "index": "🔍", "primary_key": "🔑", "foreign_key": "🔗", "function": "⚡", "procedure": "📦", "trigger": "⚙️", "folder": "📁", "folder_open": "📂", # Actions "run": "▶️", "stop": "⏹️", "explain": "🔎", "new_tab": "➕", "save": "💾", "open": "📂", "export": "📤", "import": "📥", "refresh": "🔄", "delete": "🗑️", "edit": "✏️", "add": "➕", "commit": "✅", "rollback": "↩️", "history": "📜", "filter": "🔍", "copy": "📋", "clear": "🧹", "settings": "⚙️", "help": "❓", "info": "ℹ️", "warning": "⚠️", "error": "❌", "success": "✅", "kill": "🛑", "disconnect": "🔌", # DB Types "mysql": "🐬", "postgresql": "🐘", "sqlite": "📁", "mssql": "🪟", } def make_icon(glyph: str, size: int = 20, fg: str = "#cdd6f4", bg: str = "transparent") -> QIcon: """Create a QIcon from a Unicode glyph.""" px = QPixmap(QSize(size, size)) px.fill(Qt.GlobalColor.transparent) painter = QPainter(px) painter.setRenderHint(QPainter.RenderHint.Antialiasing) font = QFont() font.setPointSize(int(size * 0.55)) painter.setFont(font) painter.setPen(QColor(fg)) painter.drawText(px.rect(), Qt.AlignmentFlag.AlignCenter, glyph) painter.end() return QIcon(px) def get_icon(name: str, size: int = 20) -> QIcon: """Get a named icon. Falls back to a question mark if unknown.""" glyph = ICONS.get(name, "❓") return make_icon(glyph, size)