- Timestamp:
- Apr 2, 2020 8:33:18 PM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 136826
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/monitor/resource/UIResourceMonitor.cpp
r83517 r83518 113 113 quint64 m_iCPUKernelLoad; 114 114 quint64 m_iCPUFreq; 115 quint64 m_iTotalRAM; 116 quint64 m_iFreeRAM; 115 quint64 m_iRAMTotal; 116 quint64 m_iRAMFree; 117 quint64 m_iFSTotal; 118 quint64 m_iFSFree; 117 119 }; 118 120 … … 139 141 140 142 void prepare(); 143 void addVerticalLine(QHBoxLayout *pLayout); 141 144 void updateLabels(); 142 145 143 146 UIVMResourceMonitorDoughnutChart *m_pHostCPUChart; 144 147 UIVMResourceMonitorDoughnutChart *m_pHostRAMChart; 148 UIVMResourceMonitorDoughnutChart *m_pHostFSChart; 145 149 QLabel *m_pCPUTitleLabel; 146 150 QLabel *m_pCPUUserLabel; 147 151 QLabel *m_pCPUKernelLabel; 148 152 QLabel *m_pCPUTotalLabel; 149 150 153 QLabel *m_pRAMTitleLabel; 151 154 QLabel *m_pRAMUsedLabel; 152 155 QLabel *m_pRAMFreeLabel; 153 156 QLabel *m_pRAMTotalLabel; 154 157 QLabel *m_pFSTitleLabel; 158 QLabel *m_pFSUsedLabel; 159 QLabel *m_pFSFreeLabel; 160 QLabel *m_pFSTotalLabel; 155 161 QColor m_CPUUserColor; 156 162 QColor m_CPUKernelColor; 157 163 QColor m_RAMFreeColor; 158 164 QColor m_RAMUsedColor; 159 160 165 UIVMResourceMonitorHostStats m_hostStats; 161 166 }; … … 419 424 , m_pHostCPUChart(0) 420 425 , m_pHostRAMChart(0) 426 , m_pHostFSChart(0) 421 427 , m_pCPUTitleLabel(0) 422 428 , m_pCPUUserLabel(0) … … 427 433 , m_pRAMFreeLabel(0) 428 434 , m_pRAMTotalLabel(0) 435 , m_pFSTitleLabel(0) 436 , m_pFSUsedLabel(0) 437 , m_pFSFreeLabel(0) 438 , m_pFSTotalLabel(0) 429 439 , m_CPUUserColor(Qt::red) 430 440 , m_CPUKernelColor(Qt::blue) … … 453 463 if (m_pHostRAMChart) 454 464 { 455 quint64 iUsedRAM = m_hostStats.m_i TotalRAM - m_hostStats.m_iFreeRAM;456 m_pHostRAMChart->updateData(iUsedRAM, m_hostStats.m_i FreeRAM);457 m_pHostRAMChart->setDataMaximum(m_hostStats.m_i TotalRAM);458 if (m_hostStats.m_i TotalRAM!= 0)465 quint64 iUsedRAM = m_hostStats.m_iRAMTotal - m_hostStats.m_iRAMFree; 466 m_pHostRAMChart->updateData(iUsedRAM, m_hostStats.m_iRAMFree); 467 m_pHostRAMChart->setDataMaximum(m_hostStats.m_iRAMTotal); 468 if (m_hostStats.m_iRAMTotal != 0) 459 469 { 460 quint64 iUsedRamPer = 100 * (iUsedRAM / (float) m_hostStats.m_i TotalRAM);470 quint64 iUsedRamPer = 100 * (iUsedRAM / (float) m_hostStats.m_iRAMTotal); 461 471 QString strCenter = QString("%1%\n%2").arg(iUsedRamPer).arg(tr("Used")); 462 472 m_pHostRAMChart->setChartCenterString(strCenter); 463 473 } 464 474 } 475 if (m_pHostFSChart) 476 { 477 quint64 iUsedFS = m_hostStats.m_iFSTotal - m_hostStats.m_iFSFree; 478 m_pHostFSChart->updateData(iUsedFS, m_hostStats.m_iFSFree); 479 m_pHostFSChart->setDataMaximum(m_hostStats.m_iFSTotal); 480 if (m_hostStats.m_iFSTotal != 0) 481 { 482 quint64 iUsedRamPer = 100 * (iUsedFS / (float) m_hostStats.m_iFSTotal); 483 QString strCenter = QString("%1%\n%2").arg(iUsedRamPer).arg(tr("Used")); 484 m_pHostFSChart->setChartCenterString(strCenter); 485 } 486 } 487 465 488 updateLabels(); 466 489 } … … 469 492 { 470 493 updateLabels(); 494 } 495 496 void UIVMResourceMonitorHostStatsWidget::addVerticalLine(QHBoxLayout *pLayout) 497 { 498 QFrame *pLine = new QFrame; 499 pLine->setFrameShape(QFrame::VLine); 500 pLine->setFrameShadow(QFrame::Sunken); 501 pLayout->addWidget(pLine); 471 502 } 472 503 … … 513 544 } 514 545 } 546 addVerticalLine(pLayout); 515 547 /* RAM Stuff: */ 516 548 { … … 521 553 QVBoxLayout *pRAMLabelsLayout = new QVBoxLayout; 522 554 pRAMLabelsLayout->setContentsMargins(0, 0, 0, 0); 555 pRAMLabelsLayout->setSpacing(0); 523 556 pRAMLabelContainer->setLayout(pRAMLabelsLayout); 524 557 m_pRAMTitleLabel = new QLabel; … … 539 572 } 540 573 } 574 addVerticalLine(pLayout); 575 /* FS Stuff: */ 576 { 577 QWidget *pFSLabelContainer = new QWidget; 578 pLayout->addWidget(pFSLabelContainer); 579 pFSLabelContainer->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum); 580 QVBoxLayout *pFSLabelsLayout = new QVBoxLayout; 581 pFSLabelsLayout->setContentsMargins(0, 0, 0, 0); 582 pFSLabelsLayout->setSpacing(0); 583 pFSLabelContainer->setLayout(pFSLabelsLayout); 584 m_pFSTitleLabel = new QLabel; 585 pFSLabelsLayout->addWidget(m_pFSTitleLabel); 586 m_pFSUsedLabel = new QLabel; 587 pFSLabelsLayout->addWidget(m_pFSUsedLabel); 588 m_pFSFreeLabel = new QLabel; 589 pFSLabelsLayout->addWidget(m_pFSFreeLabel); 590 m_pFSTotalLabel = new QLabel; 591 pFSLabelsLayout->addWidget(m_pFSTotalLabel); 592 593 m_pHostFSChart = new UIVMResourceMonitorDoughnutChart; 594 if (m_pHostFSChart) 595 { 596 m_pHostFSChart->setMinimumSize(iMinimumSize, iMinimumSize); 597 pLayout->addWidget(m_pHostFSChart); 598 m_pHostFSChart->setChartColors(m_RAMUsedColor, m_RAMFreeColor); 599 } 600 601 } 541 602 pLayout->addStretch(2); 542 603 } … … 549 610 { 550 611 QString strColor = QColor(m_CPUUserColor).name(QColor::HexRgb); 551 m_pCPUUserLabel->setText(QString("<font color=\"%1\">%2: %3%</font>").arg(strColor).arg(tr("User")).arg(QString::number(m_hostStats.m_iCPUUserLoad)));612 m_pCPUUserLabel->setText(QString("<font color=\"%1\">%2: %3%</font>").arg(strColor).arg(tr("User")).arg(QString::number(m_hostStats.m_iCPUUserLoad))); 552 613 } 553 614 if (m_pCPUKernelLabel) 554 615 { 555 616 QString strColor = QColor(m_CPUKernelColor).name(QColor::HexRgb); 556 m_pCPUKernelLabel->setText(QString("<font color=\"%1\">%2: %3%</font>").arg(strColor).arg(tr("Kernel")).arg(QString::number(m_hostStats.m_iCPUKernelLoad)));617 m_pCPUKernelLabel->setText(QString("<font color=\"%1\">%2: %3%</font>").arg(strColor).arg(tr("Kernel")).arg(QString::number(m_hostStats.m_iCPUKernelLoad))); 557 618 } 558 619 if (m_pCPUTotalLabel) 559 m_pCPUTotalLabel->setText(QString("%1: %2%").arg(tr("Total")).arg(m_hostStats.m_iCPUUserLoad + m_hostStats.m_iCPUKernelLoad));620 m_pCPUTotalLabel->setText(QString("%1: %2%").arg(tr("Total")).arg(m_hostStats.m_iCPUUserLoad + m_hostStats.m_iCPUKernelLoad)); 560 621 if (m_pRAMTitleLabel) 561 622 m_pRAMTitleLabel->setText(QString("<b>%1</b>").arg(tr("Host RAM Usage"))); 562 623 if (m_pRAMFreeLabel) 563 624 { 564 QString strRAM = uiCommon().formatSize(m_hostStats.m_i FreeRAM);625 QString strRAM = uiCommon().formatSize(m_hostStats.m_iRAMFree); 565 626 QString strColor = QColor(m_RAMFreeColor).name(QColor::HexRgb); 566 m_pRAMFreeLabel->setText(QString("<font color=\"%1\">%2:%3</font>").arg(strColor).arg(tr("Free")).arg(strRAM)); 567 } 568 627 m_pRAMFreeLabel->setText(QString("<font color=\"%1\">%2: %3</font>").arg(strColor).arg(tr("Free")).arg(strRAM)); 628 } 569 629 if (m_pRAMUsedLabel) 570 630 { 571 QString strRAM = uiCommon().formatSize(m_hostStats.m_i TotalRAM - m_hostStats.m_iFreeRAM);631 QString strRAM = uiCommon().formatSize(m_hostStats.m_iRAMTotal - m_hostStats.m_iRAMFree); 572 632 QString strColor = QColor(m_RAMUsedColor).name(QColor::HexRgb); 573 m_pRAMUsedLabel->setText(QString("<font color=\"%1\">%2: %3</font>").arg(strColor).arg(tr("Used")).arg(strRAM));633 m_pRAMUsedLabel->setText(QString("<font color=\"%1\">%2: %3</font>").arg(strColor).arg(tr("Used")).arg(strRAM)); 574 634 } 575 635 if (m_pRAMTotalLabel) 576 636 { 577 QString strRAM = uiCommon().formatSize(m_hostStats.m_iTotalRAM); 578 m_pRAMTotalLabel->setText(QString("%1:%2").arg(tr("Total")).arg(strRAM)); 579 } 580 637 QString strRAM = uiCommon().formatSize(m_hostStats.m_iRAMTotal); 638 m_pRAMTotalLabel->setText(QString("%1: %2").arg(tr("Total")).arg(strRAM)); 639 } 640 if (m_pFSTitleLabel) 641 m_pFSTitleLabel->setText(QString("<b>%1</b>").arg(tr("Host File System"))); 642 if (m_pFSFreeLabel) 643 { 644 QString strFS = uiCommon().formatSize(m_hostStats.m_iFSFree); 645 QString strColor = QColor(m_RAMFreeColor).name(QColor::HexRgb); 646 m_pFSFreeLabel->setText(QString("<font color=\"%1\">%2: %3</font>").arg(strColor).arg(tr("Free")).arg(strFS)); 647 } 648 if (m_pFSUsedLabel) 649 { 650 QString strFS = uiCommon().formatSize(m_hostStats.m_iFSTotal - m_hostStats.m_iFSFree); 651 QString strColor = QColor(m_RAMUsedColor).name(QColor::HexRgb); 652 m_pFSUsedLabel->setText(QString("<font color=\"%1\">%2: %3</font>").arg(strColor).arg(tr("Used")).arg(strFS)); 653 } 654 if (m_pFSTotalLabel) 655 { 656 QString strFS = uiCommon().formatSize(m_hostStats.m_iFSTotal); 657 m_pFSTotalLabel->setText(QString("%1: %2").arg(tr("Total")).arg(strFS)); 658 } 581 659 } 582 660 … … 739 817 , m_iCPUKernelLoad(0) 740 818 , m_iCPUFreq(0) 741 , m_iTotalRAM(0) 742 , m_iFreeRAM(0) 819 , m_iRAMTotal(0) 820 , m_iRAMFree(0) 821 , m_iFSTotal(0) 822 , m_iFSFree(0) 743 823 { 744 824 } … … 948 1028 { 949 1029 CHost comHost = uiCommon().host(); 950 m_hostStats.m_i TotalRAM= _1M * (quint64)comHost.GetMemorySize();951 m_hostStats.m_i FreeRAM= _1M * (quint64)comHost.GetMemoryAvailable();1030 m_hostStats.m_iRAMTotal = _1M * (quint64)comHost.GetMemorySize(); 1031 m_hostStats.m_iRAMFree = _1M * (quint64)comHost.GetMemoryAvailable(); 952 1032 } 953 1033 … … 1036 1116 /* This is for the host: */ 1037 1117 m_nameList << "CPU*"; 1038 //m_nameList << "CPU/Load/Kernel*";1118 m_nameList << "FS*"; 1039 1119 m_objectList = QVector<CUnknown>(m_nameList.size(), CUnknown()); 1040 1120 m_performanceMonitor.SetupMetrics(m_nameList, m_objectList, iPeriod, iMetricSetupCount); … … 1103 1183 m_hostStats.m_iCPUFreq = fData; 1104 1184 } 1105 1185 else if (aReturnNames[i].contains("FS", Qt::CaseInsensitive) && 1186 aReturnNames[i].contains("Total", Qt::CaseInsensitive) && 1187 !aReturnNames[i].contains(":")) 1188 { 1189 CHost comHost = (CHost)aReturnObjects[i]; 1190 if (!comHost.isNull()) 1191 m_hostStats.m_iFSTotal = _1M * fData; 1192 } 1193 else if (aReturnNames[i].contains("FS", Qt::CaseInsensitive) && 1194 aReturnNames[i].contains("Free", Qt::CaseInsensitive) && 1195 !aReturnNames[i].contains(":")) 1196 { 1197 CHost comHost = (CHost)aReturnObjects[i]; 1198 if (!comHost.isNull()) 1199 m_hostStats.m_iFSFree = _1M * fData; 1200 } 1106 1201 } 1107 1202 for (int i = 0; i < m_itemList.size(); ++i)
Note:
See TracChangeset
for help on using the changeset viewer.