/*************************************************************************** ksoundcfg.cpp - description ------------------- begin : Don Mai 23 2002 copyright : (C) 2002 by Dieter Landolt email : dieter.landolt@secs.ch ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include #include #include #include #include #include #include #include #include "ksoundcfg.h" ksoundCfg::ksoundCfg(QWidget *parent, const char* name, WFlags fl) : soundcfg(parent, name, fl) { KIconLoader *myico = new KIconLoader(); pathButton->setPixmap(myico->loadIcon("folder_red",KIcon::Toolbar)); playButton->setPixmap(myico->loadIcon("player_play",KIcon::Toolbar)); connect(pathButton, SIGNAL(clicked()),this,SLOT(pathButtonclicked())); connect(playButton, SIGNAL(clicked()),this,SLOT(playButtonclicked())); connect(path, SIGNAL(textChanged(const QString &)), this , SLOT(pathChanged(const QString &))); } ksoundCfg::~ksoundCfg(){ } /** To Display the select Dialog if the Button is clicked. */ void ksoundCfg::pathButtonclicked(){ QString retPath; // QPixmap *fp = new QPixmap(20,20); retPath = KFileDialog::getOpenFileName(QString::null, i18n("*.wav *.ogg *.mp3|All supported sound format\n*.ogg|Ogg Vorbis open,free audio format (OGG)\n*.mp3|Mp3 audio file format (MP3)\n*.wav|Wave table sounds (WAV)\n*.*|All files"), this,i18n("Select the right sound file")); if(retPath != QString::null) { path->setText(retPath); } } /** plays the sound for listening it */ void ksoundCfg::playButtonclicked(){ qDebug(path->text()); KAudioPlayer::play(path->text()); } /** Notify internaly, when the path wille be changed, to enable the playbutton, if the sound is valid, else disable soundbutton. */ void ksoundCfg::pathChanged(const QString& newpath){ if(QFile::exists(newpath)) { playButton->setEnabled(true); } else { playButton->setEnabled(false); } newPath(newpath); // Signals if a new path is entred // its to verify becose i don't now if its not a kinde of loop } /** Set the text in the object. */ void ksoundCfg::setText(const QString& s){ path->setText(s); } /** get the text back. */ QString ksoundCfg::text(){ return path->text(); }