Show a wait cursor while the wrapped function is running. The cursor is
    restored as soon as the function exits.

    :param func: wrapped function

def with_wait_cursor(func):
    """
    Show a wait cursor while the wrapped function is running. The cursor is
    restored as soon as the function exits.

    :param func: wrapped function
    """
    @functools.wraps(func)
    def wrapper(*args, **kwargs):
        QApplication.setOverrideCursor(
            QCursor(Qt.WaitCursor))
        try:
            ret_val = func(*args, **kwargs)
        finally:
            QApplication.restoreOverrideCursor()
        return ret_val
    return wrapper