summaryrefslogtreecommitdiffstats
path: root/examples/phonon/capabilities
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@nokia.com>2009-03-23 09:34:13 (GMT)
committerSimon Hausmann <simon.hausmann@nokia.com>2009-03-23 09:34:13 (GMT)
commit67ad0519fd165acee4a4d2a94fa502e9e4847bd0 (patch)
tree1dbf50b3dff8d5ca7e9344733968c72704eb15ff /examples/phonon/capabilities
downloadQt-67ad0519fd165acee4a4d2a94fa502e9e4847bd0.zip
Qt-67ad0519fd165acee4a4d2a94fa502e9e4847bd0.tar.gz
Qt-67ad0519fd165acee4a4d2a94fa502e9e4847bd0.tar.bz2
Long live Qt!
Diffstat (limited to 'examples/phonon/capabilities')
-rw-r--r--examples/phonon/capabilities/capabilities.pro16
-rw-r--r--examples/phonon/capabilities/main.cpp58
-rw-r--r--examples/phonon/capabilities/window.cpp166
-rw-r--r--examples/phonon/capabilities/window.h97
4 files changed, 337 insertions, 0 deletions
diff --git a/examples/phonon/capabilities/capabilities.pro b/examples/phonon/capabilities/capabilities.pro
new file mode 100644
index 0000000..52b6b1b
--- /dev/null
+++ b/examples/phonon/capabilities/capabilities.pro
@@ -0,0 +1,16 @@
+QT += phonon
+
+HEADERS += window.h
+SOURCES += window.cpp \
+ main.cpp
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/phonon/capabilities
+sources.files = $$SOURCES $$HEADERS capabilities.pro
+sources.path = $$[QT_INSTALL_EXAMPLES]/phonon/capabilities
+INSTALLS += target sources
+
+wince*{
+DEPLOYMENT_PLUGIN += phonon_ds9 phonon_waveout
+}
+
diff --git a/examples/phonon/capabilities/main.cpp b/examples/phonon/capabilities/main.cpp
new file mode 100644
index 0000000..a746925
--- /dev/null
+++ b/examples/phonon/capabilities/main.cpp
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "window.h"
+
+//! [everything]
+int main(int argv, char **args)
+{
+ QApplication app(argv, args);
+ app.setApplicationName("Phonon Capabilities Example");
+
+ Window window;
+ window.show();
+
+ return app.exec();
+}
+//! [everything]
+
diff --git a/examples/phonon/capabilities/window.cpp b/examples/phonon/capabilities/window.cpp
new file mode 100644
index 0000000..920e3e0
--- /dev/null
+++ b/examples/phonon/capabilities/window.cpp
@@ -0,0 +1,166 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "window.h"
+
+//! [constructor]
+Window::Window()
+{
+ setupUi();
+ updateWidgets();
+
+ connect(Phonon::BackendCapabilities::notifier(),
+ SIGNAL(capabilitiesChanged()), this, SLOT(updateWidgets()));
+ connect(Phonon::BackendCapabilities::notifier(),
+ SIGNAL(availableAudioOutputDevicesChanged()), SLOT(updateWidgets()));
+}
+//! [constructor]
+
+//! [outputDevices]
+void Window::updateWidgets()
+{
+ devicesListView->setModel(new QStandardItemModel());
+ Phonon::ObjectDescriptionModel<Phonon::AudioOutputDeviceType> *model =
+ new Phonon::ObjectDescriptionModel<Phonon::AudioOutputDeviceType>();
+ model->setModelData(Phonon::BackendCapabilities::availableAudioOutputDevices());
+ devicesListView->setModel(model);
+//! [outputDevices]
+
+//! [mimeTypes]
+ mimeListWidget->clear();
+ QStringList mimeTypes =
+ Phonon::BackendCapabilities::availableMimeTypes();
+ foreach (QString mimeType, mimeTypes) {
+ QListWidgetItem *item = new QListWidgetItem(mimeListWidget);
+ item->setText(mimeType);
+ }
+//! [mimeTypes]
+
+//! [effects]
+ effectsTreeWidget->clear();
+ QList<Phonon::EffectDescription> effects =
+ Phonon::BackendCapabilities::availableAudioEffects();
+ foreach (Phonon::EffectDescription effect, effects) {
+ QTreeWidgetItem *item = new QTreeWidgetItem(effectsTreeWidget);
+ item->setText(0, tr("Effect"));
+ item->setText(1, effect.name());
+ item->setText(2, effect.description());
+//! [effects]
+
+//! [effectsParameters]
+ Phonon::Effect *instance = new Phonon::Effect(effect, this);
+ QList<Phonon::EffectParameter> parameters = instance->parameters();
+ for (int i = 0; i < parameters.size(); ++i) {
+ Phonon::EffectParameter parameter = parameters.at(i);
+
+ QVariant defaultValue = parameter.defaultValue();
+ QVariant minimumValue = parameter.minimumValue();
+ QVariant maximumValue = parameter.maximumValue();
+
+ QString valueString = QString("%1 / %2 / %3")
+ .arg(defaultValue.toString()).arg(minimumValue.toString())
+ .arg(maximumValue.toString());
+
+ QTreeWidgetItem *parameterItem = new QTreeWidgetItem(item);
+ parameterItem->setText(0, tr("Parameter"));
+ parameterItem->setText(1, parameter.name());
+ parameterItem->setText(2, parameter.description());
+ parameterItem->setText(3, QVariant::typeToName(parameter.type()));
+ parameterItem->setText(4, valueString);
+ }
+ }
+//! [effectsParameters]
+ for (int i = 0; i < effectsTreeWidget->columnCount(); ++i) {
+ if (i == 0)
+ effectsTreeWidget->setColumnWidth(0, 150);
+ else if (i == 2)
+ effectsTreeWidget->setColumnWidth(2, 350);
+ else
+ effectsTreeWidget->resizeColumnToContents(i);
+ }
+}
+
+void Window::setupUi()
+{
+ setupBackendBox();
+
+ QLayout *layout = new QVBoxLayout;
+ layout->addWidget(backendBox);
+
+ setLayout(layout);
+ setWindowTitle(tr("Backend Capabilities Example"));
+}
+
+void Window::setupBackendBox()
+{
+ backendBox = new QGroupBox(tr("Backend Capabilities"));
+
+ devicesLabel = new QLabel(tr("Available Audio Devices:"));
+ devicesListView = new QListView;
+
+ mimeTypesLabel = new QLabel(tr("Supported MIME Types:"));
+ mimeListWidget = new QListWidget;
+
+ effectsLabel = new QLabel(tr("Available Audio Effects:"));
+
+ QStringList headerLabels;
+ headerLabels << tr("Type") << tr("Name") << tr("Description") <<
+ tr("Value Type") << tr("Default/Min/Max Values");
+
+ effectsTreeWidget = new QTreeWidget;
+ effectsTreeWidget->setHeaderLabels(headerLabels);
+ effectsTreeWidget->setColumnCount(5);
+
+ QGridLayout *layout = new QGridLayout;
+ layout->addWidget(devicesLabel, 0, 0);
+ layout->addWidget(devicesListView, 1, 0);
+ layout->addWidget(mimeTypesLabel, 0, 1);
+ layout->addWidget(mimeListWidget, 1, 1);
+ layout->addWidget(effectsLabel, 2, 0);
+ layout->addWidget(effectsTreeWidget, 3, 0, 2, 2);
+ layout->setRowStretch(3, 100);
+
+ backendBox = new QGroupBox(tr("Backend Capabilities"));
+ backendBox->setLayout(layout);
+}
+
diff --git a/examples/phonon/capabilities/window.h b/examples/phonon/capabilities/window.h
new file mode 100644
index 0000000..23121d3
--- /dev/null
+++ b/examples/phonon/capabilities/window.h
@@ -0,0 +1,97 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <QWidget>
+
+#include <Phonon/AudioOutput>
+#include <Phonon/SeekSlider>
+#include <Phonon/MediaObject>
+#include <Phonon/VolumeSlider>
+#include <Phonon/BackendCapabilities>
+#include <Phonon/Effect>
+#include <Phonon/EffectParameter>
+#include <Phonon/ObjectDescriptionModel>
+#include <QList>
+
+QT_BEGIN_NAMESPACE
+class QAction;
+class QGroupBox;
+class QPushButton;
+class QLabel;
+class QListWidget;
+class QListView;
+class QTextEdit;
+class QTreeWidget;
+QT_END_NAMESPACE
+
+
+class Window : public QWidget
+{
+ Q_OBJECT
+
+public:
+ Window();
+
+//! [windowMembers]
+private slots:
+ void updateWidgets();
+
+private:
+ void setupUi();
+ void setupBackendBox();
+
+ QGroupBox *backendBox;
+
+ QLabel *devicesLabel;
+ QLabel *mimeTypesLabel;
+ QLabel *effectsLabel;
+
+ QListWidget *mimeListWidget;
+ QListView *devicesListView;
+ QTreeWidget *effectsTreeWidget;
+//! [windowMembers]
+};
+
+#endif
+