VirtualBox

Ignore:
Timestamp:
Oct 25, 2018 6:11:38 PM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9241: VirtualBox Manager: A bit of optimization for tool change and item change handlers.

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

Legend:

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

    r75081 r75086  
    151151    m_pPaneToolsMachine->openTool(enmType);
    152152
    153     /* If that was 'Details' => pass there current items: */
    154     if (enmType == UIToolType_Details)
    155         m_pPaneToolsMachine->setItems(currentItems());
    156     /* If that was 'Snapshot' or 'LogViewer' => pass there current or null machine: */
    157     if (enmType == UIToolType_Snapshots || enmType == UIToolType_Logs)
    158     {
    159         UIVirtualMachineItem *pItem = currentItem();
    160         m_pPaneToolsMachine->setMachine(pItem ? pItem->machine() : CMachine());
    161     }
    162 
    163153    /* Let the parent know: */
    164154    emit sigToolTypeChange();
     
    229219void UIVirtualBoxManagerWidget::sltHandleChooserPaneIndexChange(bool fUpdateDetails /* = true */,
    230220                                                                bool fUpdateSnapshots /* = true */,
    231                                                                 bool fUpdateLogViewer /* = true */)
     221                                                                bool fUpdateLogs /* = true */)
    232222{
    233223    /* Let the parent know: */
     
    249239    /* If machine or group item is selected and we are on global tools pane => switch to machine tools pane: */
    250240    if (   (isMachineItemSelected() || isGroupItemSelected())
    251              && m_pStackedWidget->currentWidget() != m_pPaneToolsMachine)
     241        && m_pStackedWidget->currentWidget() != m_pPaneToolsMachine)
    252242    {
    253243        /* Just start animation and return, do nothing else.. */
     
    263253        /* Get current item: */
    264254        UIVirtualMachineItem *pItem = currentItem();
    265 
    266         /* Update Tools-pane: */
     255        const bool fCurrentItemIsOk = pItem && pItem->accessible();
     256
     257        /* Update machine tools availability: */
     258        m_pPaneTools->setToolsEnabled(UIToolClass_Machine, fCurrentItemIsOk);
     259
     260        /* Propagate current item anyway: */
    267261        m_pPaneToolsMachine->setCurrentItem(pItem);
    268262
    269         /* Update Machine Tools availability: */
    270         m_pPaneTools->setToolsEnabled(UIToolClass_Machine, pItem && pItem->accessible());
    271 
    272         /* If current item exists & accessible: */
    273         if (pItem && pItem->accessible())
    274         {
    275             /* If Error pane is chosen currently => open tool currently chosen in Tools-pane: */
     263        /* If current item is Ok: */
     264        if (fCurrentItemIsOk)
     265        {
     266            /* If Error-pane is chosen currently => open tool currently chosen in Tools-pane: */
    276267            if (m_pPaneToolsMachine->currentTool() == UIToolType_Error)
    277268                sltHandleToolsPaneIndexChange();
    278269
    279             /* Update Details-pane (if requested): */
     270            /* Propagate current items to update the Details-pane (if requested): */
    280271            if (fUpdateDetails)
    281272                m_pPaneToolsMachine->setItems(currentItems());
    282             /* Update the Snapshots-pane or/and Logviewer-pane (if requested): */
    283             if (fUpdateSnapshots || fUpdateLogViewer)
     273            /* Propagate current machine to update the Snapshots-pane or/and Logviewer-pane (if requested): */
     274            if (fUpdateSnapshots || fUpdateLogs)
    284275                m_pPaneToolsMachine->setMachine(pItem->machine());
    285276        }
     
    289280            m_pPaneToolsMachine->openTool(UIToolType_Error);
    290281
    291             /* Note that the machine becomes inaccessible (or if the last VM gets
    292              * deleted), we have to update all fields, ignoring input arguments. */
     282            /* Propagate last access error to update the Error-pane (if machine selected but inaccessible): */
    293283            if (pItem)
    294             {
    295                 /* The VM is inaccessible: */
    296284                m_pPaneToolsMachine->setErrorDetails(UIErrorString::formatErrorInfo(pItem->accessError()));
    297             }
    298 
    299             /* Update Details-pane (in any case): */
     285
     286            /* Propagate current items to update the Details-pane (in any case): */
    300287            m_pPaneToolsMachine->setItems(currentItems());
    301             /* Update Snapshots-pane and Logviewer-pane (in any case): */
     288            /* Propagate current machine to update the Snapshots-pane or/and Logviewer-pane (in any case): */
    302289            m_pPaneToolsMachine->setMachine(CMachine());
    303290        }
     
    343330void UIVirtualBoxManagerWidget::sltHandleToolsPaneIndexChange()
    344331{
     332    /* Acquire current class/type: */
     333    const UIToolClass enmCurrentClass = m_pPaneTools->toolsClass();
     334    const UIToolType enmCurrentType = m_pPaneTools->toolsType();
     335
     336    /* Invent default for fallback case: */
     337    const UIToolType enmDefaultType = enmCurrentClass == UIToolClass_Global ? UIToolType_Welcome
     338                                    : enmCurrentClass == UIToolClass_Machine ? UIToolType_Details
     339                                    : UIToolType_Invalid;
     340    AssertReturnVoid(enmDefaultType != UIToolType_Invalid);
     341
     342    /* Calculate new type to choose: */
     343    const UIToolType enmNewType = UIToolStuff::isTypeOfClass(enmCurrentType, enmCurrentClass)
     344                                ? enmCurrentType : enmDefaultType;
     345
     346    /* Choose new type: */
    345347    switch (m_pPaneTools->toolsClass())
    346348    {
    347         case UIToolClass_Global:
    348         {
    349             const UIToolType enmType = m_pPaneTools->areToolsEnabled(UIToolClass_Global)
    350                                      ? m_pPaneTools->toolsType()
    351                                      : UIToolType_Welcome;
    352             switchToGlobalTool(enmType);
    353             break;
    354         }
    355         case UIToolClass_Machine:
    356         {
    357             const UIToolType enmType = m_pPaneTools->areToolsEnabled(UIToolClass_Machine)
    358                                      ? m_pPaneTools->toolsType()
    359                                      : UIToolType_Details;
    360             switchToMachineTool(enmType);
    361             break;
    362         }
    363         default:
    364             break;
     349        case UIToolClass_Global: switchToGlobalTool(enmNewType); break;
     350        case UIToolClass_Machine: switchToMachineTool(enmNewType); break;
     351        default: break;
    365352    }
    366353}
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManagerWidget.h

    r75054 r75086  
    136136          * @param  fUpdateDetails    Brings whether details should be updated.
    137137          * @param  fUpdateSnapshots  Brings whether snapshots should be updated.
    138           * @param  fUpdateLogViewer  Brings whether log-viewer should be updated. */
     138          * @param  fUpdateLogs       Brings whether log-viewer should be updated. */
    139139        void sltHandleChooserPaneIndexChange(bool fUpdateDetails = true,
    140140                                             bool fUpdateSnapshots = true,
    141                                              bool fUpdateLogViewer = true);
     141                                             bool fUpdateLogs = true);
    142142        /** Handles signal about Chooser-pane index change the default way. */
    143143        void sltHandleChooserPaneIndexChangeDefault() { sltHandleChooserPaneIndexChange(); }
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