Changeset 80523 in vbox
- Timestamp:
- Sep 1, 2019 8:55:31 AM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 133030
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime/information
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIInformationRuntime.cpp
r80520 r80523 54 54 enum InfoLine 55 55 { 56 InfoLine_Title = 0, 56 57 InfoLine_Resolution, 57 58 InfoLine_Uptime, … … 79 80 80 81 UIRuntimeInfoWidget(QWidget *pParent, const CMachine &machine, const CConsole &console); 82 void guestMonitorChange(ulong uScreenId); 81 83 82 84 protected: … … 86 88 virtual QSize minimumSizeHint() const /* override */; 87 89 90 private slots: 91 92 void sltTimeout(); 93 88 94 private: 89 95 90 96 void runTimeAttributes(); 91 QString screenResolutions(); 92 93 void insertInfoLine(InfoLine enmInfoLine, const QString& strLabel, const QString &strInfo); 97 void updateScreenInfo(int iScreenId = -1); 98 void updateUpTime(); 99 QString screenResolution(int iScreenId); 100 /** Creates to QTableWidgetItems of tye @enmInfoLine using the @p strLabel and @p strInfo and inserts it 101 * to the row @p iRow. If @p iRow is -1 then the items inserted to the end of the table. */ 102 void insertInfoLine(InfoLine enmInfoLine, const QString& strLabel, const QString &strInfo, int iRow = -1); 94 103 void computeMinimumWidth(); 95 104 … … 122 131 /** Computed by computing the maximum length line. Used to avoid having horizontal scroll bars. */ 123 132 int m_iMinimumWidth; 133 QVector<QString> m_screenResolutions; 134 QTimer *m_pTimer; 124 135 }; 125 136 … … 212 223 , m_console(console) 213 224 , m_iMinimumWidth(0) 225 , m_pTimer(0) 214 226 215 227 { … … 226 238 setSelectionMode(QAbstractItemView::NoSelection); 227 239 240 241 m_pTimer = new QTimer(this); 242 if (m_pTimer) 243 { 244 connect(m_pTimer, &QTimer::timeout, this, &UIRuntimeInfoWidget::sltTimeout); 245 m_pTimer->start(5000); 246 } 247 248 228 249 retranslateUi(); 229 250 /* Add the title row: */ 230 QTableWidgetItem *pTitleItem = new QTableWidgetItem(UIIconPool::iconSet(":/state_running_16px.png"), m_strTableTitle );251 QTableWidgetItem *pTitleItem = new QTableWidgetItem(UIIconPool::iconSet(":/state_running_16px.png"), m_strTableTitle, InfoLine_Title); 231 252 QFont titleFont(font()); 232 253 titleFont.setBold(true); … … 234 255 insertRow(0); 235 256 setItem(0, 0, pTitleItem); 236 237 257 /* Make the API calls and populate the table: */ 238 258 runTimeAttributes(); 239 259 computeMinimumWidth(); 260 } 261 262 void UIRuntimeInfoWidget::guestMonitorChange(ulong uScreenId) 263 { 264 updateScreenInfo(uScreenId); 240 265 } 241 266 … … 272 297 } 273 298 274 void UIRuntimeInfoWidget::insertInfoLine(InfoLine enmInfoLine, const QString& strLabel, const QString &strInfo )299 void UIRuntimeInfoWidget::insertInfoLine(InfoLine enmInfoLine, const QString& strLabel, const QString &strInfo, int iRow /* = -1 */) 275 300 { 276 301 int iMargin = 0.2 * qApp->style()->pixelMetric(QStyle::PM_LayoutTopMargin); 277 int iRow = rowCount(); 278 insertRow(iRow); 279 setItem(iRow, 0, new QTableWidgetItem(strLabel, enmInfoLine)); 280 setItem(iRow, 1, new QTableWidgetItem(strInfo, enmInfoLine)); 281 setRowHeight(iRow, 2 * iMargin + m_iFontHeight); 282 } 283 284 QString UIRuntimeInfoWidget::screenResolutions() 285 { 286 QString strResolutions; 287 return strResolutions; 288 } 289 290 void UIRuntimeInfoWidget::runTimeAttributes() 291 { 292 ULONG cGuestScreens = m_machine.GetMonitorCount(); 293 QVector<QString> aResolutions(cGuestScreens); 294 for (ULONG iScreen = 0; iScreen < cGuestScreens; ++iScreen) 295 { 296 /* Determine resolution: */ 297 ULONG uWidth = 0; 298 ULONG uHeight = 0; 299 ULONG uBpp = 0; 300 LONG xOrigin = 0; 301 LONG yOrigin = 0; 302 KGuestMonitorStatus monitorStatus = KGuestMonitorStatus_Enabled; 303 m_console.GetDisplay().GetScreenResolution(iScreen, uWidth, uHeight, uBpp, xOrigin, yOrigin, monitorStatus); 304 QString strResolution = QString("%1x%2").arg(uWidth).arg(uHeight); 305 if (uBpp) 306 strResolution += QString("x%1").arg(uBpp); 307 strResolution += QString(" @%1,%2").arg(xOrigin).arg(yOrigin); 308 if (monitorStatus == KGuestMonitorStatus_Disabled) 309 { 310 strResolution += QString(" "); 311 strResolution += m_strMonitorTurnedOff; 312 } 313 aResolutions[iScreen] = strResolution; 314 } 315 316 /* Determine uptime: */ 302 int iNewRow = rowCount(); 303 if (iRow != -1 && iRow <= iNewRow) 304 iNewRow = iRow; 305 insertRow(iNewRow); 306 setItem(iNewRow, 0, new QTableWidgetItem(strLabel, enmInfoLine)); 307 setItem(iNewRow, 1, new QTableWidgetItem(strInfo, enmInfoLine)); 308 setRowHeight(iNewRow, 2 * iMargin + m_iFontHeight); 309 } 310 311 QString UIRuntimeInfoWidget::screenResolution(int iScreenID) 312 { 313 /* Determine resolution: */ 314 ULONG uWidth = 0; 315 ULONG uHeight = 0; 316 ULONG uBpp = 0; 317 LONG xOrigin = 0; 318 LONG yOrigin = 0; 319 KGuestMonitorStatus monitorStatus = KGuestMonitorStatus_Enabled; 320 m_console.GetDisplay().GetScreenResolution(iScreenID, uWidth, uHeight, uBpp, xOrigin, yOrigin, monitorStatus); 321 QString strResolution = QString("%1x%2").arg(uWidth).arg(uHeight); 322 if (uBpp) 323 strResolution += QString("x%1").arg(uBpp); 324 strResolution += QString(" @%1,%2").arg(xOrigin).arg(yOrigin); 325 if (monitorStatus == KGuestMonitorStatus_Disabled) 326 { 327 strResolution += QString(" "); 328 strResolution += m_strMonitorTurnedOff; 329 } 330 331 return strResolution; 332 } 333 334 void UIRuntimeInfoWidget::sltTimeout() 335 { 336 updateUpTime(); 337 } 338 339 void UIRuntimeInfoWidget::updateScreenInfo(int iScreenID /* = -1 */) 340 { 341 ULONG uGuestScreens = m_machine.GetMonitorCount(); 342 m_screenResolutions.resize(uGuestScreens); 343 344 if (iScreenID != -1 && iScreenID >= (int)uGuestScreens) 345 return; 346 if (iScreenID == -1) 347 { 348 for (ULONG iScreen = 0; iScreen < uGuestScreens; ++iScreen) 349 m_screenResolutions[iScreen] = screenResolution(iScreen); 350 } 351 else 352 m_screenResolutions[iScreenID] = screenResolution(iScreenID); 353 /* Delete all the rows (not only the updated screen's row) and reinsert them: */ 354 int iRowCount = rowCount(); 355 for (int i = iRowCount - 1; i >= 0; --i) 356 { 357 QTableWidgetItem *pItem = item(i, 0); 358 if (pItem && pItem->type() == InfoLine_Resolution) 359 removeRow(i); 360 } 361 362 for (ULONG iScreen = 0; iScreen < uGuestScreens; ++iScreen) 363 { 364 QString strLabel = uGuestScreens > 1 ? 365 QString("%1 %2:").arg(m_strScreenResolutionLabel).arg(QString::number(iScreen)) : 366 QString("%1:").arg(m_strScreenResolutionLabel); 367 /* Insert the screen resolution row at the top of the table. Row 0 is the title row: */ 368 insertInfoLine(InfoLine_Resolution, strLabel, m_screenResolutions[iScreen], iScreen + 1); 369 } 370 resizeColumnToContents(1); 371 } 372 373 void UIRuntimeInfoWidget::updateUpTime() 374 { 317 375 CMachineDebugger debugger = m_console.GetDebugger(); 318 376 uint32_t uUpSecs = (debugger.GetUptime() / 5000) * 5; … … 328 386 QString strUptime = QString(szUptime); 329 387 388 QTableWidgetItem *pItem = 0; 389 for (int i = 0; i < rowCount() && !pItem; ++i) 390 { 391 pItem = item(i, 1); 392 if (!pItem) 393 continue; 394 if (pItem->type() != InfoLine_Uptime) 395 pItem = 0; 396 } 397 if (!pItem) 398 insertInfoLine(InfoLine_Uptime, QString("%1:").arg(m_strUptimeLabel), strUptime); 399 else 400 pItem->setText(strUptime); 401 } 402 403 void UIRuntimeInfoWidget::runTimeAttributes() 404 { 405 updateScreenInfo(); 406 updateUpTime(); 407 330 408 /* Determine clipboard mode: */ 331 409 QString strClipboardMode = gpConverter->toString(m_machine.GetClipboardMode()); … … 334 412 335 413 /* Determine virtualization attributes: */ 414 CMachineDebugger debugger = m_console.GetDebugger(); 415 336 416 QString strVirtualization = debugger.GetHWVirtExEnabled() ? 337 417 m_strActive : m_strInactive; … … 386 466 m_strNotAvailable : QString("%1").arg(iVRDEPort); 387 467 388 /* Searching for longest string: */ 389 QStringList values; 390 for (ULONG iScreen = 0; iScreen < cGuestScreens; ++iScreen) 391 values << aResolutions[iScreen]; 392 values << strUptime 393 << strExecutionEngine << strNestedPaging << strUnrestrictedExecution 394 << strGAVersion << strOSType << strVRDEInfo; 395 int iMaxLength = 0; 396 foreach (const QString &strValue, values) 397 iMaxLength = iMaxLength < QApplication::fontMetrics().width(strValue) 398 ? QApplication::fontMetrics().width(strValue) : iMaxLength; 399 400 /* Summary: */ 401 for (ULONG iScreen = 0; iScreen < cGuestScreens; ++iScreen) 402 { 403 QString strLabel = cGuestScreens > 1 ? 404 QString("%1 %2:").arg(m_strScreenResolutionLabel).arg(QString::number(iScreen)) : 405 QString("%1:").arg(m_strScreenResolutionLabel); 406 insertInfoLine(InfoLine_Resolution, strLabel, aResolutions[iScreen]); 407 } 408 409 insertInfoLine(InfoLine_Uptime, QString("%1:").arg(m_strUptimeLabel), strUptime); 468 410 469 insertInfoLine(InfoLine_ClipboardMode, QString("%1:").arg(m_strClipboardModeLabel), strClipboardMode); 411 470 insertInfoLine(InfoLine_DnDMode, QString("%1:").arg(m_strDragAndDropLabel), strDnDMode); … … 1026 1085 m_comGuest = m_console.GetGuest(); 1027 1086 m_fGuestAdditionsAvailable = guestAdditionsAvailable(6 /* minimum major version */); 1028 1029 1087 connect(pSession, &UISession::sigAdditionsStateChange, this, &UIInformationRuntime::sltGuestAdditionsStateChange); 1088 connect(pSession, &UISession::sigGuestMonitorChange, this, &UIInformationRuntime::sltGuestMonitorChange); 1089 1030 1090 prepareMetrics(); 1031 1091 prepareObjects(); … … 1156 1216 m_charts[m_strCPUMetricName]->setWithPieChart(true); 1157 1217 1158 UIRuntimeInfoWidget *m_pRuntimeInfoWidget = new UIRuntimeInfoWidget(0, m_machine, m_console);1218 m_pRuntimeInfoWidget = new UIRuntimeInfoWidget(0, m_machine, m_console); 1159 1219 pContainerLayout->addWidget(m_pRuntimeInfoWidget, iRow, 0, 2, 2); 1160 1220 m_pRuntimeInfoWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); … … 1285 1345 } 1286 1346 1347 void UIInformationRuntime::sltGuestMonitorChange(KGuestMonitorChangedEventType changeType, ulong uScreenId, QRect screenGeo) 1348 { 1349 Q_UNUSED(changeType); 1350 Q_UNUSED(screenGeo); 1351 printf("%lu\n", uScreenId); 1352 if (m_pRuntimeInfoWidget) 1353 m_pRuntimeInfoWidget->guestMonitorChange(uScreenId); 1354 } 1355 1287 1356 void UIInformationRuntime::prepareMetrics() 1288 1357 { -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIInformationRuntime.h
r80494 r80523 154 154 void sltTimeout(); 155 155 void sltGuestAdditionsStateChange(); 156 void sltGuestMonitorChange(KGuestMonitorChangedEventType changeType, ulong uScreenId, QRect screenGeo); 156 157 157 158 private:
Note:
See TracChangeset
for help on using the changeset viewer.