diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2011-07-10 15:24:15 -0500 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2011-07-10 15:24:15 -0500 |
commit | 7d523fac5a54f8e695e56f4877fa852608465bc7 (patch) | |
tree | f74237f64a396d91997032df9bdf674492529c94 /main/dependencies/qt3/examples/sound | |
parent | 37e3f157c7d76f13de807fa66e36df209e1005fb (diff) | |
download | tde-7d523fac5a54f8e695e56f4877fa852608465bc7.tar.gz tde-7d523fac5a54f8e695e56f4877fa852608465bc7.zip |
Add Qt3 development HEAD version
Diffstat (limited to 'main/dependencies/qt3/examples/sound')
-rw-r--r-- | main/dependencies/qt3/examples/sound/sound.cpp | 102 | ||||
-rw-r--r-- | main/dependencies/qt3/examples/sound/sound.doc | 24 | ||||
-rw-r--r-- | main/dependencies/qt3/examples/sound/sound.h | 33 | ||||
-rw-r--r-- | main/dependencies/qt3/examples/sound/sound.pro | 11 | ||||
-rw-r--r-- | main/dependencies/qt3/examples/sound/sounds/1.wav | bin | 0 -> 8624 bytes | |||
-rw-r--r-- | main/dependencies/qt3/examples/sound/sounds/2.wav | bin | 0 -> 7266 bytes | |||
-rw-r--r-- | main/dependencies/qt3/examples/sound/sounds/3.wav | bin | 0 -> 4709 bytes | |||
-rw-r--r-- | main/dependencies/qt3/examples/sound/sounds/4.wav | bin | 0 -> 5538 bytes |
8 files changed, 170 insertions, 0 deletions
diff --git a/main/dependencies/qt3/examples/sound/sound.cpp b/main/dependencies/qt3/examples/sound/sound.cpp new file mode 100644 index 000000000..bb4210adb --- /dev/null +++ b/main/dependencies/qt3/examples/sound/sound.cpp @@ -0,0 +1,102 @@ +/**************************************************************************** +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of an example program for Qt. This example +** program may be used, distributed and modified without limitation. +** +*****************************************************************************/ +// +// Very simple example of QSound::play(filename) +// +// 99% of this program is just boilerplate Qt code to put up a nice +// window so you think something special is happening. +// + +#include "sound.h" +#include <qapplication.h> +#include <qmessagebox.h> +#include <qmenubar.h> + +SoundPlayer::SoundPlayer() : + QMainWindow(), + bucket3("sounds/3.wav"), + bucket4("sounds/4.wav") +{ + if (!QSound::isAvailable()) { + // Bail out. Programs in which sound is not critical + // could just silently (hehe) ignore the lack of a server. + // + QMessageBox::warning(this,"No Sound", + "<p><b>Sorry, you are not running the Network Audio System.</b>" + "<p>If you have the `au' command, run it in the background before this program. " + "The latest release of the Network Audio System can be obtained from:" + "<pre>\n" + " \n" + " ftp.ncd.com:/pub/ncd/technology/src/nas\n" + " ftp.x.org:/contrib/audio/nas\n" + "</pre>" + "<p>Release 1.2 of NAS is also included with the X11R6" + "contrib distribution." + "<p>After installing NAS, you will then need to reconfigure Qt with NAS sound support"); + } + + QPopupMenu *file = new QPopupMenu; + file->insertItem("Play &1", this, SLOT(doPlay1()), CTRL+Key_1); + file->insertItem("Play &2", this, SLOT(doPlay2()), CTRL+Key_2); + file->insertItem("Play from bucket &3", this, SLOT(doPlay3()), CTRL+Key_3); + file->insertItem("Play from bucket &4", this, SLOT(doPlay4()), CTRL+Key_4); + file->insertSeparator(); + file->insertItem("Play 3 and 4 together", this, SLOT(doPlay34())); + file->insertItem("Play all together", this, SLOT(doPlay1234())); + file->insertSeparator(); + file->insertItem("E&xit", qApp, SLOT(quit())); + menuBar()->insertItem("&File", file); +} + +void SoundPlayer::doPlay1() +{ + QSound::play("sounds/1.wav"); +} + +void SoundPlayer::doPlay2() +{ + QSound::play("sounds/2.wav"); +} + +void SoundPlayer::doPlay3() +{ + bucket3.play(); +} + +void SoundPlayer::doPlay4() +{ + bucket4.play(); +} + +void SoundPlayer::doPlay34() +{ + // Some sound platforms will only play one sound at a time + bucket3.play(); + bucket4.play(); +} + +void SoundPlayer::doPlay1234() +{ + // Some sound platforms will only play one sound at a time + QSound::play("sounds/1.wav"); + QSound::play("sounds/2.wav"); + bucket3.play(); + bucket4.play(); +} + +int main(int argc, char** argv) +{ + QApplication app(argc,argv); + SoundPlayer sp; + app.setMainWidget(&sp); + sp.setCaption("Qt Example - Sounds"); + sp.show(); + return app.exec(); +} + diff --git a/main/dependencies/qt3/examples/sound/sound.doc b/main/dependencies/qt3/examples/sound/sound.doc new file mode 100644 index 000000000..031c97e66 --- /dev/null +++ b/main/dependencies/qt3/examples/sound/sound.doc @@ -0,0 +1,24 @@ +/*! \page sound-example.html + + \ingroup examples + \title Sound Example + + This example shows how easy it is to play sounds, e.g. .WAV files, + if your machine is set up to play audio. + + <hr> + + Header file: + + \include sound/sound.h + + <hr> + + Implementation: + + \include sound/sound.cpp + + +*/ + + diff --git a/main/dependencies/qt3/examples/sound/sound.h b/main/dependencies/qt3/examples/sound/sound.h new file mode 100644 index 000000000..1a5546189 --- /dev/null +++ b/main/dependencies/qt3/examples/sound/sound.h @@ -0,0 +1,33 @@ +/**************************************************************************** +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of an example program for Qt. This example +** program may be used, distributed and modified without limitation. +** +*****************************************************************************/ +#ifndef PLAY_H +#define PLAY_H + +#include "qsound.h" +#include <qmainwindow.h> + +class SoundPlayer : public QMainWindow { + Q_OBJECT +public: + SoundPlayer(); + +public slots: + void doPlay1(); + void doPlay2(); + void doPlay3(); + void doPlay4(); + void doPlay34(); + void doPlay1234(); + +private: + QSound bucket3; + QSound bucket4; +}; + +#endif diff --git a/main/dependencies/qt3/examples/sound/sound.pro b/main/dependencies/qt3/examples/sound/sound.pro new file mode 100644 index 000000000..38ab30a8f --- /dev/null +++ b/main/dependencies/qt3/examples/sound/sound.pro @@ -0,0 +1,11 @@ +TEMPLATE = app +TARGET = sound + +CONFIG += qt warn_on release +DEPENDPATH = ../../include + +REQUIRES = full-config +x11:REQUIRES = nas + +HEADERS = sound.h +SOURCES = sound.cpp diff --git a/main/dependencies/qt3/examples/sound/sounds/1.wav b/main/dependencies/qt3/examples/sound/sounds/1.wav Binary files differnew file mode 100644 index 000000000..30b84e30b --- /dev/null +++ b/main/dependencies/qt3/examples/sound/sounds/1.wav diff --git a/main/dependencies/qt3/examples/sound/sounds/2.wav b/main/dependencies/qt3/examples/sound/sounds/2.wav Binary files differnew file mode 100644 index 000000000..dd32e3455 --- /dev/null +++ b/main/dependencies/qt3/examples/sound/sounds/2.wav diff --git a/main/dependencies/qt3/examples/sound/sounds/3.wav b/main/dependencies/qt3/examples/sound/sounds/3.wav Binary files differnew file mode 100644 index 000000000..5213eb55d --- /dev/null +++ b/main/dependencies/qt3/examples/sound/sounds/3.wav diff --git a/main/dependencies/qt3/examples/sound/sounds/4.wav b/main/dependencies/qt3/examples/sound/sounds/4.wav Binary files differnew file mode 100644 index 000000000..e31b06090 --- /dev/null +++ b/main/dependencies/qt3/examples/sound/sounds/4.wav |