Exemple #1
0
void DockItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
	if(event->button() == Qt::LeftButton)
	{
		m_dragging = false;
		m_dockApplet->draggingStopped();
		setZValue(0.0); // No more on top.
		startAnimation(); // Item can be out of it's regular, start animation to bring it back.
	}

	if(isUnderMouse())
	{
		if(m_clients.isEmpty())
			return;

		if(event->button() == Qt::LeftButton)
		{
			static const qreal clickMouseMoveTolerance = 10.0;

			if((event->scenePos() - m_mouseDownPosition).manhattanLength() < clickMouseMoveTolerance)
			{
				if(m_dockApplet->activeWindow() == m_clients[0]->handle())
					X11Support::minimizeWindow(m_clients[0]->handle());
				else
					X11Support::activateWindow(m_clients[0]->handle());
			}
		}

		if(!m_dragging && (event->button() == Qt::RightButton 
			|| event->button() == Qt::MiddleButton))
		{
			this->close();
		}
	}
}
QVariant Handle::itemChange(GraphicsItemChange change, const QVariant &value)
{
    if (change == ItemVisibleHasChanged && value.toBool())
        if (mUnderMouse)
            mUnderMouse = isUnderMouse();
    return QGraphicsItem::itemChange(change, value);
}
void QQuickMouseArea::ungrabMouse()
{
    Q_D(QQuickMouseArea);
    if (d->pressed) {
        // if our mouse grab has been removed (probably by Flickable), fix our
        // state
        d->pressed = 0;
        d->stealMouse = false;
        d->doubleClick = false;
        setKeepMouseGrab(false);

#ifndef QT_NO_DRAGANDDROP
        if (d->drag)
            d->drag->setActive(false);
#endif

        emit canceled();
        emit pressedChanged();
        emit containsPressChanged();
        emit pressedButtonsChanged();

        if (d->hovered && !isUnderMouse()) {
            d->hovered = false;
            emit hoveredChanged();
        }
    }
}
void PanelWindowGraphicsItem::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
{
	if(isUnderMouse())
	{
		m_panelWindow->showPanelContextMenu(QPoint(static_cast<int>(event->pos().x()), static_cast<int>(event->pos().y())));
	}
}
Exemple #5
0
void button::ourColor()
{
	if(isUnderMouse())
	glColor3f(0.5,0.5,0.6);
	else
	glColor3f(0.4,0.4,0.5);
}
void
LabelOverlayButton::updateHoverStatus()
{
    if( isUnderMouse() )
        m_scaledPixmap = m_iconEffect->apply( m_pixmap.scaledToHeight( m_size, Qt::SmoothTransformation ), KIconLoader::Desktop, KIconLoader::ActiveState );
    else
        m_scaledPixmap = m_pixmap.scaledToHeight( m_size, Qt::SmoothTransformation );
}
Exemple #7
0
bool IconItem::checkUp()
{
    if(isUnderMouse() && is_selectable_) {
        setPixmap(info_.icon_active_img_);
        return true;
    }
    return false;
}
QVariant CornerHandle::itemChange(GraphicsItemChange change,
                                  const QVariant &value)
{
    if (change == ItemVisibleHasChanged) {
        if (value.toBool())
            setOpacity(isUnderMouse() ? 1 : 0.5);
    }
    return QGraphicsItem::itemChange(change, value);
}
Exemple #9
0
bool CustomProxy::sceneEventFilter(QGraphicsItem *watched, QEvent *event)
{
    if (watched->isWindow() && (event->type() == QEvent::UngrabMouse || event->type() == QEvent::GrabMouse)) {
        popupShown = watched->isVisible();
        if (!popupShown && !isUnderMouse())
            zoomOut();
    }
    return QGraphicsProxyWidget::sceneEventFilter(watched, event);
}
void PagerApplet::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
	QGraphicsPixmapItem* item = m_listPixmapDesktops.at(0);
	int newDesktop = (int)(event->pos().x() / item->pixmap().width());
	if (m_currentDesktop != newDesktop)
		xfitMan().setActiveDesktop(newDesktop);
	if(isUnderMouse())
		if(event->buttons() == Qt::RightButton)
			showContextMenu(localToScreen(QPoint(0, 0)));
}
void
LabelOverlayButton::setPixmap( const QPixmap& pixmap )
{
    m_pixmap = pixmap;

    if( isUnderMouse() )
        m_scaledPixmap = m_iconEffect->apply( m_pixmap.scaledToHeight( m_size, Qt::SmoothTransformation ), KIconLoader::Desktop, KIconLoader::ActiveState );
    else
        m_scaledPixmap = m_pixmap.scaledToHeight( m_size, Qt::SmoothTransformation );
}
void Window::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
    //当鼠标指针不在窗口上时,忽略左键按下事件,以避免产生"仍能拖动窗口"的效果
    if (!isUnderMouse()) {
        event->ignore();
    }
    else {
        QGraphicsObject::mousePressEvent(event);
    }
}
Exemple #13
0
void QDeclarativeMouseArea::setHoverEnabled(bool h)
{
    Q_D(QDeclarativeMouseArea);
    if (h == acceptHoverEvents())
        return;

    setAcceptHoverEvents(h);
    emit hoverEnabledChanged();
    if (d->hovered != isUnderMouse())
        setHovered(!d->hovered);
}
Exemple #14
0
void TB_PokemonItem::mousePressEvent(QGraphicsSceneMouseEvent * event)
{
    if (!isUnderMouse()) {
        event->ignore();
        return;
    }
    if(event->button() == Qt::LeftButton)
    {
        startPos = event->pos();
    }
    QGraphicsPixmapItem::mousePressEvent(event);
}
void QNodeItem::paint(QPainter* pPainter, const QStyleOptionGraphicsItem* pOption, QWidget* pWidget)
{
	QBrush Brush;
	QPen Pen;

	if (isEnabled())
	{
		if (isUnderMouse() || isSelected())
		{
			Brush	= QNodeItem::m_BrushHighlight;
			Pen		= QNodeItem::m_PenHighlight;
		}
		else
		{
			Brush	= QNodeItem::m_BrushNormal;
			Pen		= QNodeItem::m_PenNormal;
		}

		if (isUnderMouse() || isSelected())
		{
			QRectF SelRect = rect();
			SelRect.adjust(-2.6, -2.6, 2.6, 2.6);

			pPainter->setBrush(QNodeItem::m_SelectionBrush);
			pPainter->setPen(QNodeItem::m_SelectionPen);
			pPainter->drawEllipse(SelRect);
		}
	}
	else
	{
		Brush	= QNodeItem::m_BrushDisabled;
		Pen		= QNodeItem::m_PenDisabled;
	}

	pPainter->setBrush(Brush);
	pPainter->setPen(Pen);
	pPainter->drawEllipse(rect());
}
Exemple #16
0
QVariant QDeclarativeMouseArea::itemChange(GraphicsItemChange change,
                                       const QVariant &value)
{
    Q_D(QDeclarativeMouseArea);
    switch (change) {
    case ItemVisibleHasChanged:
        if (acceptHoverEvents() && d->hovered != (isVisible() && isUnderMouse()))
            setHovered(!d->hovered);
        break;
    default:
        break;
    }

    return QDeclarativeItem::itemChange(change, value);
}
Exemple #17
0
void ShapeItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
    Q_UNUSED(option)
    Q_UNUSED(widget)
	
	//painter->drawRect(0, 0, width, height);
    painter->drawPixmap(0, 0, width, height, property["image"].value<QPixmap>());

	if( isUnderMouse() )
	{
		painter->setBrush( Qt::NoBrush );
		painter->setPen( QPen(QColor(255,255,0,128), 10) );
		painter->drawRect( boundingRect() );
	}
}
Exemple #18
0
void SvgCard::setSelectable( bool selectable )
{
    mSelectable = selectable;
    
    if( mSelectable ){
        setCursor( QCursor( Qt::PointingHandCursor ) );
        
        //
        if( isUnderMouse() ){
            emit signalMouseEnter( this );
        }
        //
    }else{
        setCursor( QCursor( Qt::ArrowCursor ) );
    }
}
void BlendRenderItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
	Q_UNUSED(option)
	Q_UNUSED(widget)

	painter->drawPixmap(pixmap.rect(), pixmap);

	if( isSelected() || isUnderMouse() )
	{
		painter->setBrush( Qt::NoBrush );
		painter->setPen( QPen(Qt::yellow, 2) );
		painter->drawRect( pixmap.rect().adjusted(4,4,-4,-4) );
	}

	/// DEBUG:
	//painter->drawText(10,20, QString::number(graph()->property["t"].toDouble()) );
	//painter->drawRect( pixmap.rect() );
}
Exemple #20
0
void Applet::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
{
	if(isUnderMouse())
	{
		if(event->button() == Qt::LeftButton)
		{
			// FIXME: Workaround.
			// For some weird reason, if clicked() function is called directly, and menu is opened,
			// this item will receive hover enter event on menu close. But it shouldn't (mouse is outside).
			// Probably somehow related to taking a mouse grab when one is already active.
			QTimer::singleShot(1, this, SLOT(clicked()));
		}
		if(event->button() == Qt::RightButton)
		{
			m_panelWindow->showPanelContextMenu(m_position + QPoint(static_cast<int>(event->pos().x()), static_cast<int>(event->pos().y())));
		}
	}
}
Exemple #21
0
void PixmapButton::mouseMoveEvent(QGraphicsSceneMouseEvent* event)
{
    if(!isVisible())
        return;

    if(m_pressed && !isUnderMouse()) {
        m_pressed = false;

        if(m_active)
            setPixmap(m_onPixmap);
        else
            setPixmap(m_offPixmap);

        update();
        ungrabMouse();
        Q_EMIT clickComplete();
    }
}
QVariant IncidencePointGraphicsItem::itemChange(GraphicsItemChange change, const QVariant &value)
{
    if(change == QGraphicsItem::ItemPositionHasChanged)
    {
        if(isUnderMouse())
        {
            if(mParent->isAcceptable(objectAtPoint(), role()))
                mColor = Qt::green;
            else
                mColor = Qt::red;
        }
        else if(isSelected())
            mColor = QColor(255, 128, 64);
        else
            mColor = QColor(170, 170, 170);
    }

    return PointGraphicsItem::itemChange(change, value);
}
bool MInverseMouseArea::eventFilter(QObject *obj, QEvent *ev)
{
    Q_UNUSED(obj);
    if (!m_enabled || !isVisible())
        return false;
    switch (ev->type()) {
    case QEvent::MouseButtonPress: {
        QMouseEvent *me = static_cast<QMouseEvent *>(ev);
        QPointF mappedPos = me->screenPos();//??is mapping to root item needed still
        m_pressed = !isUnderMouse() && !isClickedOnSoftwareInputPanel();

        if (m_pressed) {
            m_lastsceenPos = me->screenPos();
            emit pressedOutside(mappedPos.x(), mappedPos.y());
        }
        break;
    }
    case QEvent::MouseMove: {
        if (m_pressed) {
            QMouseEvent *me = static_cast<QMouseEvent *>(ev);
            const QPointF &dist = me->screenPos() - m_lastsceenPos;

            if (dist.x() * dist.x() + dist.y() * dist.y() > FlickThresholdSquare)
                m_pressed = false;
        }
        break;
    }
    case QEvent::MouseButtonRelease: {
        QMouseEvent *me = static_cast<QMouseEvent *>(ev);
        QPointF mappedPos = mapToRootItem(me->screenPos());

        if (m_pressed) {
            m_pressed = false;
            emit clickedOutside(mappedPos.x(), mappedPos.y());
        }
        break;
    }
    default:
        break;
    }

    return false;
}
void QQuickMouseArea::itemChange(ItemChange change, const ItemChangeData &value)
{
    Q_D(QQuickMouseArea);
    switch (change) {
    case ItemVisibleHasChanged:
        if (acceptHoverEvents() && d->hovered != (isVisible() && isUnderMouse())) {
            if (!d->hovered) {
                QPointF cursorPos = QGuiApplicationPrivate::lastCursorPosition;
                d->lastScenePos = d->window->mapFromGlobal(cursorPos.toPoint());
                d->lastPos = mapFromScene(d->lastScenePos);
            }
            setHovered(!d->hovered);
        }
        break;
    default:
        break;
    }

    QQuickItem::itemChange(change, value);
}
Exemple #25
0
void AbstractCounter::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
    if (isUnderMouse()) {
        if (event->button() == Qt::LeftButton) {
            Command_IncCounter cmd;
            cmd.set_counter_id(id);
            cmd.set_delta(1);
            player->sendGameCommand(cmd);
            event->accept();
        } else if (event->button() == Qt::RightButton) {
            Command_IncCounter cmd;
            cmd.set_counter_id(id);
            cmd.set_delta(-1);
            player->sendGameCommand(cmd);
            event->accept();
        } else if (event->button() == Qt::MidButton) {
            if (menu)
                menu->exec(event->screenPos());
            event->accept();
        } 
    }else
        event->ignore();
}
Exemple #26
0
void QNEConnection::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
    Q_UNUSED(option)
    Q_UNUSED(widget)

    QPen p = pen();
    QBrush b = brush();

    if (isSelected() ||
            (m_port1 && m_port1->isSelected()) ||
            (m_port2 && m_port2->isSelected()))
    {
        p.setColor(p.color().lighter(150));
    }
    if (isUnderMouse())
    {
        p.setColor(p.color().lighter(130));
    }

    painter->setPen(p);
    painter->setBrush(b);
    painter->drawPath(path());
}
Exemple #27
0
void DockItem::animate()
{
	bool needAnotherStep = false;

	static const qreal highlightAnimationSpeed = 0.15;
	qreal targetIntensity = isUnderMouse() ? 1.0 : 0.0;
	m_highlightIntensity = AnimationUtils::animate(m_highlightIntensity, targetIntensity, highlightAnimationSpeed, needAnotherStep);

	static const qreal urgencyHighlightAnimationSpeed = 0.015;
	qreal targetUrgencyIntensity = 0.0;
	if(isUrgent())
	{
		qint64 msecs = QDateTime::currentMSecsSinceEpoch() % 3000;
		if(msecs < 1500)
			targetUrgencyIntensity = 1.0;
		else
			targetUrgencyIntensity = 0.5;
		needAnotherStep = true;
	}
	m_urgencyHighlightIntensity = AnimationUtils::animate(m_urgencyHighlightIntensity, targetUrgencyIntensity, urgencyHighlightAnimationSpeed, needAnotherStep);

	if(!m_dragging)
	{
		static const int positionAnimationSpeed = 24;
		static const int sizeAnimationSpeed = 24;
		m_position.setX(AnimationUtils::animateExponentially(m_position.x(), m_targetPosition.x(), 0.2, positionAnimationSpeed, needAnotherStep));
		m_position.setY(AnimationUtils::animateExponentially(m_position.y(), m_targetPosition.y(), 0.2, positionAnimationSpeed, needAnotherStep));
		m_size.setWidth(AnimationUtils::animate(m_size.width(), m_targetSize.width(), sizeAnimationSpeed, needAnotherStep));
		m_size.setHeight(AnimationUtils::animate(m_size.height(), m_targetSize.height(), sizeAnimationSpeed, needAnotherStep));
		setPos(m_position.x(), m_position.y());
	}

	// update();

	if(needAnotherStep)
		m_animationTimer->start();
}
Exemple #28
0
void DockItem::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
{
	if(event->button() == Qt::LeftButton)
	{
		m_dragging = false;
		m_dockApplet->draggingStopped();
		setZValue(0.0); // No more on top.
		startAnimation(); // Item can be out of it's regular, start animation to bring it back.
	}

	if(isUnderMouse())
	{
		if(m_clients.isEmpty())
			return;

		if(event->button() == Qt::LeftButton)
		{
			static const qreal clickMouseMoveTolerance = 10.0;

			if((event->scenePos() - m_mouseDownPosition).manhattanLength() < clickMouseMoveTolerance)
			{
				if(m_dockApplet->activeWindow() == m_clients[0]->handle())
					X11Support::minimizeWindow(m_clients[0]->handle());
				else
					X11Support::activateWindow(m_clients[0]->handle());
			}
		}

		if(event->button() == Qt::RightButton && !m_dragging)
		{
			QMenu menu;
			menu.addAction(QIcon::fromTheme("window-close"), "Close", this, SLOT(close()));
			menu.exec(event->screenPos());
		}
	}
}
Exemple #29
0
void IconItem::release()
{
    if(isUnderMouse() && is_selectable_)
        emit iconClicked();
     setPixmap(info_.icon_img_);
}
void DemoApplet::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
{
	if(isUnderMouse())
		showContextMenu(localToScreen(QPoint(0, 0)));
}