Exemplo n.º 1
0
/*!
    Action when fade-out animation stops running.
*/
void HsSnapLine::actionOnFadeOutAnimationStop()
{
    mOpacity = mFadeOutAnimation->currentValue().toDouble();
    graphicsEffect()->setEnabled(false);
    hide();
    setLine(QLineF());
}
Exemplo n.º 2
0
void CardHostWindow::resizeWindowBufferEvent(int w, int h, QRect windowScreenBounds, bool forceSync)
{
	//Don't rotate.  Not now.  Not ever.
	bool directRendering = m_maximized;

	if(Settings::LunaSettings()->displayUiRotates) {
		if(directRendering)
			setMaximized(false); // disable direct rendering for the resize event
		setBoundingRect(windowScreenBounds.width(), windowScreenBounds.height());

		m_paintPath = QPainterPath();
		m_paintPath.addRoundedRect(m_boundingRect, 25, 25);

		// reconstruct shadow
		CardDropShadowEffect* shadow = static_cast<CardDropShadowEffect*>(graphicsEffect());
		if (shadow) {
			bool enable = shadow->isEnabled();
			setGraphicsEffect(0);
			shadow = new CardDropShadowEffect(this);
			setGraphicsEffect(shadow);
			shadow->setEnabled(enable);
		}

		if(directRendering)
			setMaximized(true); // re-enable direct rendering
	}
}
Exemplo n.º 3
0
void HighlightItem::setVisibility(qreal v)
{
	visibilityVal = v;
	
	static_cast<QGraphicsOpacityEffect*>(graphicsEffect())->setOpacity(
			settings()->value("highlight/opacityFactor").toDouble()*v);
}
Exemplo n.º 4
0
/*!
    Start fade-out animation.
*/
void HsSnapLine::startFadeOutAnimation()
{
    mFadeOutAnimation->setStartValue(mOpacity);
    mFadeOutAnimation->setEndValue(0.0);
    mFadeOutAnimation->setDuration(getFadeOutDuration());

    graphicsEffect()->setEnabled(true);
    mFadeOutAnimation->start();
}
Exemplo n.º 5
0
/*!
    Constructor.
    
    \a parent Owner.
*/
HsSnapLine::HsSnapLine(QGraphicsItem *parent)
  : QGraphicsLineItem(parent),
    mFadeInAnimation(0),
    mFadeOutAnimation(0),
    mOpacity(0.0),
    mFadeInAnimationDuration(0),
    mFadeOutAnimationDuration(0)
{
    QGraphicsOpacityEffect *effect = new QGraphicsOpacityEffect(this);
    effect->setOpacity(0.0);
    effect->setEnabled(false);
    setGraphicsEffect(effect);

    mFadeInAnimation = new QPropertyAnimation(graphicsEffect(), "opacity", this);
    connect(mFadeInAnimation, SIGNAL(finished()), SLOT(fadeInAnimationFinished()));

    mFadeOutAnimation = new QPropertyAnimation(graphicsEffect(), "opacity", this);
    connect(mFadeOutAnimation, SIGNAL(finished()), SLOT(fadeOutAnimationFinished()));
}
Exemplo n.º 6
0
bool CDiagramItem::effectEnabled()
{
	bool				r = false;
	QGraphicsEffect		*effect = NULL;

	effect = graphicsEffect();
	if (effect)
	{
		r = effect->isEnabled();
	}
	return r;
}
Exemplo n.º 7
0
void CDiagramItem::setEffectEnabled(bool value)
{
	QGraphicsEffect		*effect = NULL;

	effect = graphicsEffect();
	if (effect)
	{
		effect->setEnabled(value);
		update();
		emit propertyChanged(QString("effectEnabled"), qVariantFromValue(value) );
	}
}
Exemplo n.º 8
0
bool HoverShadowFilter::eventFilter(QObject *obj, QEvent *event)
{
    switch (event->type()) {
    case QEvent::Enter: {
        auto w = qobject_cast<QWidget *>(obj);
        auto shadow = new QGraphicsDropShadowEffect(w);
        shadow->setBlurRadius(8);
        shadow->setOffset(0, 0);
        shadow->setColor(Qt::white);
        w->setGraphicsEffect(shadow);
        w->setCursor(QCursor(Qt::PointingHandCursor));
        return QObject::eventFilter(obj, event);
    }
    case QEvent::Leave: {
        auto w = qobject_cast<QWidget *>(obj);
        w->graphicsEffect()->deleteLater();
        w->setGraphicsEffect(nullptr);
        w->unsetCursor();
        return QObject::eventFilter(obj, event);
    }
    default:
        return QObject::eventFilter(obj, event);
    }
}
Exemplo n.º 9
0
//键盘按下事件处理函数,判断是否是"-"键,如果是,则向下移动图形项
void MyItem::keyPressEvent(QKeyEvent *event)
{
    if(event->key()==Qt::Key_S)
    {
        moveBy(0,10);
    }
    else if(event->key()==Qt::Key_W)
    {
        moveBy(0,-10);
    }
    else if(event->key()==Qt::Key_A)
    {
        moveBy(-10,0);
    }
    else if(event->key()==Qt::Key_D)
    {
        moveBy(10,0);
    }

    /*
     *QGraphicsBlurEffect类提供了一个模糊效果
     *QGraphicsColorizeEffect类提供了一个染色效果
     *QGraphicsDropShadowEffect类提供了一个阴影效果
     *QGraphicsOpacityEffect类提供了一个透明效果
     */
    switch (event->key())
    {
        case Qt::Key_1:
        {
            QGraphicsBlurEffect *blurEffect=new QGraphicsBlurEffect;
            blurEffect->setBlurHints(QGraphicsBlurEffect::QualityHint);//指定模糊怎样来执行
            blurEffect->setBlurRadius(8);//修改细节等级,默认的模糊半径是5像素
            setGraphicsEffect(blurEffect);
            break;
        }
        case Qt::Key_2:
        {
            QGraphicsColorizeEffect *colorizeEffect=new QGraphicsColorizeEffect;
            colorizeEffect->setColor(Qt::white);//修改颜色,默认是浅紫色
            colorizeEffect->setStrength(0.6);//修改效果强度
            setGraphicsEffect(colorizeEffect);
            break;
        }
        case Qt::Key_3:
        {
            QGraphicsDropShadowEffect *dropShadowEffect=new QGraphicsDropShadowEffect;
            dropShadowEffect->setColor(QColor(63,63,63,100));//修改阴影颜色,默认是透明的黑灰色
            dropShadowEffect->setBlurRadius(2);//改变模糊半径
            dropShadowEffect->setOffset(10);//改变阴影偏移值
            setGraphicsEffect(dropShadowEffect);
            break;
        }
        case Qt::Key_4:
        {
            QGraphicsOpacityEffect *opacityEffect=new QGraphicsOpacityEffect;
            opacityEffect->setOpacity(0.4);//修改透明度
            setGraphicsEffect(opacityEffect);
            break;
        }
        case Qt::Key_5:
        {
            graphicsEffect()->setEnabled(false);
            break;
        }

    }
}
Exemplo n.º 10
0
int QGraphicsObject::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 13)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 13;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QGraphicsObject**>(_v) = parentObject(); break;
        case 1: *reinterpret_cast< qreal*>(_v) = opacity(); break;
        case 2: *reinterpret_cast< bool*>(_v) = isEnabled(); break;
        case 3: *reinterpret_cast< bool*>(_v) = isVisible(); break;
        case 4: *reinterpret_cast< QPointF*>(_v) = pos(); break;
        case 5: *reinterpret_cast< qreal*>(_v) = x(); break;
        case 6: *reinterpret_cast< qreal*>(_v) = y(); break;
        case 7: *reinterpret_cast< qreal*>(_v) = zValue(); break;
        case 8: *reinterpret_cast< qreal*>(_v) = rotation(); break;
        case 9: *reinterpret_cast< qreal*>(_v) = scale(); break;
        case 10: *reinterpret_cast< QPointF*>(_v) = transformOriginPoint(); break;
        case 11: *reinterpret_cast< QGraphicsEffect**>(_v) = graphicsEffect(); break;
        case 12: *reinterpret_cast< QDeclarativeListProperty<QGraphicsObject>*>(_v) = QGraphicsItem::d_func()->childrenList(); break;
        case 13: *reinterpret_cast< qreal*>(_v) = QGraphicsItem::d_func()->width(); break;
        case 14: *reinterpret_cast< qreal*>(_v) = QGraphicsItem::d_func()->height(); break;
        }
        _id -= 15;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setParentItem(*reinterpret_cast< QGraphicsObject**>(_v)); break;
        case 1: setOpacity(*reinterpret_cast< qreal*>(_v)); break;
        case 2: setEnabled(*reinterpret_cast< bool*>(_v)); break;
        case 3: setVisible(*reinterpret_cast< bool*>(_v)); break;
        case 4: setPos(*reinterpret_cast< QPointF*>(_v)); break;
        case 5: setX(*reinterpret_cast< qreal*>(_v)); break;
        case 6: setY(*reinterpret_cast< qreal*>(_v)); break;
        case 7: setZValue(*reinterpret_cast< qreal*>(_v)); break;
        case 8: setRotation(*reinterpret_cast< qreal*>(_v)); break;
        case 9: setScale(*reinterpret_cast< qreal*>(_v)); break;
        case 10: setTransformOriginPoint(*reinterpret_cast< QPointF*>(_v)); break;
        case 11: setGraphicsEffect(*reinterpret_cast< QGraphicsEffect**>(_v)); break;
        case 13: QGraphicsItem::d_func()->setWidth(*reinterpret_cast< qreal*>(_v)); break;
        case 14: QGraphicsItem::d_func()->setHeight(*reinterpret_cast< qreal*>(_v)); break;
        }
        _id -= 15;
    } else if (_c == QMetaObject::ResetProperty) {
        switch (_id) {
        case 13: QGraphicsItem::d_func()->resetWidth(); break;
        case 14: QGraphicsItem::d_func()->resetHeight(); break;
        }
        _id -= 15;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 15;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 15;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 15;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 15;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 15;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Exemplo n.º 11
0
void EmulatedCardWindow::resizeWindowBufferEvent(int w, int h, QRect windowScreenBounds, bool forceSync, bool ignoreFixedOrient)
{
	bool directRendering = m_maximized;
	bool visible = isVisible() && this->sceneBoundingRect().intersects(WindowServer::instance()->sceneRect());
	bool obscured = SystemUiController::instance()->maximizedCardWindow() ? (SystemUiController::instance()->maximizedCardWindow() != this) : false;
	bool synch = forceSync || m_maximized || (visible  && !obscured);

	if((w == (int)m_bufWidth) && (h == (int)m_bufHeight)) {
		// already the right size, so do nothing
		return;
	}

	if(Settings::LunaSettings()->displayUiRotates) {
		if(directRendering)
			setMaximized(false); // disable direct rendering for the resize event

			//Emulated cards cannot resize to full screen, ever.
			int maxWidth = Settings::LunaSettings()->emulatedCardWidth;
			int maxHeight = Settings::LunaSettings()->emulatedCardHeight;

			m_screenMidLine = (SystemUiController::instance()->currentUiHeight() - Settings::LunaSettings()->positiveSpaceTopPadding)/2;

			if (!m_fullScreenMode) {
				maxHeight = maxHeight - Settings::LunaSettings()->positiveSpaceTopPadding;

			}

			w = (w > maxWidth ? maxWidth : w);
			h = (h > maxHeight ? maxHeight : h);

			if (w>h) {
				//Going to a landscape card
				setNewEmuRect(maxHeight, maxWidth);
				HostWindow::resizeEventSync(maxHeight,maxWidth);
			} else {
				//Going to a portrait card
				setNewEmuRect(maxWidth, maxHeight);
				HostWindow::resizeEventSync(maxWidth,maxHeight);
			}


		setBoundingRect(windowScreenBounds.width(), windowScreenBounds.height());
		setVisibleDimensions(windowScreenBounds.width(), windowScreenBounds.height());

		m_paintPath = QPainterPath();
		m_paintPath.addRoundedRect(m_boundingRect, 25, 25);

		// reconstruct shadow
		CardDropShadowEffect* shadow = static_cast<CardDropShadowEffect*>(graphicsEffect());
		if (shadow) {
			bool enable = shadow->isEnabled();
			setGraphicsEffect(0);
			shadow = new CardDropShadowEffect(this);
			setGraphicsEffect(shadow);
			shadow->setEnabled(enable);
		}

		if(directRendering)
			setMaximized(true); // re-enable direct rendering
	}

}