- Timestamp:
- Jul 30, 2020 9:14:00 AM (4 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
r85512 r85547 3378 3378 setStatusTip(QApplication::translate("UIActionPool", "Show/Hide Columns")); 3379 3379 setToolTip( QApplication::translate("UIActionPool", "Show/Hide Columns") 3380 + (shortcut().isEmpty() ? QString() : QString(" (%1)").arg(shortcut().toString()))); 3381 } 3382 }; 3383 3384 class UIActionMenuSelectorVMResourceMonitorSwitchToMachinePerformance : public UIActionSimple 3385 { 3386 Q_OBJECT; 3387 3388 public: 3389 3390 /** Constructs action passing @a pParent to the base-class. */ 3391 UIActionMenuSelectorVMResourceMonitorSwitchToMachinePerformance(UIActionPool *pParent) 3392 : UIActionSimple(pParent, 3393 ":/cloud_console_application_remove_32px .png", ":/cloud_console_application_remove_16px.png", 3394 ":/cloud_console_application_remove_disabled_32px.png", ":/cloud_console_application_remove_disabled_16px.png") 3395 { 3396 setShortcutContext(Qt::WidgetWithChildrenShortcut); 3397 } 3398 3399 protected: 3400 3401 /** Returns shortcut extra-data ID. */ 3402 virtual QString shortcutExtraDataID() const /* override */ 3403 { 3404 return QString("VMResourceMonitorSwitchToMachinePerformance"); 3405 } 3406 3407 /** Handles translation event. */ 3408 virtual void retranslateUi() /* override */ 3409 { 3410 setName(QApplication::translate("UIActionPool", "To Performance")); 3411 setShortcutScope(QApplication::translate("UIActionPool", "Resource Manager")); 3412 setStatusTip(QApplication::translate("UIActionPool", "Switch to selected machine's performance pane")); 3413 setToolTip( QApplication::translate("UIActionPool", "Switch to selected machine's performance pane") 3380 3414 + (shortcut().isEmpty() ? QString() : QString(" (%1)").arg(shortcut().toString()))); 3381 3415 } … … 3552 3586 m_pool[UIActionIndexST_M_VMResourceMonitor] = new UIActionMenuVMResourceMonitor(this); 3553 3587 m_pool[UIActionIndexST_M_VMResourceMonitor_M_Columns] = new UIActionMenuSelectorVMResourceMonitorToggleColumns(this); 3588 m_pool[UIActionIndexST_M_VMResourceMonitor_S_SwitchToMachinePerformance] = new UIActionMenuSelectorVMResourceMonitorSwitchToMachinePerformance(this); 3554 3589 3555 3590 /* 'Group' action groups: */ … … 4213 4248 pMenu->clear(); 4214 4249 addAction(pMenu, action(UIActionIndexST_M_VMResourceMonitor_M_Columns)); 4250 addAction(pMenu, action(UIActionIndexST_M_VMResourceMonitor_S_SwitchToMachinePerformance)); 4215 4251 } 4216 4252 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPoolManager.h
r85445 r85547 196 196 UIActionIndexST_M_VMResourceMonitor, 197 197 UIActionIndexST_M_VMResourceMonitor_M_Columns, 198 UIActionIndexST_M_VMResourceMonitor_S_SwitchToMachinePerformance, 198 199 199 200 /* Maximum index: */ -
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManagerWidget.cpp
r85508 r85547 782 782 { 783 783 m_pToolBar->addAction(actionPool()->action(UIActionIndexST_M_VMResourceMonitor_M_Columns)); 784 m_pToolBar->addAction(actionPool()->action(UIActionIndexST_M_VMResourceMonitor_S_SwitchToMachinePerformance)); 784 785 QToolButton *pButton = 785 786 qobject_cast<QToolButton*>(m_pToolBar->widgetForAction(actionPool()->action(UIActionIndexST_M_VMResourceMonitor_M_Columns))); -
trunk/src/VBox/Frontends/VirtualBox/src/monitor/resource/UIResourceMonitor.cpp
r85515 r85547 179 179 Q_OBJECT; 180 180 181 signals: 182 183 void sigSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected); 184 181 185 public: 182 186 … … 185 189 void updateColumVisibility(); 186 190 int selectedItemIndex() const; 191 bool hasSelection() const; 187 192 188 193 protected: 189 194 190 195 virtual void resizeEvent(QResizeEvent *pEvent) /* override */; 196 virtual void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected) /* override */; 191 197 192 198 private slots: … … 692 698 } 693 699 700 bool UIVMResourceMonitorTableView::hasSelection() const 701 { 702 if (!selectionModel()) 703 return false; 704 return selectionModel()->hasSelection(); 705 } 706 694 707 void UIVMResourceMonitorTableView::resizeEvent(QResizeEvent *pEvent) 695 708 { 696 709 resizeHeaders(); 697 710 QTableView::resizeEvent(pEvent); 711 } 712 713 void UIVMResourceMonitorTableView::selectionChanged(const QItemSelection &selected, const QItemSelection &deselected) 714 { 715 emit sigSelectionChanged(selected, deselected); 716 QTableView::selectionChanged(selected, deselected); 698 717 } 699 718 … … 1292 1311 } 1293 1312 1313 void UIResourceMonitorWidget::showEvent(QShowEvent *pEvent) 1314 { 1315 QAction *pSwitchAction = m_pActionPool->action(UIActionIndexST_M_VMResourceMonitor_S_SwitchToMachinePerformance); 1316 if (pSwitchAction && m_pTableView) 1317 pSwitchAction->setEnabled(m_pTableView->hasSelection()); 1318 1319 QIWithRetranslateUI<QWidget>::showEvent(pEvent); 1320 } 1321 1294 1322 void UIResourceMonitorWidget::prepare() 1295 1323 { … … 1362 1390 connect(m_pTableView, &UIVMResourceMonitorTableView::customContextMenuRequested, 1363 1391 this, &UIResourceMonitorWidget::sltHandleTableContextMenuRequest); 1364 1392 connect(m_pTableView, &UIVMResourceMonitorTableView::sigSelectionChanged, 1393 this, &UIResourceMonitorWidget::sltHandleTableSelectionChanged); 1365 1394 updateModelColumVisibilityCache(); 1366 1395 } … … 1390 1419 m_pShowPerformanceMonitorAction = new QAction(this); 1391 1420 connect(m_pShowPerformanceMonitorAction, &QAction::triggered, this, &UIResourceMonitorWidget::sltHandleShowPerformanceMonitor); 1421 QAction *pSwitchAction = m_pActionPool->action(UIActionIndexST_M_VMResourceMonitor_S_SwitchToMachinePerformance); 1422 if (pSwitchAction) 1423 connect(pSwitchAction, &QAction::triggered, this, &UIResourceMonitorWidget::sltHandleShowPerformanceMonitor); 1392 1424 } 1393 1425 … … 1472 1504 void UIResourceMonitorWidget::sltHandleTableContextMenuRequest(const QPoint &pos) 1473 1505 { 1474 if (!m_pTableView )1506 if (!m_pTableView || !m_pTableView->hasSelection()) 1475 1507 return; 1476 1508 … … 1480 1512 1481 1513 menu.exec(m_pTableView->mapToGlobal(pos)); 1514 } 1515 1516 void UIResourceMonitorWidget::sltHandleTableSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected) 1517 { 1518 Q_UNUSED(deselected); 1519 QAction *pSwitchAction = m_pActionPool->action(UIActionIndexST_M_VMResourceMonitor_S_SwitchToMachinePerformance); 1520 if (pSwitchAction) 1521 pSwitchAction->setEnabled(!selected.isEmpty()); 1482 1522 } 1483 1523 -
trunk/src/VBox/Frontends/VirtualBox/src/monitor/resource/UIResourceMonitor.h
r85515 r85547 32 32 class QAbstractButton; 33 33 class QFrame; 34 class QItemSelection; 34 35 class QLabel; 35 36 class QTableView; … … 73 74 * @{ */ 74 75 virtual void retranslateUi() /* override */; 76 virtual void showEvent(QShowEvent *pEvent) /* override */; 75 77 /** @} */ 76 78 … … 83 85 void sltHandleTableContextMenuRequest(const QPoint &pos); 84 86 void sltHandleShowPerformanceMonitor(); 87 void sltHandleTableSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected); 85 88 86 89 private:
Note:
See TracChangeset
for help on using the changeset viewer.