Changeset 104413 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Apr 24, 2024 11:12:47 AM (12 months ago)
- svn:sync-xref-src-repo-rev:
- 162911
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/activity/vmactivity/UIVMActivityMonitor.cpp
r103943 r104413 145 145 int maxDataSize() const; 146 146 QString toolTipText() const; 147 bool isUnderMouse() const; 148 void updateIndexUnderCursor(const QPoint &point); 149 void updateToolTip(); 147 150 148 151 UIMetric *m_pMetric; … … 378 381 } 379 382 else if (pEvent->type() == QEvent::ToolTip) 380 { 381 QHelpEvent *pToolTipEvent = static_cast<QHelpEvent *>(pEvent); 382 if (m_pMouseOverLabel) 383 { 384 if (m_iDataIndexUnderCursor < 0) 385 m_pMouseOverLabel->setVisible(false); 386 else 387 { 388 QString strToolTip = toolTipText(); 389 if (!strToolTip.isEmpty()) 390 { 391 m_pMouseOverLabel->setText(strToolTip); 392 m_pMouseOverLabel->move(QPoint(pToolTipEvent->pos().x(), pToolTipEvent->pos().y() - m_pMouseOverLabel->height())); 393 m_pMouseOverLabel->setVisible(true); 394 } 395 else 396 m_pMouseOverLabel->setVisible(false); 397 } 398 } 399 400 401 } 383 updateToolTip(); 384 402 385 return QWidget::event(pEvent); 403 386 } … … 411 394 } 412 395 413 void UIChart::mouseMoveEvent(QMouseEvent *pEvent) 414 { 415 const int iX = width() - pEvent->position().x() - m_iMarginRight; 416 QPoint eventPosition(pEvent->position().x(), pEvent->position().y()); 396 void UIChart::updateIndexUnderCursor(const QPoint &point) 397 { 398 if (!isUnderMouse()) 399 { 400 m_iDataIndexUnderCursor = -1; 401 return; 402 } 403 const int iX = width() - point.x() - m_iMarginRight; 404 417 405 int iDataSize = maxDataSize(); 418 406 m_iDataIndexUnderCursor = -1; 419 407 420 if (iDataSize > 0 && m_lineChartRect.contains( eventPosition))408 if (iDataSize > 0 && m_lineChartRect.contains(point)) 421 409 { 422 410 m_iDataIndexUnderCursor = m_iMaximumQueueSize - (int)((iX) / m_fPixelPerDataPoint) - 1; 423 411 m_iDataIndexUnderCursor = m_iDataIndexUnderCursor - (m_iMaximumQueueSize - iDataSize); 424 412 } 425 413 } 414 415 void UIChart::updateToolTip() 416 { 417 updateIndexUnderCursor(mapFromGlobal(QCursor::pos())); 418 if (m_pMouseOverLabel) 419 { 420 if (m_iDataIndexUnderCursor < 0) 421 m_pMouseOverLabel->setVisible(false); 422 else 423 { 424 QString strToolTip = toolTipText(); 425 QPoint pos = mapFromGlobal(QCursor::pos()); 426 427 if (!strToolTip.isEmpty()) 428 { 429 m_pMouseOverLabel->setText(strToolTip); 430 m_pMouseOverLabel->move(QPoint(pos.x(), pos.y() - m_pMouseOverLabel->height())); 431 m_pMouseOverLabel->setVisible(true); 432 } 433 else 434 m_pMouseOverLabel->setVisible(false); 435 } 436 } 437 } 438 void UIChart::mouseMoveEvent(QMouseEvent *pEvent) 439 { 440 QPoint eventPosition(pEvent->position().x(), pEvent->position().y()); 441 updateIndexUnderCursor(eventPosition); 426 442 update(); 427 443 QWidget::mouseMoveEvent(pEvent); … … 430 446 void UIChart::paintEvent(QPaintEvent *pEvent) 431 447 { 448 if (isUnderMouse()) 449 updateToolTip(); 450 432 451 Q_UNUSED(pEvent); 433 452 if (!m_pMetric || m_iMaximumQueueSize <= 1) … … 731 750 } 732 751 752 bool UIChart::isUnderMouse() const 753 { 754 return rect().contains(mapFromGlobal(QCursor::pos())); 755 } 756 733 757 void UIChart::drawCombinedPieCharts(QPainter &painter, quint64 iMaximum) 734 758 {
Note:
See TracChangeset
for help on using the changeset viewer.