VirtualBox

Changeset 102592 in vbox for trunk


Ignore:
Timestamp:
Dec 13, 2023 7:43:13 PM (10 months ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10501. Some fixes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/activity/vmactivity/UIVMActivityMonitor.cpp

    r102273 r102592  
    318318    , m_fIsAvailable(true)
    319319    , m_fIsAreaChartAllowed(false)
    320     , m_fDrawCurenValueIndicators(false)
     320    , m_fDrawCurenValueIndicators(true)
    321321    , m_iRightMarginCharWidth(10)
    322322    , m_iMaximumQueueSize(iMaximumQueueSize)
     
    486486{
    487487    const int iX = width() - pEvent->position().x() - m_iMarginRight;
     488    QPoint eventPosition(pEvent->position().x(), pEvent->position().y());
    488489    m_iDataIndexUnderCursor = -1;
    489     if (iX > m_iMarginLeft && iX <= width() - m_iMarginRight)
    490         m_iDataIndexUnderCursor = (int)((iX) / m_fPixelPerDataPoint) + 1;
     490    if (m_lineChartRect.contains(eventPosition))
     491        m_iDataIndexUnderCursor = m_iMaximumQueueSize  - (int)((iX) / m_fPixelPerDataPoint) - 1;
     492    //printf("m_iDataIndexUnderCursor %d\n", m_iDataIndexUnderCursor);
    491493    update();
    492494    QIWithRetranslateUI<QWidget>::mouseMoveEvent(pEvent);
     
    549551    QFontMetrics fontMetrics(painter.font());
    550552    int iFontHeight = fontMetrics.height();
    551     int iAverageFontWidth = fontMetrics.averageCharWidth();
    552553
    553554    /* Draw the data lines: */
    554555    float fBarWidth = m_lineChartRect.width() / (float) (m_iMaximumQueueSize - 1);
    555556    float fH = iMaximum == 0 ? 0 : m_lineChartRect.height() / (float)iMaximum;
     557    const float fPenWidth = 1.5f;
     558    const float fPointSize = 3.5f;
    556559    for (int k = 0; k < DATA_SERIES_SIZE; ++k)
    557560    {
     
    561564            gradient.setColorAt(0, Qt::black);
    562565            gradient.setColorAt(1, m_dataSeriesColor[k]);
    563             painter.setPen(QPen(gradient, 2.5));
     566            painter.setPen(QPen(gradient, fPenWidth));
    564567        }
    565568        const QQueue<quint64> *data = m_pMetric->data(k);
    566569        if (!m_fUseGradientLineColor)
    567             painter.setPen(QPen(m_dataSeriesColor[k], 2.5));
     570            painter.setPen(QPen(m_dataSeriesColor[k], fPenWidth));
    568571        if (m_fUseAreaChart && m_fIsAreaChartAllowed)
    569572        {
     
    572575            {
    573576                float fHeight = fH * data->at(i);
     577                /* Stack 0th data series on top of the 1st data series: */
    574578                if (k == 0)
    575579                {
     
    590594        else
    591595        {
     596            /* Draw lines between data  points: */
    592597            for (int i = 0; i < data->size() - 1; ++i)
    593598            {
    594599                int j = i + 1;
    595600                float fHeight = fH * data->at(i);
    596                 float fX = (width() - m_iMarginRight) - ((data->size() -i - 1) * fBarWidth);
     601                float fX = (width() - m_iMarginRight) - ((data->size() - i - 1) * fBarWidth);
    597602                float fHeight2 = fH * data->at(j);
    598                 float fX2 = (width() - m_iMarginRight) - ((data->size() -j - 1) * fBarWidth);
     603                float fX2 = (width() - m_iMarginRight) - ((data->size() - j - 1) * fBarWidth);
    599604                QLineF bar(fX, height() - (fHeight + m_iMarginBottom), fX2, height() - (fHeight2 + m_iMarginBottom));
    600605                painter.drawLine(bar);
     606            }
     607            /* Draw a point at each data point: */
     608            painter.setPen(QPen(m_dataSeriesColor[k], fPointSize));
     609            for (int i = 0; i < data->size(); ++i)
     610            {
     611                float fHeight = fH * data->at(i);
     612                float fX = (width() - m_iMarginRight) - ((data->size() - i - 1) * fBarWidth);
     613                painter.drawPoint(fX, height() - (fHeight + m_iMarginBottom));
    601614            }
    602615        }
     
    609622            if (fHeight > 0)
    610623            {
    611                 painter.drawLine(m_iMarginLeft, height() - (fHeight + m_iMarginBottom),
    612                                  width() - m_iMarginRight, height() - (fHeight + m_iMarginBottom));
    613                 QPoint cursorPosition = mapFromGlobal(cursor().pos());
     624                // painter.drawLine(m_iMarginLeft, height() - (fHeight + m_iMarginBottom),
     625                //                  width() - m_iMarginRight, height() - (fHeight + m_iMarginBottom));
    614626                painter.setPen(mainAxisColor);
    615                 painter.drawLine(cursorPosition.x(), 0,
    616                                  cursorPosition.x(), height() - m_iMarginBottom);
    617                 QString strValue = QString::number(data->at(data->size() - m_iDataIndexUnderCursor));
    618 #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)
    619                 painter.drawText(m_iMarginLeft - fontMetrics.horizontalAdvance(strValue) - iAverageFontWidth,
    620                                  height() - (fHeight + m_iMarginBottom) + 0.5 * iFontHeight, strValue);
    621 #else
    622                 painter.drawText(m_iMarginLeft - fontMetrics.width(strValue) - iAverageFontWidth,
    623                                  height() - (fHeight + m_iMarginBottom) + 0.5 * iFontHeight, strValue);
    624 #endif
     627                float fX = (width() - m_iMarginRight) - ((data->size() - m_iDataIndexUnderCursor - 1) * fBarWidth);
     628                painter.drawLine(fX, 0, fX, height() - m_iMarginBottom);
     629                //    int iAverageFontWidth = fontMetrics.averageCharWidth();
     630//                 QString strValue = QString::number(data->at(data->size() - m_iDataIndexUnderCursor));
     631// #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)
     632//                 painter.drawText(m_iMarginLeft - fontMetrics.horizontalAdvance(strValue) - iAverageFontWidth,
     633//                                  height() - (fHeight + m_iMarginBottom) + 0.5 * iFontHeight, strValue);
     634// #else
     635//                 painter.drawText(m_iMarginLeft - fontMetrics.width(strValue) - iAverageFontWidth,
     636//                                  height() - (fHeight + m_iMarginBottom) + 0.5 * iFontHeight, strValue);
     637// #endif
    625638
    626639            }
     
    893906        m_iMaximum = qMax(m_iMaximum, iData);
    894907
     908    /* dequeue if needed and update the maximum value: */
    895909    if (m_data[iDataSeriesIndex].size() > m_iMaximumQueueSize)
    896910    {
     
    11421156    }
    11431157
    1144     /* Configure charts: */
    1145     if (m_charts.contains(m_strCPUMetricName) && m_charts[m_strCPUMetricName])
    1146     {
    1147         m_charts[m_strCPUMetricName]->setIsPieChartAllowed(true);
    1148         m_charts[m_strCPUMetricName]->setIsAreaChartAllowed(true);
    1149     }
    1150 
    11511158    QWidget *bottomSpacerWidget = new QWidget(this);
    11521159    bottomSpacerWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
     
    12931300    connect(&uiCommon(), &UICommon::sigAskToDetachCOM, this, &UIVMActivityMonitorLocal::sltClearCOMData);
    12941301    setMachine(machine);
     1302
     1303    /* Configure charts: */
     1304    if (m_charts.contains(m_strCPUMetricName) && m_charts[m_strCPUMetricName])
     1305    {
     1306        m_charts[m_strCPUMetricName]->setIsPieChartAllowed(true);
     1307        m_charts[m_strCPUMetricName]->setIsAreaChartAllowed(true);
     1308    }
    12951309}
    12961310
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette