VirtualBox

Changeset 94708 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Apr 25, 2022 2:55:57 PM (3 years ago)
Author:
vboxsync
Message:

FE/Qt/Ds: bugref:6899: Machine settings: Audio page accessibility improvements; Moving editor related stuff into separate UIAudioSettingsEditor widget.

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
3 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk

    r94653 r94708  
    896896        src/settings/editors/UIAudioControllerEditor.h \
    897897        src/settings/editors/UIAudioHostDriverEditor.h \
     898        src/settings/editors/UIAudioSettingsEditor.h \
    898899        src/settings/editors/UIAutoCaptureKeyboardEditor.h \
    899900        src/settings/editors/UIBaseMemoryEditor.h \
     
    14641465        src/settings/editors/UIAudioControllerEditor.cpp \
    14651466        src/settings/editors/UIAudioHostDriverEditor.cpp \
     1467        src/settings/editors/UIAudioSettingsEditor.cpp \
    14661468        src/settings/editors/UIAutoCaptureKeyboardEditor.cpp \
    14671469        src/settings/editors/UIBaseMemoryEditor.cpp \
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIAudioSettingsEditor.cpp

    r94707 r94708  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - UINetworkSettingsEditor class implementation.
     3 * VBox Qt GUI - UIAudioSettingsEditor class implementation.
    44 */
    55
     
    2222
    2323/* GUI includes: */
    24 #include "UINetworkAttachmentEditor.h"
    25 #include "UINetworkFeaturesEditor.h"
    26 #include "UINetworkSettingsEditor.h"
    27 
    28 
    29 UINetworkSettingsEditor::UINetworkSettingsEditor(QWidget *pParent /* = 0 */)
     24#include "UIAudioControllerEditor.h"
     25#include "UIAudioHostDriverEditor.h"
     26#include "UIAudioSettingsEditor.h"
     27#include "UIMachineAudioFeaturesEditor.h"
     28
     29
     30UIAudioSettingsEditor::UIAudioSettingsEditor(QWidget *pParent /* = 0 */)
    3031    : QIWithRetranslateUI<QWidget>(pParent)
    3132    , m_fFeatureEnabled(false)
    3233    , m_pCheckboxFeature(0)
    3334    , m_pWidgetSettings(0)
    34     , m_pEditorNetworkAttachment(0)
    35     , m_pEditorNetworkFeatures(0)
     35    , m_pEditorAudioHostDriver(0)
     36    , m_pEditorAudioController(0)
     37    , m_pEditorAudioFeatures(0)
    3638{
    3739    prepare();
    3840}
    3941
    40 void UINetworkSettingsEditor::setFeatureEnabled(bool fEnabled)
     42void UIAudioSettingsEditor::setFeatureEnabled(bool fEnabled)
    4143{
    4244    if (m_fFeatureEnabled != fEnabled)
     
    4850}
    4951
    50 bool UINetworkSettingsEditor::isFeatureEnabled() const
     52bool UIAudioSettingsEditor::isFeatureEnabled() const
    5153{
    5254    return m_pCheckboxFeature ? m_pCheckboxFeature->isChecked() : m_fFeatureEnabled;
    5355}
    5456
    55 void UINetworkSettingsEditor::setFeatureAvailable(bool fAvailable)
     57void UIAudioSettingsEditor::setFeatureAvailable(bool fAvailable)
    5658{
    5759    if (m_pCheckboxFeature)
     
    5961}
    6062
    61 void UINetworkSettingsEditor::setValueType(KNetworkAttachmentType enmType)
    62 {
    63     if (m_pEditorNetworkAttachment)
    64         m_pEditorNetworkAttachment->setValueType(enmType);
    65 }
    66 
    67 KNetworkAttachmentType UINetworkSettingsEditor::valueType() const
    68 {
    69     return m_pEditorNetworkAttachment ? m_pEditorNetworkAttachment->valueType() : KNetworkAttachmentType_Null;
    70 }
    71 
    72 void UINetworkSettingsEditor::setValueNames(KNetworkAttachmentType enmType, const QStringList &names)
    73 {
    74     if (m_pEditorNetworkAttachment)
    75         m_pEditorNetworkAttachment->setValueNames(enmType, names);
    76 }
    77 
    78 void UINetworkSettingsEditor::setValueName(KNetworkAttachmentType enmType, const QString &strName)
    79 {
    80     if (m_pEditorNetworkAttachment)
    81         m_pEditorNetworkAttachment->setValueName(enmType, strName);
    82 }
    83 
    84 QString UINetworkSettingsEditor::valueName(KNetworkAttachmentType enmType) const
    85 {
    86     return m_pEditorNetworkAttachment ? m_pEditorNetworkAttachment->valueName(enmType) : QString();
    87 }
    88 
    89 void UINetworkSettingsEditor::setAttachmentOptionsAvailable(bool fAvailable)
    90 {
    91     if (m_pEditorNetworkAttachment)
    92         m_pEditorNetworkAttachment->setEnabled(fAvailable);
    93 }
    94 
    95 void UINetworkSettingsEditor::setAdvancedButtonExpanded(bool fExpanded)
    96 {
    97     if (m_pEditorNetworkFeatures)
    98         m_pEditorNetworkFeatures->setAdvancedButtonExpanded(fExpanded);
    99 }
    100 
    101 bool UINetworkSettingsEditor::advancedButtonExpanded() const
    102 {
    103     return m_pEditorNetworkFeatures ? m_pEditorNetworkFeatures->advancedButtonExpanded() : false;
    104 }
    105 
    106 void UINetworkSettingsEditor::setAdapterType(const KNetworkAdapterType &enmType)
    107 {
    108     if (m_pEditorNetworkFeatures)
    109         m_pEditorNetworkFeatures->setAdapterType(enmType);
    110 }
    111 
    112 KNetworkAdapterType UINetworkSettingsEditor::adapterType() const
    113 {
    114     return m_pEditorNetworkFeatures ? m_pEditorNetworkFeatures->adapterType() : KNetworkAdapterType_Null;
    115 }
    116 
    117 void UINetworkSettingsEditor::setPromiscuousMode(const KNetworkAdapterPromiscModePolicy &enmMode)
    118 {
    119     if (m_pEditorNetworkFeatures)
    120         m_pEditorNetworkFeatures->setPromiscuousMode(enmMode);
    121 }
    122 
    123 KNetworkAdapterPromiscModePolicy UINetworkSettingsEditor::promiscuousMode() const
    124 {
    125     return m_pEditorNetworkFeatures ? m_pEditorNetworkFeatures->promiscuousMode() : KNetworkAdapterPromiscModePolicy_Deny;
    126 }
    127 
    128 void UINetworkSettingsEditor::setMACAddress(const QString &strAddress)
    129 {
    130     if (m_pEditorNetworkFeatures)
    131         m_pEditorNetworkFeatures->setMACAddress(strAddress);
    132 }
    133 
    134 QString UINetworkSettingsEditor::macAddress() const
    135 {
    136     return m_pEditorNetworkFeatures ? m_pEditorNetworkFeatures->macAddress() : QString();
    137 }
    138 
    139 void UINetworkSettingsEditor::setGenericProperties(const QString &strProperties)
    140 {
    141     if (m_pEditorNetworkFeatures)
    142         m_pEditorNetworkFeatures->setGenericProperties(strProperties);
    143 }
    144 
    145 QString UINetworkSettingsEditor::genericProperties() const
    146 {
    147     return m_pEditorNetworkFeatures ? m_pEditorNetworkFeatures->genericProperties() : QString();
    148 }
    149 
    150 void UINetworkSettingsEditor::setCableConnected(bool fConnected)
    151 {
    152     if (m_pEditorNetworkFeatures)
    153         m_pEditorNetworkFeatures->setCableConnected(fConnected);
    154 }
    155 
    156 bool UINetworkSettingsEditor::cableConnected() const
    157 {
    158     return m_pEditorNetworkFeatures ? m_pEditorNetworkFeatures->cableConnected() : false;
    159 }
    160 
    161 void UINetworkSettingsEditor::setPortForwardingRules(const UIPortForwardingDataList &rules)
    162 {
    163     if (m_pEditorNetworkFeatures)
    164         m_pEditorNetworkFeatures->setPortForwardingRules(rules);
    165 }
    166 
    167 UIPortForwardingDataList UINetworkSettingsEditor::portForwardingRules() const
    168 {
    169     return m_pEditorNetworkFeatures ? m_pEditorNetworkFeatures->portForwardingRules() : UIPortForwardingDataList();
    170 }
    171 
    172 void UINetworkSettingsEditor::setAdvancedOptionsAvailable(bool fAvailable)
    173 {
    174     if (m_pEditorNetworkFeatures)
    175         m_pEditorNetworkFeatures->setAdvancedOptionsAvailable(fAvailable);
    176 }
    177 
    178 void UINetworkSettingsEditor::setAdapterOptionsAvailable(bool fAvailable)
    179 {
    180     if (m_pEditorNetworkFeatures)
    181         m_pEditorNetworkFeatures->setAdapterOptionsAvailable(fAvailable);
    182 }
    183 
    184 void UINetworkSettingsEditor::setPromiscuousOptionsAvailable(bool fAvailable)
    185 {
    186     if (m_pEditorNetworkFeatures)
    187         m_pEditorNetworkFeatures->setPromiscuousOptionsAvailable(fAvailable);
    188 }
    189 
    190 void UINetworkSettingsEditor::setMACOptionsAvailable(bool fAvailable)
    191 {
    192     if (m_pEditorNetworkFeatures)
    193         m_pEditorNetworkFeatures->setMACOptionsAvailable(fAvailable);
    194 }
    195 
    196 void UINetworkSettingsEditor::setGenericPropertiesAvailable(bool fAvailable)
    197 {
    198     if (m_pEditorNetworkFeatures)
    199         m_pEditorNetworkFeatures->setGenericPropertiesAvailable(fAvailable);
    200 }
    201 
    202 void UINetworkSettingsEditor::setCableOptionsAvailable(bool fAvailable)
    203 {
    204     if (m_pEditorNetworkFeatures)
    205         m_pEditorNetworkFeatures->setCableOptionsAvailable(fAvailable);
    206 }
    207 
    208 void UINetworkSettingsEditor::setForwardingOptionsAvailable(bool fAvailable)
    209 {
    210     if (m_pEditorNetworkFeatures)
    211         m_pEditorNetworkFeatures->setForwardingOptionsAvailable(fAvailable);
    212 }
    213 
    214 void UINetworkSettingsEditor::retranslateUi()
     63void UIAudioSettingsEditor::setHostDriverType(KAudioDriverType enmType)
     64{
     65    if (m_pEditorAudioHostDriver)
     66        m_pEditorAudioHostDriver->setValue(enmType);
     67}
     68
     69KAudioDriverType UIAudioSettingsEditor::hostDriverType() const
     70{
     71    return m_pEditorAudioHostDriver ? m_pEditorAudioHostDriver->value() : KAudioDriverType_Max;
     72}
     73
     74void UIAudioSettingsEditor::setHostDriverOptionAvailable(bool fAvailable)
     75{
     76    if (m_pEditorAudioHostDriver)
     77        m_pEditorAudioHostDriver->setEnabled(fAvailable);
     78}
     79
     80void UIAudioSettingsEditor::setControllerType(KAudioControllerType enmType)
     81{
     82    if (m_pEditorAudioController)
     83        m_pEditorAudioController->setValue(enmType);
     84}
     85
     86KAudioControllerType UIAudioSettingsEditor::controllerType() const
     87{
     88    return m_pEditorAudioController ? m_pEditorAudioController->value() : KAudioControllerType_Max;
     89}
     90
     91void UIAudioSettingsEditor::setControllerOptionAvailable(bool fAvailable)
     92{
     93    if (m_pEditorAudioController)
     94        m_pEditorAudioController->setEnabled(fAvailable);
     95}
     96
     97void UIAudioSettingsEditor::setEnableOutput(bool fConnected)
     98{
     99    if (m_pEditorAudioFeatures)
     100        m_pEditorAudioFeatures->setEnableOutput(fConnected);
     101}
     102
     103bool UIAudioSettingsEditor::outputEnabled() const
     104{
     105    return m_pEditorAudioFeatures ? m_pEditorAudioFeatures->outputEnabled() : false;
     106}
     107
     108void UIAudioSettingsEditor::setEnableInput(bool fConnected)
     109{
     110    if (m_pEditorAudioFeatures)
     111        m_pEditorAudioFeatures->setEnableInput(fConnected);
     112}
     113
     114bool UIAudioSettingsEditor::inputEnabled() const
     115{
     116    return m_pEditorAudioFeatures ? m_pEditorAudioFeatures->inputEnabled() : false;
     117}
     118
     119void UIAudioSettingsEditor::setFeatureOptionsAvailable(bool fAvailable)
     120{
     121    if (m_pEditorAudioFeatures)
     122        m_pEditorAudioFeatures->setEnabled(fAvailable);
     123}
     124
     125void UIAudioSettingsEditor::retranslateUi()
    215126{
    216127    if (m_pCheckboxFeature)
    217128    {
    218         m_pCheckboxFeature->setText(tr("&Enable Network Adapter"));
    219         m_pCheckboxFeature->setToolTip(tr("When checked, plugs this virtual network adapter into the virtual machine."));
     129        m_pCheckboxFeature->setText(tr("Enable &Audio"));
     130        m_pCheckboxFeature->setToolTip(tr("When checked, a virtual PCI audio card will be plugged into the virtual machine "
     131                                          "and will communicate with the host audio system using the specified driver."));
    220132    }
    221133
    222134    /* These editors have own labels, but we want them to be properly layouted according to each other: */
    223135    int iMinimumLayoutHint = 0;
    224     if (m_pEditorNetworkAttachment)
    225         iMinimumLayoutHint = qMax(iMinimumLayoutHint, m_pEditorNetworkAttachment->minimumLabelHorizontalHint());
    226     if (m_pEditorNetworkFeatures)
    227         iMinimumLayoutHint = qMax(iMinimumLayoutHint, m_pEditorNetworkFeatures->minimumLabelHorizontalHint());
    228     if (m_pEditorNetworkAttachment)
    229         m_pEditorNetworkAttachment->setMinimumLayoutIndent(iMinimumLayoutHint);
    230     if (m_pEditorNetworkFeatures)
    231         m_pEditorNetworkFeatures->setMinimumLayoutIndent(iMinimumLayoutHint);
    232 }
    233 
    234 void UINetworkSettingsEditor::sltHandleFeatureToggled()
     136    if (m_pEditorAudioHostDriver)
     137        iMinimumLayoutHint = qMax(iMinimumLayoutHint, m_pEditorAudioHostDriver->minimumLabelHorizontalHint());
     138    if (m_pEditorAudioController)
     139        iMinimumLayoutHint = qMax(iMinimumLayoutHint, m_pEditorAudioController->minimumLabelHorizontalHint());
     140    if (m_pEditorAudioFeatures)
     141        iMinimumLayoutHint = qMax(iMinimumLayoutHint, m_pEditorAudioFeatures->minimumLabelHorizontalHint());
     142    if (m_pEditorAudioHostDriver)
     143        m_pEditorAudioHostDriver->setMinimumLayoutIndent(iMinimumLayoutHint);
     144    if (m_pEditorAudioController)
     145        m_pEditorAudioController->setMinimumLayoutIndent(iMinimumLayoutHint);
     146    if (m_pEditorAudioFeatures)
     147        m_pEditorAudioFeatures->setMinimumLayoutIndent(iMinimumLayoutHint);
     148}
     149
     150void UIAudioSettingsEditor::sltHandleFeatureToggled()
    235151{
    236152    /* Update widget availability: */
    237153    updateFeatureAvailability();
    238 
    239     /* Generate a new MAC address in case it's currently empty: */
    240     if (   m_pCheckboxFeature->isChecked()
    241         && m_pEditorNetworkFeatures->macAddress().isEmpty())
    242         m_pEditorNetworkFeatures->generateMac();
    243 
    244     /* Notify listeners: */
    245     emit sigFeatureStateChanged();
    246 }
    247 
    248 void UINetworkSettingsEditor::sltHandleAttachmentTypeChange()
    249 {
    250     /* Update widget availability: */
    251     const KNetworkAttachmentType enmType = m_pEditorNetworkAttachment->valueType();
    252     m_pEditorNetworkFeatures->setPromiscuousOptionsAvailable(   enmType != KNetworkAttachmentType_Null
    253                                                              && enmType != KNetworkAttachmentType_Generic
    254                                                              && enmType != KNetworkAttachmentType_NAT);
    255     m_pEditorNetworkFeatures->setGenericPropertiesAvailable(enmType == KNetworkAttachmentType_Generic);
    256     m_pEditorNetworkFeatures->setForwardingOptionsAvailable(enmType == KNetworkAttachmentType_NAT);
    257 
    258     /* Notify listeners: */
    259     emit sigAttachmentTypeChanged();
    260 }
    261 
    262 void UINetworkSettingsEditor::prepare()
     154}
     155
     156void UIAudioSettingsEditor::prepare()
    263157{
    264158    /* Prepare stuff: */
     
    273167}
    274168
    275 void UINetworkSettingsEditor::prepareWidgets()
     169void UIAudioSettingsEditor::prepareWidgets()
    276170{
    277171    /* Prepare main layout: */
     
    291185            pLayout->addItem(pSpacerItem, 1, 0);
    292186
    293         /* Prepare adapter settings widget: */
     187        /* Prepare settings widget: */
    294188        m_pWidgetSettings = new QWidget(this);
    295189        if (m_pWidgetSettings)
    296190        {
    297             /* Prepare adapter settings widget layout: */
    298             QVBoxLayout *pLayoutAdapterSettings = new QVBoxLayout(m_pWidgetSettings);
    299             if (pLayoutAdapterSettings)
     191            /* Prepare settings layout: */
     192            QVBoxLayout *pLayoutAudioSettings = new QVBoxLayout(m_pWidgetSettings);
     193            if (pLayoutAudioSettings)
    300194            {
    301                 pLayoutAdapterSettings->setContentsMargins(0, 0, 0, 0);
    302 
    303                 /* Prepare attachment type editor: */
    304                 m_pEditorNetworkAttachment = new UINetworkAttachmentEditor(m_pWidgetSettings);
    305                 if (m_pEditorNetworkAttachment)
    306                     pLayoutAdapterSettings->addWidget(m_pEditorNetworkAttachment);
    307 
    308                 /* Prepare advanced settingseditor: */
    309                 m_pEditorNetworkFeatures = new UINetworkFeaturesEditor(m_pWidgetSettings);
    310                 if (m_pEditorNetworkFeatures)
    311                     pLayoutAdapterSettings->addWidget(m_pEditorNetworkFeatures);
     195                pLayoutAudioSettings->setContentsMargins(0, 0, 0, 0);
     196
     197                /* Prepare host driver editor: */
     198                m_pEditorAudioHostDriver = new UIAudioHostDriverEditor(m_pWidgetSettings);
     199                if (m_pEditorAudioHostDriver)
     200                    pLayoutAudioSettings->addWidget(m_pEditorAudioHostDriver);
     201
     202                /* Prepare host controller editor: */
     203                m_pEditorAudioController = new UIAudioControllerEditor(m_pWidgetSettings);
     204                if (m_pEditorAudioController)
     205                    pLayoutAudioSettings->addWidget(m_pEditorAudioController);
     206
     207                /* Prepare extended features editor: */
     208                m_pEditorAudioFeatures = new UIMachineAudioFeaturesEditor(m_pWidgetSettings);
     209                if (m_pEditorAudioFeatures)
     210                    pLayoutAudioSettings->addWidget(m_pEditorAudioFeatures);
    312211            }
    313212
     
    317216}
    318217
    319 void UINetworkSettingsEditor::prepareConnections()
     218void UIAudioSettingsEditor::prepareConnections()
    320219{
    321220    if (m_pCheckboxFeature)
    322221        connect(m_pCheckboxFeature, &QCheckBox::stateChanged,
    323                 this, &UINetworkSettingsEditor::sltHandleFeatureToggled);
    324     if (m_pEditorNetworkAttachment)
    325         connect(m_pEditorNetworkAttachment, &UINetworkAttachmentEditor::sigValueTypeChanged,
    326                 this, &UINetworkSettingsEditor::sltHandleAttachmentTypeChange);
    327     if (m_pEditorNetworkAttachment)
    328         connect(m_pEditorNetworkAttachment, &UINetworkAttachmentEditor::sigValueNameChanged,
    329                 this, &UINetworkSettingsEditor::sigAlternativeNameChanged);
    330     if (m_pEditorNetworkFeatures)
    331         connect(m_pEditorNetworkFeatures, &UINetworkFeaturesEditor::sigAdvancedButtonStateChange,
    332                 this, &UINetworkSettingsEditor::sigAdvancedButtonStateChange);
    333     if (m_pEditorNetworkFeatures)
    334         connect(m_pEditorNetworkFeatures, &UINetworkFeaturesEditor::sigMACAddressChanged,
    335                 this, &UINetworkSettingsEditor::sigMACAddressChanged);
    336 }
    337 
    338 void UINetworkSettingsEditor::updateFeatureAvailability()
     222                this, &UIAudioSettingsEditor::sltHandleFeatureToggled);
     223}
     224
     225void UIAudioSettingsEditor::updateFeatureAvailability()
    339226{
    340227    m_pWidgetSettings->setEnabled(m_pCheckboxFeature->isChecked());
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIAudioSettingsEditor.h

    r94707 r94708  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - UINetworkSettingsEditor class declaration.
     3 * VBox Qt GUI - UIAudioSettingsEditor class declaration.
    44 */
    55
     
    1616 */
    1717
    18 #ifndef FEQT_INCLUDED_SRC_settings_editors_UINetworkSettingsEditor_h
    19 #define FEQT_INCLUDED_SRC_settings_editors_UINetworkSettingsEditor_h
     18#ifndef FEQT_INCLUDED_SRC_settings_editors_UIAudioSettingsEditor_h
     19#define FEQT_INCLUDED_SRC_settings_editors_UIAudioSettingsEditor_h
    2020#ifndef RT_WITHOUT_PRAGMA_ONCE
    2121# pragma once
     
    3535/* Forward declarations: */
    3636class QCheckBox;
    37 class UINetworkAttachmentEditor;
    38 class UINetworkFeaturesEditor;
     37class UIAudioControllerEditor;
     38class UIAudioHostDriverEditor;
     39class UIMachineAudioFeaturesEditor;
    3940
    40 /** QWidget subclass used as a network settings editor. */
    41 class SHARED_LIBRARY_STUFF UINetworkSettingsEditor : public QIWithRetranslateUI<QWidget>
     41/** QWidget subclass used as a audio settings editor. */
     42class SHARED_LIBRARY_STUFF UIAudioSettingsEditor : public QIWithRetranslateUI<QWidget>
    4243{
    4344    Q_OBJECT;
    44 
    45 signals:
    46 
    47     /** @name Attachment editor stuff
    48      * @{ */
    49         /** Notifies about feature state changed. */
    50         void sigFeatureStateChanged();
    51         /** Notifies about attachment type changed. */
    52         void sigAttachmentTypeChanged();
    53         /** Notifies about alternative name changed. */
    54         void sigAlternativeNameChanged();
    55     /** @} */
    56 
    57     /** @name Features editor stuff
    58      * @{ */
    59         /** Notifies about the advanced button state change to @a fExpanded. */
    60         void sigAdvancedButtonStateChange(bool fExpanded);
    61         /** Notifies about MAC address changed. */
    62         void sigMACAddressChanged();
    63     /** @} */
    6445
    6546public:
    6647
    6748    /** Constructs editor passing @a pParent to the base-class. */
    68     UINetworkSettingsEditor(QWidget *pParent = 0);
     49    UIAudioSettingsEditor(QWidget *pParent = 0);
    6950
    7051    /** @name General stuff
     
    7960    /** @} */
    8061
    81     /** @name Attachment editor stuff
     62    /** @name Host driver editor stuff
    8263     * @{ */
    83         /** Defines value @a enmType. */
    84         void setValueType(KNetworkAttachmentType enmType);
    85         /** Returns value type. */
    86         KNetworkAttachmentType valueType() const;
     64        /** Defines host driver @a enmType. */
     65        void setHostDriverType(KAudioDriverType enmType);
     66        /** Returns host driver type. */
     67        KAudioDriverType hostDriverType() const;
    8768
    88         /** Defines value @a names for specified @a enmType. */
    89         void setValueNames(KNetworkAttachmentType enmType, const QStringList &names);
    90         /** Defines value @a strName for specified @a enmType. */
    91         void setValueName(KNetworkAttachmentType enmType, const QString &strName);
    92         /** Returns current name for specified @a enmType. */
    93         QString valueName(KNetworkAttachmentType enmType) const;
     69        /** Defines whether host driver option @a fAvailable. */
     70        void setHostDriverOptionAvailable(bool fAvailable);
     71    /** @} */
    9472
    95         /** Defines whether attachment options @a fAvailable. */
    96         void setAttachmentOptionsAvailable(bool fAvailable);
     73    /** @name Controller editor stuff
     74     * @{ */
     75        /** Defines controller @a enmType. */
     76        void setControllerType(KAudioControllerType enmValue);
     77        /** Returns controller type. */
     78        KAudioControllerType controllerType() const;
     79
     80        /** Defines whether controller option @a fAvailable. */
     81        void setControllerOptionAvailable(bool fAvailable);
    9782    /** @} */
    9883
    9984    /** @name Features editor stuff
    10085     * @{ */
    101         /** Defines whether advanced button @a fExpanded. */
    102         void setAdvancedButtonExpanded(bool fExpanded);
    103         /** Returns whether advanced button expanded. */
    104         bool advancedButtonExpanded() const;
     86        /** Defines whether 'enable output' feature in @a fOn. */
     87        void setEnableOutput(bool fOn);
     88        /** Returns 'enable output' feature value. */
     89        bool outputEnabled() const;
    10590
    106         /** Defines adapter @a enmType. */
    107         void setAdapterType(const KNetworkAdapterType &enmType);
    108         /** Returns adapter type. */
    109         KNetworkAdapterType adapterType() const;
     91        /** Defines whether 'enable input' feature in @a fOn. */
     92        void setEnableInput(bool fOn);
     93        /** Returns 'enable input' feature value. */
     94        bool inputEnabled() const;
    11095
    111         /** Defines promiscuous @a enmMode. */
    112         void setPromiscuousMode(const KNetworkAdapterPromiscModePolicy &enmMode);
    113         /** Returns promiscuous mode. */
    114         KNetworkAdapterPromiscModePolicy promiscuousMode() const;
    115 
    116         /** Defines MAC @a strAddress. */
    117         void setMACAddress(const QString &strAddress);
    118         /** Returns MAC address. */
    119         QString macAddress() const;
    120 
    121         /** Defines generic @a strProperties. */
    122         void setGenericProperties(const QString &strProperties);
    123         /** Returns generic properties. */
    124         QString genericProperties() const;
    125 
    126         /** Defines whether cable is @a fConnected. */
    127         void setCableConnected(bool fConnected);
    128         /** Returns whether cable is connected. */
    129         bool cableConnected() const;
    130 
    131         /** Defines list of port forwarding @a rules. */
    132         void setPortForwardingRules(const UIPortForwardingDataList &rules);
    133         /** Returns list of port forwarding rules. */
    134         UIPortForwardingDataList portForwardingRules() const;
    135 
    136         /** Defines whether advanced options @a fAvailable. */
    137         void setAdvancedOptionsAvailable(bool fAvailable);
    138         /** Defines whether adapter options @a fAvailable. */
    139         void setAdapterOptionsAvailable(bool fAvailable);
    140         /** Defines whether promiscuous options @a fAvailable. */
    141         void setPromiscuousOptionsAvailable(bool fAvailable);
    142         /** Defines whether MAC options @a fAvailable. */
    143         void setMACOptionsAvailable(bool fAvailable);
    144         /** Defines whether generic properties @a fAvailable. */
    145         void setGenericPropertiesAvailable(bool fAvailable);
    146         /** Defines whether cable options @a fAvailable. */
    147         void setCableOptionsAvailable(bool fAvailable);
    148         /** Defines whether forwarding options @a fAvailable. */
    149         void setForwardingOptionsAvailable(bool fAvailable);
     96        /** Defines whether feature options @a fAvailable. */
     97        void setFeatureOptionsAvailable(bool fAvailable);
    15098    /** @} */
    15199
     
    159107    /** Handles feature toggling. */
    160108    void sltHandleFeatureToggled();
    161     /** Handles adapter attachment type change. */
    162     void sltHandleAttachmentTypeChange();
    163109
    164110private:
     
    183129     * @{ */
    184130        /** Holds the feature check-box instance. */
    185         QCheckBox                 *m_pCheckboxFeature;
     131        QCheckBox                    *m_pCheckboxFeature;
    186132        /** Holds the settings widget instance. */
    187         QWidget                   *m_pWidgetSettings;
    188         /** Holds the network attachment editor instance. */
    189         UINetworkAttachmentEditor *m_pEditorNetworkAttachment;
    190         /** Holds the network features editor instance. */
    191         UINetworkFeaturesEditor   *m_pEditorNetworkFeatures;
     133        QWidget                      *m_pWidgetSettings;
     134        /** Holds the audio host driver editor instance. */
     135        UIAudioHostDriverEditor      *m_pEditorAudioHostDriver;
     136        /** Holds the audio host controller editor instance. */
     137        UIAudioControllerEditor      *m_pEditorAudioController;
     138        /** Holds the audio features editor instance. */
     139        UIMachineAudioFeaturesEditor *m_pEditorAudioFeatures;
    192140    /** @} */
    193141};
    194142
    195 #endif /* !FEQT_INCLUDED_SRC_settings_editors_UINetworkSettingsEditor_h */
     143#endif /* !FEQT_INCLUDED_SRC_settings_editors_UIAudioSettingsEditor_h */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsAudio.cpp

    r94667 r94708  
    1717
    1818/* Qt includes: */
    19 #include <QCheckBox>
    20 #include <QGridLayout>
    2119#include <QVBoxLayout>
    2220
    2321/* GUI includes: */
    24 #include "UIAudioControllerEditor.h"
    25 #include "UIAudioHostDriverEditor.h"
    26 #include "UIConverter.h"
     22#include "UIAudioSettingsEditor.h"
    2723#include "UIErrorString.h"
    28 #include "UIMachineAudioFeaturesEditor.h"
    2924#include "UIMachineSettingsAudio.h"
    3025
     
    7772UIMachineSettingsAudio::UIMachineSettingsAudio()
    7873    : m_pCache(0)
    79     , m_pCheckBoxAudio(0)
    80     , m_pWidgetAudioSettings(0)
    81     , m_pEditorAudioHostDriver(0)
    82     , m_pEditorAudioController(0)
    83     , m_pEditorAudioFeatures(0)
     74    , m_pEditorAudioSettings(0)
    8475{
    8576    prepare();
     
    140131
    141132    /* Load old data from cache: */
    142     m_pCheckBoxAudio->setChecked(oldAudioData.m_fAudioEnabled);
    143     if (m_pEditorAudioHostDriver)
    144         m_pEditorAudioHostDriver->setValue(oldAudioData.m_audioDriverType);
    145     if (m_pEditorAudioController)
    146         m_pEditorAudioController->setValue(oldAudioData.m_audioControllerType);
    147     if (m_pEditorAudioFeatures)
    148     {
    149         m_pEditorAudioFeatures->setEnableOutput(oldAudioData.m_fAudioOutputEnabled);
    150         m_pEditorAudioFeatures->setEnableInput(oldAudioData.m_fAudioInputEnabled);
     133    if (m_pEditorAudioSettings)
     134    {
     135        m_pEditorAudioSettings->setFeatureEnabled(oldAudioData.m_fAudioEnabled);
     136        m_pEditorAudioSettings->setHostDriverType(oldAudioData.m_audioDriverType);
     137        m_pEditorAudioSettings->setControllerType(oldAudioData.m_audioControllerType);
     138        m_pEditorAudioSettings->setEnableOutput(oldAudioData.m_fAudioOutputEnabled);
     139        m_pEditorAudioSettings->setEnableInput(oldAudioData.m_fAudioInputEnabled);
    151140    }
    152141
     
    165154
    166155    /* Cache new data: */
    167     if (m_pCheckBoxAudio)
    168         newAudioData.m_fAudioEnabled = m_pCheckBoxAudio->isChecked();
    169     if (m_pEditorAudioHostDriver)
    170         newAudioData.m_audioDriverType = m_pEditorAudioHostDriver->value();
    171     if (m_pEditorAudioController)
    172         newAudioData.m_audioControllerType = m_pEditorAudioController->value();
    173     if (m_pEditorAudioFeatures)
    174     {
    175         newAudioData.m_fAudioOutputEnabled = m_pEditorAudioFeatures->outputEnabled();
    176         newAudioData.m_fAudioInputEnabled = m_pEditorAudioFeatures->inputEnabled();
     156    if (m_pEditorAudioSettings)
     157    {
     158        newAudioData.m_fAudioEnabled = m_pEditorAudioSettings->isFeatureEnabled();
     159        newAudioData.m_audioDriverType = m_pEditorAudioSettings->hostDriverType();
     160        newAudioData.m_audioControllerType = m_pEditorAudioSettings->controllerType();
     161        newAudioData.m_fAudioOutputEnabled = m_pEditorAudioSettings->outputEnabled();
     162        newAudioData.m_fAudioInputEnabled = m_pEditorAudioSettings->inputEnabled();
    177163    }
    178164    m_pCache->cacheCurrentData(newAudioData);
     
    193179void UIMachineSettingsAudio::retranslateUi()
    194180{
    195     m_pCheckBoxAudio->setText(tr("Enable &Audio"));
    196     m_pCheckBoxAudio->setToolTip(tr("When checked, a virtual PCI audio card will be plugged into the virtual machine "
    197                                     "and will communicate with the host audio system using the specified driver."));
    198 
    199     /* These editors have own labels, but we want them to be properly layouted according to each other: */
    200     int iMinimumLayoutHint = 0;
    201     iMinimumLayoutHint = qMax(iMinimumLayoutHint, m_pEditorAudioHostDriver->minimumLabelHorizontalHint());
    202     iMinimumLayoutHint = qMax(iMinimumLayoutHint, m_pEditorAudioController->minimumLabelHorizontalHint());
    203     iMinimumLayoutHint = qMax(iMinimumLayoutHint, m_pEditorAudioFeatures->minimumLabelHorizontalHint());
    204     m_pEditorAudioHostDriver->setMinimumLayoutIndent(iMinimumLayoutHint);
    205     m_pEditorAudioController->setMinimumLayoutIndent(iMinimumLayoutHint);
    206     m_pEditorAudioFeatures->setMinimumLayoutIndent(iMinimumLayoutHint);
    207181}
    208182
     
    210184{
    211185    /* Polish audio page availability: */
    212     m_pCheckBoxAudio->setEnabled(isMachineOffline());
    213     m_pEditorAudioHostDriver->setEnabled(isMachineOffline() || isMachineSaved());
    214     m_pEditorAudioController->setEnabled(isMachineOffline());
    215     m_pEditorAudioFeatures->setEnabled(isMachineInValidMode());
    216     m_pWidgetAudioSettings->setEnabled(m_pCheckBoxAudio->isChecked());
     186    if (m_pEditorAudioSettings)
     187    {
     188        m_pEditorAudioSettings->setFeatureAvailable(isMachineOffline());
     189        m_pEditorAudioSettings->setHostDriverOptionAvailable(isMachineOffline() || isMachineSaved());
     190        m_pEditorAudioSettings->setControllerOptionAvailable(isMachineOffline());
     191        m_pEditorAudioSettings->setFeatureOptionsAvailable(isMachineInValidMode());
     192    }
    217193}
    218194
     
    234210{
    235211    /* Prepare main layout: */
    236     QGridLayout *pLayout = new QGridLayout(this);
     212    QVBoxLayout *pLayout = new QVBoxLayout(this);
    237213    if (pLayout)
    238214    {
    239         pLayout->setRowStretch(2, 1);
    240 
    241         /* Prepare audio check-box: */
    242         m_pCheckBoxAudio = new QCheckBox(this);
    243         if (m_pCheckBoxAudio)
    244             pLayout->addWidget(m_pCheckBoxAudio, 0, 0, 1, 2);
    245 
    246         /* Prepare 20-px shifting spacer: */
    247         QSpacerItem *pSpacerItem = new QSpacerItem(20, 0, QSizePolicy::Fixed, QSizePolicy::Minimum);
    248         if (pSpacerItem)
    249             pLayout->addItem(pSpacerItem, 1, 0);
    250 
    251         /* Prepare audio settings widget: */
    252         m_pWidgetAudioSettings = new QWidget(this);
    253         if (m_pWidgetAudioSettings)
    254         {
    255             /* Prepare audio settings widget layout: */
    256             QVBoxLayout *pLayoutAudioSettings = new QVBoxLayout(m_pWidgetAudioSettings);
    257             if (pLayoutAudioSettings)
    258             {
    259                 pLayoutAudioSettings->setContentsMargins(0, 0, 0, 0);
    260 
    261                 /* Prepare audio host driver editor: */
    262                 m_pEditorAudioHostDriver = new UIAudioHostDriverEditor(m_pWidgetAudioSettings);
    263                 if (m_pEditorAudioHostDriver)
    264                     pLayoutAudioSettings->addWidget(m_pEditorAudioHostDriver);
    265 
    266                 /* Prepare audio host controller editor: */
    267                 m_pEditorAudioController = new UIAudioControllerEditor(m_pWidgetAudioSettings);
    268                 if (m_pEditorAudioController)
    269                     pLayoutAudioSettings->addWidget(m_pEditorAudioController);
    270 
    271                 /* Prepare audio extended features editor: */
    272                 m_pEditorAudioFeatures = new UIMachineAudioFeaturesEditor(m_pWidgetAudioSettings);
    273                 if (m_pEditorAudioFeatures)
    274                     pLayoutAudioSettings->addWidget(m_pEditorAudioFeatures);
    275             }
    276 
    277             pLayout->addWidget(m_pWidgetAudioSettings, 1, 1);
    278         }
     215        /* Prepare settings editor: */
     216        m_pEditorAudioSettings = new UIAudioSettingsEditor(this);
     217        if (m_pEditorAudioSettings)
     218            pLayout->addWidget(m_pEditorAudioSettings);
     219
     220        pLayout->addStretch();
    279221    }
    280222}
     
    282224void UIMachineSettingsAudio::prepareConnections()
    283225{
    284     connect(m_pCheckBoxAudio, &QCheckBox::toggled, m_pWidgetAudioSettings, &QWidget::setEnabled);
    285226}
    286227
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsAudio.h

    r94333 r94708  
    2626
    2727/* Forward declarations: */
    28 class QCheckBox;
    29 class UIAudioControllerEditor;
    30 class UIAudioHostDriverEditor;
    31 class UIMachineAudioFeaturesEditor;
     28class UIAudioSettingsEditor;
    3229struct UIDataSettingsMachineAudio;
    3330typedef UISettingsCache<UIDataSettingsMachineAudio> UISettingsCacheMachineAudio;
     
    8986    /** @name Widgets
    9087     * @{ */
    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 audio host driver editor instance. */
    96         UIAudioHostDriverEditor      *m_pEditorAudioHostDriver;
    97         /** Holds the audio host controller editor instance. */
    98         UIAudioControllerEditor      *m_pEditorAudioController;
    99         /** Holds the audio features editor instance. */
    100         UIMachineAudioFeaturesEditor *m_pEditorAudioFeatures;
     88        /** Holds the audio settings editor instance. */
     89        UIAudioSettingsEditor *m_pEditorAudioSettings;
    10190    /** @} */
    10291};
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