import requests
import os

ICONS = {
    "settings.svg": "https://raw.githubusercontent.com/FortAwesome/Font-Awesome/6.x/svgs/solid/gear.svg",
    "visibility.svg": "https://raw.githubusercontent.com/FortAwesome/Font-Awesome/6.x/svgs/solid/eye.svg",
    "smart_toy.svg": "https://raw.githubusercontent.com/FortAwesome/Font-Awesome/6.x/svgs/solid/brain.svg",
    "microphone.svg": "https://raw.githubusercontent.com/FortAwesome/Font-Awesome/6.x/svgs/solid/microphone.svg"
}

TARGET_DIR = r"d:\!!! SYSTEM DATA !!!\Desktop\python crap\whisper_voice\src\ui\qml"

def download_icons():
    if not os.path.exists(TARGET_DIR):
        print(f"Directory not found: {TARGET_DIR}")
        return

    for filename, url in ICONS.items():
        try:
            print(f"Downloading {filename} from {url}...")
            response = requests.get(url, timeout=10)
            response.raise_for_status()
            
            # Force white fill
            content = response.text
            if "<path" in content and "fill=" not in content:
                content = content.replace("<path", '<path fill="#ffffff"')
            elif "<path" in content and "fill=" in content:
                 # Regex or simple replace if possible, but simplest is usually just injecting style or checking common FA format
                 pass # FA standard usually has no fill.
            
            # Additional safety: Replace currentcolor if present
            content = content.replace("currentColor", "#ffffff")

            filepath = os.path.join(TARGET_DIR, filename)
            with open(filepath, 'w', encoding='utf-8') as f:
                f.write(content)
            print(f"Saved {filepath} (modified to white)")
        except Exception as e:
            print(f"FAILED to download {filename}: {e}")

if __name__ == "__main__":
    download_icons()
