1 | /* $Id: UIAudioFeaturesEditor.cpp 104313 2024-04-12 13:10:30Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UIAudioFeaturesEditor class implementation.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2023 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox base platform packages, as
|
---|
10 | * available from https://www.virtualbox.org.
|
---|
11 | *
|
---|
12 | * This program is free software; you can redistribute it and/or
|
---|
13 | * modify it under the terms of the GNU General Public License
|
---|
14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
15 | * License.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful, but
|
---|
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | * General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | *
|
---|
25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
26 | */
|
---|
27 |
|
---|
28 | /* Qt includes: */
|
---|
29 | #include <QCheckBox>
|
---|
30 | #include <QGridLayout>
|
---|
31 | #include <QLabel>
|
---|
32 |
|
---|
33 | /* GUI includes: */
|
---|
34 | #include "UIAudioFeaturesEditor.h"
|
---|
35 |
|
---|
36 |
|
---|
37 | UIAudioFeaturesEditor::UIAudioFeaturesEditor(QWidget *pParent /* = 0 */)
|
---|
38 | : UIEditor(pParent, true /* show in basic mode? */)
|
---|
39 | , m_fEnableOutput(false)
|
---|
40 | , m_fEnableInput(false)
|
---|
41 | , m_pLabel(0)
|
---|
42 | , m_pCheckBoxEnableOutput(0)
|
---|
43 | , m_pCheckBoxEnableInput(0)
|
---|
44 | {
|
---|
45 | prepare();
|
---|
46 | }
|
---|
47 |
|
---|
48 | void UIAudioFeaturesEditor::setEnableOutput(bool fOn)
|
---|
49 | {
|
---|
50 | /* Update cached value and
|
---|
51 | * check-box if value has changed: */
|
---|
52 | if (m_fEnableOutput != fOn)
|
---|
53 | {
|
---|
54 | m_fEnableOutput = fOn;
|
---|
55 | if (m_pCheckBoxEnableOutput)
|
---|
56 | m_pCheckBoxEnableOutput->setCheckState(m_fEnableOutput ? Qt::Checked : Qt::Unchecked);
|
---|
57 | }
|
---|
58 | }
|
---|
59 |
|
---|
60 | bool UIAudioFeaturesEditor::outputEnabled() const
|
---|
61 | {
|
---|
62 | return m_pCheckBoxEnableOutput
|
---|
63 | ? m_pCheckBoxEnableOutput->checkState() == Qt::Checked
|
---|
64 | : m_fEnableOutput;
|
---|
65 | }
|
---|
66 |
|
---|
67 | void UIAudioFeaturesEditor::setEnableInput(bool fOn)
|
---|
68 | {
|
---|
69 | /* Update cached value and
|
---|
70 | * check-box if value has changed: */
|
---|
71 | if (m_fEnableInput != fOn)
|
---|
72 | {
|
---|
73 | m_fEnableInput = fOn;
|
---|
74 | if (m_pCheckBoxEnableInput)
|
---|
75 | m_pCheckBoxEnableInput->setCheckState(m_fEnableInput ? Qt::Checked : Qt::Unchecked);
|
---|
76 | }
|
---|
77 | }
|
---|
78 |
|
---|
79 | bool UIAudioFeaturesEditor::inputEnabled() const
|
---|
80 | {
|
---|
81 | return m_pCheckBoxEnableInput
|
---|
82 | ? m_pCheckBoxEnableInput->checkState() == Qt::Checked
|
---|
83 | : m_fEnableInput;
|
---|
84 | }
|
---|
85 |
|
---|
86 | int UIAudioFeaturesEditor::minimumLabelHorizontalHint() const
|
---|
87 | {
|
---|
88 | return m_pLabel ? m_pLabel->minimumSizeHint().width() : 0;
|
---|
89 | }
|
---|
90 |
|
---|
91 | void UIAudioFeaturesEditor::setMinimumLayoutIndent(int iIndent)
|
---|
92 | {
|
---|
93 | if (m_pLayout)
|
---|
94 | m_pLayout->setColumnMinimumWidth(0, iIndent);
|
---|
95 | }
|
---|
96 |
|
---|
97 | void UIAudioFeaturesEditor::sltRetranslateUI()
|
---|
98 | {
|
---|
99 | if (m_pLabel)
|
---|
100 | m_pLabel->setText(tr("Extended Features:"));
|
---|
101 | if (m_pCheckBoxEnableOutput)
|
---|
102 | {
|
---|
103 | m_pCheckBoxEnableOutput->setText(tr("Enable Audio &Output"));
|
---|
104 | m_pCheckBoxEnableOutput->setToolTip(tr("When checked, output to the virtual audio device will reach the host. "
|
---|
105 | "Otherwise the guest is muted."));
|
---|
106 | }
|
---|
107 | if (m_pCheckBoxEnableInput)
|
---|
108 | {
|
---|
109 | m_pCheckBoxEnableInput->setText(tr("Enable Audio &Input"));
|
---|
110 | m_pCheckBoxEnableInput->setToolTip(tr("When checked, the guest will be able to capture audio input from the host. "
|
---|
111 | "Otherwise the guest will capture only silence."));
|
---|
112 | }
|
---|
113 | }
|
---|
114 |
|
---|
115 | void UIAudioFeaturesEditor::prepare()
|
---|
116 | {
|
---|
117 | /* Prepare main layout: */
|
---|
118 | m_pLayout = new QGridLayout(this);
|
---|
119 | if (m_pLayout)
|
---|
120 | {
|
---|
121 | m_pLayout->setContentsMargins(0, 0, 0, 0);
|
---|
122 | m_pLayout->setColumnStretch(1, 1);
|
---|
123 |
|
---|
124 | /* Prepare label: */
|
---|
125 | m_pLabel = new QLabel(this);
|
---|
126 | if (m_pLabel)
|
---|
127 | {
|
---|
128 | m_pLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
---|
129 | m_pLayout->addWidget(m_pLabel, 0, 0);
|
---|
130 | }
|
---|
131 | /* Prepare 'enable output' check-box: */
|
---|
132 | m_pCheckBoxEnableOutput = new QCheckBox(this);
|
---|
133 | if (m_pCheckBoxEnableOutput)
|
---|
134 | m_pLayout->addWidget(m_pCheckBoxEnableOutput, 0, 1);
|
---|
135 | /* Prepare 'enable input' check-box: */
|
---|
136 | m_pCheckBoxEnableInput = new QCheckBox(this);
|
---|
137 | if (m_pCheckBoxEnableInput)
|
---|
138 | m_pLayout->addWidget(m_pCheckBoxEnableInput, 1, 1);
|
---|
139 | }
|
---|
140 |
|
---|
141 | /* Apply language settings: */
|
---|
142 | sltRetranslateUI();
|
---|
143 | }
|
---|