Changeset 80246 in vbox
- Timestamp:
- Aug 13, 2019 9:39:44 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIPerformanceMonitor.cpp
r80243 r80246 40 40 const int iMaximumQueueSize = 120; 41 41 const int iMetricSetupCount = 1; 42 42 const int iDecimalCount = 2; 43 43 /********************************************************************************************************************************* 44 44 * UIChart definition. * … … 67 67 void setDataSeriesColor(int iDataSeriesIndex, const QColor &color); 68 68 69 QString dataSeriesLabel(int iDataSeriesIndex);70 void set DataSeriesLabel(int iDataSeriesIndex,const QString &strLabel);69 QString XAxisLabel(); 70 void setXAxisLabel(const QString &strLabel); 71 71 72 72 protected: … … 90 90 bool m_fUseGradientLineColor; 91 91 QColor m_dataSeriesColor[2]; 92 QString m_ dataSeriesLabel[2];92 QString m_strXAxisLabel; 93 93 }; 94 94 … … 109 109 110 110 m_iMarginLeft = 1 * qApp->QApplication::style()->pixelMetric(QStyle::PM_LayoutTopMargin); 111 m_iMarginRight = 4* qApp->QApplication::style()->pixelMetric(QStyle::PM_LayoutTopMargin);111 m_iMarginRight = 6 * qApp->QApplication::style()->pixelMetric(QStyle::PM_LayoutTopMargin); 112 112 m_iMarginTop = 0.3 * qApp->QApplication::style()->pixelMetric(QStyle::PM_LayoutTopMargin); 113 113 m_iMarginBottom = 2 * qApp->QApplication::style()->pixelMetric(QStyle::PM_LayoutTopMargin); … … 182 182 } 183 183 184 QString UIChart::dataSeriesLabel(int iDataSeriesIndex) 185 { 186 if (iDataSeriesIndex >= 2) 187 return QString(); 188 return m_dataSeriesLabel[iDataSeriesIndex]; 189 } 190 191 void UIChart::setDataSeriesLabel(int iDataSeriesIndex, const QString &strLabel) 192 { 193 if (iDataSeriesIndex >= 2) 194 return; 195 if (m_dataSeriesLabel[iDataSeriesIndex] == strLabel) 196 return; 197 m_dataSeriesLabel[iDataSeriesIndex] = strLabel; 198 update(); 184 QString UIChart::XAxisLabel() 185 { 186 return m_strXAxisLabel; 187 } 188 189 void UIChart::setXAxisLabel(const QString &strLabel) 190 { 191 m_strXAxisLabel = strLabel; 199 192 } 200 193 … … 269 262 if (i == 0) 270 263 { 271 strCurentSec += " seconds";264 strCurentSec += " " + m_strXAxisLabel; 272 265 painter.drawText(iTextX, height() - m_iMarginBottom + iFontHeight, strCurentSec); 273 266 } … … 323 316 /* Draw YAxis tick labels: */ 324 317 painter.setPen(mainAxisColor); 325 for (int i = 1; i < iYSubAxisCount + 2; ++i)326 { 327 328 int iTextY = m_iMarginTop + i * iChartHeight / (float) (iYSubAxisCount + 1);318 for (int i = 0; i < iYSubAxisCount + 2; ++i) 319 { 320 321 int iTextY = 0.5 * iFontHeight + m_iMarginTop + i * iChartHeight / (float) (iYSubAxisCount + 1); 329 322 QString strValue; 330 ULONG iValue = iMaximum - (i +1) * iMaximum / (float) (iYSubAxisCount + 2); 323 ULONG iValue = (iYSubAxisCount + 1 - i) * (iMaximum / (float) (iYSubAxisCount + 1)); 324 //printf("%d %u\n", i, iValue); 331 325 if (m_pSubMetric->unit().compare("%", Qt::CaseInsensitive) == 0) 332 326 strValue = QString::number(iValue); 333 327 else if (m_pSubMetric->unit().compare("kb", Qt::CaseInsensitive) == 0) 334 strValue = uiCommon().formatSize(_1K * (quint64)iValue );328 strValue = uiCommon().formatSize(_1K * (quint64)iValue, iDecimalCount); 335 329 else if (m_pSubMetric->unit().compare("b", Qt::CaseInsensitive) == 0 || 336 330 m_pSubMetric->unit().compare("b/s", Qt::CaseInsensitive) == 0) 337 strValue = uiCommon().formatSize(iValue );331 strValue = uiCommon().formatSize(iValue, iDecimalCount); 338 332 painter.drawText(width() - 0.9 * m_iMarginRight, iTextY, strValue); 339 333 } … … 486 480 void UIPerformanceMonitor::retranslateUi() 487 481 { 482 foreach (UIChart *pChart, m_charts) 483 pChart->setXAxisLabel(QApplication::translate("UIVMInformationDialog", "Seconds")); 484 int iMaximum = 0; 488 485 m_strCPUInfoLabelTitle = QApplication::translate("UIVMInformationDialog", "CPU Load"); 486 iMaximum = qMax(iMaximum, m_strCPUInfoLabelTitle.length()); 487 489 488 m_strRAMInfoLabelTitle = QApplication::translate("UIVMInformationDialog", "RAM Usage"); 489 iMaximum = qMax(iMaximum, m_strRAMInfoLabelTitle.length()); 490 490 m_strRAMInfoLabelTotal = QApplication::translate("UIVMInformationDialog", "Total"); 491 iMaximum = qMax(iMaximum, m_strRAMInfoLabelTotal.length()); 491 492 m_strRAMInfoLabelFree = QApplication::translate("UIVMInformationDialog", "Free"); 493 iMaximum = qMax(iMaximum, m_strRAMInfoLabelFree.length()); 492 494 m_strRAMInfoLabelUsed = QApplication::translate("UIVMInformationDialog", "Used"); 495 iMaximum = qMax(iMaximum, m_strRAMInfoLabelUsed.length()); 493 496 m_strNetInfoLabelTitle = QApplication::translate("UIVMInformationDialog", "Network"); 497 iMaximum = qMax(iMaximum, m_strNetInfoLabelTitle.length()); 494 498 m_strNetInfoLabelReceived = QApplication::translate("UIVMInformationDialog", "Received"); 499 iMaximum = qMax(iMaximum, m_strNetInfoLabelReceived.length()); 495 500 m_strNetInfoLabelTransmitted = QApplication::translate("UIVMInformationDialog", "Trasmitted"); 501 iMaximum = qMax(iMaximum, m_strNetInfoLabelTransmitted.length()); 496 502 m_strNetInfoLabelMaximum = QApplication::translate("UIVMInformationDialog", "Maximum"); 503 iMaximum = qMax(iMaximum, m_strNetInfoLabelMaximum.length()); 504 505 /* Compute the maximum label string length and set it as a fixed width to labels to prevent always changing widths: */ 506 /* Add m_iDecimalCount plus 3 characters for the number and 2 for unit string: */ 507 iMaximum += (iDecimalCount + 5); 508 if (!m_infoLabels.isEmpty()) 509 { 510 QLabel *pLabel = m_infoLabels.begin().value(); 511 512 if (pLabel) 513 { 514 QFontMetrics labelFontMetric(pLabel->font()); 515 int iWidth = iMaximum * labelFontMetric.width('X'); 516 foreach (QLabel *pInfoLabel, m_infoLabels) 517 pInfoLabel->setFixedWidth(iWidth); 518 } 519 } 520 497 521 } 498 522 … … 537 561 m_charts[m_strNetMetricName]->setUseGradientLineColor(false); 538 562 } 539 //if (m_charts.contains(m_strCPUMetricName) && m_charts[m_strCPUMetricName])540 //m_charts[m_strCPUMetricName]->setUseGradientLineColor(false);563 if (m_charts.contains(m_strCPUMetricName) && m_charts[m_strCPUMetricName]) 564 m_charts[m_strCPUMetricName]->setUseGradientLineColor(false); 541 565 542 566 QWidget *bottomSpacerWidget = new QWidget(this); … … 714 738 void UIPerformanceMonitor::updateCPUGraphsAndMetric(ULONG iExecutingPercentage, ULONG iOtherPercentage) 715 739 { 716 Q_UNUSED(iOtherPercentage);717 740 UISubMetric &CPUMetric = m_subMetrics[m_strCPUMetricName]; 718 741 CPUMetric.addData(0, iExecutingPercentage); 719 //CPUMetric.addData(1, iOtherPercentage);742 CPUMetric.addData(1, iOtherPercentage); 720 743 CPUMetric.setMaximum(100); 721 744 if (m_infoLabels.contains(m_strCPUMetricName) && m_infoLabels[m_strCPUMetricName]) … … 741 764 QString strInfo; 742 765 if (m_infoLabels[m_strRAMMetricName]->isEnabled()) 743 strInfo = QString("<b>%1</b><br/>%2: %3<br/>%4: %5<br/>%6: %7").arg(m_strRAMInfoLabelTitle).arg(m_strRAMInfoLabelTotal).arg(uiCommon().formatSize(_1K * iTotalRAM ))744 .arg(m_strRAMInfoLabelFree).arg(uiCommon().formatSize(_1K * (iFreeRAM) ))745 .arg(m_strRAMInfoLabelUsed).arg(uiCommon().formatSize(_1K * (iTotalRAM - iFreeRAM) ));766 strInfo = QString("<b>%1</b><br/>%2: %3<br/>%4: %5<br/>%6: %7").arg(m_strRAMInfoLabelTitle).arg(m_strRAMInfoLabelTotal).arg(uiCommon().formatSize(_1K * iTotalRAM, iDecimalCount)) 767 .arg(m_strRAMInfoLabelFree).arg(uiCommon().formatSize(_1K * (iFreeRAM), iDecimalCount)) 768 .arg(m_strRAMInfoLabelUsed).arg(uiCommon().formatSize(_1K * (iTotalRAM - iFreeRAM), iDecimalCount)); 746 769 else 747 770 strInfo = QString("<b>%1</b><br/>%2: %3<br/>%4: %5<br/>%6: %7").arg(m_strRAMInfoLabelTitle).arg(m_strRAMInfoLabelTotal).arg("---").arg(m_strRAMInfoLabelFree).arg("---").arg(m_strRAMInfoLabelUsed).arg("---"); … … 767 790 if (m_infoLabels[m_strNetMetricName]->isEnabled()) 768 791 strInfo = QString("<b>%1</b></b><br/><font color=\"#FF0000\">%2: %3</font><br/><font color=\"#0000FF\">%4: %5</font><br/>%6: %7").arg(m_strNetInfoLabelTitle) 769 .arg(m_strNetInfoLabelReceived).arg(uiCommon().formatSize((quint64)iReceiveRate ))770 .arg(m_strNetInfoLabelTransmitted).arg(uiCommon().formatSize((quint64)iTransmitRate ))771 .arg(m_strNetInfoLabelMaximum).arg(uiCommon().formatSize((quint64)iMaximum ));792 .arg(m_strNetInfoLabelReceived).arg(uiCommon().formatSize((quint64)iReceiveRate, iDecimalCount)) 793 .arg(m_strNetInfoLabelTransmitted).arg(uiCommon().formatSize((quint64)iTransmitRate, iDecimalCount)) 794 .arg(m_strNetInfoLabelMaximum).arg(uiCommon().formatSize((quint64)iMaximum, iDecimalCount)); 772 795 else 773 796 strInfo = QString("<b>%1</b><br/>%2: %3<br/>%4: %5<br/>%6: %7").arg(m_strNetInfoLabelTitle).arg(m_strNetInfoLabelReceived).arg("---").arg(m_strNetInfoLabelTransmitted).arg("---");
Note:
See TracChangeset
for help on using the changeset viewer.