VirtualBox

Changeset 54527 in vbox


Ignore:
Timestamp:
Feb 26, 2015 1:01:00 PM (10 years ago)
Author:
vboxsync
Message:

FE/Qt: 7462: Add menu-bar enable check-box to menu-bar editor opened from the VM settings / Interface page.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMenuBarEditorWindow.cpp

    r54350 r54527  
    2424# include <QPaintEvent>
    2525# include <QMetaEnum>
     26# include <QCheckBox>
    2627# include <QMenuBar>
    2728# include <QPainter>
     
    5455    , m_pToolBar(0)
    5556    , m_pButtonClose(0)
     57    , m_pCheckBoxEnable(0)
    5658{
    5759    /* Prepare: */
     
    8183        return;
    8284
     85    /* Update enable-checkbox: */
     86    updateEnableCheckbox();
     87
    8388    /* Update menus: */
    8489    updateMenus();
     90}
     91
     92void UIMenuBarEditorWidget::sltHandleMenuBarEnableToggle(bool fEnabled)
     93{
     94    /* Toggle enable-checkbox if necessary: */
     95    if (m_fStartedFromVMSettings && m_pCheckBoxEnable)
     96    {
     97        /* Check whether this value is really changed: */
     98        const bool fMenuBarEnabled = gEDataManager->menuBarEnabled(machineID());
     99        if (fMenuBarEnabled != fEnabled)
     100        {
     101            /* Set new value: */
     102            gEDataManager->setMenuBarEnabled(fEnabled, machineID());
     103        }
     104    }
    85105}
    86106
     
    236256    {
    237257        /* Configure main-layout: */
    238 #ifdef Q_WS_MAC
    239         /* Standard margins on Mac OS X are too big: */
    240         m_pMainLayout->setContentsMargins(10, 5, 10, 10);
    241 #else /* !Q_WS_MAC */
    242         /* Standard margins on Windows/X11: */
    243258        int iLeft, iTop, iRight, iBottom;
    244259        m_pMainLayout->getContentsMargins(&iLeft, &iTop, &iRight, &iBottom);
     260        /* Standard margins should not be too big: */
     261        iLeft   = qMin(iLeft,   10);
     262        iTop    = qMin(iTop,    10);
     263        iRight  = qMin(iRight,  10);
     264        iBottom = qMin(iBottom, 10);
     265        /* Top margin should be smaller for the common case: */
    245266        if (iTop >= 5)
    246267            iTop -= 5;
     268        /* Right margin should be bigger for the settings case: */
     269        if (m_fStartedFromVMSettings)
     270            iRight += 5;
     271        /* Apply margins/spacing finally: */
    247272        m_pMainLayout->setContentsMargins(iLeft, iTop, iRight, iBottom);
    248 #endif /* !Q_WS_MAC */
    249273        m_pMainLayout->setSpacing(0);
    250274        /* Create tool-bar: */
     
    272296                /* Add close-button into main-layout: */
    273297                m_pMainLayout->addWidget(m_pButtonClose);
     298            }
     299        }
     300        /* Create enable-checkbox if necessary: */
     301        else
     302        {
     303            m_pCheckBoxEnable = new QCheckBox;
     304            AssertPtrReturnVoid(m_pCheckBoxEnable);
     305            {
     306                /* Configure enable-checkbox: */
     307                m_pCheckBoxEnable->setFocusPolicy(Qt::StrongFocus);
     308                connect(m_pCheckBoxEnable, SIGNAL(toggled(bool)), this, SLOT(sltHandleMenuBarEnableToggle(bool)));
     309                /* Add enable-checkbox into main-layout: */
     310                m_pMainLayout->addWidget(m_pCheckBoxEnable);
     311                /* Update enable-checkbox: */
     312                updateEnableCheckbox();
    274313            }
    275314        }
     
    599638}
    600639
     640void UIMenuBarEditorWidget::updateEnableCheckbox()
     641{
     642    /* Update enable-checkbox if necessary: */
     643    if (m_fStartedFromVMSettings && m_pCheckBoxEnable)
     644    {
     645        m_pCheckBoxEnable->blockSignals(true);
     646        m_pCheckBoxEnable->setChecked(gEDataManager->menuBarEnabled(machineID()));
     647        m_pCheckBoxEnable->blockSignals(false);
     648    }
     649}
     650
    601651void UIMenuBarEditorWidget::updateMenus()
    602652{
     
    887937    if (!m_fStartedFromVMSettings && m_pButtonClose)
    888938        m_pButtonClose->setToolTip(tr("Close"));
     939    /* Translate enable-checkbox if necessary: */
     940    if (m_fStartedFromVMSettings && m_pCheckBoxEnable)
     941        m_pCheckBoxEnable->setToolTip(tr("Enable Menu Bar"));
    889942}
    890943
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMenuBarEditorWindow.h

    r54272 r54527  
    3131class UIAction;
    3232class QIToolButton;
     33class QCheckBox;
    3334class QHBoxLayout;
    3435class QAction;
     
    8687    void sltHandleConfigurationChange(const QString &strMachineID);
    8788
     89    /** Handles menu-bar enable toggle. */
     90    void sltHandleMenuBarEnableToggle(bool fEnabled);
    8891    /** Handles menu-bar menu click. */
    8992    void sltHandleMenuBarMenuClick();
     
    135138    void prepareMenuHelp();
    136139
    137     /** Updates menus routine. */
     140    /** Update enable-checkbox routine. */
     141    void updateEnableCheckbox();
     142    /** Update menus routine. */
    138143    void updateMenus();
    139144#ifdef Q_WS_MAC
    140     /** Mac OS X: Updates 'Application' menu routine. */
     145    /** Mac OS X: Update 'Application' menu routine. */
    141146    void updateMenuApplication();
    142147#endif /* Q_WS_MAC */
    143     /** Updates 'Machine' menu routine. */
     148    /** Update 'Machine' menu routine. */
    144149    void updateMenuMachine();
    145     /** Updates 'View' menu routine. */
     150    /** Update 'View' menu routine. */
    146151    void updateMenuView();
    147     /** Updates 'Input' menu routine. */
     152    /** Update 'Input' menu routine. */
    148153    void updateMenuInput();
    149     /** Updates 'Devices' menu routine. */
     154    /** Update 'Devices' menu routine. */
    150155    void updateMenuDevices();
    151156#ifdef VBOX_WITH_DEBUGGER_GUI
    152     /** Updates 'Debug' menu routine. */
     157    /** Update 'Debug' menu routine. */
    153158    void updateMenuDebug();
    154159#endif /* VBOX_WITH_DEBUGGER_GUI */
    155160#ifdef Q_WS_MAC
    156     /** Mac OS X: Updates 'Window' menu routine. */
     161    /** Mac OS X: Update 'Window' menu routine. */
    157162    void updateMenuWindow();
    158163#endif /* Q_WS_MAC */
    159     /** Updates 'Help' menu routine. */
     164    /** Update 'Help' menu routine. */
    160165    void updateMenuHelp();
    161166
     
    186191        /** Holds the close-button instance. */
    187192        QIToolButton *m_pButtonClose;
     193        /** Holds the enable-checkbox instance. */
     194        QCheckBox *m_pCheckBoxEnable;
    188195        /** Holds tool-bar action references. */
    189196        QMap<QString, QAction*> m_actions;
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