#!/bin/bash

SVG_SOURCE=vidcutter.svg
SVG_SOURCE_MINI=vidcutter-mini.svg

# X11 icons
echo -e "\n[ creating X11 icons ]\n"

rm -rf ./hicolor

mkdir -p ./hicolor/16x16/apps
mkdir -p ./hicolor/22x22/apps
mkdir -p ./hicolor/24x24/apps
mkdir -p ./hicolor/32x32/apps
mkdir -p ./hicolor/48x48/apps
mkdir -p ./hicolor/64x64/apps
mkdir -p ./hicolor/128x128/apps
mkdir -p ./hicolor/256x256/apps
mkdir -p ./hicolor/512x512/apps
mkdir -p ./hicolor/scalable/apps

inkscape -z -e ./vidcutter.png -w 256 -h 256 ${SVG_SOURCE}
inkscape -z -e ./hicolor/16x16/apps/com.ozmartians.VidCutter.png -w 16 -h 16 ${SVG_SOURCE_MINI}
inkscape -z -e ./hicolor/22x22/apps/com.ozmartians.VidCutter.png -w 22 -h 22 ${SVG_SOURCE_MINI}
inkscape -z -e ./hicolor/24x24/apps/com.ozmartians.VidCutter.png -w 24 -h 24 ${SVG_SOURCE_MINI}
inkscape -z -e ./hicolor/32x32/apps/com.ozmartians.VidCutter.png -w 32 -h 32 ${SVG_SOURCE}
inkscape -z -e ./hicolor/48x48/apps/com.ozmartians.VidCutter.png -w 48 -h 48 ${SVG_SOURCE}
inkscape -z -e ./hicolor/64x64/apps/com.ozmartians.VidCutter.png -w 64 -h 64 ${SVG_SOURCE}
inkscape -z -e ./hicolor/128x128/apps/com.ozmartians.VidCutter.png -w 128 -h 128 ${SVG_SOURCE}
inkscape -z -e ./hicolor/256x256/apps/com.ozmartians.VidCutter.png -w 256 -h 256 ${SVG_SOURCE}
inkscape -z -e ./hicolor/512x512/apps/com.ozmartians.VidCutter.png -w 512 -h 512 ${SVG_SOURCE}

cp ${SVG_SOURCE} ./hicolor/scalable/apps/com.ozmartians.VidCutter.svg

# Windows icons
echo -e "\n[ creating Windows icon ]\n"
icotool -c -o vidcutter.ico \
              ./hicolor/16x16/apps/com.ozmartians.VidCutter.png \
              ./hicolor/24x24/apps/com.ozmartians.VidCutter.png \
              ./hicolor/32x32/apps/com.ozmartians.VidCutter.png \
              ./hicolor/48x48/apps/com.ozmartians.VidCutter.png \
              ./hicolor/64x64/apps/com.ozmartians.VidCutter.png \
              ./hicolor/128x128/apps/com.ozmartians.VidCutter.png \
              ./hicolor/256x256/apps/com.ozmartians.VidCutter.png
icotool -c -o uninstall.ico \
              ./uninstall/uninstall-16.png \
              ./uninstall/uninstall-24.png \
              ./uninstall/uninstall-32.png \
              ./uninstall/uninstall-48.png \
              ./uninstall/uninstall-64.png \
              ./uninstall/uninstall-128.png \
              ./uninstall/uninstall-256.png

# macOS icon
echo -e "\n[ creating macOS icon ]\n"
png2icns vidcutter.icns vidcutter.png

# application icons
echo -e "\n[ creating application icons ]\n"
inkscape -z -e ../../vidcutter/images/vidcutter.png -w 128 -h 128 ${SVG_SOURCE}
inkscape -z -e ../../vidcutter/images/vidcutter-small.png -w 82 -h 82 ${SVG_SOURCE}

# recreate PyQt resource file
echo -e "\n[ updating PyQt resource file ]\n"
cd ../../vidcutter
pyrcc5 -compress 9 -o resources.py resources.qrc

echo -e "\n** DONE **"
