Changeset 82828 in vbox for trunk/src/VBox
- Timestamp:
- Jan 22, 2020 2:14:02 PM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 135797
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/widgets
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIAudioHostDriverEditor.cpp
r80079 r82828 23 23 /* GUI includes: */ 24 24 #include "QIComboBox.h" 25 #include "UICommon.h" 25 26 #include "UIConverter.h" 26 27 #include "UIAudioHostDriverEditor.h" 28 29 /* COM includes: */ 30 #include "CSystemProperties.h" 27 31 28 32 … … 30 34 : QIWithRetranslateUI<QWidget>(pParent) 31 35 , m_fWithLabel(fWithLabel) 36 , m_enmValue(KAudioDriverType_Max) 32 37 , m_pLabel(0) 33 38 , m_pCombo(0) … … 40 45 if (m_pCombo) 41 46 { 42 int iIndex = m_pCombo->findData(QVariant::fromValue(enmValue)); 47 /* Update cached value and 48 * combo if value has changed: */ 49 if (m_enmValue != enmValue) 50 { 51 m_enmValue = enmValue; 52 populateCombo(); 53 } 54 55 /* Look for proper index to choose: */ 56 int iIndex = m_pCombo->findData(QVariant::fromValue(m_enmValue)); 43 57 if (iIndex != -1) 44 58 m_pCombo->setCurrentIndex(iIndex); … … 48 62 KAudioDriverType UIAudioHostDriverEditor::value() const 49 63 { 50 return m_pCombo ? m_pCombo-> itemData(m_pCombo->currentIndex()).value<KAudioDriverType>() : KAudioDriverType_Null;64 return m_pCombo ? m_pCombo->currentData().value<KAudioDriverType>() : m_enmValue; 51 65 } 52 66 … … 95 109 { 96 110 setFocusProxy(m_pCombo->focusProxy()); 111 /* This is necessary since contents is dynamical now: */ 112 m_pCombo->setSizeAdjustPolicy(QComboBox::AdjustToContents); 97 113 if (m_pLabel) 98 114 m_pLabel->setBuddy(m_pCombo->focusProxy()); … … 119 135 void UIAudioHostDriverEditor::populateCombo() 120 136 { 121 /* Fill combo manually: */ 122 m_pCombo->addItem(QString(), QVariant::fromValue(KAudioDriverType_Null)); 123 #ifdef Q_OS_WIN 124 m_pCombo->addItem(QString(), QVariant::fromValue(KAudioDriverType_DirectSound)); 125 # ifdef VBOX_WITH_WINMM 126 m_pCombo->addItem(QString(), QVariant::fromValue(KAudioDriverType_WinMM)); 127 # endif 128 #endif 129 #ifdef VBOX_WITH_AUDIO_OSS 130 m_pCombo->addItem(QString(), QVariant::fromValue(KAudioDriverType_OSS)); 131 #endif 132 #ifdef VBOX_WITH_AUDIO_ALSA 133 m_pCombo->addItem(QString(), QVariant::fromValue(KAudioDriverType_ALSA)); 134 #endif 135 #ifdef VBOX_WITH_AUDIO_PULSE 136 m_pCombo->addItem(QString(), QVariant::fromValue(KAudioDriverType_Pulse)); 137 #endif 138 #ifdef Q_OS_MACX 139 m_pCombo->addItem(QString(), QVariant::fromValue(KAudioDriverType_CoreAudio)); 140 #endif 137 if (m_pCombo) 138 { 139 /* Clear combo first of all: */ 140 m_pCombo->clear(); 141 142 /* Load currently supported audio driver types: */ 143 CSystemProperties comProperties = uiCommon().virtualBox().GetSystemProperties(); 144 m_supportedValues = comProperties.GetSupportedAudioDriverTypes(); 145 146 /* Make sure requested value if sane is present as well: */ 147 if ( m_enmValue != KAudioDriverType_Max 148 && !m_supportedValues.contains(m_enmValue)) 149 m_supportedValues.prepend(m_enmValue); 150 151 /* Update combo with all the supported values: */ 152 foreach (const KAudioDriverType &enmType, m_supportedValues) 153 m_pCombo->addItem(QString(), QVariant::fromValue(enmType)); 154 155 /* Retranslate finally: */ 156 retranslateUi(); 157 } 141 158 } -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIAudioHostDriverEditor.h
r80081 r82828 57 57 KAudioDriverType value() const; 58 58 59 /** Returns the vector of supported values. */ 60 QVector<KAudioDriverType> supportedValues() const { return m_supportedValues; } 61 59 62 protected: 60 63 … … 77 80 bool m_fWithLabel; 78 81 82 /** Holds the value to be selected. */ 83 KAudioDriverType m_enmValue; 84 85 /** Holds the vector of supported values. */ 86 QVector<KAudioDriverType> m_supportedValues; 87 79 88 /** Holds the label instance. */ 80 89 QLabel *m_pLabel;
Note:
See TracChangeset
for help on using the changeset viewer.