VirtualBox

Changeset 73601 in vbox for trunk/src/VBox/Frontends


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

FE/Qt: UIToolbarTools: Add possibility to switch tab-bar layout directly instead of internal hardcoded action toggle connection.

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

Legend:

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

    r73552 r73601  
    4747}
    4848
     49void UIToolbarTools::switchToTabBar(TabBarType enmType)
     50{
     51    /* Handle known types: */
     52    switch (enmType)
     53    {
     54        case TabBarType_Machine:
     55        {
     56            if (m_pTabBarGlobal)
     57                m_pTabBarGlobal->setVisible(false);
     58            if (m_pTabBarMachine)
     59                m_pTabBarMachine->setVisible(true);
     60            break;
     61        }
     62        case TabBarType_Global:
     63        {
     64            if (m_pTabBarMachine)
     65                m_pTabBarMachine->setVisible(false);
     66            if (m_pTabBarGlobal)
     67                m_pTabBarGlobal->setVisible(true);
     68            break;
     69        }
     70    }
     71}
     72
    4973void UIToolbarTools::setTabBarEnabledMachine(bool fEnabled)
    5074{
     
    163187}
    164188
    165 void UIToolbarTools::sltHandleActionToggle()
    166 {
    167     /* Handle known actions: */
    168     if (m_pActionPool->action(UIActionIndexST_M_Tools_T_Machine)->isChecked())
    169     {
    170         if (m_pTabBarGlobal)
    171             m_pTabBarGlobal->setVisible(false);
    172         if (m_pTabBarMachine)
    173             m_pTabBarMachine->setVisible(true);
    174     }
    175     else if (m_pActionPool->action(UIActionIndexST_M_Tools_T_Global)->isChecked())
    176     {
    177         if (m_pTabBarMachine)
    178             m_pTabBarMachine->setVisible(false);
    179         if (m_pTabBarGlobal)
    180             m_pTabBarGlobal->setVisible(true);
    181     }
    182 }
    183 
    184189void UIToolbarTools::prepare()
    185190{
     
    188193    /* Prepare widgets: */
    189194    prepareWidgets();
    190 
    191     /* Make sure just one tab-bar shown initially: */
    192     sltHandleActionToggle();
    193195}
    194196
     
    223225    /* Configure 'Machine' toggle action: */
    224226    m_pActionPool->action(UIActionIndexST_M_Tools_T_Machine)->setMenu(pMenuMachine);
    225     connect(m_pActionPool->action(UIActionIndexST_M_Tools_T_Machine), &UIAction::toggled,
    226             this, &UIToolbarTools::sltHandleActionToggle);
    227227
    228228    /* Configure 'Global' menu: */
     
    247247    /* Configure 'Global' toggle action: */
    248248    m_pActionPool->action(UIActionIndexST_M_Tools_T_Global)->setMenu(pMenuGlobal);
    249     connect(m_pActionPool->action(UIActionIndexST_M_Tools_T_Global), &UIAction::toggled,
    250             this, &UIToolbarTools::sltHandleActionToggle);
    251 
    252     /* By default 'Machine' toggle action is toggled: */
    253     m_pActionPool->action(UIActionIndexST_M_Tools_T_Machine)->setChecked(true);
    254249}
    255250
     
    280275        if (m_pTabBarGlobal)
    281276        {
    282             /* Configure tab-bar connections: */
    283277            connect(m_pTabBarGlobal, &UITabBar::sigTabRequestForClosing,
    284278                    this, &UIToolbarTools::sltHandleCloseToolGlobal);
     
    291285
    292286        /* Let the tab-bars know our opinion: */
    293         sltHandleActionToggle();
    294     }
    295 }
     287        switchToTabBar(TabBarType_Machine);
     288    }
     289}
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIToolbarTools.h

    r73552 r73601  
    5757public:
    5858
     59    /** Tab-bar types. */
     60    enum TabBarType { TabBarType_Machine, TabBarType_Global };
     61
    5962    /** Constructs Tools toolbar passing @a pParent to the base-class.
    6063      * @param  pActionPool  Brings the action-pool to take corresponding actions from. */
    6164    UIToolbarTools(UIActionPool *pActionPool, QWidget *pParent = 0);
     65
     66    /** Switches to tab-bar of certain @a enmType. */
     67    void switchToTabBar(TabBarType enmType);
    6268
    6369    /** Defines whether Machine tab-bar is @a fEnabled. */
     
    8894    void sltHandleToolChosenGlobal(const QUuid &uuid);
    8995
    90     /** Handles action toggle. */
    91     void sltHandleActionToggle();
    92 
    9396private:
    9497
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