2
* KMix -- KDE's full featured mini mixer
5
* Copyright (C) 1996-2004 Christian Esken <esken@kde.org>
7
* This program is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU Library General Public
9
* License as published by the Free Software Foundation; either
10
* version 2 of the License, or (at your option) any later version.
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
* Library General Public License for more details.
17
* You should have received a copy of the GNU Library General Public
18
* License along with this program; if not, write to the Free
19
* Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22
#include "viewsurround.h"
31
#include <kiconloader.h>
34
#include "kmixtoolbox.h"
35
#include "mdwslider.h"
39
* Demonstration verion of a "surround view"
40
* Not really usable right now.
42
ViewSurround::ViewSurround(QWidget* parent, const char* name, Mixer* mixer, ViewBase::ViewFlags vflags)
43
: ViewBase(parent, name, mixer, WStyle_Customize|WStyle_NoBorder, vflags)
47
_layoutMDW = new QHBoxLayout(this);
48
_layoutMDW->setMargin(8);
49
// Create switch buttonGroup
50
if ( _vflags & ViewBase::Vertical ) {
51
_layoutSliders = new QVBoxLayout(_layoutMDW);
54
_layoutSliders = new QHBoxLayout(_layoutMDW);
56
_layoutSurround = new QGridLayout(_layoutMDW,3,5);
57
// _layoutMDW->setMargin(8);
61
ViewSurround::~ViewSurround() {
64
void ViewSurround::setMixSet(MixSet *mixset)
67
for ( md = mixset->first(); md != 0; md = mixset->next() ) {
68
if ( ! md->isSwitch() ) {
69
switch ( md->type() ) {
70
case MixDevice::VOLUME:
71
case MixDevice::SURROUND:
72
case MixDevice::SURROUND_BACK:
73
case MixDevice::SURROUND_LFE:
74
case MixDevice::SURROUND_CENTERFRONT:
75
case MixDevice::SURROUND_CENTERBACK:
80
// we are not interested in other channels
87
int ViewSurround::count()
89
return ( _mixSet->count() );
92
int ViewSurround::advice() {
93
if ( _mixSet->count() > 0 ) {
94
// The standard input and output views are always advised, if there are devices in it
102
QWidget* ViewSurround::add(MixDevice *md)
105
Qt::Orientation orientation = Qt::Vertical;
106
switch ( md->type() ) {
107
case MixDevice::VOLUME:
108
_mdSurroundFront = md;
111
case MixDevice::SURROUND_BACK:
112
_mdSurroundBack = md;
115
case MixDevice::SURROUND_LFE:
116
orientation = Qt::Horizontal;
119
case MixDevice::SURROUND_CENTERFRONT:
120
orientation = Qt::Horizontal;
123
case MixDevice::SURROUND_CENTERBACK:
124
orientation = Qt::Horizontal;
130
// these are the sliders on the left side of the surround View
131
orientation = (_vflags & ViewBase::Vertical) ? Qt::Horizontal : Qt::Vertical;
134
MixDeviceWidget *mdw = createMDW(md, small, orientation);
136
switch ( md->type() ) {
137
case MixDevice::VOLUME:
138
_layoutSurround->addWidget(mdw ,0,0, Qt::AlignBottom | Qt::AlignLeft);
141
case MixDevice::SURROUND_BACK:
142
_layoutSurround->addWidget(mdw ,2,0, Qt::AlignTop | Qt::AlignLeft);
144
case MixDevice::SURROUND_LFE:
145
_layoutSurround->addWidget(mdw,1,3, Qt::AlignVCenter | Qt::AlignRight ); break;
147
case MixDevice::SURROUND_CENTERFRONT:
148
_layoutSurround->addWidget(mdw,0,2, Qt::AlignTop | Qt::AlignHCenter); break;
150
case MixDevice::SURROUND_CENTERBACK:
151
_layoutSurround->addWidget(mdw,2,2, Qt::AlignBottom | Qt::AlignHCenter); break;
154
case MixDevice::SURROUND:
155
case MixDevice::AC97:
157
// Add as slider to the layout on the left side
158
_layoutSliders->add(mdw);
165
QSize ViewSurround::sizeHint() const {
166
// kdDebug(67100) << "ViewSurround::sizeHint(): NewSize is " << _layoutMDW->sizeHint() << "\n";
167
return( _layoutMDW->sizeHint() );
170
void ViewSurround::constructionFinished() {
171
QLabel* personLabel = new QLabel("Listener", this);
172
QPixmap icon = UserIcon( "Listener" );
173
if ( ! icon.isNull()) personLabel->setPixmap(icon);
174
personLabel->setLineWidth( 4 );
175
personLabel->setMidLineWidth( 3 );
176
personLabel->setFrameStyle( QFrame::Panel | QFrame::Sunken );
177
int rowOfSpeaker = 0;
178
if ( _mdSurroundBack != 0 ) {
179
// let the speaker "sit" in the rear of the room, if there is
180
// rear speaker support in this sound card
183
_layoutSurround->addWidget(personLabel ,rowOfSpeaker, 2, Qt::AlignHCenter | Qt::AlignVCenter);
185
if ( _mdSurroundFront != 0 ) {
186
MixDeviceWidget *mdw = createMDW(_mdSurroundFront, true, Qt::Vertical);
187
_layoutSurround->addWidget(mdw,0,4, Qt::AlignBottom | Qt::AlignRight);
190
QLabel* speakerIcon = new QLabel("Speaker", this);
191
icon = UserIcon( "SpeakerFrontLeft" );
192
if ( ! icon.isNull()) speakerIcon->setPixmap(icon);
193
_layoutSurround->addWidget(speakerIcon,0,1, Qt::AlignTop | Qt::AlignLeft);
195
speakerIcon = new QLabel("Speaker", this);
196
icon = UserIcon( "SpeakerFrontRight" );
197
if ( ! icon.isNull()) speakerIcon->setPixmap(icon);
198
_layoutSurround->addWidget(speakerIcon,0,3, Qt::AlignTop | Qt::AlignRight);
202
if ( _mdSurroundBack != 0 ) {
203
MixDeviceWidget *mdw = createMDW(_mdSurroundBack, true, Qt::Vertical);
204
_layoutSurround->addWidget(mdw,2,4, Qt::AlignTop | Qt::AlignRight);
207
QLabel* speakerIcon = new QLabel("Speaker", this);
208
icon = UserIcon( "SpeakerRearLeft" );
209
if ( ! icon.isNull()) speakerIcon->setPixmap(icon);
210
_layoutSurround->addWidget(speakerIcon,2,1, Qt::AlignBottom | Qt::AlignLeft);
212
speakerIcon = new QLabel("Speaker", this);
213
icon = UserIcon( "SpeakerRearRight" );
214
if ( ! icon.isNull()) speakerIcon->setPixmap(icon);
215
_layoutSurround->addWidget(speakerIcon,2,3, Qt::AlignBottom | Qt::AlignRight);
220
// !! just for the demo version
221
KMixToolBox::setIcons (_mdws, true);
222
KMixToolBox::setLabels(_mdws, true);
223
KMixToolBox::setTicks (_mdws, true);
225
_layoutMDW->activate();
228
void ViewSurround::refreshVolumeLevels() {
229
// kdDebug(67100) << "ViewSurround::refreshVolumeLevels()\n";
231
QWidget *mdw = _mdws.first();
233
for ( md = _mixSet->first(); md != 0; md = _mixSet->next() ) {
235
kdError(67100) << "ViewSurround::refreshVolumeLevels(): mdw == 0\n";
236
break; // sanity check (normally the lists are set up correctly)
239
if ( mdw->inherits("MDWSlider")) {
240
//kdDebug(67100) << "ViewSurround::refreshVolumeLevels(): updating\n";
241
// a slider, fine. Lets update its value
242
static_cast<MDWSlider*>(mdw)->update();
245
kdError(67100) << "ViewSurround::refreshVolumeLevels(): mdw is not slider\n";
246
// no slider. Cannot happen in theory => skip it
254
MixDeviceWidget* ViewSurround::createMDW(MixDevice *md, bool small, Qt::Orientation orientation)
256
MixDeviceWidget* mdw = new MDWSlider(
257
_mixer, // the mixer for this device
258
md, // MixDevice (parameter)
259
false, // Show Mute LED
260
false, // Show Record LED
262
orientation, // Orientation
270
#include "viewsurround.moc"