~ubuntu-branches/ubuntu/raring/virtualbox-ose/raring

« back to all changes in this revision

Viewing changes to src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsAudio.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Felix Geyer
  • Date: 2011-01-30 23:27:25 UTC
  • mfrom: (0.3.12 upstream)
  • Revision ID: james.westby@ubuntu.com-20110130232725-2ouajjd2ggdet0zd
Tags: 4.0.2-dfsg-1ubuntu1
* Merge from Debian unstable, remaining changes:
  - Add Apport hook.
    - debian/virtualbox-ose.files/source_virtualbox-ose.py
    - debian/virtualbox-ose.install
  - Drop *-source packages.
* Drop ubuntu-01-fix-build-gcc45.patch, fixed upstream.
* Drop ubuntu-02-as-needed.patch, added to the Debian package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $Id: UIMachineSettingsAudio.cpp 33882 2010-11-09 09:32:27Z vboxsync $ */
 
2
/** @file
 
3
 *
 
4
 * VBox frontends: Qt4 GUI ("VirtualBox"):
 
5
 * UIMachineSettingsAudio class implementation
 
6
 */
 
7
 
 
8
/*
 
9
 * Copyright (C) 2006-2010 Oracle Corporation
 
10
 *
 
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.
 
18
 */
 
19
 
 
20
#include "UIMachineSettingsAudio.h"
 
21
#include "VBoxGlobal.h"
 
22
 
 
23
UIMachineSettingsAudio::UIMachineSettingsAudio()
 
24
{
 
25
    /* Apply UI decorations */
 
26
    Ui::UIMachineSettingsAudio::setupUi (this);
 
27
    /* Applying language settings */
 
28
    retranslateUi();
 
29
}
 
30
 
 
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)
 
34
{
 
35
    /* Fetch data to machine: */
 
36
    UISettingsPageMachine::fetchData(data);
 
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();
 
43
 
 
44
    /* Upload machine to data: */
 
45
    UISettingsPageMachine::uploadData(data);
 
46
}
 
47
 
 
48
/* Load data to corresponding widgets from cache,
 
49
 * this task SHOULD be performed in GUI thread only: */
 
50
void UIMachineSettingsAudio::getFromCache()
 
51
{
 
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)));
 
56
}
 
57
 
 
58
/* Save data from corresponding widgets to cache,
 
59
 * this task SHOULD be performed in GUI thread only: */
 
60
void UIMachineSettingsAudio::putToCache()
 
61
{
 
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());
 
66
}
 
67
 
 
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)
 
71
{
 
72
    /* Fetch data to machine: */
 
73
    UISettingsPageMachine::fetchData(data);
 
74
 
 
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);
 
80
 
 
81
    /* Upload machine to data: */
 
82
    UISettingsPageMachine::uploadData(data);
 
83
}
 
84
 
 
85
void UIMachineSettingsAudio::setOrderAfter (QWidget *aWidget)
 
86
{
 
87
    setTabOrder (aWidget, mGbAudio);
 
88
    setTabOrder (mGbAudio, mCbAudioDriver);
 
89
    setTabOrder (mCbAudioDriver, mCbAudioController);
 
90
}
 
91
 
 
92
void UIMachineSettingsAudio::retranslateUi()
 
93
{
 
94
    /* Translate uic generated strings */
 
95
    Ui::UIMachineSettingsAudio::retranslateUi (this);
 
96
    /* Fill the comboboxes */
 
97
    prepareComboboxes();
 
98
}
 
99
 
 
100
void UIMachineSettingsAudio::prepareComboboxes()
 
101
{
 
102
    /* Save the current selected value */
 
103
    int currentDriver = mCbAudioDriver->currentIndex();
 
104
    /* Clear the driver box */
 
105
    mCbAudioDriver->clear();
 
106
    /* Refill them */
 
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));
 
112
# endif
 
113
#endif
 
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));
 
118
#endif
 
119
#endif
 
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));
 
124
# endif
 
125
#endif
 
126
#if defined Q_OS_LINUX
 
127
# ifdef VBOX_WITH_ALSA
 
128
    mCbAudioDriver->addItem (vboxGlobal().toString (KAudioDriverType_ALSA));
 
129
# endif
 
130
#endif
 
131
#if defined Q_OS_MACX
 
132
    mCbAudioDriver->addItem (vboxGlobal().toString (KAudioDriverType_CoreAudio));
 
133
#endif
 
134
    /* Set the old value */
 
135
    mCbAudioDriver->setCurrentIndex (currentDriver);
 
136
 
 
137
    /* Save the current selected value */
 
138
    int currentController = mCbAudioController->currentIndex();
 
139
    /* Clear the controller box */
 
140
    mCbAudioController->clear();
 
141
    /* Refill them */
 
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);
 
150
}
 
151