Changeset 80243 in vbox
- Timestamp:
- Aug 13, 2019 6:39:03 AM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 132693
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime/information
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIPerformanceMonitor.cpp
r80203 r80243 299 299 QLinearGradient gradient(0, 0, 0, iChartHeight); 300 300 gradient.setColorAt(1.0, Qt::green); 301 gradient.setColorAt(0.5, Qt::yellow); 301 302 gradient.setColorAt(0.0, Qt::red); 302 303 painter.setPen(QPen(gradient, 2.5)); … … 335 336 m_pSubMetric->unit().compare("b/s", Qt::CaseInsensitive) == 0) 336 337 strValue = uiCommon().formatSize(iValue); 337 338 // QString strCurentSec = QString::number(iTotalSeconds - i * iTotalSeconds / (float)(iXSubAxisCount + 1));339 // int iTextWidth = fontMetrics.width(strCurentSec);340 // if (i == 0)341 // {342 // strCurentSec += " seconds";343 // painter.drawText(iTextX, height() - m_iMarginBottom + iFontHeight, strCurentSec);344 // }345 // else346 // painter.drawText(iTextX - 0.5 * iTextWidth, height() - m_iMarginBottom + iFontHeight, strCurentSec);347 338 painter.drawText(width() - 0.9 * m_iMarginRight, iTextY, strValue); 348 339 } … … 357 348 QPainterPath fillPath; 358 349 fillPath.moveTo(center); 359 360 350 fillPath.arcTo(m_pieChartRect, 90/*startAngle*/, 361 351 -1 * 360 /*sweepLength*/); 362 352 363 353 /* First draw a white filled circle and that the arc for data: */ 354 painter.setPen(Qt::NoPen); 355 painter.setBrush(QColor(255, 255, 255, 175)); 356 painter.drawPath(fillPath); 357 358 /* Prepare the gradient for the pie chart: */ 364 359 QConicalGradient pieGradient; 365 360 pieGradient.setCenter(m_pieChartRect.center()); 366 361 pieGradient.setAngle(90); 367 362 pieGradient.setColorAt(0, Qt::red); 363 pieGradient.setColorAt(0.5, Qt::yellow); 368 364 pieGradient.setColorAt(1, Qt::green); 369 370 painter.setPen(Qt::NoPen);371 painter.setBrush(Qt::white);372 painter.drawPath(fillPath);373 365 374 366 if (isEnabled()) … … 466 458 467 459 UIPerformanceMonitor::UIPerformanceMonitor(QWidget *pParent, const CMachine &machine, const CConsole &console, const UISession *pSession) 468 : Q Widget(pParent)460 : QIWithRetranslateUI<QWidget>(pParent) 469 461 , m_fGuestAdditionsAvailable(false) 470 462 , m_machine(machine) … … 485 477 prepareObjects(); 486 478 enableDisableGuestAdditionDependedWidgets(m_fGuestAdditionsAvailable); 479 retranslateUi(); 487 480 } 488 481 489 482 UIPerformanceMonitor::~UIPerformanceMonitor() 490 483 { 484 } 485 486 void UIPerformanceMonitor::retranslateUi() 487 { 488 m_strCPUInfoLabelTitle = QApplication::translate("UIVMInformationDialog", "CPU Load"); 489 m_strRAMInfoLabelTitle = QApplication::translate("UIVMInformationDialog", "RAM Usage"); 490 m_strRAMInfoLabelTotal = QApplication::translate("UIVMInformationDialog", "Total"); 491 m_strRAMInfoLabelFree = QApplication::translate("UIVMInformationDialog", "Free"); 492 m_strRAMInfoLabelUsed = QApplication::translate("UIVMInformationDialog", "Used"); 493 m_strNetInfoLabelTitle = QApplication::translate("UIVMInformationDialog", "Network"); 494 m_strNetInfoLabelReceived = QApplication::translate("UIVMInformationDialog", "Received"); 495 m_strNetInfoLabelTransmitted = QApplication::translate("UIVMInformationDialog", "Trasmitted"); 496 m_strNetInfoLabelMaximum = QApplication::translate("UIVMInformationDialog", "Maximum"); 491 497 } 492 498 … … 531 537 m_charts[m_strNetMetricName]->setUseGradientLineColor(false); 532 538 } 539 // if (m_charts.contains(m_strCPUMetricName) && m_charts[m_strCPUMetricName]) 540 // m_charts[m_strCPUMetricName]->setUseGradientLineColor(false); 541 533 542 QWidget *bottomSpacerWidget = new QWidget(this); 534 543 bottomSpacerWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); … … 605 614 ULONG aPctOther; 606 615 m_machineDebugger.GetCPULoad(0x7fffffff, aPctExecuting, aPctHalted, aPctOther); 607 updateCPUGraphsAndMetric(aPctExecuting );616 updateCPUGraphsAndMetric(aPctExecuting, aPctOther); 608 617 } 609 618 … … 703 712 } 704 713 705 void UIPerformanceMonitor::updateCPUGraphsAndMetric(ULONG iLoadPercentage) 706 { 714 void UIPerformanceMonitor::updateCPUGraphsAndMetric(ULONG iExecutingPercentage, ULONG iOtherPercentage) 715 { 716 Q_UNUSED(iOtherPercentage); 707 717 UISubMetric &CPUMetric = m_subMetrics[m_strCPUMetricName]; 708 CPUMetric.addData(0, iLoadPercentage); 718 CPUMetric.addData(0, iExecutingPercentage); 719 //CPUMetric.addData(1, iOtherPercentage); 709 720 CPUMetric.setMaximum(100); 710 721 if (m_infoLabels.contains(m_strCPUMetricName) && m_infoLabels[m_strCPUMetricName]) … … 712 723 QString strInfo; 713 724 if (m_infoLabels[m_strCPUMetricName]->isEnabled()) 714 strInfo = QString("<b>%1</b><br/>%2%3").arg( "CPU Load").arg(QString::number(iLoadPercentage)).arg("%");725 strInfo = QString("<b>%1</b><br/>%2%3").arg(m_strCPUInfoLabelTitle).arg(QString::number(iExecutingPercentage)).arg("%"); 715 726 else 716 strInfo = QString("<b>%1</b><br/>%2%3").arg( "CPU Load").arg("--").arg("%");727 strInfo = QString("<b>%1</b><br/>%2%3").arg(m_strCPUInfoLabelTitle).arg("--").arg("%"); 717 728 m_infoLabels[m_strCPUMetricName]->setText(strInfo); 718 729 } … … 730 741 QString strInfo; 731 742 if (m_infoLabels[m_strRAMMetricName]->isEnabled()) 732 strInfo = QString("<b>%1</b><br/>%2: %3<br/>%4: %5<br/>%6: %7").arg( "RAM Usage").arg("Total").arg(uiCommon().formatSize(_1K * iTotalRAM))733 .arg( "Free:").arg(uiCommon().formatSize(_1K * (iFreeRAM)))734 .arg( "Used:").arg(uiCommon().formatSize(_1K * (iTotalRAM - iFreeRAM)));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))); 735 746 else 736 strInfo = QString("<b>%1</b><br/>%2: %3<br/>%4: %5<br/>%6: %7").arg( "RAM Usage").arg("Total").arg("---").arg("Free").arg("---").arg("Used").arg("---");747 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("---"); 737 748 m_infoLabels[m_strRAMMetricName]->setText(strInfo); 738 749 } … … 755 766 QString strInfo; 756 767 if (m_infoLabels[m_strNetMetricName]->isEnabled()) 757 strInfo = QString("<b>%1</b></b><br/><font color=\"#FF0000\">%2: %3</font><br/><font color=\"#0000FF\">%4: %5</font><br/>%6: %7").arg( "Network")758 .arg( "Receive").arg(uiCommon().formatSize((quint64)iReceiveRate))759 .arg( "Transmit:").arg(uiCommon().formatSize((quint64)iTransmitRate))760 .arg( "Maximum:").arg(uiCommon().formatSize((quint64)iMaximum));768 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)); 761 772 else 762 strInfo = QString("<b>%1</b><br/>%2: %3<br/>%4: %5<br/>%6: %7").arg( "Network").arg("Receieve").arg("---").arg("Transmit").arg("---");773 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("---"); 763 774 m_infoLabels[m_strNetMetricName]->setText(strInfo); 764 775 } -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIPerformanceMonitor.h
r80203 r80243 37 37 38 38 /* GUI includes: */ 39 #include "QIWithRetranslateUI.h" 39 40 #include "UIMainEventListener.h" 40 41 … … 76 77 }; 77 78 78 class UIPerformanceMonitor : public QWidget 79 /** UIPerformanceMonitor class displays some high level performance metric of the guest system. 80 * The values are read in certain periods and cached in the GUI side. Currently we draw some line charts 81 * and pie charts (where applicable) alongside with some text. */ 82 class UIPerformanceMonitor : public QIWithRetranslateUI<QWidget> 79 83 { 80 84 Q_OBJECT; … … 87 91 UIPerformanceMonitor(QWidget *pParent, const CMachine &machine, const CConsole &console, const UISession *pSession); 88 92 ~UIPerformanceMonitor(); 93 94 protected: 95 void retranslateUi(); 89 96 90 97 private slots: … … 100 107 bool guestAdditionsAvailable(int iMinimumMajorVersion); 101 108 void enableDisableGuestAdditionDependedWidgets(bool fEnable); 102 void updateCPUGraphsAndMetric(ULONG iLoadPercentage );109 void updateCPUGraphsAndMetric(ULONG iLoadPercentage, ULONG iOtherPercentage); 103 110 void updateRAMGraphsAndMetric(quint64 iTotalRAM, quint64 iFreeRAM); 104 111 void updateNewGraphsAndMetric(ULONG iReceiveRate, ULONG iTransmitRate); … … 124 131 QMap<QString,QLabel*> m_infoLabels; 125 132 126 QString m_strCPUMetricName; 127 QString m_strRAMMetricName; 128 QString m_strDiskMetricName; 129 QString m_strNetMetricName; 133 /** @name These metric names are used for map keys to identify metrics. 134 * @{ */ 135 QString m_strCPUMetricName; 136 QString m_strRAMMetricName; 137 QString m_strDiskMetricName; 138 QString m_strNetMetricName; 139 /** @} */ 140 141 /** @name These metric names are used for map keys to identify metrics. 142 * @{ */ 143 /** CPU info label strings. */ 144 QString m_strCPUInfoLabelTitle; 145 /** RAM usage info label strings. */ 146 QString m_strRAMInfoLabelTitle; 147 QString m_strRAMInfoLabelTotal; 148 QString m_strRAMInfoLabelFree; 149 QString m_strRAMInfoLabelUsed; 150 /** Net traffic info label strings. */ 151 QString m_strNetInfoLabelTitle; 152 QString m_strNetInfoLabelReceived; 153 QString m_strNetInfoLabelTransmitted; 154 QString m_strNetInfoLabelMaximum; 155 /** @} */ 156 157 130 158 }; 131 159
Note:
See TracChangeset
for help on using the changeset viewer.