void AvatarEditScene::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
    if (event->button() != Qt::LeftButton)
        return;

    QGraphicsView *view = qobject_cast<QGraphicsView*>(event->widget()->parent());
    Q_ASSERT(view);
    QPoint p(view->mapFromScene(event->scenePos()));

    if (!isSizing && crop.contains(p))
    {
        isDragged = true;
        view->setCursor(Qt::ClosedHandCursor);
        origin = p;
    }
    else if (!isDragged && cropper.contains(p))
    {
        isSizing = true;
        view->setCursor(Qt::SizeFDiagCursor);
    }

    QGraphicsScene::mousePressEvent(event);
}
void AvatarEditScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
    if (event->button() != Qt::LeftButton)
        return;

    QGraphicsView *view = qobject_cast<QGraphicsView*>(event->widget()->parent());
    Q_ASSERT(view);

    view->setCursor(Qt::ArrowCursor);

    isDragged = false;
    isSizing = false;

    QGraphicsScene::mouseMoveEvent(event);
}