Changeset 36924 in vbox for trunk/src/VBox
- Timestamp:
- May 3, 2011 7:39:41 AM (14 years ago)
- 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
r36519 r36924 36 36 UISettingsPageMachine::fetchData(data); 37 37 38 /* Fill internal variables with corresponding values: */ 39 const CAudioAdapter &audio = m_machine.GetAudioAdapter(); 40 m_cache.m_fAudioEnabled = audio.GetEnabled(); 41 m_cache.m_audioDriverType = audio.GetAudioDriver(); 42 m_cache.m_audioControllerType = audio.GetAudioController(); 38 /* Prepare audio data: */ 39 UIDataSettingsMachineAudio audioData; 40 41 /* Check if adapter is valid: */ 42 const CAudioAdapter &adapter = m_machine.GetAudioAdapter(); 43 if (!adapter.isNull()) 44 { 45 /* Gather audio data: */ 46 audioData.m_fAudioEnabled = adapter.GetEnabled(); 47 audioData.m_audioDriverType = adapter.GetAudioDriver(); 48 audioData.m_audioControllerType = adapter.GetAudioController(); 49 } 50 51 /* Cache audio data: */ 52 m_cache.cacheInitialData(audioData); 43 53 44 54 /* Upload machine to data: */ … … 50 60 void UIMachineSettingsAudio::getFromCache() 51 61 { 52 /* Apply internal variables data to QWidget(s): */ 53 mGbAudio->setChecked(m_cache.m_fAudioEnabled); 54 mCbAudioDriver->setCurrentIndex(mCbAudioDriver->findText(vboxGlobal().toString(m_cache.m_audioDriverType))); 55 mCbAudioController->setCurrentIndex(mCbAudioController->findText(vboxGlobal().toString(m_cache.m_audioControllerType))); 62 /* Get audio data from cache: */ 63 const UIDataSettingsMachineAudio &audioData = m_cache.base(); 64 65 /* Load audio data to page: */ 66 mGbAudio->setChecked(audioData.m_fAudioEnabled); 67 mCbAudioDriver->setCurrentIndex(mCbAudioDriver->findText(vboxGlobal().toString(audioData.m_audioDriverType))); 68 mCbAudioController->setCurrentIndex(mCbAudioController->findText(vboxGlobal().toString(audioData.m_audioControllerType))); 56 69 } 57 70 … … 60 73 void UIMachineSettingsAudio::putToCache() 61 74 { 62 /* Gather internal variables data from QWidget(s): */ 63 m_cache.m_fAudioEnabled = mGbAudio->isChecked(); 64 m_cache.m_audioDriverType = vboxGlobal().toAudioDriverType(mCbAudioDriver->currentText()); 65 m_cache.m_audioControllerType = vboxGlobal().toAudioControllerType(mCbAudioController->currentText()); 75 /* Prepare audio data: */ 76 UIDataSettingsMachineAudio audioData = m_cache.base(); 77 78 /* Gather audio data: */ 79 audioData.m_fAudioEnabled = mGbAudio->isChecked(); 80 audioData.m_audioDriverType = vboxGlobal().toAudioDriverType(mCbAudioDriver->currentText()); 81 audioData.m_audioControllerType = vboxGlobal().toAudioControllerType(mCbAudioController->currentText()); 82 83 /* Cache audio data: */ 84 m_cache.cacheCurrentData(audioData); 66 85 } 67 86 … … 73 92 UISettingsPageMachine::fetchData(data); 74 93 75 if (isMachineOffline()) 94 /* Check if audio data was changed: */ 95 if (m_cache.wasChanged()) 76 96 { 77 CAudioAdapter audio = m_machine.GetAudioAdapter(); 78 audio.SetEnabled(m_cache.m_fAudioEnabled); 79 audio.SetAudioDriver(m_cache.m_audioDriverType); 80 audio.SetAudioController(m_cache.m_audioControllerType); 97 /* Check if adapter still valid: */ 98 CAudioAdapter adapter = m_machine.GetAudioAdapter(); 99 if (!adapter.isNull()) 100 { 101 /* Get audio data from cache: */ 102 const UIDataSettingsMachineAudio &audioData = m_cache.data(); 103 104 /* Store audio data: */ 105 if (isMachineOffline()) 106 { 107 adapter.SetEnabled(audioData.m_fAudioEnabled); 108 adapter.SetAudioDriver(audioData.m_audioDriverType); 109 adapter.SetAudioController(audioData.m_audioControllerType); 110 } 111 } 81 112 } 82 113 -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsAudio.h
r36357 r36924 24 24 #include "COMDefs.h" 25 25 26 /* Machine settings / Audio page / Cache: */27 struct UI SettingsCacheMachineAudio26 /* Machine settings / Audio page / Data: */ 27 struct UIDataSettingsMachineAudio 28 28 { 29 /* Default constructor: */ 30 UIDataSettingsMachineAudio() 31 : m_fAudioEnabled(false) 32 , m_audioDriverType(KAudioDriverType_Null) 33 , m_audioControllerType(KAudioControllerType_AC97) {} 34 /* Functions: */ 35 bool equal(const UIDataSettingsMachineAudio &other) const 36 { 37 return (m_fAudioEnabled == other.m_fAudioEnabled) && 38 (m_audioDriverType == other.m_audioDriverType) && 39 (m_audioControllerType == other.m_audioControllerType); 40 } 41 /* Operators: */ 42 bool operator==(const UIDataSettingsMachineAudio &other) const { return equal(other); } 43 bool operator!=(const UIDataSettingsMachineAudio &other) const { return !equal(other); } 44 /* Variables: */ 29 45 bool m_fAudioEnabled; 30 46 KAudioDriverType m_audioDriverType; 31 47 KAudioControllerType m_audioControllerType; 32 48 }; 49 typedef UISettingsCache<UIDataSettingsMachineAudio> UICacheSettingsMachineAudio; 33 50 34 51 /* Machine settings / Audio page: */ … … 69 86 70 87 /* Cache: */ 71 UI SettingsCacheMachineAudio m_cache;88 UICacheSettingsMachineAudio m_cache; 72 89 }; 73 90
Note:
See TracChangeset
for help on using the changeset viewer.