add more spacing
[personal-kdebase.git] / runtime / phonon / tests / guitest / audiooutputitem.cpp
blob4b995c2f18cb5c5e30f9afaf20f14221d43cd39c
1 /* This file is part of the KDE project
2 Copyright (C) 2007 Matthias Kretz <kretz@kde.org>
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License version 2 as published by the Free Software Foundation.
8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details.
13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 Boston, MA 02110-1301, USA.
20 #include "audiooutputitem.h"
21 #include <QtCore/QModelIndex>
22 #include <QtGui/QHBoxLayout>
23 #include <QtGui/QListView>
25 #include <Phonon/AudioOutputDevice>
26 #include <Phonon/BackendCapabilities>
27 #include <kdebug.h>
29 using Phonon::AudioOutputDevice;
31 AudioOutputItem::AudioOutputItem()
32 : m_output(Phonon::MusicCategory)
34 m_output.setName("GUI-Test");
36 QHBoxLayout *hlayout = new QHBoxLayout(this);
37 hlayout->setMargin(0);
39 m_deviceListView = new QListView(this);
40 hlayout->addWidget(m_deviceListView);
41 QList<AudioOutputDevice> deviceList = Phonon::BackendCapabilities::availableAudioOutputDevices();
42 m_model = new AudioOutputDeviceModel(deviceList, m_deviceListView);
43 m_deviceListView->setModel(m_model);
44 m_deviceListView->setCurrentIndex(m_model->index(deviceList.indexOf(m_output.outputDevice()), 0));
45 connect(m_deviceListView, SIGNAL(activated(const QModelIndex &)), SLOT(deviceChange(const QModelIndex &)));
47 m_volslider = new VolumeSlider(this);
48 m_volslider->setOrientation(Qt::Vertical);
49 m_volslider->setAudioOutput(&m_output);
50 hlayout->addWidget(m_volslider);
52 connect(Phonon::BackendCapabilities::notifier(), SIGNAL(availableAudioOutputDevicesChanged()),
53 SLOT(availableDevicesChanged()));
56 void AudioOutputItem::availableDevicesChanged()
58 QList<AudioOutputDevice> deviceList = Phonon::BackendCapabilities::availableAudioOutputDevices();
59 Q_ASSERT(m_model);
60 m_model->setModelData(deviceList);
61 m_deviceListView->setCurrentIndex(m_model->index(deviceList.indexOf(m_output.outputDevice()), 0));
64 void AudioOutputItem::deviceChange(const QModelIndex &modelIndex)
66 Q_ASSERT(m_model);
67 AudioOutputDevice device = m_model->modelData(modelIndex);
68 m_output.setOutputDevice(device);
71 #include "moc_audiooutputitem.cpp"
72 #include "moc_sinkitem.cpp"