KContacts::Sound
KContacts::Sound Class Reference
#include <sound.h>
Public Types | |
typedef QList< Sound > | List |
Public Member Functions | |
Sound () | |
Sound (const QByteArray &data) | |
Sound (const QString &url) | |
Sound (const Sound &other) | |
~Sound () | |
QByteArray | data () const |
bool | isEmpty () const |
bool | isIntern () const |
bool | operator!= (const Sound &other) const |
Sound & | operator= (const Sound &other) |
bool | operator== (const Sound &other) const |
void | setData (const QByteArray &data) |
void | setUrl (const QString &url) |
QString | toString () const |
QString | url () const |
Detailed Description
Class that holds a Sound clip for a contact.
The sound can be played doing something like this:
KTempFile tmp;
if ( sound.isIntern() ) {
tmp.file()->write( sound.data() );
tmp.close();
KAudioPlayer::play( tmp.name() );
} else if( !sound.url().isEmpty() ) {
QString tmpFile;
if ( !KIO::NetAccess::download( QUrl( themeURL.url() ), tmpFile, 0 ) ) {
KIO::NetAccess::lastErrorString(),
i18n( "Failed to download sound file" ),
);
return;
}
KAudioPlayer::play( tmpFile );
}
QString i18n(const char *text, const TYPE &arg...)
void error(QWidget *parent, const QString &text, const QString &title, const KGuiItem &buttonOk, Options options=Notify)
Notify
Unfortunately, KAudioPlayer::play is ASync, so to delete the temporary file the best you can really do is set a timer.
Member Typedef Documentation
◆ List
Constructor & Destructor Documentation
◆ Sound() [1/4]
◆ Sound() [2/4]
Sound::Sound | ( | const QString & | url | ) |
◆ Sound() [3/4]
Sound::Sound | ( | const QByteArray & | data | ) |
◆ Sound() [4/4]
◆ ~Sound()
Member Function Documentation
◆ data()
QByteArray Sound::data | ( | ) | const |
◆ isEmpty()
bool Sound::isEmpty | ( | ) | const |
◆ isIntern()
bool Sound::isIntern | ( | ) | const |
◆ operator!=()
bool Sound::operator!= | ( | const Sound & | other | ) | const |
◆ operator=()
◆ operator==()
bool Sound::operator== | ( | const Sound & | other | ) | const |
◆ setData()
void Sound::setData | ( | const QByteArray & | data | ) |
Sets the raw data of the sound.
When using this function, isIntern() will return 'true' until you use setUrl().
- Parameters
-
data The raw data of the sound.
◆ setUrl()
void Sound::setUrl | ( | const QString & | url | ) |
Sets a URL for the location of the sound file.
When using this function, isIntern() will return 'false' until you use setData().
- Parameters
-
url The location URL of the sound file.
◆ toString()
QString Sound::toString | ( | ) | const |
◆ url()
QString Sound::url | ( | ) | const |
The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:01:27 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:01:27 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.