#!/bin/bash

if type pyside-uic >/dev/null 2>&1; then
    pyside-uic DetectorViewer.ui            -o ui_tmp0.py
    pyside-uic PixelInfo.ui       -o ui_tmp1.py
    cat ui_tmp0.py | grep -v "import DetectorViewer_rc" > ui_DetectorViewer.py
    cat ui_tmp1.py | grep -v "coding: utf-8" | grep -v "from PySide import QtCore, QtGui" >> ui_DetectorViewer.py
    echo "try:" >> ui_DetectorViewer.py
    echo "    import DetectorViewer_rc" >> ui_DetectorViewer.py
    echo "except:" >> ui_DetectorViewer.py
    echo "    import uGao.DetectorViewer_rc" >> ui_DetectorViewer.py
    echo "Created by pyside-uic"
else
    echo "pyside-uic: not found"
fi

if type pyside2-uic >/dev/null 2>&1; then
    pyside2-uic DetectorViewer.ui            -o ui_tmp0.py
    pyside2-uic PixelInfo.ui       -o ui_tmp1.py
    cat ui_tmp0.py | grep -v "import DetectorViewer_rc" > ui2_DetectorViewer.py
    cat ui_tmp1.py | grep -v "coding: utf-8" | grep -v "from PySide import QtCore, QtGui" >> ui2_DetectorViewer.py
    echo "try:" >> ui2_DetectorViewer.py
    echo "    import DetectorViewer_rc" >> ui2_DetectorViewer.py
    echo "except:" >> ui2_DetectorViewer.py
    echo "    import uGao.DetectorViewer_rc" >> ui2_DetectorViewer.py
    echo "Created by pyside2-uic"
else
    echo "pyside2-uic: not found"
fi
rm ui_tmp*.py
