VirtualBox

Ignore:
Timestamp:
Sep 1, 2020 8:54:56 AM (4 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9812: VM settings: Prepare cascade cleanup for User Interface page.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsInterface.cpp

    r85710 r85972  
    144144    , m_pActionPool(0)
    145145    , m_pCache(0)
    146     , m_pStatusBarEditor(0)
    147     , m_pMenuBarEditor(0)
     146    , m_pEditorMenuBar(0)
     147    , m_pLabelVisualState(0)
     148    , m_pEditorVisualState(0)
     149    , m_pLabelMiniToolBar(0)
    148150    , m_pCheckBoxShowMiniToolBar(0)
    149     , m_pComboToolBarAlignment(0)
    150     , m_pLabelVisualState(0)
    151     , m_pVisualStateEditor(0)
    152     , m_pLabelMiniToolBar(0)
     151    , m_pCheckBoxToolBarAlignment(0)
     152    , m_pEditorStatusBar(0)
    153153{
    154154    /* Prepare: */
     
    217217
    218218    /* Load old interface data from the cache: */
    219     m_pStatusBarEditor->setStatusBarEnabled(oldInterfaceData.m_fStatusBarEnabled);
    220     m_pStatusBarEditor->setStatusBarConfiguration(oldInterfaceData.m_statusBarRestrictions,
     219    m_pEditorStatusBar->setStatusBarEnabled(oldInterfaceData.m_fStatusBarEnabled);
     220    m_pEditorStatusBar->setStatusBarConfiguration(oldInterfaceData.m_statusBarRestrictions,
    221221                                                  oldInterfaceData.m_statusBarOrder);
    222222#ifndef VBOX_WS_MAC
    223     m_pMenuBarEditor->setMenuBarEnabled(oldInterfaceData.m_fMenuBarEnabled);
    224 #endif
    225     m_pMenuBarEditor->setRestrictionsOfMenuBar(oldInterfaceData.m_restrictionsOfMenuBar);
    226     m_pMenuBarEditor->setRestrictionsOfMenuApplication(oldInterfaceData.m_restrictionsOfMenuApplication);
    227     m_pMenuBarEditor->setRestrictionsOfMenuMachine(oldInterfaceData.m_restrictionsOfMenuMachine);
    228     m_pMenuBarEditor->setRestrictionsOfMenuView(oldInterfaceData.m_restrictionsOfMenuView);
    229     m_pMenuBarEditor->setRestrictionsOfMenuInput(oldInterfaceData.m_restrictionsOfMenuInput);
    230     m_pMenuBarEditor->setRestrictionsOfMenuDevices(oldInterfaceData.m_restrictionsOfMenuDevices);
    231 #ifdef VBOX_WITH_DEBUGGER_GUI
    232     m_pMenuBarEditor->setRestrictionsOfMenuDebug(oldInterfaceData.m_restrictionsOfMenuDebug);
    233 #endif
    234 #ifdef VBOX_WS_MAC
    235     m_pMenuBarEditor->setRestrictionsOfMenuWindow(oldInterfaceData.m_restrictionsOfMenuWindow);
    236 #endif
    237     m_pMenuBarEditor->setRestrictionsOfMenuHelp(oldInterfaceData.m_restrictionsOfMenuHelp);
     223    m_pEditorMenuBar->setMenuBarEnabled(oldInterfaceData.m_fMenuBarEnabled);
     224#endif
     225    m_pEditorMenuBar->setRestrictionsOfMenuBar(oldInterfaceData.m_restrictionsOfMenuBar);
     226    m_pEditorMenuBar->setRestrictionsOfMenuApplication(oldInterfaceData.m_restrictionsOfMenuApplication);
     227    m_pEditorMenuBar->setRestrictionsOfMenuMachine(oldInterfaceData.m_restrictionsOfMenuMachine);
     228    m_pEditorMenuBar->setRestrictionsOfMenuView(oldInterfaceData.m_restrictionsOfMenuView);
     229    m_pEditorMenuBar->setRestrictionsOfMenuInput(oldInterfaceData.m_restrictionsOfMenuInput);
     230    m_pEditorMenuBar->setRestrictionsOfMenuDevices(oldInterfaceData.m_restrictionsOfMenuDevices);
     231#ifdef VBOX_WITH_DEBUGGER_GUI
     232    m_pEditorMenuBar->setRestrictionsOfMenuDebug(oldInterfaceData.m_restrictionsOfMenuDebug);
     233#endif
     234#ifdef VBOX_WS_MAC
     235    m_pEditorMenuBar->setRestrictionsOfMenuWindow(oldInterfaceData.m_restrictionsOfMenuWindow);
     236#endif
     237    m_pEditorMenuBar->setRestrictionsOfMenuHelp(oldInterfaceData.m_restrictionsOfMenuHelp);
    238238#ifndef VBOX_WS_MAC
    239239    m_pCheckBoxShowMiniToolBar->setChecked(oldInterfaceData.m_fShowMiniToolBar);
    240     m_pComboToolBarAlignment->setChecked(oldInterfaceData.m_fMiniToolBarAtTop);
    241 #endif
    242     m_pVisualStateEditor->setMachineId(m_machine.GetId());
    243     m_pVisualStateEditor->setValue(oldInterfaceData.m_enmVisualState);
     240    m_pCheckBoxToolBarAlignment->setChecked(oldInterfaceData.m_fMiniToolBarAtTop);
     241#endif
     242    m_pEditorVisualState->setMachineId(m_machine.GetId());
     243    m_pEditorVisualState->setValue(oldInterfaceData.m_enmVisualState);
    244244
    245245    /* Polish page finally: */
     
    256256
    257257    /* Gather new interface data: */
    258     newInterfaceData.m_fStatusBarEnabled = m_pStatusBarEditor->isStatusBarEnabled();
    259     newInterfaceData.m_statusBarRestrictions = m_pStatusBarEditor->statusBarIndicatorRestrictions();
    260     newInterfaceData.m_statusBarOrder = m_pStatusBarEditor->statusBarIndicatorOrder();
    261 #ifndef VBOX_WS_MAC
    262     newInterfaceData.m_fMenuBarEnabled = m_pMenuBarEditor->isMenuBarEnabled();
    263 #endif
    264     newInterfaceData.m_restrictionsOfMenuBar = m_pMenuBarEditor->restrictionsOfMenuBar();
    265     newInterfaceData.m_restrictionsOfMenuApplication = m_pMenuBarEditor->restrictionsOfMenuApplication();
    266     newInterfaceData.m_restrictionsOfMenuMachine = m_pMenuBarEditor->restrictionsOfMenuMachine();
    267     newInterfaceData.m_restrictionsOfMenuView = m_pMenuBarEditor->restrictionsOfMenuView();
    268     newInterfaceData.m_restrictionsOfMenuInput = m_pMenuBarEditor->restrictionsOfMenuInput();
    269     newInterfaceData.m_restrictionsOfMenuDevices = m_pMenuBarEditor->restrictionsOfMenuDevices();
    270 #ifdef VBOX_WITH_DEBUGGER_GUI
    271     newInterfaceData.m_restrictionsOfMenuDebug = m_pMenuBarEditor->restrictionsOfMenuDebug();
    272 #endif
    273 #ifdef VBOX_WS_MAC
    274     newInterfaceData.m_restrictionsOfMenuWindow = m_pMenuBarEditor->restrictionsOfMenuWindow();
    275 #endif
    276     newInterfaceData.m_restrictionsOfMenuHelp = m_pMenuBarEditor->restrictionsOfMenuHelp();
     258    newInterfaceData.m_fStatusBarEnabled = m_pEditorStatusBar->isStatusBarEnabled();
     259    newInterfaceData.m_statusBarRestrictions = m_pEditorStatusBar->statusBarIndicatorRestrictions();
     260    newInterfaceData.m_statusBarOrder = m_pEditorStatusBar->statusBarIndicatorOrder();
     261#ifndef VBOX_WS_MAC
     262    newInterfaceData.m_fMenuBarEnabled = m_pEditorMenuBar->isMenuBarEnabled();
     263#endif
     264    newInterfaceData.m_restrictionsOfMenuBar = m_pEditorMenuBar->restrictionsOfMenuBar();
     265    newInterfaceData.m_restrictionsOfMenuApplication = m_pEditorMenuBar->restrictionsOfMenuApplication();
     266    newInterfaceData.m_restrictionsOfMenuMachine = m_pEditorMenuBar->restrictionsOfMenuMachine();
     267    newInterfaceData.m_restrictionsOfMenuView = m_pEditorMenuBar->restrictionsOfMenuView();
     268    newInterfaceData.m_restrictionsOfMenuInput = m_pEditorMenuBar->restrictionsOfMenuInput();
     269    newInterfaceData.m_restrictionsOfMenuDevices = m_pEditorMenuBar->restrictionsOfMenuDevices();
     270#ifdef VBOX_WITH_DEBUGGER_GUI
     271    newInterfaceData.m_restrictionsOfMenuDebug = m_pEditorMenuBar->restrictionsOfMenuDebug();
     272#endif
     273#ifdef VBOX_WS_MAC
     274    newInterfaceData.m_restrictionsOfMenuWindow = m_pEditorMenuBar->restrictionsOfMenuWindow();
     275#endif
     276    newInterfaceData.m_restrictionsOfMenuHelp = m_pEditorMenuBar->restrictionsOfMenuHelp();
    277277#ifndef VBOX_WS_MAC
    278278    newInterfaceData.m_fShowMiniToolBar = m_pCheckBoxShowMiniToolBar->isChecked();
    279     newInterfaceData.m_fMiniToolBarAtTop = m_pComboToolBarAlignment->isChecked();
    280 #endif
    281     newInterfaceData.m_enmVisualState = m_pVisualStateEditor->value();
     279    newInterfaceData.m_fMiniToolBarAtTop = m_pCheckBoxToolBarAlignment->isChecked();
     280#endif
     281    newInterfaceData.m_enmVisualState = m_pEditorVisualState->value();
    282282
    283283    /* Cache new interface data: */
     
    299299void UIMachineSettingsInterface::retranslateUi()
    300300{
    301     m_pMenuBarEditor->setWhatsThis(tr("Allows to modify VM menu-bar contents."));
     301    m_pEditorMenuBar->setWhatsThis(tr("Allows to modify VM menu-bar contents."));
    302302    m_pLabelVisualState->setText(tr("Visual State:"));
    303     m_pVisualStateEditor->setWhatsThis(tr("Selects the visual state. If machine is running it will be applied as soon as possible,"
     303    m_pEditorVisualState->setWhatsThis(tr("Selects the visual state. If machine is running it will be applied as soon as possible,"
    304304                                          "otherwise desired one will be defined."));
    305305    m_pLabelMiniToolBar->setText(tr("Mini ToolBar:"));
    306306    m_pCheckBoxShowMiniToolBar->setWhatsThis(tr("When checked, show the Mini ToolBar in full-screen and seamless modes."));
    307307    m_pCheckBoxShowMiniToolBar->setText(tr("Show in &Full-screen/Seamless"));
    308     m_pComboToolBarAlignment->setWhatsThis(tr("When checked, show the Mini ToolBar at the top of the screen, rather than in its"
     308    m_pCheckBoxToolBarAlignment->setWhatsThis(tr("When checked, show the Mini ToolBar at the top of the screen, rather than in its"
    309309                                              "default position at the bottom of the screen."));
    310     m_pComboToolBarAlignment->setText(tr("Show at &Top of Screen"));
    311     m_pStatusBarEditor->setWhatsThis(tr("Allows to modify VM status-bar contents."));
     310    m_pCheckBoxToolBarAlignment->setText(tr("Show at &Top of Screen"));
     311    m_pEditorStatusBar->setWhatsThis(tr("Allows to modify VM status-bar contents."));
    312312}
    313313
     
    315315{
    316316    /* Polish interface page availability: */
    317     m_pMenuBarEditor->setEnabled(isMachineInValidMode());
     317    m_pEditorMenuBar->setEnabled(isMachineInValidMode());
    318318#ifdef VBOX_WS_MAC
    319319    m_pLabelMiniToolBar->hide();
    320320    m_pCheckBoxShowMiniToolBar->hide();
    321     m_pComboToolBarAlignment->hide();
     321    m_pCheckBoxToolBarAlignment->hide();
    322322#else /* !VBOX_WS_MAC */
    323323    m_pLabelMiniToolBar->setEnabled(isMachineInValidMode());
    324324    m_pCheckBoxShowMiniToolBar->setEnabled(isMachineInValidMode());
    325     m_pComboToolBarAlignment->setEnabled(isMachineInValidMode() && m_pCheckBoxShowMiniToolBar->isChecked());
    326 #endif /* !VBOX_WS_MAC */
    327     m_pStatusBarEditor->setEnabled(isMachineInValidMode());
    328 }
    329 
    330 void UIMachineSettingsInterface::prepareWidgets()
    331 {
    332     if (objectName().isEmpty())
    333         setObjectName(QStringLiteral("UIMachineSettingsInterface"));
    334     resize(350, 300);
    335     QGridLayout *pLayoutMain = new QGridLayout(this);
    336     pLayoutMain->setObjectName(QStringLiteral("pLayoutMain"));
    337     m_pMenuBarEditor = new UIMenuBarEditorWidget(this);
    338     m_pMenuBarEditor->setObjectName(QStringLiteral("m_pMenuBarEditor"));
    339     QSizePolicy sizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
    340     sizePolicy.setHorizontalStretch(0);
    341     sizePolicy.setVerticalStretch(0);
    342     sizePolicy.setHeightForWidth(m_pMenuBarEditor->sizePolicy().hasHeightForWidth());
    343     m_pMenuBarEditor->setSizePolicy(sizePolicy);
    344     pLayoutMain->addWidget(m_pMenuBarEditor, 0, 0, 1, 3);
    345 
    346     m_pLabelVisualState = new QLabel;
    347     m_pLabelVisualState->setObjectName(QStringLiteral("m_pLabelVisualState"));
    348     m_pLabelVisualState->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
    349     pLayoutMain->addWidget(m_pLabelVisualState, 1, 0, 1, 1);
    350 
    351     m_pVisualStateEditor = new UIVisualStateEditor;
    352     m_pVisualStateEditor->setObjectName(QStringLiteral("m_pVisualStateEditor"));
    353     pLayoutMain->addWidget(m_pVisualStateEditor, 1, 1, 1, 2);
    354 
    355     m_pLabelMiniToolBar = new QLabel;
    356     m_pLabelMiniToolBar->setObjectName(QStringLiteral("m_pLabelMiniToolBar"));
    357     m_pLabelMiniToolBar->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
    358     pLayoutMain->addWidget(m_pLabelMiniToolBar, 2, 0, 1, 1);
    359 
    360     m_pCheckBoxShowMiniToolBar = new QCheckBox;
    361     m_pCheckBoxShowMiniToolBar->setObjectName(QStringLiteral("m_pCheckBoxShowMiniToolBar"));
    362     sizePolicy.setHeightForWidth(m_pCheckBoxShowMiniToolBar->sizePolicy().hasHeightForWidth());
    363     m_pCheckBoxShowMiniToolBar->setSizePolicy(sizePolicy);
    364     m_pCheckBoxShowMiniToolBar->setChecked(true);
    365     pLayoutMain->addWidget(m_pCheckBoxShowMiniToolBar, 2, 1, 1, 2);
    366 
    367     m_pComboToolBarAlignment = new QCheckBox;
    368     m_pComboToolBarAlignment->setObjectName(QStringLiteral("m_pComboToolBarAlignment"));
    369     sizePolicy.setHeightForWidth(m_pComboToolBarAlignment->sizePolicy().hasHeightForWidth());
    370     m_pComboToolBarAlignment->setSizePolicy(sizePolicy);
    371     m_pComboToolBarAlignment->setChecked(false);
    372     pLayoutMain->addWidget(m_pComboToolBarAlignment, 3, 1, 1, 2);
    373 
    374     QSpacerItem *pSpacer = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
    375     pLayoutMain->addItem(pSpacer, 4, 0, 1, 3);
    376 
    377     m_pStatusBarEditor = new UIStatusBarEditorWidget(this);
    378     m_pStatusBarEditor->setObjectName(QStringLiteral("m_pStatusBarEditor"));
    379     sizePolicy.setHeightForWidth(m_pStatusBarEditor->sizePolicy().hasHeightForWidth());
    380     m_pStatusBarEditor->setSizePolicy(sizePolicy);
    381     pLayoutMain->addWidget(m_pStatusBarEditor, 5, 0, 1, 3);
    382 
    383     QObject::connect(m_pCheckBoxShowMiniToolBar, &QCheckBox::toggled,
    384                      m_pComboToolBarAlignment, &UIMachineSettingsInterface::setEnabled);
     325    m_pCheckBoxToolBarAlignment->setEnabled(isMachineInValidMode() && m_pCheckBoxShowMiniToolBar->isChecked());
     326#endif /* !VBOX_WS_MAC */
     327    m_pEditorStatusBar->setEnabled(isMachineInValidMode());
    385328}
    386329
    387330void UIMachineSettingsInterface::prepare()
    388331{
    389     prepareWidgets();
     332    /* Prepare action-pool: */
     333    m_pActionPool = UIActionPool::create(UIActionPoolType_Runtime);
    390334
    391335    /* Prepare cache: */
     
    393337    AssertPtrReturnVoid(m_pCache);
    394338
    395     /* Layout created in the .ui file. */
    396     {
    397         /* Menu-bar editor created in the .ui file. */
    398         AssertPtrReturnVoid(m_pMenuBarEditor);
    399         {
    400             /* Configure editor: */
    401             m_pActionPool = UIActionPool::create(UIActionPoolType_Runtime);
    402             m_pMenuBarEditor->setActionPool(m_pActionPool);
    403             m_pMenuBarEditor->setMachineID(m_uMachineId);
    404         }
    405 
    406         /* Status-bar editor created in the .ui file. */
    407         AssertPtrReturnVoid(m_pStatusBarEditor);
    408         {
    409             /* Configure editor: */
    410             m_pStatusBarEditor->setMachineID(m_uMachineId);
    411         }
    412     }
     339    /* Prepare everything: */
     340    prepareWidgets();
     341    prepareConnections();
    413342
    414343    /* Apply language settings: */
     
    416345}
    417346
     347void UIMachineSettingsInterface::prepareWidgets()
     348{
     349    /* Prepare main layout: */
     350    QGridLayout *pLayoutMain = new QGridLayout(this);
     351    if (pLayoutMain)
     352    {
     353        pLayoutMain->setColumnStretch(1, 1);
     354        pLayoutMain->setRowStretch(4, 1);
     355
     356        /* Prepare menu-bar editor: */
     357        m_pEditorMenuBar = new UIMenuBarEditorWidget(this);
     358        if (m_pEditorMenuBar)
     359        {
     360            m_pEditorMenuBar->setActionPool(m_pActionPool);
     361            m_pEditorMenuBar->setMachineID(m_uMachineId);
     362
     363            pLayoutMain->addWidget(m_pEditorMenuBar, 0, 0, 1, 2);
     364        }
     365
     366        /* Prepare visual-state label: */
     367        m_pLabelVisualState = new QLabel(this);
     368        if (m_pLabelVisualState)
     369        {
     370            m_pLabelVisualState->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
     371            pLayoutMain->addWidget(m_pLabelVisualState, 1, 0);
     372        }
     373        /* Prepare visual-state editor: */
     374        m_pEditorVisualState = new UIVisualStateEditor(this);
     375        if (m_pEditorVisualState)
     376            pLayoutMain->addWidget(m_pEditorVisualState, 1, 1);
     377
     378        /* Prepare mini-toolbar label: */
     379        m_pLabelMiniToolBar = new QLabel(this);
     380        if (m_pLabelMiniToolBar)
     381        {
     382            m_pLabelMiniToolBar->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
     383            pLayoutMain->addWidget(m_pLabelMiniToolBar, 2, 0);
     384        }
     385        /* Prepare show mini-toolbar check-box: */
     386        m_pCheckBoxShowMiniToolBar = new QCheckBox(this);
     387        if (m_pCheckBoxShowMiniToolBar)
     388            pLayoutMain->addWidget(m_pCheckBoxShowMiniToolBar, 2, 1);
     389        /* Prepare mini-toolbar alignment check-box: */
     390        m_pCheckBoxToolBarAlignment = new QCheckBox(this);
     391        if (m_pCheckBoxToolBarAlignment)
     392            pLayoutMain->addWidget(m_pCheckBoxToolBarAlignment, 3, 1);
     393
     394        /* Prepare status-bar editor: */
     395        m_pEditorStatusBar = new UIStatusBarEditorWidget(this);
     396        if (m_pEditorStatusBar)
     397        {
     398            m_pEditorStatusBar->setMachineID(m_uMachineId);
     399            pLayoutMain->addWidget(m_pEditorStatusBar, 5, 0, 1, 2);
     400        }
     401    }
     402}
     403
     404void UIMachineSettingsInterface::prepareConnections()
     405{
     406    connect(m_pCheckBoxShowMiniToolBar, &QCheckBox::toggled,
     407            m_pCheckBoxToolBarAlignment, &UIMachineSettingsInterface::setEnabled);
     408}
     409
    418410void UIMachineSettingsInterface::cleanup()
    419411{
    420     /* Destroy personal action-pool: */
     412    /* Cleanup action-pool: */
    421413    UIActionPool::destroy(m_pActionPool);
    422414
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsInterface.h

    r85679 r85972  
    7878    /** Prepares widgets. */
    7979    void prepareWidgets();
     80    /** Prepares connections. */
     81    void prepareConnections();
    8082    /** Cleanups all. */
    8183    void cleanup();
     
    102104    /** @name Widgets
    103105     * @{ */
    104         UIStatusBarEditorWidget *m_pStatusBarEditor;
    105         UIMenuBarEditorWidget *m_pMenuBarEditor;
    106         QCheckBox *m_pCheckBoxShowMiniToolBar;
    107         QCheckBox *m_pComboToolBarAlignment;
    108         QLabel *m_pLabelVisualState;
    109         UIVisualStateEditor *m_pVisualStateEditor;
    110         QLabel *m_pLabelMiniToolBar;
     106        /** Holds the menu-bar editor instance. */
     107        UIMenuBarEditorWidget   *m_pEditorMenuBar;
     108        /** Holds the visual state label instance. */
     109        QLabel                  *m_pLabelVisualState;
     110        /** Holds the visual state label instance. */
     111        UIVisualStateEditor     *m_pEditorVisualState;
     112        /** Holds the mini-toolbar label instance. */
     113        QLabel                  *m_pLabelMiniToolBar;
     114        /** Holds the show mini-toolbar check-box instance. */
     115        QCheckBox               *m_pCheckBoxShowMiniToolBar;
     116        /** Holds the mini-toolbar alignment check-box instance. */
     117        QCheckBox               *m_pCheckBoxToolBarAlignment;
     118        /** Holds the status-bar editor instance. */
     119        UIStatusBarEditorWidget *m_pEditorStatusBar;
    111120    /** @} */
    112121};
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