VirtualBox

Changeset 68225 in vbox for trunk/src


Ignore:
Timestamp:
Aug 2, 2017 8:35:17 AM (7 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:8900: UIToolsToolbar: Get rid of stacked-layout.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UIToolsToolbar.cpp

    r68212 r68225  
    2323# include <QAction>
    2424# include <QButtonGroup>
     25# include <QHBoxLayout>
    2526# include <QLabel>
    26 # include <QStackedLayout>
    2727# include <QToolButton>
    2828
     
    4343    , m_pActionPool(pActionPool)
    4444    , m_pLayoutMain(0)
    45     , m_pLayoutStacked(0)
    4645    , m_pTabBarMachine(0)
    4746    , m_pTabBarGlobal(0)
     
    147146void UIToolsToolbar::sltHandleActionToggle()
    148147{
    149     /* Acquire the sender: */
    150     UIAction *pAction = sender() ? qobject_cast<UIAction*>(sender()) : 0;
    151     if (!pAction)
    152         pAction = m_pActionPool->action(UIActionIndexST_M_Tools_T_Machine);
    153 
    154148    /* Handle known actions: */
    155     if (m_pLayoutStacked)
    156     {
    157         if (pAction == m_pActionPool->action(UIActionIndexST_M_Tools_T_Machine))
    158             m_pLayoutStacked->setCurrentWidget(m_pTabBarMachine);
    159 
    160         else
    161 
    162         if (pAction == m_pActionPool->action(UIActionIndexST_M_Tools_T_Global))
    163             m_pLayoutStacked->setCurrentWidget(m_pTabBarGlobal);
    164     }
     149    const bool fShowMachine = m_pActionPool->action(UIActionIndexST_M_Tools_T_Machine)->isChecked();
     150    const bool fShowGlobal  = m_pActionPool->action(UIActionIndexST_M_Tools_T_Global)->isChecked();
     151    if (m_pTabBarMachine)
     152        m_pTabBarMachine->setHidden(!fShowMachine);
     153    if (m_pTabBarGlobal)
     154        m_pTabBarGlobal->setHidden(!fShowGlobal);
    165155}
    166156
     
    171161    /* Prepare widgets: */
    172162    prepareWidgets();
     163
     164    /* Make sure just one tab-bar shown initially: */
     165    sltHandleActionToggle();
    173166}
    174167
     
    237230        m_pLayoutMain->setSpacing(10);
    238231
    239         /* Create stacked layout: */
    240         m_pLayoutStacked = new QStackedLayout(m_pLayoutMain);
    241         AssertPtrReturnVoid(m_pLayoutStacked);
     232        /* Create Machine tab-bar: */
     233        m_pTabBarMachine = new UITabBar;
     234        AssertPtrReturnVoid(m_pTabBarMachine);
    242235        {
    243             /* Create Machine tab-bar: */
    244             m_pTabBarMachine = new UITabBar;
    245             AssertPtrReturnVoid(m_pTabBarMachine);
    246             {
    247                 /* Configure tab-bar: */
    248                 connect(m_pTabBarMachine, &UITabBar::sigTabRequestForClosing,
    249                         this, &UIToolsToolbar::sltHandleCloseToolMachine);
    250                 connect(m_pTabBarMachine, &UITabBar::sigCurrentTabChanged,
    251                         this, &UIToolsToolbar::sltHandleToolChosenMachine);
    252 
    253                 /* Add into layout: */
    254                 m_pLayoutStacked->addWidget(m_pTabBarMachine);
    255             }
    256 
    257             /* Create Global tab-bar: */
    258             m_pTabBarGlobal = new UITabBar;
    259             AssertPtrReturnVoid(m_pTabBarGlobal);
    260             {
    261                 /* Configure tab-bar: */
    262                 connect(m_pTabBarGlobal, &UITabBar::sigTabRequestForClosing,
    263                         this, &UIToolsToolbar::sltHandleCloseToolGlobal);
    264                 connect(m_pTabBarGlobal, &UITabBar::sigCurrentTabChanged,
    265                         this, &UIToolsToolbar::sltHandleToolChosenGlobal);
    266 
    267                 /* Add into layout: */
    268                 m_pLayoutStacked->addWidget(m_pTabBarGlobal);
    269             }
     236            /* Configure tab-bar: */
     237            connect(m_pTabBarMachine, &UITabBar::sigTabRequestForClosing,
     238                    this, &UIToolsToolbar::sltHandleCloseToolMachine);
     239            connect(m_pTabBarMachine, &UITabBar::sigCurrentTabChanged,
     240                    this, &UIToolsToolbar::sltHandleToolChosenMachine);
    270241
    271242            /* Add into layout: */
    272             m_pLayoutMain->addLayout(m_pLayoutStacked);
     243            m_pLayoutMain->addWidget(m_pTabBarMachine);
     244        }
     245
     246        /* Create Global tab-bar: */
     247        m_pTabBarGlobal = new UITabBar;
     248        AssertPtrReturnVoid(m_pTabBarGlobal);
     249        {
     250            /* Configure tab-bar: */
     251            connect(m_pTabBarGlobal, &UITabBar::sigTabRequestForClosing,
     252                    this, &UIToolsToolbar::sltHandleCloseToolGlobal);
     253            connect(m_pTabBarGlobal, &UITabBar::sigCurrentTabChanged,
     254                    this, &UIToolsToolbar::sltHandleToolChosenGlobal);
     255
     256            /* Add into layout: */
     257            m_pLayoutMain->addWidget(m_pTabBarGlobal);
    273258        }
    274259
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UIToolsToolbar.h

    r68212 r68225  
    3131class QAction;
    3232class QHBoxLayout;
    33 class QStackedLayout;
    3433class QUuid;
    3534class QWidget;
     
    9897
    9998    /** Holds the main layout instance. */
    100     QHBoxLayout    *m_pLayoutMain;
    101     /** Holds the stacked layout instance. */
    102     QStackedLayout *m_pLayoutStacked;
     99    QHBoxLayout *m_pLayoutMain;
    103100
    104101    /** Holds the Machine tab-bar instance. */
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