VirtualBox

Ignore:
Timestamp:
Aug 14, 2018 7:02:08 PM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: VirtualBox Manager UI: Integrating Snapshot-pane toolbar into Main application toolbar.

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIToolPaneMachine.cpp

    r73671 r73676  
    134134            {
    135135                /* Create Snapshots pane: */
    136                 m_pPaneSnapshots = new UISnapshotPane(m_pActionPool);
     136                m_pPaneSnapshots = new UISnapshotPane(m_pActionPool, false /* show toolbar? */);
    137137                AssertPtrReturnVoid(m_pPaneSnapshots);
    138138                {
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.cpp

    r73674 r73676  
    112112    , m_pGroupMenuAction(0)
    113113    , m_pMachineMenuAction(0)
     114    , m_pSnapshotMenuAction(0)
    114115    , m_pManagerVirtualMedia(0)
    115116    , m_pManagerHostNetwork(0)
     
    12271228    m_pMachineMenuAction = menuBar()->addMenu(actionPool()->action(UIActionIndexST_M_Machine)->menu());
    12281229
     1230    /* Prepare Snapshot-menu: */
     1231    prepareMenuSnapshot(actionPool()->action(UIActionIndexST_M_Snapshot)->menu());
     1232    m_pSnapshotMenuAction = menuBar()->addMenu(actionPool()->action(UIActionIndexST_M_Snapshot)->menu());
     1233
    12291234#ifdef VBOX_WS_MAC
    12301235    /* Prepare 'Window' menu: */
     
    15991604}
    16001605
     1606void UIVirtualBoxManager::prepareMenuSnapshot(QMenu *pMenu)
     1607{
     1608    /* Do not touch if filled already: */
     1609    if (!pMenu->isEmpty())
     1610        return;
     1611
     1612#ifdef VBOX_WS_X11
     1613    // WORKAROUND:
     1614    // There is an issue under Ubuntu which uses special kind of QPA
     1615    // plugin (appmenu-qt5) which redirects actions added to Qt menu-bar
     1616    // directly to Ubuntu Application menu-bar. In that case action
     1617    // shortcuts are not being handled by the Qt and that way ignored.
     1618    // As a workaround we can add those actions into QMainWindow as well.
     1619    addAction(actionPool()->action(UIActionIndexST_M_Snapshot_S_Take));
     1620    addAction(actionPool()->action(UIActionIndexST_M_Snapshot_S_Delete));
     1621    addAction(actionPool()->action(UIActionIndexST_M_Snapshot_S_Restore));
     1622    addAction(actionPool()->action(UIActionIndexST_M_Snapshot_T_Properties));
     1623    addAction(actionPool()->action(UIActionIndexST_M_Snapshot_S_Clone));
     1624#endif /* VBOX_WS_X11 */
     1625
     1626    /* Populate Snapshot-menu: */
     1627    pMenu->addAction(actionPool()->action(UIActionIndexST_M_Snapshot_S_Take));
     1628    pMenu->addAction(actionPool()->action(UIActionIndexST_M_Snapshot_S_Delete));
     1629    pMenu->addAction(actionPool()->action(UIActionIndexST_M_Snapshot_S_Restore));
     1630    pMenu->addAction(actionPool()->action(UIActionIndexST_M_Snapshot_T_Properties));
     1631    pMenu->addAction(actionPool()->action(UIActionIndexST_M_Snapshot_S_Clone));
     1632
     1633    /* Remember action list: */
     1634    m_snapshotActions << actionPool()->action(UIActionIndexST_M_Snapshot_S_Take)
     1635                      << actionPool()->action(UIActionIndexST_M_Snapshot_S_Delete)
     1636                      << actionPool()->action(UIActionIndexST_M_Snapshot_S_Restore)
     1637                      << actionPool()->action(UIActionIndexST_M_Snapshot_T_Properties)
     1638                      << actionPool()->action(UIActionIndexST_M_Snapshot_S_Clone);
     1639}
     1640
    16011641void UIVirtualBoxManager::prepareStatusBar()
    16021642{
     
    18881928    m_pGroupMenuAction->setVisible(fMachineOrGroupMenuShown && !fMachineMenuShown);
    18891929
     1930    /* Determine whether Snapshot actions should be visible: */
     1931    const bool fSnapshotMenuShown = fMachineOrGroupMenuShown && m_pWidget->currentMachineTool() == ToolTypeMachine_Snapshots;
     1932    m_pSnapshotMenuAction->setVisible(fSnapshotMenuShown);
     1933    actionPool()->action(UIActionIndexST_M_Snapshot_S_Take)->setVisible(fSnapshotMenuShown);
     1934    actionPool()->action(UIActionIndexST_M_Snapshot_S_Delete)->setVisible(fSnapshotMenuShown);
     1935    actionPool()->action(UIActionIndexST_M_Snapshot_S_Restore)->setVisible(fSnapshotMenuShown);
     1936    actionPool()->action(UIActionIndexST_M_Snapshot_T_Properties)->setVisible(fSnapshotMenuShown);
     1937    actionPool()->action(UIActionIndexST_M_Snapshot_S_Clone)->setVisible(fSnapshotMenuShown);
     1938
    18901939    /* Hide action shortcuts: */
    18911940    if (!fMachineMenuShown)
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.h

    r73673 r73676  
    248248        /** Prepares @a pMenu Machine => Close. */
    249249        void prepareMenuMachineClose(QMenu *pMenu);
     250        /** Prepares @a pMenu Snapshot. */
     251        void prepareMenuSnapshot(QMenu *pMenu);
    250252        /** Prepares status-bar. */
    251253        void prepareStatusBar();
     
    348350    QAction          *m_pMachineMenuAction;
    349351
     352    /** Holds the list of Snapshot menu actions. */
     353    QList<UIAction*>  m_snapshotActions;
     354    /** Holds the Snapshot menu parent action. */
     355    QAction          *m_pSnapshotMenuAction;
     356
    350357    /** Holds the Virtual Media Manager window instance. */
    351358    QIManagerDialog *m_pManagerVirtualMedia;
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManagerWidget.cpp

    r73673 r73676  
    104104}
    105105
     106ToolTypeMachine UIVirtualBoxManagerWidget::currentMachineTool() const
     107{
     108    return m_pPaneToolsMachine->currentTool();
     109}
     110
     111ToolTypeGlobal UIVirtualBoxManagerWidget::currentGlobalTool() const
     112{
     113    return m_pPaneToolsGlobal->currentTool();
     114}
     115
    106116bool UIVirtualBoxManagerWidget::isToolOpened(ToolTypeMachine enmType) const
    107117{
     
    393403        m_pToolBar->addAction(actionPool()->action(UIActionIndexST_M_Machine_S_Discard));
    394404        m_pToolBar->addAction(actionPool()->action(UIActionIndexST_M_Machine_M_StartOrShow));
     405
     406        /* Add Snapshot actions block: */
     407        m_pToolBar->addSeparator();
     408        m_pToolBar->addAction(actionPool()->action(UIActionIndexST_M_Snapshot_S_Take));
     409        m_pToolBar->addAction(actionPool()->action(UIActionIndexST_M_Snapshot_S_Delete));
     410        m_pToolBar->addAction(actionPool()->action(UIActionIndexST_M_Snapshot_S_Restore));
     411        m_pToolBar->addAction(actionPool()->action(UIActionIndexST_M_Snapshot_T_Properties));
     412        m_pToolBar->addAction(actionPool()->action(UIActionIndexST_M_Snapshot_S_Clone));
     413
    395414#ifdef VBOX_WS_MAC
    396415        // WORKAROUND:
    397416        // Actually Qt should do that itself but by some unknown reason it sometimes
    398         // forget to update toolbar after changing its actions on cocoa platform.
     417        // forget to update toolbar after changing its actions on Cocoa platform.
    399418        connect(actionPool()->action(UIActionIndexST_M_Machine_S_New), &UIAction::changed,
    400419                m_pToolBar, static_cast<void(UIToolBar::*)(void)>(&UIToolBar::update));
     
    405424        connect(actionPool()->action(UIActionIndexST_M_Machine_M_StartOrShow), &UIAction::changed,
    406425                m_pToolBar, static_cast<void(UIToolBar::*)(void)>(&UIToolBar::update));
    407 #endif /* VBOX_WS_MAC */
    408 
    409 #ifdef VBOX_WS_MAC
     426
    410427        // WORKAROUND:
    411428        // There is a bug in Qt Cocoa which result in showing a "more arrow" when
     
    414431        // after changing the text.
    415432        m_pToolBar->updateLayout();
    416 #endif
     433#endif /* VBOX_WS_MAC */
    417434    }
    418435}
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManagerWidget.h

    r73673 r73676  
    8686        bool isSingleGroupSelected() const;
    8787
     88        /** Returns a type of curent Machine tool. */
     89        ToolTypeMachine currentMachineTool() const;
     90        /** Returns a type of curent Global tool. */
     91        ToolTypeGlobal currentGlobalTool() const;
    8892        /** Returns whether Machine tool of passed @a enmType is opened. */
    8993        bool isToolOpened(ToolTypeMachine enmType) const;
  • trunk/src/VBox/Frontends/VirtualBox/src/snapshots/UISnapshotPane.cpp

    r73671 r73676  
    452452*********************************************************************************************************************************/
    453453
    454 UISnapshotPane::UISnapshotPane(UIActionPool *pActionPool, QWidget *pParent /* = 0 */)
     454UISnapshotPane::UISnapshotPane(UIActionPool *pActionPool, bool fShowToolbar /* = true */, QWidget *pParent /* = 0 */)
    455455    : QIWithRetranslateUI<QWidget>(pParent)
    456456    , m_pActionPool(pActionPool)
     457    , m_fShowToolbar(fShowToolbar)
    457458    , m_enmSessionState(KSessionState_Null)
    458459    , m_fShapshotOperationsAllowed(false)
     
    12201221#endif
    12211222
    1222         /* Prepare toolbar: */
    1223         prepareToolbar();
     1223        /* Prepare toolbar, if requested: */
     1224        if (m_fShowToolbar)
     1225            prepareToolbar();
    12241226        /* Prepare snapshot tree: */
    12251227        prepareTreeWidget();
     
    12331235    /* Create snapshot toolbar: */
    12341236    m_pToolBar = new UIToolBar(this);
    1235     AssertPtrReturnVoid(m_pToolBar);
     1237    if (m_pToolBar)
    12361238    {
    12371239        /* Configure toolbar: */
  • trunk/src/VBox/Frontends/VirtualBox/src/snapshots/UISnapshotPane.h

    r73671 r73676  
    5858
    5959    /** Constructs snapshot pane passing @a pParent to the base-class. */
    60     UISnapshotPane(UIActionPool *pActionPool, QWidget *pParent = 0);
     60    UISnapshotPane(UIActionPool *pActionPool, bool fShowToolbar = true, QWidget *pParent = 0);
    6161    /** Destructs snapshot pane. */
    6262    virtual ~UISnapshotPane() /* override */;
     
    198198        /** Holds the action-pool reference. */
    199199        UIActionPool  *m_pActionPool;
     200        /** Holds whether we should show toolbar. */
     201        bool           m_fShowToolbar;
    200202        /** Holds the COM machine object. */
    201203        CMachine       m_comMachine;
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