source: trunk/examples/phonon/capabilities/window.cpp@ 563

Last change on this file since 563 was 561, checked in by Dmitry A. Kuminov, 15 years ago

trunk: Merged in qt 4.6.1 sources.

File size: 6.0 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
6**
7** This file is part of the examples of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
15**
16** GNU Lesser General Public License Usage
17** Alternatively, this file may be used under the terms of the GNU Lesser
18** General Public License version 2.1 as published by the Free Software
19** Foundation and appearing in the file LICENSE.LGPL included in the
20** packaging of this file. Please review the following information to
21** ensure the GNU Lesser General Public License version 2.1 requirements
22** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23**
24** In addition, as a special exception, Nokia gives you certain additional
25** rights. These rights are described in the Nokia Qt LGPL Exception
26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you have questions regarding the use of this file, please contact
37** Nokia at [email protected].
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#include <QtGui>
43
44#include "window.h"
45
46//! [constructor]
47Window::Window()
48{
49 setupUi();
50 updateWidgets();
51
52 connect(Phonon::BackendCapabilities::notifier(),
53 SIGNAL(capabilitiesChanged()), this, SLOT(updateWidgets()));
54 connect(Phonon::BackendCapabilities::notifier(),
55 SIGNAL(availableAudioOutputDevicesChanged()), SLOT(updateWidgets()));
56}
57//! [constructor]
58
59//! [outputDevices]
60void Window::updateWidgets()
61{
62 devicesListView->setModel(new QStandardItemModel());
63 Phonon::ObjectDescriptionModel<Phonon::AudioOutputDeviceType> *model =
64 new Phonon::ObjectDescriptionModel<Phonon::AudioOutputDeviceType>();
65 model->setModelData(Phonon::BackendCapabilities::availableAudioOutputDevices());
66 devicesListView->setModel(model);
67//! [outputDevices]
68
69//! [mimeTypes]
70 mimeListWidget->clear();
71 QStringList mimeTypes =
72 Phonon::BackendCapabilities::availableMimeTypes();
73 foreach (QString mimeType, mimeTypes) {
74 QListWidgetItem *item = new QListWidgetItem(mimeListWidget);
75 item->setText(mimeType);
76 }
77//! [mimeTypes]
78
79//! [effects]
80 effectsTreeWidget->clear();
81 QList<Phonon::EffectDescription> effects =
82 Phonon::BackendCapabilities::availableAudioEffects();
83 foreach (Phonon::EffectDescription effect, effects) {
84 QTreeWidgetItem *item = new QTreeWidgetItem(effectsTreeWidget);
85 item->setText(0, tr("Effect"));
86 item->setText(1, effect.name());
87 item->setText(2, effect.description());
88//! [effects]
89
90//! [effectsParameters]
91 Phonon::Effect *instance = new Phonon::Effect(effect, this);
92 QList<Phonon::EffectParameter> parameters = instance->parameters();
93 for (int i = 0; i < parameters.size(); ++i) {
94 Phonon::EffectParameter parameter = parameters.at(i);
95
96 QVariant defaultValue = parameter.defaultValue();
97 QVariant minimumValue = parameter.minimumValue();
98 QVariant maximumValue = parameter.maximumValue();
99
100 QString valueString = QString("%1 / %2 / %3")
101 .arg(defaultValue.toString()).arg(minimumValue.toString())
102 .arg(maximumValue.toString());
103
104 QTreeWidgetItem *parameterItem = new QTreeWidgetItem(item);
105 parameterItem->setText(0, tr("Parameter"));
106 parameterItem->setText(1, parameter.name());
107 parameterItem->setText(2, parameter.description());
108 parameterItem->setText(3, QVariant::typeToName(parameter.type()));
109 parameterItem->setText(4, valueString);
110 }
111 }
112//! [effectsParameters]
113 for (int i = 0; i < effectsTreeWidget->columnCount(); ++i) {
114 if (i == 0)
115 effectsTreeWidget->setColumnWidth(0, 150);
116 else if (i == 2)
117 effectsTreeWidget->setColumnWidth(2, 350);
118 else
119 effectsTreeWidget->resizeColumnToContents(i);
120 }
121}
122
123void Window::setupUi()
124{
125 setupBackendBox();
126
127 QLayout *layout = new QVBoxLayout;
128 layout->addWidget(backendBox);
129
130 setLayout(layout);
131 setWindowTitle(tr("Backend Capabilities Example"));
132}
133
134void Window::setupBackendBox()
135{
136 backendBox = new QGroupBox(tr("Backend Capabilities"));
137
138 devicesLabel = new QLabel(tr("Available Audio Devices:"));
139 devicesListView = new QListView;
140
141 mimeTypesLabel = new QLabel(tr("Supported MIME Types:"));
142 mimeListWidget = new QListWidget;
143
144 effectsLabel = new QLabel(tr("Available Audio Effects:"));
145
146 QStringList headerLabels;
147 headerLabels << tr("Type") << tr("Name") << tr("Description") <<
148 tr("Value Type") << tr("Default/Min/Max Values");
149
150 effectsTreeWidget = new QTreeWidget;
151 effectsTreeWidget->setHeaderLabels(headerLabels);
152 effectsTreeWidget->setColumnCount(5);
153
154 QGridLayout *layout = new QGridLayout;
155 layout->addWidget(devicesLabel, 0, 0);
156 layout->addWidget(devicesListView, 1, 0);
157 layout->addWidget(mimeTypesLabel, 0, 1);
158 layout->addWidget(mimeListWidget, 1, 1);
159 layout->addWidget(effectsLabel, 2, 0);
160 layout->addWidget(effectsTreeWidget, 3, 0, 2, 2);
161 layout->setRowStretch(3, 100);
162
163 backendBox = new QGroupBox(tr("Backend Capabilities"));
164 backendBox->setLayout(layout);
165}
166
Note: See TracBrowser for help on using the repository browser.