Beispiel #1
0
    void UiProxyWidget::InitEffectsAndAnimations()
    {
        if (widget_properties_.GetWidgetType() != UiServices::CoreLayoutWidget)
        {
            QGraphicsDropShadowEffect shadow_effect(this);
            shadow_effect.setBlurRadius(3);
            shadow_effect.setOffset(3.0, 3.0);
            setGraphicsEffect(&shadow_effect);

            animations_ = new QParallelAnimationGroup(this);
            animations_->setDirection(QAbstractAnimation::Forward);
            connect(animations_, SIGNAL( finished() ), this, SLOT( FinishHide() ));

            fade_animation_ = new QPropertyAnimation(this, "opacity");
            fade_animation_->setDuration(300);
            fade_animation_->setStartValue(0.0);
            fade_animation_->setEndValue(1.0);

            animations_->addAnimation(fade_animation_);
        }
    }
Beispiel #2
0
UiProxyWidget::UiProxyWidget(QWidget *widget, Qt::WindowFlags flags):
    QGraphicsProxyWidget(0, flags),
    show_animation_enabled_(true),
    unfocus_opacity_(1.0),
    animations_(0),
    fade_animation_(0)
{
    QString name = "UiProxyWidget";
    if (!widget->objectName().isEmpty())
        name.append(":" + widget->objectName());
    else if (widget->windowTitle().isEmpty())
        name.append(":" + widget->windowTitle());
    setObjectName(name);

    // Embed widget to this proxy widget.
    setWidget(widget);
    widget->installEventFilter(this);

    // Init effects and animations
    if (windowFlags() != Qt::Widget)
    {
        QGraphicsDropShadowEffect *shadow_effect = new QGraphicsDropShadowEffect(this);
        shadow_effect->setBlurRadius(3);
        shadow_effect->setOffset(3.0, 3.0);
        setGraphicsEffect(shadow_effect);

        animations_ = new QParallelAnimationGroup(this);
        animations_->setDirection(QAbstractAnimation::Forward);
        connect(animations_, SIGNAL(finished()), this, SLOT(FinishHide()));

        fade_animation_ = new QPropertyAnimation(this, "opacity", this);
        fade_animation_->setDuration(300);
        fade_animation_->setStartValue(0.0);
        fade_animation_->setEndValue(1.0);

        animations_->addAnimation(fade_animation_);
    }
}