1
/* $Id: UIMachineSettingsAudio.cpp 33882 2010-11-09 09:32:27Z vboxsync $ */
4
* VBox frontends: Qt4 GUI ("VirtualBox"):
5
* UIMachineSettingsAudio class implementation
9
* Copyright (C) 2006-2010 Oracle Corporation
11
* This file is part of VirtualBox Open Source Edition (OSE), as
12
* available from http://www.virtualbox.org. This file is free software;
13
* you can redistribute it and/or modify it under the terms of the GNU
14
* General Public License (GPL) as published by the Free Software
15
* Foundation, in version 2 as it comes in the "COPYING" file of the
16
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
17
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
20
#include "UIMachineSettingsAudio.h"
21
#include "VBoxGlobal.h"
23
UIMachineSettingsAudio::UIMachineSettingsAudio()
25
/* Apply UI decorations */
26
Ui::UIMachineSettingsAudio::setupUi (this);
27
/* Applying language settings */
31
/* Load data to cashe from corresponding external object(s),
32
* this task COULD be performed in other than GUI thread: */
33
void UIMachineSettingsAudio::loadToCacheFrom(QVariant &data)
35
/* Fetch data to machine: */
36
UISettingsPageMachine::fetchData(data);
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();
44
/* Upload machine to data: */
45
UISettingsPageMachine::uploadData(data);
48
/* Load data to corresponding widgets from cache,
49
* this task SHOULD be performed in GUI thread only: */
50
void UIMachineSettingsAudio::getFromCache()
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)));
58
/* Save data from corresponding widgets to cache,
59
* this task SHOULD be performed in GUI thread only: */
60
void UIMachineSettingsAudio::putToCache()
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());
68
/* Save data from cache to corresponding external object(s),
69
* this task COULD be performed in other than GUI thread: */
70
void UIMachineSettingsAudio::saveFromCacheTo(QVariant &data)
72
/* Fetch data to machine: */
73
UISettingsPageMachine::fetchData(data);
75
/* Gather corresponding values from internal variables: */
76
CAudioAdapter audio = m_machine.GetAudioAdapter();
77
audio.SetEnabled(m_cache.m_fAudioEnabled);
78
audio.SetAudioDriver(m_cache.m_audioDriverType);
79
audio.SetAudioController(m_cache.m_audioControllerType);
81
/* Upload machine to data: */
82
UISettingsPageMachine::uploadData(data);
85
void UIMachineSettingsAudio::setOrderAfter (QWidget *aWidget)
87
setTabOrder (aWidget, mGbAudio);
88
setTabOrder (mGbAudio, mCbAudioDriver);
89
setTabOrder (mCbAudioDriver, mCbAudioController);
92
void UIMachineSettingsAudio::retranslateUi()
94
/* Translate uic generated strings */
95
Ui::UIMachineSettingsAudio::retranslateUi (this);
96
/* Fill the comboboxes */
100
void UIMachineSettingsAudio::prepareComboboxes()
102
/* Save the current selected value */
103
int currentDriver = mCbAudioDriver->currentIndex();
104
/* Clear the driver box */
105
mCbAudioDriver->clear();
107
mCbAudioDriver->addItem (vboxGlobal().toString (KAudioDriverType_Null));
108
#if defined Q_WS_WIN32
109
mCbAudioDriver->addItem (vboxGlobal().toString (KAudioDriverType_DirectSound));
110
# ifdef VBOX_WITH_WINMM
111
mCbAudioDriver->addItem (vboxGlobal().toString (KAudioDriverType_WinMM));
114
#if defined Q_OS_SOLARIS
115
mCbAudioDriver->addItem (vboxGlobal().toString (KAudioDriverType_SolAudio));
116
# if defined VBOX_WITH_SOLARIS_OSS
117
mCbAudioDriver->addItem (vboxGlobal().toString (KAudioDriverType_OSS));
120
#if defined Q_OS_LINUX || defined Q_OS_FREEBSD
121
mCbAudioDriver->addItem (vboxGlobal().toString (KAudioDriverType_OSS));
122
# ifdef VBOX_WITH_PULSE
123
mCbAudioDriver->addItem (vboxGlobal().toString (KAudioDriverType_Pulse));
126
#if defined Q_OS_LINUX
127
# ifdef VBOX_WITH_ALSA
128
mCbAudioDriver->addItem (vboxGlobal().toString (KAudioDriverType_ALSA));
131
#if defined Q_OS_MACX
132
mCbAudioDriver->addItem (vboxGlobal().toString (KAudioDriverType_CoreAudio));
134
/* Set the old value */
135
mCbAudioDriver->setCurrentIndex (currentDriver);
137
/* Save the current selected value */
138
int currentController = mCbAudioController->currentIndex();
139
/* Clear the controller box */
140
mCbAudioController->clear();
142
mCbAudioController->insertItem (mCbAudioController->count(),
143
vboxGlobal().toString (KAudioControllerType_HDA));
144
mCbAudioController->insertItem (mCbAudioController->count(),
145
vboxGlobal().toString (KAudioControllerType_AC97));
146
mCbAudioController->insertItem (mCbAudioController->count(),
147
vboxGlobal().toString (KAudioControllerType_SB16));
148
/* Set the old value */
149
mCbAudioController->setCurrentIndex (currentController);