Changeset 85413 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Jul 22, 2020 1:37:29 PM (4 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/monitor/performance
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/monitor/performance/UIPerformanceMonitor.cpp
r85410 r85413 87 87 QString XAxisLabel(); 88 88 void setXAxisLabel(const QString &strLabel); 89 90 bool isAvailable() const; 91 void setIsAvailable(bool fIsAvailable); 89 92 90 93 protected: … … 135 138 * We draw first data0 then data 1 on top. Makes sense where the summation of data is guaranteed not to exceed some max. */ 136 139 bool m_fUseAreaChart; 140 /** False if the chart is not useable for some reason. For example it depends guest additions and they are not installed. */ 141 bool m_fIsAvailable; 137 142 /** For some charts it does not make sense to have an area chart. */ 138 143 bool m_fIsAreaChartAllowed; … … 158 163 , m_fUseGradientLineColor(false) 159 164 , m_fUseAreaChart(true) 165 , m_fIsAvailable(true) 160 166 , m_fIsAreaChartAllowed(false) 161 167 { … … 274 280 } 275 281 282 bool UIChart::isAvailable() const 283 { 284 return m_fIsAvailable; 285 } 286 287 void UIChart::setIsAvailable(bool fIsAvailable) 288 { 289 if (m_fIsAvailable == fIsAvailable) 290 return; 291 m_fIsAvailable = fIsAvailable; 292 update(); 293 } 294 276 295 QSize UIChart::minimumSizeHint() const 277 296 { … … 336 355 drawXAxisLabels(painter, iXSubAxisCount); 337 356 338 /* Draw a half-transparent rectangle over the whole widget to indicate the it is disabled: */339 357 if (!isEnabled()) 358 return; 359 360 /* Draw a half-transparent rectangle over the whole widget to indicate the it is not available: */ 361 if (!isAvailable()) 340 362 { 341 363 drawDisabledChartRectangle(painter); … … 743 765 if (m_comMachine.GetState() == KMachineState_Running) 744 766 { 767 setEnabled(true); 745 768 openSession(); 746 769 start(); … … 944 967 if (m_comMachine.GetState() == KMachineState_Running) 945 968 { 969 setEnabled(true); 946 970 openSession(); 947 971 start(); … … 1056 1080 continue; 1057 1081 if (m_charts.contains(iterator.key()) && m_charts[iterator.key()]) 1058 { 1059 m_charts[iterator.key()]->setEnabled(fEnable); 1060 m_charts[iterator.key()]->update(); 1061 } 1082 m_charts[iterator.key()]->setIsAvailable(fEnable); 1062 1083 if (m_infoLabels.contains(iterator.key()) && m_infoLabels[iterator.key()]) 1063 1084 { … … 1077 1098 { 1078 1099 QString strInfo; 1079 if (m_infoLabels[m_strCPUMetricName]->isEnabled()) 1080 strInfo = QString("<b>%1</b></b><br/><font color=\"%2\">%3: %4%5</font><br/><font color=\"%6\">%7: %8%9</font>") 1081 .arg(m_strCPUInfoLabelTitle) 1082 .arg(dataColorString(m_strCPUMetricName, 0)) 1083 .arg(m_strCPUInfoLabelGuest).arg(QString::number(iExecutingPercentage)).arg(CPUMetric.unit()) 1084 .arg(dataColorString(m_strCPUMetricName, 1)) 1085 .arg(m_strCPUInfoLabelVMM).arg(QString::number(iOtherPercentage)).arg(CPUMetric.unit()); 1086 else 1087 strInfo = QString("<b>%1</b><br/>%2%3").arg(m_strCPUInfoLabelTitle).arg("--").arg("%"); 1100 1101 strInfo = QString("<b>%1</b></b><br/><font color=\"%2\">%3: %4%5</font><br/><font color=\"%6\">%7: %8%9</font>") 1102 .arg(m_strCPUInfoLabelTitle) 1103 .arg(dataColorString(m_strCPUMetricName, 0)) 1104 .arg(m_strCPUInfoLabelGuest).arg(QString::number(iExecutingPercentage)).arg(CPUMetric.unit()) 1105 .arg(dataColorString(m_strCPUMetricName, 1)) 1106 .arg(m_strCPUInfoLabelVMM).arg(QString::number(iOtherPercentage)).arg(CPUMetric.unit()); 1088 1107 m_infoLabels[m_strCPUMetricName]->setText(strInfo); 1089 1108 } … … 1101 1120 { 1102 1121 QString strInfo; 1103 if (m_infoLabels[m_strRAMMetricName]->isEnabled()) 1104 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, g_iDecimalCount)) 1105 .arg(m_strRAMInfoLabelFree).arg(uiCommon().formatSize(_1K * (iFreeRAM), g_iDecimalCount)) 1106 .arg(m_strRAMInfoLabelUsed).arg(uiCommon().formatSize(_1K * (iTotalRAM - iFreeRAM), g_iDecimalCount)); 1107 else 1108 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("---"); 1122 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, g_iDecimalCount)) 1123 .arg(m_strRAMInfoLabelFree).arg(uiCommon().formatSize(_1K * (iFreeRAM), g_iDecimalCount)) 1124 .arg(m_strRAMInfoLabelUsed).arg(uiCommon().formatSize(_1K * (iTotalRAM - iFreeRAM), g_iDecimalCount)); 1109 1125 m_infoLabels[m_strRAMMetricName]->setText(strInfo); 1110 1126 } … … 1123 1139 NetMetric.setTotal(1, iTransmitTotal); 1124 1140 1125 /* Do not set data and maximum if the metric has not been initialized since we need to initialize totals "(t-1)" first: */1126 1141 if (!NetMetric.isInitialized()) 1127 1142 { … … 1129 1144 return; 1130 1145 } 1146 1131 1147 NetMetric.addData(0, iReceiveRate); 1132 1148 NetMetric.addData(1, iTransmitRate); … … 1137 1153 { 1138 1154 QString strInfo; 1139 if (m_infoLabels[m_strNetworkMetricName]->isEnabled()) 1140 strInfo = QString("<b>%1</b></b><br/><font color=\"%2\">%3: %4<br/>%5 %6</font><br/><font color=\"%7\">%8: %9<br/>%10 %11</font>") 1141 .arg(m_strNetworkInfoLabelTitle) 1142 .arg(dataColorString(m_strNetworkMetricName, 0)).arg(m_strNetworkInfoLabelReceived).arg(uiCommon().formatSize((quint64)iReceiveRate, g_iDecimalCount)) 1143 .arg(m_strNetworkInfoLabelReceivedTotal).arg(uiCommon().formatSize((quint64)iReceiveTotal, g_iDecimalCount)) 1144 .arg(dataColorString(m_strNetworkMetricName, 1)).arg(m_strNetworkInfoLabelTransmitted).arg(uiCommon().formatSize((quint64)iTransmitRate, g_iDecimalCount)) 1145 .arg(m_strNetworkInfoLabelTransmittedTotal).arg(uiCommon().formatSize((quint64)iTransmitTotal, g_iDecimalCount)); 1146 1147 else 1148 strInfo = QString("<b>%1</b><br/>%2: %3<br/>%4: %5"). 1149 arg(m_strNetworkInfoLabelTitle) 1150 .arg(m_strNetworkInfoLabelReceived).arg("---") 1151 .arg(m_strNetworkInfoLabelTransmitted).arg("---"); 1155 strInfo = QString("<b>%1</b></b><br/><font color=\"%2\">%3: %4<br/>%5 %6</font><br/><font color=\"%7\">%8: %9<br/>%10 %11</font>") 1156 .arg(m_strNetworkInfoLabelTitle) 1157 .arg(dataColorString(m_strNetworkMetricName, 0)).arg(m_strNetworkInfoLabelReceived).arg(uiCommon().formatSize((quint64)iReceiveRate, g_iDecimalCount)) 1158 .arg(m_strNetworkInfoLabelReceivedTotal).arg(uiCommon().formatSize((quint64)iReceiveTotal, g_iDecimalCount)) 1159 .arg(dataColorString(m_strNetworkMetricName, 1)).arg(m_strNetworkInfoLabelTransmitted).arg(uiCommon().formatSize((quint64)iTransmitRate, g_iDecimalCount)) 1160 .arg(m_strNetworkInfoLabelTransmittedTotal).arg(uiCommon().formatSize((quint64)iTransmitTotal, g_iDecimalCount)); 1152 1161 m_infoLabels[m_strNetworkMetricName]->setText(strInfo); 1153 1162 } … … 1156 1165 } 1157 1166 1167 void UIPerformanceMonitor::resetCPUInfoLabel() 1168 { 1169 if (m_infoLabels.contains(m_strCPUMetricName) && m_infoLabels[m_strCPUMetricName]) 1170 { 1171 QString strInfo =QString("<b>%1</b></b><br/>%2: %3<br/>%4: %5") 1172 .arg(m_strCPUInfoLabelTitle) 1173 .arg(m_strCPUInfoLabelGuest).arg("--") 1174 .arg(m_strCPUInfoLabelVMM).arg("--"); 1175 m_infoLabels[m_strCPUMetricName]->setText(strInfo); 1176 } 1177 } 1178 1179 void UIPerformanceMonitor::resetRAMInfoLabel() 1180 { 1181 if (m_infoLabels.contains(m_strRAMMetricName) && m_infoLabels[m_strRAMMetricName]) 1182 { 1183 QString strInfo = QString("<b>%1</b><br/>%2: %3<br/>%4: %5<br/>%6: %7"). 1184 arg(m_strRAMInfoLabelTitle).arg(m_strRAMInfoLabelTotal).arg("--") 1185 .arg(m_strRAMInfoLabelFree).arg("--") 1186 .arg(m_strRAMInfoLabelUsed).arg("--"); 1187 m_infoLabels[m_strRAMMetricName]->setText(strInfo); 1188 } 1189 } 1190 1191 void UIPerformanceMonitor::resetNetworkInfoLabel() 1192 { 1193 if (m_infoLabels.contains(m_strNetworkMetricName) && m_infoLabels[m_strNetworkMetricName]) 1194 { 1195 QString strInfo = QString("<b>%1</b></b><br/>%2: %3<br/>%4 %5<br/>%6: %7<br/>%8 %9") 1196 .arg(m_strNetworkInfoLabelTitle) 1197 .arg(m_strNetworkInfoLabelReceived).arg("--") 1198 .arg(m_strNetworkInfoLabelReceivedTotal).arg("--") 1199 .arg(m_strNetworkInfoLabelTransmitted).arg("--") 1200 .arg(m_strNetworkInfoLabelTransmittedTotal).arg("--"); 1201 m_infoLabels[m_strNetworkMetricName]->setText(strInfo); 1202 } 1203 } 1204 1205 void UIPerformanceMonitor::resetVMExitInfoLabel() 1206 { 1207 if (m_infoLabels.contains(m_strVMExitMetricName) && m_infoLabels[m_strVMExitMetricName]) 1208 { 1209 QString strInfo; 1210 strInfo = QString("<b>%1</b></b><br/>%2: %3<br/>%4: %5") 1211 .arg(m_strVMExitInfoLabelTitle) 1212 .arg(m_strVMExitLabelCurrent).arg("--") 1213 .arg(m_strVMExitLabelTotal).arg("--"); 1214 1215 m_infoLabels[m_strVMExitMetricName]->setText(strInfo); 1216 } 1217 } 1218 1219 void UIPerformanceMonitor::resetDiskIOInfoLabel() 1220 { 1221 if (m_infoLabels.contains(m_strDiskIOMetricName) && m_infoLabels[m_strDiskIOMetricName]) 1222 { 1223 QString strInfo = QString("<b>%1</b></b><br/>%2: %3<br/>%4 %5<br/>%6: %7<br/>%8 %9") 1224 .arg(m_strDiskIOInfoLabelTitle) 1225 .arg(m_strDiskIOInfoLabelWritten).arg("--") 1226 .arg(m_strDiskIOInfoLabelWrittenTotal).arg("--") 1227 .arg(m_strDiskIOInfoLabelRead).arg("--") 1228 .arg(m_strDiskIOInfoLabelReadTotal).arg("--"); 1229 m_infoLabels[m_strDiskIOMetricName]->setText(strInfo); 1230 } 1231 } 1232 1158 1233 void UIPerformanceMonitor::updateDiskIOGraphsAndMetric(quint64 uDiskIOTotalWritten, quint64 uDiskIOTotalRead) 1159 1234 { … … 1166 1241 diskMetric.setTotal(1, uDiskIOTotalRead); 1167 1242 1168 /* Do not set data and maximum if the metric has not been initialized since we need to initialize totals "(t-1)" first: */1169 if (!diskMetric.isInitialized())1170 {1171 diskMetric.setIsInitialized(true);1172 return;1173 }1174 1243 diskMetric.addData(0, iWriteRate); 1175 1244 diskMetric.addData(1, iReadRate); 1245 /* Do not set data and maximum if the metric has not been initialized since we need to initialize totals "(t-1)" first: */ 1246 if (!diskMetric.isInitialized()){ 1247 diskMetric.setIsInitialized(true); 1248 return; 1249 } 1250 1176 1251 quint64 iMaximum = qMax(diskMetric.maximum(), qMax(iWriteRate, iReadRate)); 1177 1252 diskMetric.setMaximum(iMaximum); … … 1179 1254 if (m_infoLabels.contains(m_strDiskIOMetricName) && m_infoLabels[m_strDiskIOMetricName]) 1180 1255 { 1181 QString strInfo; 1182 if (m_infoLabels[m_strDiskIOMetricName]->isEnabled()) 1183 strInfo = QString("<b>%1</b></b><br/><font color=\"%2\">%3: %4<br/>%5 %6</font><br/><font color=\"%7\">%8: %9<br/>%10 %11</font>") 1184 .arg(m_strDiskIOInfoLabelTitle) 1185 .arg(dataColorString(m_strDiskIOMetricName, 0)).arg(m_strDiskIOInfoLabelWritten).arg(uiCommon().formatSize((quint64)iWriteRate, g_iDecimalCount)) 1186 .arg(m_strDiskIOInfoLabelWrittenTotal).arg(uiCommon().formatSize((quint64)uDiskIOTotalWritten, g_iDecimalCount)) 1187 .arg(dataColorString(m_strDiskIOMetricName, 1)).arg(m_strDiskIOInfoLabelRead).arg(uiCommon().formatSize((quint64)iReadRate, g_iDecimalCount)) 1188 .arg(m_strDiskIOInfoLabelReadTotal).arg(uiCommon().formatSize((quint64)uDiskIOTotalRead, g_iDecimalCount)); 1189 1190 else 1191 strInfo = QString("<b>%1</b><br/>%2: %3<br/>%4: %5"). 1192 arg(m_strDiskIOInfoLabelTitle) 1193 .arg(m_strDiskIOInfoLabelWritten).arg("---") 1194 .arg(m_strDiskIOInfoLabelRead).arg("---"); 1256 QString strInfo = QString("<b>%1</b></b><br/><font color=\"%2\">%3: %4<br/>%5 %6</font><br/><font color=\"%7\">%8: %9<br/>%10 %11</font>") 1257 .arg(m_strDiskIOInfoLabelTitle) 1258 .arg(dataColorString(m_strDiskIOMetricName, 0)).arg(m_strDiskIOInfoLabelWritten).arg(uiCommon().formatSize((quint64)iWriteRate, g_iDecimalCount)) 1259 .arg(m_strDiskIOInfoLabelWrittenTotal).arg(uiCommon().formatSize((quint64)uDiskIOTotalWritten, g_iDecimalCount)) 1260 .arg(dataColorString(m_strDiskIOMetricName, 1)).arg(m_strDiskIOInfoLabelRead).arg(uiCommon().formatSize((quint64)iReadRate, g_iDecimalCount)) 1261 .arg(m_strDiskIOInfoLabelReadTotal).arg(uiCommon().formatSize((quint64)uDiskIOTotalRead, g_iDecimalCount)); 1195 1262 m_infoLabels[m_strDiskIOMetricName]->setText(strInfo); 1196 1263 } … … 1219 1286 { 1220 1287 QString strInfo; 1221 if (m_infoLabels[m_strVMExitMetricName]->isEnabled()) 1222 strInfo = QString("<b>%1</b></b><br/>%2: %3 %4<br/>%5: %6 %7") 1223 .arg(m_strVMExitInfoLabelTitle) 1224 .arg(m_strVMExitLabelCurrent).arg(UICommon::addMetricSuffixToNumber(iRate)).arg(VMExitMetric.unit()) 1225 .arg(m_strVMExitLabelTotal).arg(UICommon::addMetricSuffixToNumber(uTotalVMExits)).arg(VMExitMetric.unit()); 1226 else 1227 strInfo = QString("<b>%1</b><br/>%2%3").arg(m_strVMExitInfoLabelTitle).arg("--").arg("%"); 1228 m_infoLabels[m_strVMExitMetricName]->setText(strInfo); 1288 strInfo = QString("<b>%1</b></b><br/>%2: %3 %4<br/>%5: %6 %7") 1289 .arg(m_strVMExitInfoLabelTitle) 1290 .arg(m_strVMExitLabelCurrent).arg(UICommon::addMetricSuffixToNumber(iRate)).arg(VMExitMetric.unit()) 1291 .arg(m_strVMExitLabelTotal).arg(UICommon::addMetricSuffixToNumber(uTotalVMExits)).arg(VMExitMetric.unit()); 1292 m_infoLabels[m_strVMExitMetricName]->setText(strInfo); 1229 1293 } 1230 1294 if (m_charts.contains(m_strVMExitMetricName)) … … 1235 1299 { 1236 1300 if (!m_charts.contains(strChartName)) 1237 return QColor(Qt:: red).name(QColor::HexRgb);1301 return QColor(Qt::black).name(QColor::HexRgb); 1238 1302 UIChart *pChart = m_charts[strChartName]; 1239 1303 if (!pChart) 1240 return QColor(Qt:: red).name(QColor::HexRgb);1304 return QColor(Qt::black).name(QColor::HexRgb); 1241 1305 return pChart->dataSeriesColor(iDataIndex).name(QColor::HexRgb); 1242 1306 } … … 1245 1309 { 1246 1310 m_fGuestAdditionsAvailable = false; 1311 setEnabled(false); 1312 1247 1313 if (m_pTimer) 1248 1314 m_pTimer->stop(); … … 1256 1322 iterator.value()->update(); 1257 1323 /* Reset the info labels: */ 1258 updateRAMGraphsAndMetric(0, 0); 1259 updateCPUGraphsAndMetric(0, 0); 1260 updateNetworkGraphsAndMetric(0, 0); 1261 updateDiskIOGraphsAndMetric(0, 0); 1262 updateVMExitMetric(0); 1324 resetCPUInfoLabel(); 1325 resetRAMInfoLabel(); 1326 resetNetworkInfoLabel(); 1327 resetDiskIOInfoLabel(); 1328 resetVMExitInfoLabel(); 1329 update(); 1263 1330 } 1264 1331 -
trunk/src/VBox/Frontends/VirtualBox/src/monitor/performance/UIPerformanceMonitor.h
r85406 r85413 153 153 void updateDiskIOGraphsAndMetric(quint64 uDiskIOTotalWritten, quint64 uDiskIOTotalRead); 154 154 void updateVMExitMetric(quint64 uTotalVMExits); 155 /** @} */ 156 157 /** @name The following functions reset corresponding info labels 158 * @{ */ 159 void resetCPUInfoLabel(); 160 void resetRAMInfoLabel(); 161 void resetNetworkInfoLabel(); 162 void resetDiskIOInfoLabel(); 163 void resetVMExitInfoLabel(); 155 164 /** @} */ 156 165
Note:
See TracChangeset
for help on using the changeset viewer.