void RadialMap::Widget::mouseMoveEvent( QMouseEvent *e ) { //set m_focus to what we hover over, update UI if it's a new segment Segment const * const oldFocus = m_focus; QPoint p = e->pos(); m_focus = segmentAt( p ); //NOTE p is passed by non-const reference if( m_focus && m_focus->file() != m_tree ) { if( m_focus != oldFocus ) //if not same as last time { setCursor( KCursor::handCursor() ); m_tip->updateTip( m_focus->file(), m_tree ); emit mouseHover( m_focus->file()->fullPath() ); //repaint required to update labels now before transparency is generated repaint( false ); } m_tip->moveTo( e->globalPos(), *this, ( p.y() < 0 ) ); //updates tooltip psuedo-tranparent background } else if( oldFocus && oldFocus->file() != m_tree ) { unsetCursor(); m_tip->hide(); update(); emit mouseHover( QString::null ); } }
bool FrameLess::eventFilter(QObject *o, QEvent*e) { if (e->type() == QEvent::MouseMove || e->type() == QEvent::HoverMove || e->type() == QEvent::Leave || e->type() == QEvent::MouseButtonPress || e->type() == QEvent::MouseButtonRelease) { switch (e->type()) { case QEvent::MouseMove: mouseMove(static_cast<QMouseEvent*>(e)); return true; break; case QEvent::HoverMove: mouseHover(static_cast<QHoverEvent*>(e)); return true; break; case QEvent::Leave: mouseLeave(e); return true; break; case QEvent::MouseButtonPress: mousePress(static_cast<QMouseEvent*>(e)); return true; break; case QEvent::MouseButtonRelease: mouseRealese(static_cast<QMouseEvent*>(e)); return true; break; } } else { return false; } }
void RadialMap::Widget::enterEvent(QEvent *) { if (!m_focus) return; setCursor(Qt::PointingHandCursor); emit mouseHover(m_focus->file()->fullPath()); update(); }
void Tile::draw(sf::RenderWindow& w) { if (isPolluted()){ cooldown--; if (cooldown == 0) { currentSprite = 0; spriteUpdate(currentSprite); } } if (hasTower() && isHovered) { getTower()->showRangeCircle(w); } sprite.setTexture(texture); sf::Vector2i spriteInit(0, currentSprite*height); sprite.setTextureRect(sf::IntRect(spriteInit, sf::Vector2i(width, height))); sprite.setPosition(sf::Vector2f(float(positionPixel.x), float(positionPixel.y))); mouseHover(w); w.draw(sprite); }
void CPushButton::enterEvent(QEvent* event){ emit mouseHover(); event->ignore(); }
void RadialMap::Widget::mouseMoveEvent(QMouseEvent *e) { //set m_focus to what we hover over, update UI if it's a new segment Segment const * const oldFocus = m_focus; QPoint p = e->pos(); m_focus = segmentAt(p); //NOTE p is passed by non-const reference if (m_focus) { m_tooltip.move(e->globalX() + 20, e->globalY() + 20); if (m_focus != oldFocus) //if not same as last time { setCursor(Qt::PointingHandCursor); QString string = m_focus->file()->fullPath(m_tree) + QLatin1Char('\n') + m_focus->file()->humanReadableSize(); if (m_focus->file()->isFolder()) { int files = static_cast<const Folder*>(m_focus->file())->children(); const uint percent = uint((100 * files) / (double)m_tree->children()); string += QLatin1Char('\n'); string += i18np("File: %1", "Files: %1", files); if (percent > 0) string += QString(QLatin1String(" (%1%)")).arg(percent); } const QUrl url = Widget::url(m_focus->file()); if (m_focus == m_rootSegment && url != KIO::upUrl(url)) { string += i18n("\nClick to go up to parent directory"); } // Calculate a semi-sane size for the tooltip QFontMetrics fontMetrics(font()); int tooltipWidth = 0; int tooltipHeight = 0; for (const QString &part : string.split(QLatin1Char('\n'))) { tooltipHeight += fontMetrics.height(); tooltipWidth = qMax(tooltipWidth, fontMetrics.width(part)); } // Limit it to the window size, probably should find something better tooltipWidth = qMin(tooltipWidth, window()->width()); tooltipWidth += 10; tooltipHeight += 10; m_tooltip.resize(tooltipWidth, tooltipHeight); m_tooltip.setText(string); m_tooltip.show(); emit mouseHover(m_focus->file()->fullPath()); update(); } } else if (oldFocus && oldFocus->file() != m_tree) { m_tooltip.hide(); unsetCursor(); update(); emit mouseHover(QString()); } }