VirtualBox

Ignore:
Timestamp:
Aug 9, 2018 6:13:11 PM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: VirtualBox Manager UI: Link global/machine item selection with tool-pane global/machine tab-bar activation.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/manager
Files:
3 edited

Legend:

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

    r73517 r73602  
    18711871{
    18721872    /* Determine whether Machine or Group menu should be shown at all: */
    1873     const bool fMachineOrGroupMenuShown = actionPool()->action(UIActionIndexST_M_Tools_T_Machine)->isChecked();
     1873    const bool fMachineOrGroupMenuShown = m_pWidget->isMachineItemSelected();
    18741874    const bool fMachineMenuShown = !isSingleGroupSelected();
    18751875    m_pMachineMenuAction->setVisible(fMachineOrGroupMenuShown && fMachineMenuShown);
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManagerWidget.cpp

    r73552 r73602  
    6464}
    6565
     66bool UIVirtualBoxManagerWidget::isGlobalItemSelected() const
     67{
     68    return m_pPaneChooser->isGlobalItemSelected();
     69}
     70
     71bool UIVirtualBoxManagerWidget::isMachineItemSelected() const
     72{
     73    return m_pPaneChooser->isMachineItemSelected();
     74}
     75
    6676UIVirtualMachineItem *UIVirtualBoxManagerWidget::currentItem() const
    6777{
     
    210220    emit sigChooserPaneIndexChange();
    211221
    212     /* Get current item: */
    213     UIVirtualMachineItem *pItem = currentItem();
    214 
    215     /* Update Tools-pane: */
    216     m_pPaneToolsMachine->setCurrentItem(pItem);
    217 
    218     /* Update Machine tab-bar availability: */
    219     m_pToolbarTools->setTabBarEnabledMachine(pItem && pItem->accessible());
    220 
    221     /* If current item exists & accessible: */
    222     if (pItem && pItem->accessible())
    223     {
    224         /* If Desktop pane is chosen currently: */
    225         if (m_pPaneToolsMachine->currentTool() == ToolTypeMachine_Desktop)
     222    /* If global item is selected and we are on machine tools pane => switch to global tools pane: */
     223    if (isGlobalItemSelected() && m_pSlidingWidget->state() == UISlidingWidget::State_Start)
     224    {
     225        m_pSlidingWidget->moveForward();
     226        m_pToolbarTools->switchToTabBar(UIToolbarTools::TabBarType_Global);
     227    }
     228
     229    else
     230
     231    /* If machine item is selected and we are on global tools pane => switch to machine tools pane: */
     232    if (isMachineItemSelected() && m_pSlidingWidget->state() == UISlidingWidget::State_Final)
     233    {
     234        m_pSlidingWidget->moveBackward();
     235        m_pToolbarTools->switchToTabBar(UIToolbarTools::TabBarType_Machine);
     236    }
     237
     238    /* If that was machine item selected: */
     239    if (isMachineItemSelected())
     240    {
     241        /* Get current item: */
     242        UIVirtualMachineItem *pItem = currentItem();
     243
     244        /* Update Tools-pane: */
     245        m_pPaneToolsMachine->setCurrentItem(pItem);
     246
     247        /* Update Machine tab-bar availability: */
     248        m_pToolbarTools->setTabBarEnabledMachine(pItem && pItem->accessible());
     249
     250        /* If current item exists & accessible: */
     251        if (pItem && pItem->accessible())
    226252        {
    227             /* Make sure Details or Snapshot pane is chosen if opened: */
     253            /* If Desktop pane is chosen currently: */
     254            if (m_pPaneToolsMachine->currentTool() == ToolTypeMachine_Desktop)
     255            {
     256                /* Make sure Details or Snapshot pane is chosen if opened: */
     257                if (m_pPaneToolsMachine->isToolOpened(ToolTypeMachine_Details))
     258                    actionPool()->action(UIActionIndexST_M_Tools_M_Machine_S_Details)->trigger();
     259                else
     260                if (m_pPaneToolsMachine->isToolOpened(ToolTypeMachine_Snapshots))
     261                    actionPool()->action(UIActionIndexST_M_Tools_M_Machine_S_Snapshots)->trigger();
     262                else
     263                if (m_pPaneToolsMachine->isToolOpened(ToolTypeMachine_LogViewer))
     264                    actionPool()->action(UIActionIndexST_M_Tools_M_Machine_S_LogViewer)->trigger();
     265            }
     266
     267            /* Update Details-pane (if requested): */
     268            if (   fUpdateDetails
     269                && m_pPaneToolsMachine->isToolOpened(ToolTypeMachine_Details))
     270                m_pPaneToolsMachine->setItems(currentItems());
     271            /* Update the Snapshots-pane or/and Logviewer-pane (if requested): */
     272            if (fUpdateSnapshots || fUpdateLogViewer)
     273                m_pPaneToolsMachine->setMachine(pItem->machine());
     274        }
     275        else
     276        {
     277            /* Make sure Desktop-pane raised: */
     278            m_pPaneToolsMachine->openTool(ToolTypeMachine_Desktop);
     279
     280            /* Note that the machine becomes inaccessible (or if the last VM gets
     281             * deleted), we have to update all fields, ignoring input arguments. */
     282            if (pItem)
     283            {
     284                /* The VM is inaccessible: */
     285                m_pPaneToolsMachine->setDetailsError(UIErrorString::formatErrorInfo(pItem->accessError()));
     286            }
     287
     288            /* Update Details-pane (in any case): */
    228289            if (m_pPaneToolsMachine->isToolOpened(ToolTypeMachine_Details))
    229                 actionPool()->action(UIActionIndexST_M_Tools_M_Machine_S_Details)->trigger();
    230             else
    231             if (m_pPaneToolsMachine->isToolOpened(ToolTypeMachine_Snapshots))
    232                 actionPool()->action(UIActionIndexST_M_Tools_M_Machine_S_Snapshots)->trigger();
    233             else
    234             if (m_pPaneToolsMachine->isToolOpened(ToolTypeMachine_LogViewer))
    235                 actionPool()->action(UIActionIndexST_M_Tools_M_Machine_S_LogViewer)->trigger();
     290                m_pPaneToolsMachine->setItems(currentItems());
     291            /* Update Snapshots-pane and Logviewer-pane (in any case): */
     292            m_pPaneToolsMachine->setMachine(CMachine());
    236293        }
    237 
    238         /* Update Details-pane (if requested): */
    239         if (   fUpdateDetails
    240             && m_pPaneToolsMachine->isToolOpened(ToolTypeMachine_Details))
    241             m_pPaneToolsMachine->setItems(currentItems());
    242         /* Update the Snapshots-pane or/and Logviewer-pane (if requested): */
    243         if (fUpdateSnapshots || fUpdateLogViewer)
    244             m_pPaneToolsMachine->setMachine(pItem->machine());
    245     }
    246     else
    247     {
    248         /* Make sure Desktop-pane raised: */
    249         m_pPaneToolsMachine->openTool(ToolTypeMachine_Desktop);
    250 
    251         /* Note that the machine becomes inaccessible (or if the last VM gets
    252          * deleted), we have to update all fields, ignoring input arguments. */
    253         if (pItem)
    254         {
    255             /* The VM is inaccessible: */
    256             m_pPaneToolsMachine->setDetailsError(UIErrorString::formatErrorInfo(pItem->accessError()));
    257         }
    258 
    259         /* Update Details-pane (in any case): */
    260         if (m_pPaneToolsMachine->isToolOpened(ToolTypeMachine_Details))
    261             m_pPaneToolsMachine->setItems(currentItems());
    262         /* Update Snapshots-pane and Logviewer-pane (in any case): */
    263         m_pPaneToolsMachine->setMachine(CMachine());
    264     }
    265 }
    266 
    267 void UIVirtualBoxManagerWidget::sltHandleToolsTypeSwitch()
    268 {
    269     /* If Machine tool button is checked => go backward: */
    270     if (actionPool()->action(UIActionIndexST_M_Tools_T_Machine)->isChecked())
    271         m_pSlidingWidget->moveBackward();
    272 
    273     else
    274 
    275     /* If Global tool button is checked => go forward: */
    276     if (actionPool()->action(UIActionIndexST_M_Tools_T_Global)->isChecked())
    277         m_pSlidingWidget->moveForward();
    278 
    279     /* Update action visibility: */
    280     emit sigToolsTypeSwitch();
    281 
    282     /* Make sure chosen item fetched: */
    283     sltHandleChooserPaneIndexChange(false /* update details? */, false /* update snapshots? */, false /* update the logviewer? */);
     294    }
    284295}
    285296
     
    491502            this, &UIVirtualBoxManagerWidget::sltHandleToolClosedGlobal);
    492503
    493     /* 'Tools' actions connections: */
    494     connect(actionPool()->action(UIActionIndexST_M_Tools_T_Machine), &UIAction::toggled,
    495             this, &UIVirtualBoxManagerWidget::sltHandleToolsTypeSwitch);
    496     connect(actionPool()->action(UIActionIndexST_M_Tools_T_Global), &UIAction::toggled,
    497             this, &UIVirtualBoxManagerWidget::sltHandleToolsTypeSwitch);
    498 
    499504    /* Chooser-pane connections: */
    500505    connect(m_pPaneChooser, &UIChooser::sigSelectionChanged,
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManagerWidget.h

    r73552 r73602  
    6868        UIActionPool *actionPool() const { return m_pActionPool; }
    6969
     70        /** Returns whether global current-item is selected. */
     71        bool isGlobalItemSelected() const;
     72        /** Returns whether machine current-item is selected. */
     73        bool isMachineItemSelected() const;
    7074        /** Returns current-item. */
    7175        UIVirtualMachineItem *currentItem() const;
     
    131135    /** @name Tools stuff.
    132136      * @{ */
    133         /** Handles tools type switch. */
    134         void sltHandleToolsTypeSwitch();
    135 
    136137        /** Handles rquest to open Machine tool of passed @a enmType. */
    137138        void sltHandleToolOpenedMachine(ToolTypeMachine enmType);
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