- Timestamp:
- Apr 8, 2020 8:55:56 AM (5 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPoolManager.cpp
r83608 r83616 2827 2827 2828 2828 /** Toggle action extension, used as 'Toggle Columns' action class. */ 2829 class UIActionMenuSelectorVMResourceMonitorToggleColumns : public UIAction Toggle2829 class UIActionMenuSelectorVMResourceMonitorToggleColumns : public UIActionMenu 2830 2830 { 2831 2831 Q_OBJECT; … … 2835 2835 /** Constructs action passing @a pParent to the base-class. */ 2836 2836 UIActionMenuSelectorVMResourceMonitorToggleColumns(UIActionPool *pParent) 2837 : UIActionToggle(pParent) 2838 { 2839 setShortcutContext(Qt::WidgetWithChildrenShortcut); 2840 setIcon(UIIconPool::iconSetFull(":/cloud_profile_edit_32px.png", ":/cloud_profile_edit_16px.png", 2841 ":/cloud_profile_edit_disabled_32px.png", ":/cloud_profile_edit_disabled_16px.png")); 2842 } 2843 2844 protected: 2845 2846 /** Returns shortcut extra-data ID. */ 2847 virtual QString shortcutExtraDataID() const /* override */ 2848 { 2849 return QString("ToggleVMResourceMonitorColumns"); 2850 } 2851 2852 /** Returns default shortcut. */ 2853 virtual QKeySequence defaultShortcut(UIActionPoolType) const /* override */ 2854 { 2855 return QKeySequence(); 2856 } 2857 2858 /** Handles translation event. */ 2859 virtual void retranslateUi() /* override */ 2860 { 2837 : UIActionMenu(pParent, ":/exit_16px.png") 2838 {} 2839 2840 protected: 2841 2842 /** Handles translation event. */ 2843 virtual void retranslateUi() /* override */ 2844 { 2845 setName(QApplication::translate("UIActionPool", "Columns")); 2861 2846 setIconText(QApplication::translate("UIActionPool", "Columns")); 2862 setName(QApplication::translate("UIActionPool", "Add Remove Columns")); 2863 //setShortcutScope(QApplication::translate("UIActionPool", "Cloud Profile Manager")); 2864 setStatusTip(QApplication::translate("UIActionPool", "Open context menu to disable/menu table columns")); 2865 setToolTip( QApplication::translate("UIActionPool", "Open context menu to disable/menu table columns") 2847 setStatusTip(QApplication::translate("UIActionPool", "Show/Hide Columns")); 2848 setToolTip( QApplication::translate("UIActionPool", "Show/Hide Columns") 2866 2849 + (shortcut().isEmpty() ? QString() : QString(" (%1)").arg(shortcut().toString()))); 2867 2850 } … … 3007 2990 /* VM resource Monitor actions: */ 3008 2991 m_pool[UIActionIndexST_M_VMResourceMonitor] = new UIActionMenuVMResourceMonitor(this); 3009 m_pool[UIActionIndexST_M_VMResourceMonitor_ T_Columns] = new UIActionMenuSelectorVMResourceMonitorToggleColumns(this);2992 m_pool[UIActionIndexST_M_VMResourceMonitor_M_Columns] = new UIActionMenuSelectorVMResourceMonitorToggleColumns(this); 3010 2993 3011 2994 /* 'Group' action groups: */ … … 3605 3588 /* Clear contents: */ 3606 3589 pMenu->clear(); 3607 3608 addAction(pMenu, action(UIActionIndexST_M_VMResourceMonitor_T_Columns)); 3590 addAction(pMenu, action(UIActionIndexST_M_VMResourceMonitor_M_Columns)); 3609 3591 } 3610 3592 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPoolManager.h
r83608 r83616 166 166 /* VM resource Monitor actions: */ 167 167 UIActionIndexST_M_VMResourceMonitor, 168 UIActionIndexST_M_VMResourceMonitor_ T_Columns,168 UIActionIndexST_M_VMResourceMonitor_M_Columns, 169 169 170 170 /* Maximum index: */ -
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManagerWidget.cpp
r83482 r83616 20 20 #include <QStackedWidget> 21 21 #include <QStyle> 22 #include <QToolButton> 22 23 #include <QVBoxLayout> 23 24 … … 672 673 case UIToolType_VMResourceMonitor: 673 674 { 674 m_pToolBar->addAction(actionPool()->action(UIActionIndexST_M_VMResourceMonitor_T_Columns)); 675 m_pToolBar->addAction(actionPool()->action(UIActionIndexST_M_VMResourceMonitor_M_Columns)); 676 QToolButton *pButton = 677 qobject_cast<QToolButton*>(m_pToolBar->widgetForAction(actionPool()->action(UIActionIndexST_M_VMResourceMonitor_M_Columns))); 678 if (pButton) 679 { 680 pButton->setPopupMode(QToolButton::InstantPopup); 681 pButton->setAutoRaise(true); 682 } 683 675 684 break; 676 685 } -
trunk/src/VBox/Frontends/VirtualBox/src/monitor/resource/UIResourceMonitor.cpp
r83610 r83616 274 274 UIResourceMonitorProxyModel(QObject *parent = 0); 275 275 void dataUpdate(); 276 void reFilter();277 278 protected:279 280 //virtual bool lessThan(const QModelIndex &left, const QModelIndex &right) const /* override */;281 /** Section (column) visibility is controlled by the QHeaderView (see UIVMResourceMonitorTableView::updateColumVisibility)282 * to have somewhat meaningful column resizing. */283 //virtual bool filterAcceptsColumn(int source_column, const QModelIndex &source_parent) const /* override */;284 285 private:286 287 276 }; 288 277 … … 331 320 /* Used to find machines by uid. key is the machine uid and int is the index to m_itemList */ 332 321 QMap<QUuid, int> m_itemMap; 333 QMap<int, QString> m_column Captions;322 QMap<int, QString> m_columnTitles; 334 323 QTimer *m_pTimer; 335 324 /** @name The following are used during UIPerformanceCollector::QueryMetricsData(..) … … 868 857 } 869 858 870 void UIResourceMonitorProxyModel::reFilter()871 {872 emit layoutAboutToBeChanged();873 invalidateFilter();874 emit layoutChanged();875 }876 877 /* See the function definition comment: */878 // bool UIResourceMonitorProxyModel::filterAcceptsColumn(int iSourceColumn, const QModelIndex &sourceParent) const879 // {880 // Q_UNUSED(sourceParent);881 // UIResourceMonitorModel* pModel = qobject_cast<UIResourceMonitorModel*>(sourceModel());882 // if (!pModel)883 // return true;884 // return pModel->columnVisible(iSourceColumn);885 // }886 887 859 888 860 /********************************************************************************************************************************* … … 945 917 { 946 918 if (role == Qt::DisplayRole && orientation == Qt::Horizontal) 947 return m_column Captions.value((VMResourceMonitorColumn)section, QString());;919 return m_columnTitles.value((VMResourceMonitorColumn)section, QString());; 948 920 return QVariant(); 949 921 } … … 951 923 void UIResourceMonitorModel::setColumnCaptions(const QMap<int, QString>& captions) 952 924 { 953 m_column Captions = captions;925 m_columnTitles = captions; 954 926 } 955 927 … … 1005 977 ULONG aPctVMM; 1006 978 1007 // bool fRAMColumns = columnVisible(VMResourceMonitorColumn_RAMUsedAndTotal)1008 // || columnVisible(VMResourceMonitorColumn_RAMUsedPercentage);1009 979 bool fCPUColumns = columnVisible(VMResourceMonitorColumn_CPUVMMLoad) || columnVisible(VMResourceMonitorColumn_CPUGuestLoad); 1010 980 bool fNetworkColumns = columnVisible(VMResourceMonitorColumn_NetworkUpRate) … … 1018 988 bool fVMExitColumn = columnVisible(VMResourceMonitorColumn_VMExits); 1019 989 990 /* Host's RAM usage is obtained from IHost not from IPerformanceCollectior: */ 1020 991 getHostRAMStats(); 1021 992 1022 /* RAM usage and Host CPU: */ 1023 //if (!m_performanceMonitor.isNull() && fRAMColumns) 993 /* RAM usage and Host Stats: */ 1024 994 queryPerformanceCollector(); 1025 995 … … 1275 1245 , m_fIsCurrentTool(true) 1276 1246 { 1277 /* Prepare: */1278 1247 prepare(); 1279 1248 } … … 1308 1277 void UIResourceMonitorWidget::retranslateUi() 1309 1278 { 1310 m_column Captions[VMResourceMonitorColumn_Name] = tr("VM Name");1311 m_column Captions[VMResourceMonitorColumn_CPUGuestLoad] = tr("CPU Guest");1312 m_column Captions[VMResourceMonitorColumn_CPUVMMLoad] = tr("CPU VMM");1313 m_column Captions[VMResourceMonitorColumn_RAMUsedAndTotal] = tr("RAM Used/Total");1314 m_column Captions[VMResourceMonitorColumn_RAMUsedPercentage] = tr("RAM %");1315 m_column Captions[VMResourceMonitorColumn_NetworkUpRate] = tr("Network Up Rate");1316 m_column Captions[VMResourceMonitorColumn_NetworkDownRate] = tr("Network Down Rate");1317 m_column Captions[VMResourceMonitorColumn_NetworkUpTotal] = tr("Network Up Total");1318 m_column Captions[VMResourceMonitorColumn_NetworkDownTotal] = tr("Network Down Total");1319 m_column Captions[VMResourceMonitorColumn_DiskIOReadRate] = tr("Disk Read Rate");1320 m_column Captions[VMResourceMonitorColumn_DiskIOWriteRate] = tr("Disk Write Rate");1321 m_column Captions[VMResourceMonitorColumn_DiskIOReadTotal] = tr("Disk Read Total");1322 m_column Captions[VMResourceMonitorColumn_DiskIOWriteTotal] = tr("Disk Write Total");1323 m_column Captions[VMResourceMonitorColumn_VMExits] = tr("VM Exits");1279 m_columnTitles[VMResourceMonitorColumn_Name] = tr("VM Name"); 1280 m_columnTitles[VMResourceMonitorColumn_CPUGuestLoad] = tr("CPU Guest"); 1281 m_columnTitles[VMResourceMonitorColumn_CPUVMMLoad] = tr("CPU VMM"); 1282 m_columnTitles[VMResourceMonitorColumn_RAMUsedAndTotal] = tr("RAM Used/Total"); 1283 m_columnTitles[VMResourceMonitorColumn_RAMUsedPercentage] = tr("RAM %"); 1284 m_columnTitles[VMResourceMonitorColumn_NetworkUpRate] = tr("Network Up Rate"); 1285 m_columnTitles[VMResourceMonitorColumn_NetworkDownRate] = tr("Network Down Rate"); 1286 m_columnTitles[VMResourceMonitorColumn_NetworkUpTotal] = tr("Network Up Total"); 1287 m_columnTitles[VMResourceMonitorColumn_NetworkDownTotal] = tr("Network Down Total"); 1288 m_columnTitles[VMResourceMonitorColumn_DiskIOReadRate] = tr("Disk Read Rate"); 1289 m_columnTitles[VMResourceMonitorColumn_DiskIOWriteRate] = tr("Disk Write Rate"); 1290 m_columnTitles[VMResourceMonitorColumn_DiskIOReadTotal] = tr("Disk Read Total"); 1291 m_columnTitles[VMResourceMonitorColumn_DiskIOWriteTotal] = tr("Disk Write Total"); 1292 m_columnTitles[VMResourceMonitorColumn_VMExits] = tr("VM Exits"); 1324 1293 if (m_pModel) 1325 m_pModel->setColumnCaptions(m_column Captions);1294 m_pModel->setColumnCaptions(m_columnTitles); 1326 1295 computeMinimumColumnWidths(); 1327 1296 } … … 1341 1310 QIWithRetranslateUI<QWidget>::paintEvent(pEvent); 1342 1311 } 1343 1344 1312 1345 1313 void UIResourceMonitorWidget::prepare() … … 1381 1349 { 1382 1350 layout()->addWidget(m_pTableView); 1383 // m_pTableView->setContextMenuPolicy(Qt::CustomContextMenu);1384 // connect(m_pTableView, &QTableView::customContextMenuRequested,1385 // this, &UIResourceMonitorWidget::sltCreateContextMenu);1386 1351 m_pProxyModel->setSourceModel(m_pModel); 1387 1352 m_pTableView->setModel(m_pProxyModel); 1388 1353 m_pTableView->setItemDelegate(new UIVMResourceMonitorDelegate); 1389 1354 m_pTableView->setSelectionMode(QAbstractItemView::NoSelection); 1390 /* m_pTableView->setSelectionMode(QAbstractItemView::SingleSelection);1391 m_pTableView->setSelectionBehavior(QAbstractItemView::SelectRows);*/1392 1355 m_pTableView->setShowGrid(false); 1393 1356 m_pTableView->horizontalHeader()->setHighlightSections(false); … … 1408 1371 void UIResourceMonitorWidget::prepareActions() 1409 1372 { 1410 m_pColumnVisibilityToggleMenu = new QMenu(this); 1373 if (!m_pActionPool->action(UIActionIndexST_M_VMResourceMonitor_M_Columns)) 1374 return; 1375 UIMenu *pMenu = m_pActionPool->action(UIActionIndexST_M_VMResourceMonitor_M_Columns)->menu(); 1376 if (!pMenu) 1377 return; 1378 1411 1379 for (int i = 0; i < VMResourceMonitorColumn_Max; ++i) 1412 1380 { 1413 QAction *pAction = m_pColumnVisibilityToggleMenu->addAction(m_columnCaptions[i]);1381 QAction *pAction = pMenu->addAction(m_columnTitles[i]); 1414 1382 pAction->setCheckable(true); 1415 } 1416 1417 connect(m_pActionPool->action(UIActionIndexST_M_VMResourceMonitor_T_Columns), &QAction::toggled, 1418 this, &UIResourceMonitorWidget::sltToggleColumnSelectionMenu); 1383 if (i == (int)VMResourceMonitorColumn_Name) 1384 pAction->setEnabled(false); 1385 pAction->setData(i); 1386 pAction->setChecked(columnVisible(i)); 1387 connect(pAction, &QAction::toggled, this, &UIResourceMonitorWidget::sltHandleColumnAction); 1388 } 1419 1389 return; 1420 // m_pColumnSelectionMenu->setAutoFillBackground(true);1421 // m_pColumnSelectionMenu->setFrameStyle(QFrame::Panel | QFrame::Plain);1422 // m_pColumnSelectionMenu->hide();1423 // QVBoxLayout* pLayout = new QVBoxLayout(m_pColumnSelectionMenu);1424 // int iLength = 0;1425 // for (int i = 0; i < VMResourceMonitorColumn_Max; ++i)1426 // {1427 // UIVMResourceMonitorCheckBox* pCheckBox = new UIVMResourceMonitorCheckBox;1428 // QString strCaption = m_columnCaptions.value((VMResourceMonitorColumn)i, QString());1429 // pCheckBox->setText(strCaption);1430 // iLength = strCaption.length() > iLength ? strCaption.length() : iLength;1431 // if (!pCheckBox)1432 // continue;1433 // pLayout->addWidget(pCheckBox);1434 // pCheckBox->setData(i);1435 // pCheckBox->setChecked(columnVisible(i));1436 // if (i == (int)VMResourceMonitorColumn_Name)1437 // pCheckBox->setEnabled(false);1438 // connect(pCheckBox, &UIVMResourceMonitorCheckBox::toggled, this, &UIResourceMonitorWidget::sltHandleColumnAction);1439 // }1440 // QFontMetrics fontMetrics(m_pColumnSelectionMenu->font());1441 // int iWidth = iLength * fontMetrics.width('x') +1442 // QApplication::style()->pixelMetric(QStyle::PM_IndicatorWidth) +1443 // 2 * QApplication::style()->pixelMetric(QStyle::PM_LayoutLeftMargin) +1444 // 2 * QApplication::style()->pixelMetric(QStyle::PM_LayoutRightMargin);1445 // m_pColumnSelectionMenu->setFixedWidth(iWidth);1446 1390 } 1447 1391 … … 1501 1445 return; 1502 1446 m_pColumnVisibilityToggleMenu->exec(this->mapToGlobal(QPoint(0,0))); 1503 1504 // if (!m_pColumnSelectionMenu)1505 // return;1506 // m_pColumnSelectionMenu->setVisible(fChecked);1507 1508 // if (fChecked)1509 // {1510 // m_pColumnSelectionMenu->move(0, 0);1511 // m_pColumnSelectionMenu->raise();1512 // m_pColumnSelectionMenu->resize(400, 400);1513 // m_pColumnSelectionMenu->show();1514 // m_pColumnSelectionMenu->setFocus();1515 // }1516 // else1517 // m_pColumnSelectionMenu->hide();1518 //update();1519 1447 } 1520 1448 1521 1449 void UIResourceMonitorWidget::sltHandleColumnAction(bool fChecked) 1522 1450 { 1523 UIVMResourceMonitorCheckBox* pSender = qobject_cast<UIVMResourceMonitorCheckBox*>(sender());1451 QAction* pSender = qobject_cast<QAction*>(sender()); 1524 1452 if (!pSender) 1525 1453 return; … … 1568 1496 { 1569 1497 int iColumnStringWidth = columnDataStringLengths.value(i, 0); 1570 int iColumnTitleWidth = m_column Captions.value(i, QString()).length();1498 int iColumnTitleWidth = m_columnTitles.value(i, QString()).length(); 1571 1499 int iMax = iColumnStringWidth > iColumnTitleWidth ? iColumnStringWidth : iColumnTitleWidth; 1572 1500 columnWidthsInPixels[i] = iMax * fontMetrics.width('x') + -
trunk/src/VBox/Frontends/VirtualBox/src/monitor/resource/UIResourceMonitor.h
r83610 r83616 118 118 QMenu *m_pColumnVisibilityToggleMenu; 119 119 /* The key is the column id (VMResourceMonitorColumn) and value is column title. */ 120 QMap<int, QString> m_column Captions;120 QMap<int, QString> m_columnTitles; 121 121 /* The key is the column id (VMResourceMonitorColumn) and value is true if the column is visible. */ 122 122 QMap<int, bool> m_columnVisible;
Note:
See TracChangeset
for help on using the changeset viewer.