#!/bin/sh

# Converts the qrc, ts and ui files to Python files and moves them to
# the package directory.

cd $(dirname $0)

files=$(ls)

for f_name in $files
do
    ext=`echo $f_name | cut -d"." -f2`
    name=`echo $f_name | cut -d"." -f1`
    
    if [ $ext = "ui" ]; then
        pyuic4 -o $name.py $f_name
        sed 's/import icons_rc/from watchvideo import icons_rc/
/import icons_rc/a\
assert icons_rc' < $name.py > ../watchvideo/$name.py
	rm $name.py
	echo "$f_name --> ../watchvideo/$name.py"
    fi
done

pylupdate4 ../watchvideo.pro
lrelease ../watchvideo.pro

# Prepare logo.
for size in 32 48 200
do
    inkscape -e ../media/watchvideo-${size}x${size}.png \
	-w $size -h $size ../media/watchvideo.svg
    optipng ../media/watchvideo-${size}x${size}.png
done

for f_name in $files
do
    ext=`echo $f_name | cut -d"." -f2`
    name=`echo $f_name | cut -d"." -f1`
    
    if [ $ext = "qrc" ]; then
        name=$name"_rc"
        pyrcc4 $f_name -o $name.py 
        mv $name.py ../watchvideo/$name.py
	echo "$f_name --> ../watchvideo/$name.py"
    fi
      
done
