VirtualBox

Changeset 85547 in vbox for trunk


Ignore:
Timestamp:
Jul 30, 2020 9:14:00 AM (4 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9686, bugref:9510. Adding 'switch to machine performance pane' action to window menu and tool bar

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  
    33783378        setStatusTip(QApplication::translate("UIActionPool", "Show/Hide Columns"));
    33793379        setToolTip(  QApplication::translate("UIActionPool", "Show/Hide Columns")
     3380                   + (shortcut().isEmpty() ? QString() : QString(" (%1)").arg(shortcut().toString())));
     3381    }
     3382};
     3383
     3384class UIActionMenuSelectorVMResourceMonitorSwitchToMachinePerformance : public UIActionSimple
     3385{
     3386    Q_OBJECT;
     3387
     3388public:
     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
     3399protected:
     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")
    33803414                   + (shortcut().isEmpty() ? QString() : QString(" (%1)").arg(shortcut().toString())));
    33813415    }
     
    35523586    m_pool[UIActionIndexST_M_VMResourceMonitor] = new UIActionMenuVMResourceMonitor(this);
    35533587    m_pool[UIActionIndexST_M_VMResourceMonitor_M_Columns] = new UIActionMenuSelectorVMResourceMonitorToggleColumns(this);
     3588    m_pool[UIActionIndexST_M_VMResourceMonitor_S_SwitchToMachinePerformance] = new UIActionMenuSelectorVMResourceMonitorSwitchToMachinePerformance(this);
    35543589
    35553590    /* 'Group' action groups: */
     
    42134248    pMenu->clear();
    42144249    addAction(pMenu, action(UIActionIndexST_M_VMResourceMonitor_M_Columns));
     4250    addAction(pMenu, action(UIActionIndexST_M_VMResourceMonitor_S_SwitchToMachinePerformance));
    42154251}
    42164252
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPoolManager.h

    r85445 r85547  
    196196    UIActionIndexST_M_VMResourceMonitor,
    197197    UIActionIndexST_M_VMResourceMonitor_M_Columns,
     198    UIActionIndexST_M_VMResourceMonitor_S_SwitchToMachinePerformance,
    198199
    199200    /* Maximum index: */
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManagerWidget.cpp

    r85508 r85547  
    782782                {
    783783                    m_pToolBar->addAction(actionPool()->action(UIActionIndexST_M_VMResourceMonitor_M_Columns));
     784                    m_pToolBar->addAction(actionPool()->action(UIActionIndexST_M_VMResourceMonitor_S_SwitchToMachinePerformance));
    784785                    QToolButton *pButton =
    785786                        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  
    179179    Q_OBJECT;
    180180
     181signals:
     182
     183    void sigSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
     184
    181185public:
    182186
     
    185189    void updateColumVisibility();
    186190    int selectedItemIndex() const;
     191    bool hasSelection() const;
    187192
    188193protected:
    189194
    190195    virtual void resizeEvent(QResizeEvent *pEvent) /* override */;
     196    virtual void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected) /* override */;
    191197
    192198private slots:
     
    692698}
    693699
     700bool UIVMResourceMonitorTableView::hasSelection() const
     701{
     702    if (!selectionModel())
     703        return false;
     704    return selectionModel()->hasSelection();
     705}
     706
    694707void UIVMResourceMonitorTableView::resizeEvent(QResizeEvent *pEvent)
    695708{
    696709    resizeHeaders();
    697710    QTableView::resizeEvent(pEvent);
     711}
     712
     713void UIVMResourceMonitorTableView::selectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
     714{
     715    emit sigSelectionChanged(selected, deselected);
     716    QTableView::selectionChanged(selected, deselected);
    698717}
    699718
     
    12921311}
    12931312
     1313void 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
    12941322void UIResourceMonitorWidget::prepare()
    12951323{
     
    13621390        connect(m_pTableView, &UIVMResourceMonitorTableView::customContextMenuRequested,
    13631391                this, &UIResourceMonitorWidget::sltHandleTableContextMenuRequest);
    1364 
     1392        connect(m_pTableView, &UIVMResourceMonitorTableView::sigSelectionChanged,
     1393                this, &UIResourceMonitorWidget::sltHandleTableSelectionChanged);
    13651394        updateModelColumVisibilityCache();
    13661395    }
     
    13901419    m_pShowPerformanceMonitorAction = new QAction(this);
    13911420    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);
    13921424}
    13931425
     
    14721504void UIResourceMonitorWidget::sltHandleTableContextMenuRequest(const QPoint &pos)
    14731505{
    1474     if (!m_pTableView)
     1506    if (!m_pTableView || !m_pTableView->hasSelection())
    14751507        return;
    14761508
     
    14801512
    14811513    menu.exec(m_pTableView->mapToGlobal(pos));
     1514}
     1515
     1516void 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());
    14821522}
    14831523
  • trunk/src/VBox/Frontends/VirtualBox/src/monitor/resource/UIResourceMonitor.h

    r85515 r85547  
    3232class QAbstractButton;
    3333class QFrame;
     34class QItemSelection;
    3435class QLabel;
    3536class QTableView;
     
    7374      * @{ */
    7475        virtual void retranslateUi() /* override */;
     76        virtual void showEvent(QShowEvent *pEvent) /* override */;
    7577    /** @} */
    7678
     
    8385    void sltHandleTableContextMenuRequest(const QPoint &pos);
    8486    void sltHandleShowPerformanceMonitor();
     87    void sltHandleTableSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
    8588
    8689private:
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette