VirtualBox

Changeset 68230 in vbox


Ignore:
Timestamp:
Aug 2, 2017 9:40:44 AM (7 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:8900: Selector UI: Move tab-bars out of the UIToolsToolbar to UISelectorWindow allowing main toolbar to control tab-bars visibility directly; that should fix the layout issues.

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

Legend:

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

    r68221 r68230  
    4646# include "UISlidingWidget.h"
    4747# include "UISpacerWidgets.h"
     48# include "UITabBar.h"
    4849# include "UIToolBar.h"
    4950# include "UIVMLogViewer.h"
     
    118119#endif
    119120    , m_pToolBar(0)
     121    , m_pTabBarMachine(0)
     122    , m_pTabBarGlobal(0)
     123    , m_pActionTabBarMachine(0)
     124    , m_pActionTabBarGlobal(0)
    120125    , m_pToolbarTools(0)
    121126    , m_pPaneChooser(0)
     
    152157}
    153158#endif /* VBOX_WS_X11 && QT_VERSION >= 0x050000 */
     159
     160void UISelectorWindow::sltHandleShowTabBarMachine()
     161{
     162    m_pActionTabBarGlobal->setVisible(false);
     163    m_pActionTabBarMachine->setVisible(true);
     164}
     165
     166void UISelectorWindow::sltHandleShowTabBarGlobal()
     167{
     168    m_pActionTabBarMachine->setVisible(false);
     169    m_pActionTabBarGlobal->setVisible(true);
     170}
    154171
    155172void UISelectorWindow::sltShowSelectorWindowContextMenu(const QPoint &position)
     
    18001817        m_pToolBar->addWidget(new UIHorizontalSpacerWidget);
    18011818
     1819        /* Create Machine tab-bar: */
     1820        m_pTabBarMachine = new UITabBar;
     1821        AssertPtrReturnVoid(m_pTabBarMachine);
     1822        {
     1823            /* Configure tab-bar: */
     1824            m_pTabBarMachine->setContentsMargins(0, 0, 10, 0);
     1825
     1826            /* Add into toolbar: */
     1827            m_pActionTabBarMachine = m_pToolBar->addWidget(m_pTabBarMachine);
     1828        }
     1829
     1830        /* Create Global tab-bar: */
     1831        m_pTabBarGlobal = new UITabBar;
     1832        AssertPtrReturnVoid(m_pTabBarGlobal);
     1833        {
     1834            /* Configure tab-bar: */
     1835            m_pTabBarGlobal->setContentsMargins(0, 0, 10, 0);
     1836
     1837            /* Add into toolbar: */
     1838            m_pActionTabBarGlobal = m_pToolBar->addWidget(m_pTabBarGlobal);
     1839        }
     1840
    18021841        /* Create Tools toolbar: */
    18031842        m_pToolbarTools = new UIToolsToolbar(actionPool());
     
    18061845            /* Configure toolbar: */
    18071846            m_pToolbarTools->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::MinimumExpanding);
     1847            connect(m_pToolbarTools, &UIToolsToolbar::sigShowTabBarMachine,
     1848                    this, &UISelectorWindow::sltHandleShowTabBarMachine);
     1849            connect(m_pToolbarTools, &UIToolsToolbar::sigShowTabBarGlobal,
     1850                    this, &UISelectorWindow::sltHandleShowTabBarGlobal);
     1851            m_pToolbarTools->setTabBars(m_pTabBarMachine, m_pTabBarGlobal);
    18081852
    18091853            /* Create exclusive action-group: */
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.h

    r68200 r68230  
    4040#endif
    4141class UISlidingWidget;
     42class UITabBar;
    4243class UIToolBar;
    4344class UIToolsToolbar;
     
    8283    void QT_VERSION_NOT_DEFINED
    8384#endif /* VBOX_WS_X11 && QT_VERSION >= 0x050000 */
     85
     86    /** Handles request to show Machine tab-bar. */
     87    void sltHandleShowTabBarMachine();
     88    /** Handles request to show Global tab-bar. */
     89    void sltHandleShowTabBarGlobal();
    8490
    8591    /** Handles selector-window context-menu call for passed @a position. */
     
    333339#ifndef VBOX_WS_MAC
    334340    /** Holds the main bar instance. */
    335     UIMainBar      *m_pBar;
     341    UIMainBar *m_pBar;
    336342#endif
    337343    /** Holds the main toolbar instance. */
    338     UIToolBar      *m_pToolBar;
     344    UIToolBar *m_pToolBar;
     345
     346    /** Holds the Machine tab-bar instance. */
     347    UITabBar *m_pTabBarMachine;
     348    /** Holds the Global tab-bar instance. */
     349    UITabBar *m_pTabBarGlobal;
     350    /** Holds the Machine tab-bar action reference. */
     351    QAction *m_pActionTabBarMachine;
     352    /** Holds the Global tab-bar action reference. */
     353    QAction *m_pActionTabBarGlobal;
     354
    339355    /** Holds the Tools-toolbar instance. */
    340356    UIToolsToolbar *m_pToolbarTools;
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UIToolsToolbar.cpp

    r68225 r68230  
    4242    : QWidget(pParent)
    4343    , m_pActionPool(pActionPool)
    44     , m_pLayoutMain(0)
    4544    , m_pTabBarMachine(0)
    4645    , m_pTabBarGlobal(0)
     46    , m_pLayoutMain(0)
    4747    , m_pToolBar(0)
    4848{
    4949    /* Prepare: */
    5050    prepare();
     51}
     52
     53void UIToolsToolbar::setTabBars(UITabBar *pTabBarMachine, UITabBar *pTabBarGlobal)
     54{
     55    /* Remember the new tab-bars: */
     56    m_pTabBarMachine = pTabBarMachine;
     57    m_pTabBarGlobal = pTabBarGlobal;
     58
     59    /* Configure tab-bar connections: */
     60    connect(m_pTabBarMachine, &UITabBar::sigTabRequestForClosing,
     61            this, &UIToolsToolbar::sltHandleCloseToolMachine);
     62    connect(m_pTabBarMachine, &UITabBar::sigCurrentTabChanged,
     63            this, &UIToolsToolbar::sltHandleToolChosenMachine);
     64    connect(m_pTabBarGlobal, &UITabBar::sigTabRequestForClosing,
     65            this, &UIToolsToolbar::sltHandleCloseToolGlobal);
     66    connect(m_pTabBarGlobal, &UITabBar::sigCurrentTabChanged,
     67            this, &UIToolsToolbar::sltHandleToolChosenGlobal);
     68
     69    /* Let the tab-bars know our opinion: */
     70    sltHandleActionToggle();
    5171}
    5272
     
    147167{
    148168    /* Handle known actions: */
    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);
     169    if (m_pActionPool->action(UIActionIndexST_M_Tools_T_Machine)->isChecked())
     170        emit sigShowTabBarMachine();
     171    else if (m_pActionPool->action(UIActionIndexST_M_Tools_T_Global)->isChecked())
     172        emit sigShowTabBarGlobal();
    155173}
    156174
     
    228246        /* Configure layout: */
    229247        m_pLayoutMain->setContentsMargins(0, 0, 0, 0);
    230         m_pLayoutMain->setSpacing(10);
    231 
    232         /* Create Machine tab-bar: */
    233         m_pTabBarMachine = new UITabBar;
    234         AssertPtrReturnVoid(m_pTabBarMachine);
    235         {
    236             /* Configure tab-bar: */
    237             connect(m_pTabBarMachine, &UITabBar::sigTabRequestForClosing,
    238                     this, &UIToolsToolbar::sltHandleCloseToolMachine);
    239             connect(m_pTabBarMachine, &UITabBar::sigCurrentTabChanged,
    240                     this, &UIToolsToolbar::sltHandleToolChosenMachine);
    241 
    242             /* Add into layout: */
    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);
    258         }
    259248
    260249        /* Create toolbar: */
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UIToolsToolbar.h

    r68225 r68230  
    4545signals:
    4646
    47     /** Notify listeners about Machine tool of particular @a enmType opened. */
     47    /** Notifies listeners about Machine tab-bar should be shown. */
     48    void sigShowTabBarMachine();
     49    /** Notifies listeners about Global tab-bar should be shown. */
     50    void sigShowTabBarGlobal();
     51
     52    /** Notifies listeners about Machine tool of particular @a enmType opened. */
    4853    void sigToolOpenedMachine(const ToolTypeMachine enmType);
    49     /** Notify listeners about Global tool of particular @a enmType opened. */
     54    /** Notifies listeners about Global tool of particular @a enmType opened. */
    5055    void sigToolOpenedGlobal(const ToolTypeGlobal enmType);
    5156
    52     /** Notify listeners about Machine tool of particular @a enmType closed. */
     57    /** Notifies listeners about Machine tool of particular @a enmType closed. */
    5358    void sigToolClosedMachine(const ToolTypeMachine enmType);
    54     /** Notify listeners about Global tool of particular @a enmType closed. */
     59    /** Notifies listeners about Global tool of particular @a enmType closed. */
    5560    void sigToolClosedGlobal(const ToolTypeGlobal enmType);
    5661
     
    6065      * @param  pActionPool  Brings the action-pool to take corresponding actions from. */
    6166    UIToolsToolbar(UIActionPool *pActionPool, QWidget *pParent = 0);
     67
     68    /** Defines the tab-bars to control. */
     69    void setTabBars(UITabBar *pTabBarMachine, UITabBar *pTabBarGlobal);
    6270
    6371    /** Defines toolbar tool button @a enmStyle. */
     
    96104    UIActionPool *m_pActionPool;
    97105
    98     /** Holds the main layout instance. */
    99     QHBoxLayout *m_pLayoutMain;
    100 
    101106    /** Holds the Machine tab-bar instance. */
    102107    UITabBar *m_pTabBarMachine;
     
    104109    UITabBar *m_pTabBarGlobal;
    105110
     111    /** Holds the main layout instance. */
     112    QHBoxLayout *m_pLayoutMain;
    106113    /** Holds the toolbar instance. */
    107     UIToolBar *m_pToolBar;
     114    UIToolBar   *m_pToolBar;
    108115
    109116    /** Holds the map of opened Machine tool IDs. */
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