VirtualBox

Ignore:
Timestamp:
Aug 25, 2020 11:35:49 AM (4 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9812: VM settings: Prepare cascade cleanup for Audio 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/UIMachineSettingsAudio.cpp

    r85710 r85883  
    7676UIMachineSettingsAudio::UIMachineSettingsAudio()
    7777    : m_pCache(0)
     78    , m_pCheckBoxAudio(0)
     79    , m_pWidgetAudioSettings(0)
    7880    , m_pAudioHostDriverLabel(0)
     81    , m_pAudioHostDriverEditor(0)
    7982    , m_pAudioControllerLabel(0)
     83    , m_pAudioControllerEditor(0)
    8084    , m_pLabelAudioExtended(0)
    81     , m_pContainerAudioSubOptions(0)
    82     , m_pAudioHostDriverEditor(0)
    83     , m_pAudioControllerEditor(0)
     85    , m_pCheckBoxAudioOutput(0)
     86    , m_pCheckBoxAudioInput(0)
    8487{
    8588    /* Prepare: */
     
    208211    m_pCheckBoxAudioOutput->setEnabled(isMachineInValidMode());
    209212    m_pCheckBoxAudioInput->setEnabled(isMachineInValidMode());
    210     m_pContainerAudioSubOptions->setEnabled(m_pCheckBoxAudio->isChecked());
     213    m_pWidgetAudioSettings->setEnabled(m_pCheckBoxAudio->isChecked());
    211214}
    212215
    213216void UIMachineSettingsAudio::prepare()
    214217{
    215     prepareWidgets();
    216 
    217218    /* Prepare cache: */
    218219    m_pCache = new UISettingsCacheMachineAudio;
    219220    AssertPtrReturnVoid(m_pCache);
    220221
    221     /* Layout created in the .ui file. */
     222    /* Prepare everything: */
     223    prepareWidgets();
     224    prepareConnections();
     225
     226    /* Apply language settings: */
     227    retranslateUi();
     228}
     229
     230void UIMachineSettingsAudio::prepareWidgets()
     231{
     232    /* Prepare main layout: */
     233    QGridLayout *pMainLayout = new QGridLayout(this);
     234    if (pMainLayout)
    222235    {
    223         /* Audio host-driver label & editor created in the .ui file. */
    224         AssertPtrReturnVoid(m_pAudioHostDriverLabel);
    225         AssertPtrReturnVoid(m_pAudioHostDriverEditor);
     236        pMainLayout->setRowStretch(2, 1);
     237
     238        /* Prepare audio check-box: */
     239        m_pCheckBoxAudio = new QCheckBox(this);
     240        if (m_pCheckBoxAudio)
     241            pMainLayout->addWidget(m_pCheckBoxAudio, 0, 0, 1, 2);
     242
     243        /* Prepare 20-px shifting spacer: */
     244        QSpacerItem *pSpacerItem = new QSpacerItem(20, 0, QSizePolicy::Fixed, QSizePolicy::Minimum);
     245        if (pSpacerItem)
     246            pMainLayout->addItem(pSpacerItem, 1, 0);
     247
     248        /* Prepare audio settings widget: */
     249        m_pWidgetAudioSettings = new QWidget(this);
     250        if (m_pWidgetAudioSettings)
    226251        {
    227             /* Configure label & editor: */
    228             m_pAudioHostDriverLabel->setBuddy(m_pAudioHostDriverEditor->focusProxy());
    229         }
    230 
    231         /* Audio controller label & editor created in the .ui file. */
    232         AssertPtrReturnVoid(m_pAudioControllerLabel);
    233         AssertPtrReturnVoid(m_pAudioControllerEditor);
    234         {
    235             /* Configure label & editor: */
    236             m_pAudioControllerLabel->setBuddy(m_pAudioControllerEditor->focusProxy());
     252            /* Prepare audio settings widget layout: */
     253            QGridLayout *pLayoutAudioSettings = new QGridLayout(m_pWidgetAudioSettings);
     254            if (pLayoutAudioSettings)
     255            {
     256                pLayoutAudioSettings->setContentsMargins(0, 0, 0, 0);
     257
     258                /* Prepare host driver label: */
     259                m_pAudioHostDriverLabel = new QLabel(m_pWidgetAudioSettings);
     260                if (m_pAudioHostDriverLabel)
     261                {
     262                    m_pAudioHostDriverLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
     263                    pLayoutAudioSettings->addWidget(m_pAudioHostDriverLabel, 0, 0);
     264                }
     265                /* Prepare host driver editor: */
     266                m_pAudioHostDriverEditor = new UIAudioHostDriverEditor(m_pWidgetAudioSettings);
     267                if (m_pAudioHostDriverEditor)
     268                {
     269                    m_pAudioHostDriverLabel->setBuddy(m_pAudioHostDriverEditor->focusProxy());
     270                    pLayoutAudioSettings->addWidget(m_pAudioHostDriverEditor, 0, 1);
     271                }
     272
     273                /* Prepare host controller label: */
     274                m_pAudioControllerLabel = new QLabel(m_pWidgetAudioSettings);
     275                if (m_pAudioControllerLabel)
     276                {
     277                    m_pAudioControllerLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
     278                    pLayoutAudioSettings->addWidget(m_pAudioControllerLabel, 1, 0);
     279                }
     280                /* Prepare host controller editor: */
     281                m_pAudioControllerEditor = new UIAudioControllerEditor(m_pWidgetAudioSettings);
     282                if (m_pAudioControllerEditor)
     283                {
     284                    m_pAudioControllerLabel->setBuddy(m_pAudioControllerEditor->focusProxy());
     285                    pLayoutAudioSettings->addWidget(m_pAudioControllerEditor, 1, 1);
     286                }
     287
     288                /* Prepare extended label: */
     289                m_pLabelAudioExtended = new QLabel(m_pWidgetAudioSettings);
     290                if (m_pLabelAudioExtended)
     291                {
     292                    m_pLabelAudioExtended->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
     293                    pLayoutAudioSettings->addWidget(m_pLabelAudioExtended, 2, 0);
     294                }
     295                /* Prepare output check-box: */
     296                m_pCheckBoxAudioOutput = new QCheckBox(m_pWidgetAudioSettings);
     297                if (m_pCheckBoxAudioOutput)
     298                    pLayoutAudioSettings->addWidget(m_pCheckBoxAudioOutput, 2, 1);
     299                /* Prepare input check-box: */
     300                m_pCheckBoxAudioInput = new QCheckBox(m_pWidgetAudioSettings);
     301                if (m_pCheckBoxAudioInput)
     302                    pLayoutAudioSettings->addWidget(m_pCheckBoxAudioInput, 3, 1);
     303
     304                pMainLayout->addWidget(m_pWidgetAudioSettings, 1, 1, 1, 1);
     305            }
    237306        }
    238307    }
    239 
    240     /* Apply language settings: */
    241     retranslateUi();
    242 }
    243 
    244 void UIMachineSettingsAudio::prepareWidgets()
    245 {
    246     if (objectName().isEmpty())
    247         setObjectName(QStringLiteral("UIMachineSettingsAudio"));
    248     QVBoxLayout *pMainLayout = new QVBoxLayout(this);
    249     pMainLayout->setObjectName(QStringLiteral("pMainLayout"));
    250     QWidget *pContainerAudioOptions = new QWidget();
    251     pContainerAudioOptions->setObjectName(QStringLiteral("pContainerAudioOptions"));
    252     QGridLayout *pContainerLayoutAudioOptions = new QGridLayout(pContainerAudioOptions);
    253     pContainerLayoutAudioOptions->setObjectName(QStringLiteral("pContainerLayoutAudioOptions"));
    254     pContainerLayoutAudioOptions->setContentsMargins(0, 0, 0, 0);
    255     m_pCheckBoxAudio = new QCheckBox(pContainerAudioOptions);
    256     m_pCheckBoxAudio->setObjectName(QStringLiteral("m_pCheckBoxAudio"));
    257     pContainerLayoutAudioOptions->addWidget(m_pCheckBoxAudio, 0, 0, 1, 2);
    258 
    259     QSpacerItem *pSpacerItem = new QSpacerItem(20, 0, QSizePolicy::Fixed, QSizePolicy::Minimum);
    260     pContainerLayoutAudioOptions->addItem(pSpacerItem, 1, 0, 1, 1);
    261 
    262     m_pContainerAudioSubOptions = new QWidget(pContainerAudioOptions);
    263     m_pContainerAudioSubOptions->setObjectName(QStringLiteral("m_pContainerAudioSubOptions"));
    264     QGridLayout *pContainerLayoutAudioSubOptions = new QGridLayout(m_pContainerAudioSubOptions);
    265     pContainerLayoutAudioSubOptions->setContentsMargins(0, 0, 0, 0);
    266     pContainerLayoutAudioSubOptions->setObjectName(QStringLiteral("pContainerLayoutAudioSubOptions"));
    267     pContainerLayoutAudioSubOptions->setContentsMargins(0, 0, 0, 0);
    268     m_pAudioHostDriverLabel = new QLabel(m_pContainerAudioSubOptions);
    269     m_pAudioHostDriverLabel->setObjectName(QStringLiteral("m_pAudioHostDriverLabel"));
    270     m_pAudioHostDriverLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
    271     pContainerLayoutAudioSubOptions->addWidget(m_pAudioHostDriverLabel, 0, 0, 1, 1);
    272 
    273     m_pAudioHostDriverEditor = new UIAudioHostDriverEditor(m_pContainerAudioSubOptions);
    274     m_pAudioHostDriverEditor->setObjectName(QStringLiteral("m_pAudioHostDriverEditor"));
    275     pContainerLayoutAudioSubOptions->addWidget(m_pAudioHostDriverEditor, 0, 1, 1, 1);
    276 
    277     m_pAudioControllerLabel = new QLabel(m_pContainerAudioSubOptions);
    278     m_pAudioControllerLabel->setObjectName(QStringLiteral("m_pAudioControllerLabel"));
    279     m_pAudioControllerLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
    280     pContainerLayoutAudioSubOptions->addWidget(m_pAudioControllerLabel, 1, 0, 1, 1);
    281 
    282     m_pAudioControllerEditor = new UIAudioControllerEditor(m_pContainerAudioSubOptions);
    283     m_pAudioControllerEditor->setObjectName(QStringLiteral("m_pAudioControllerEditor"));
    284     pContainerLayoutAudioSubOptions->addWidget(m_pAudioControllerEditor, 1, 1, 1, 1);
    285 
    286     m_pLabelAudioExtended = new QLabel(m_pContainerAudioSubOptions);
    287     m_pLabelAudioExtended->setObjectName(QStringLiteral("m_pLabelAudioExtended"));
    288     m_pLabelAudioExtended->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
    289     pContainerLayoutAudioSubOptions->addWidget(m_pLabelAudioExtended, 2, 0, 1, 1);
    290 
    291     m_pCheckBoxAudioOutput = new QCheckBox(m_pContainerAudioSubOptions);
    292     m_pCheckBoxAudioOutput->setObjectName(QStringLiteral("m_pCheckBoxAudioOutput"));
    293     QSizePolicy sizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
    294     sizePolicy.setHorizontalStretch(1);
    295     sizePolicy.setVerticalStretch(0);
    296     sizePolicy.setHeightForWidth(m_pCheckBoxAudioOutput->sizePolicy().hasHeightForWidth());
    297     m_pCheckBoxAudioOutput->setSizePolicy(sizePolicy);
    298     pContainerLayoutAudioSubOptions->addWidget(m_pCheckBoxAudioOutput, 2, 1, 1, 1);
    299 
    300     m_pCheckBoxAudioInput = new QCheckBox(m_pContainerAudioSubOptions);
    301     m_pCheckBoxAudioInput->setObjectName(QStringLiteral("m_pCheckBoxAudioInput"));
    302     sizePolicy.setHeightForWidth(m_pCheckBoxAudioInput->sizePolicy().hasHeightForWidth());
    303     m_pCheckBoxAudioInput->setSizePolicy(sizePolicy);
    304     pContainerLayoutAudioSubOptions->addWidget(m_pCheckBoxAudioInput, 3, 1, 1, 1);
    305 
    306     pContainerLayoutAudioOptions->addWidget(m_pContainerAudioSubOptions, 1, 1, 1, 1);
    307     pMainLayout->addWidget(pContainerAudioOptions);
    308 
    309     QSpacerItem *pSpacerItem1 = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
    310     pMainLayout->addItem(pSpacerItem1);
    311 
    312     QObject::connect(m_pCheckBoxAudio, &QCheckBox::toggled, m_pContainerAudioSubOptions, &QWidget::setEnabled);
     308}
     309
     310void UIMachineSettingsAudio::prepareConnections()
     311{
     312    QObject::connect(m_pCheckBoxAudio, &QCheckBox::toggled, m_pWidgetAudioSettings, &QWidget::setEnabled);
    313313}
    314314
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsAudio.h

    r85680 r85883  
    7676    /** Prepares widgets. */
    7777    void prepareWidgets();
     78    /** Prepares connections. */
     79    void prepareConnections();
    7880    /** Cleanups all. */
    7981    void cleanup();
     
    8587    UISettingsCacheMachineAudio *m_pCache;
    8688
    87     QCheckBox *m_pCheckBoxAudio;
    88     QCheckBox *m_pCheckBoxAudioOutput;
    89     QCheckBox *m_pCheckBoxAudioInput;
    90 
    9189    /** @name Widgets
    9290     * @{ */
    93         QLabel *m_pAudioHostDriverLabel;
    94         QLabel *m_pAudioControllerLabel;
    95         QLabel *m_pLabelAudioExtended;
    96         QWidget *m_pContainerAudioSubOptions;
     91        /** Holds the audio check-box instance. */
     92        QCheckBox               *m_pCheckBoxAudio;
     93        /** Holds the audio settings widget instance. */
     94        QWidget                 *m_pWidgetAudioSettings;
     95        /** Holds the host audio driver label instance. */
     96        QLabel                  *m_pAudioHostDriverLabel;
     97        /** Holds the host audio driver editor instance. */
    9798        UIAudioHostDriverEditor *m_pAudioHostDriverEditor;
     99        /** Holds the host audio controller label instance. */
     100        QLabel                  *m_pAudioControllerLabel;
     101        /** Holds the host audio controller instance instance. */
    98102        UIAudioControllerEditor *m_pAudioControllerEditor;
     103        /** Holds the audio extended label instance. */
     104        QLabel                  *m_pLabelAudioExtended;
     105        /** Holds the audio output check-box instance. */
     106        QCheckBox               *m_pCheckBoxAudioOutput;
     107        /** Holds the audio input check-box instance. */
     108        QCheckBox               *m_pCheckBoxAudioInput;
    99109    /** @} */
    100110};
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