void Window::appear()
{
    //模态化该窗口
    //用户必须通过单击该按钮来关闭窗口,在关闭窗口之前,
    //不能操作当前scene下的其他items
    if (m_isModal) {
        setFlags(flags() | ItemIsPanel);

        QGraphicsScene *const currentScene = scene();
        if (currentScene) {
            if (!s_panelStack.empty()) {
                QGraphicsItem* item = s_panelStack.top();
                item->setPanelModality(NonModal);
            }

            setPanelModality(SceneModal);
            s_panelStack.push(this);

            currentScene->setActivePanel(this);
        }
    }

    QPropertyAnimation *scale_x = new QPropertyAnimation(scaleTransform, "xScale", this);
    QPropertyAnimation *scale_y = new QPropertyAnimation(scaleTransform, "yScale", this);
    QPropertyAnimation *opacity = new QPropertyAnimation(this, "opacity", this);
    QParallelAnimationGroup *group = new QParallelAnimationGroup(this);

    scale_x->setEndValue(1);
    scale_y->setEndValue(1);
    opacity->setEndValue(1.0);
    group->addAnimation(scale_x);
    group->addAnimation(scale_y);
    group->addAnimation(opacity);

    group->start(QAbstractAnimation::DeleteWhenStopped);
}
void Window::disappear()
{
    QPropertyAnimation *scale_x = new QPropertyAnimation(scaleTransform, "xScale", this);
    QPropertyAnimation *scale_y = new QPropertyAnimation(scaleTransform, "yScale", this);
    QPropertyAnimation *opacity = new QPropertyAnimation(this, "opacity", this);
    QParallelAnimationGroup *group = new QParallelAnimationGroup(this);

    scale_x->setEndValue(1.05);
    scale_y->setEndValue(0.95);
    opacity->setEndValue(0.0);
    group->addAnimation(scale_x);
    group->addAnimation(scale_y);
    group->addAnimation(opacity);

    if (!keep_when_disappear) {
        connect(group, SIGNAL(finished()), this, SLOT(deleteLater()));
    }

    group->start(QAbstractAnimation::DeleteWhenStopped);

    if (m_isModal) {
        QGraphicsScene *const currentScene = scene();
        if (currentScene) {
            if (!s_panelStack.empty()) {
                s_panelStack.pop();

                if (!s_panelStack.empty()) {
                    QGraphicsItem* item = s_panelStack.top();
                    item->setPanelModality(SceneModal);

                    currentScene->setActivePanel(item);
                }
            }
        }
    }
}